Forums

Help with Displaying Post Titles Based on page Category (2 posts)

  1. Davebenroberts
    Member
    Posted 2 years ago #

    I've created a slider that goes at the top of my page, and it displays posts titles. I have it sliding and it looks great, but I need the coding for how to make just the post title appear, and when it appears its only posts from the category of the page that you are on.

    For example: I'm on a page titled Jamaica, the category is vacations. at the top I want the posts to only be from the category vacations. If i move to a page titled Island cuisine, and the category is food, I want only food posts titles to show up in the slider.

    Also I've seen it where you can say how many posts are to be skipped before posting a title.

    for example the most recent post is number 1, next is 2, then 3...ect.

    I want to have it set so that the first is a featured post, so the slider skips 1 post and then shows 2, 3, 4,....ect.

    I'd like to also be able to pull the first image from the post and place it in front of the title on the slider......

    All this has a deadline of November 5th......
    Anything would help!

    Thanks
    Dave

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    For example: I'm on a page titled Jamaica, the category is vacations. at the top I want the posts to only be from the category vacations. If i move to a page titled Island cuisine, and the category is food, I want only food posts titles to show up in the slider.

    WordPress does not normally allow categorization of Pages.

    But will add this:

    <?php
    //Use page title to 'formulate a category'
    if (is_page()) {
      $cat=get_cat_ID($post->post_title); //use page title to get a category ID
      $posts = get_posts ("cat=$cat&showposts=5");
      if ($posts) {
        foreach ($posts as $post):
          setup_postdata($post); ?>
          <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
        <?php endforeach;
      }
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic