WordPress.org

Ready to get started?Download WordPress

Forums

Display Posts Shortcode
[resolved] use $category in opener without hacking plugin? (3 posts)

  1. raskull
    Member
    Posted 2 years ago #

    Hi, it's me again. I see your code for filtering the wrapper opening and close. However I need to get the category variable into the opening. What is the best way to accomplish what I want without hacking your plugin?

    Below is my hack to your line 149, the results of which provide a link to the category page of the category that was specified in the shortcode [display-posts category="Foo" posts_per_page="3"] and looks like this: Foo Headlines : More Foo

    $open = apply_filters( 'display_posts_shortcode_wrapper_open', '<h2>' . $category . ' Headlines : <a href="' . get_category_link( get_cat_ID( $category ) ) . '">More ' . $category . '</a></h2><' . $wrapper . ' class="display-posts-listing">' );

    http://wordpress.org/extend/plugins/display-posts-shortcode/

  2. Bill Erickson
    Member
    Plugin Author

    Posted 2 years ago #

    Hmm, I don't think that can be done with the filter as it is. All the filter lets you do is modify it as straight text - it doesn't pass any of the shortcode's parameters for you to work with (like category).

    I'd need to modify the filter to pass the $atts, and then you could then pull the category out of that.

  3. raskull
    Member
    Posted 2 years ago #

    Well, I'll leave it up to you whether you think that would be useful to others and worth your effort.

    p.s. I do appreciate your super clean work, which even I, a novice, can recognize!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic