The MU forums have moved to WordPress.org

looking for a category function (2 posts)

  1. anointed
    Member
    Posted 12 years ago #

    On my single.php pages I want to add in an area below the post that shows other posts belonging to the same category as being viewed at the time. I plan on putting this into a slider. --the 'tricky' part that I am getting stuck on is how to use the same slider on all single.php pages, yet display different posts depending upon the single.page the viewer is looking at.

    Meaning if a user is reading an article from category 'food' I want the slider to show other posts from 'food'.
    --if a user is reading an article from category 'dishes' I want the slider to show other posts from 'dishes'.

    I already have the majority of the functions written to do what I need.

    However, I am struggling to find a function that will return the category id# of the single.php article being displayed. (my permalink structure is /%postname%/ and I cannot change that due to other issues. This means that I don't think I can use the slug to grab the cat_id.

    My function is as follows:
    <?php query_posts("cat=-".get_option('article_cat')."&showposts=".get_option('number_posts')); ?>

    What I need is to define article_cat as the category of the page being viewed.

    Can someone help me define article_cat please?

    (I looked in the codex, but saw nothing that does this as far as I could find)

  2. anointed
    Member
    Posted 12 years ago #

    btw article_cat needs to be the cat id# not the category name

About this Topic

  • Started 12 years ago by anointed
  • Latest reply from anointed