Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #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

    #1094880

    It’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;
    }

    #1094951

    Hi,
    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

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.