• Resolved Lightpurple

    (@pamkaur14)


    Hi,

    I love this plugin! Thanks so much for it. I have tried multiple other plugins and have not been able to get them to work the way I want.

    I only have 1 minor issue now and was wondering if you could help me. I have done the following:

    Added the filter add_filter( 'widget_text', 'do_shortcode' ); to my functions.php file to be able to work the shortcode in a widget.

    I also have the following in my CSS file for styling:
    .display-posts-listing .listing-item {text-transform: uppercase; font-size: 0.5em; display: inline-block;}
    .display-posts-listing img {float: center; margin: 0 20px 5px 0; text-align: center;}

    I then added the following shortcode to a text widget: [display-posts tag="featured female" post_status="publish" image_size="thumbnail" posts_per_page="3" orderby="rand"]

    and it doesn’t seem to be working. I am using the same shortcode on a page and it works. I am not sure if it has something to do with the following function which I added to my functions.php file as well:

    //----------------------------------------------------------
    // POsts by Tag Shortcode plugin: add H2 to title //----------------------------------------------------------
    add_filter( 'posts_by_tag_shortcode_output', 'format_pbts_title', 10, 7 );
    function format_pbts_title( $output, $atts, $image, $title, $date, $excerpt, $inner_wrapper ) {
    // Make Title and H2
    $title = ' <h2>'. $title .'</h2>';
    // Now let's rebuild the output.
    $output = '<' . $inner_wrapper . ' class="listing-item">' . $image . $title . $date . $excerpt . '</' . $inner_wrapper . '>';
    // Finally we'll return the modified output
    return $output; }

    I did the above to get the title under the thumbnail. Any help on getting the shortcode to work in the widget would be great. Thanks in advance!

    https://www.ads-software.com/plugins/display-posts-shortcode/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Shortcode not working in widget’ is closed to new replies.