• Resolved RudolfFiedler

    (@rudolffiedler)


    Hi, I have a problem with the output-filter.
    I have about 5-10 different shortcodes on one page. And for every shortcode I need a different outputfilter. (Other contents, other css).
    Reason is: This different outputs would be published with a jquery responsive slider, so I must know exactly which slider I have to connect with the correct display_shortcode-output.
    Thanks a lot, very nice plugin.

    Rudi

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Bill Erickson

    (@billerickson)

    The second parameter in the output filter gives you the original shortcode attributes, so you can use that to limit an output filter to a specific shortcode. You can add any custom attribute to your shortcode and access it inside your output filter.

    For instance, if you had the following shortcode: [display-posts my_custom_layout=”testing”]

    You could then limit your output filter to that specific shortcode with:

    
    /**
     * Display Posts Output Filter
     * @see https://displayposts.com/docs/the-output-filter/
     *
     */
    function be_dps_output_customization( $output, $original_atts, $image, $title, $date, $excerpt, $inner_wrapper, $content, $class, $author, $category_display_text ) {
    
      // Only run if my_custom_layout="testing"
      if( empty( $original_atts['my_custom_layout'] ) || 'testing' !== $original_atts['my_custom_layout'] ) )
        return $output;
    
      $output = '<' . $inner_wrapper . ' class="' . implode( ' ', $class ) . '">' . $image . $title . $date . $author . $category_display_text . $excerpt . $content . '</' . $inner_wrapper . '>';
      return $output;
    }
    add_filter( 'display_posts_shortcode_output', 'be_dps_output_customization', 10, 11 );
    
Viewing 1 replies (of 1 total)
  • The topic ‘Create different Outputfilters for different display_posts’ is closed to new replies.