-
AuthorPosts
-
April 26, 2019 at 11:01 pm #1094837
my shortcode is showing perfectly everywhere except the portfolio items excerpts.
is there another place that i need to add the shortcode besides the functions.php?
Thanks
April 27, 2019 at 10:16 am #1094880It’s a gravity forms short-code provided by gravitywiz. that shows the remaining number of entries available on a given form. In this example form 227.
[gravityforms action=”entries_left” id=”227″]
I’ve added the following to functions.php
add_filter(‘widget_text’, ‘do_shortcode’);
add_filter(‘the_excerpt’, ‘do_shortcode’);and I’ve added the snippet they gave me. Is there anything I can do to get this to work in the portfolio items excerpt?
/**
* Entries Left Shortcode
* http://gravitywiz.com/2012/09/19/shortcode-display-number-of-entries-left/
*/
add_filter(‘gform_shortcode_entries_left’, ‘gwiz_entries_left_shortcode’, 10, 2 );
function gwiz_entries_left_shortcode( $output, $atts ) {extract( shortcode_atts( array(
‘id’ => false,
‘format’ => false // should be ‘comma’, ‘decimal’
), $atts ) );if( ! $id )
return ”;$form = RGFormsModel::get_form_meta( $id );
if( ! rgar( $form, ‘limitEntries’ ) || ! rgar( $form, ‘limitEntriesCount’ ) )
return ”;$entry_count = RGFormsModel::get_lead_count( $form[‘id’], ”, null, null, null, null, ‘active’ );
$entries_left = rgar( $form, ‘limitEntriesCount’ ) – $entry_count;
$output = $entries_left;if( $format ) {
$format = $format == ‘decimal’ ? ‘.’ : ‘,’;
$output = number_format( $entries_left, 0, false, $format );
}return $entries_left > 0 ? $output : 0;
}April 27, 2019 at 7:49 pm #1094951Hi,
Sorry the login didn’t work for me, Excerpts do not support shortcodes by default but you can use the do_shortcode() function to execute them, I see that you have tried this with add_filter(‘the_excerpt’, ‘do_shortcode’); but please try adding this:add_filter( 'the_excerpt', 'shortcode_unautop');
or try this solution.
Best regards,
Mike -
AuthorPosts
- You must be logged in to reply to this topic.