WordPress.org

Ready to get started?Download WordPress

Forums

WP Category Post List Widget
No template tag? (1 post)

  1. YorkshireLad
    Member
    Posted 10 months ago #

    Hi,

    Using the widget, I can list posts relating to the current category. If I use the shortcode, I can lists posts with cat_id=x. If I want to use a template tag to do the same as the widget... I can't - as far as I can tell there isn't one, and using do_shortcode won't work, as leaving out the cat_id will bring up everything.

    Of course, I might be missing something!

    But here's how I got around my problem. First, determine the category id; then manually build your shortcode before 'do'ing it (you don't need all the options I'm using here):

    $scategory = get_the_category();
    $scat2 = $scategory[0]->cat_ID;
    $shortcat="[wp_cpl_sc cat_id=" . $scat2 . " show_author=false optional_excerpt=true read_more='' show_date=false show_comments=false is_thumb=true]";
    echo (do_shortcode($shortcat));

    Like I said, I might have missed there being a template tag, but if there really isn't one then I hope my hack helps.

    Gary

    http://wordpress.org/plugins/wp-category-posts-list/

Reply

You must log in to post.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 10 months ago by YorkshireLad
  • This topic is not resolved
  • WordPress version: 3.6.1