WordPress.org

Ready to get started?Download WordPress

Forums

list titles of a category (13 posts)

  1. slyguyr3
    Member
    Posted 8 years ago #

    How would I go about listing the titles in a specific category only while i am on a page that is a child or grand child of a specified page?

    I am wanting to implement some php on the side bar to do this... Thanks in advance

    Rueben Ramirez

  2. moshu
    Member
    Posted 8 years ago #

    Are we talking about categories or Pages.
    Categories cannot be children of a "page".

  3. slyguyr3
    Member
    Posted 8 years ago #

    No, what I have right now are a bunch of static pages and also, separatley, a category of posts that is to be updated. How would I do something like this

    if current page is child or grandchild of (specific page)
    then list titles of given category...

  4. slyguyr3
    Member
    Posted 8 years ago #

    Let me clarify, now that I am looking at some more documentation it is more correct to ask how to list the posts' titles of a given category.

  5. moshu
    Member
    Posted 8 years ago #

    I did that once on a category template (category-X.php), where it will pick the posts from cat ID# =X automatically, and simply deleted the_content from The_Loop, so it dislpayed only the_title.
    If you want it on a Page then you should "tell" the Loop to show only cat=X.
    e.g. Template_Tags/query_posts

  6. slyguyr3
    Member
    Posted 8 years ago #

    Do you have some sample code? I'm new to both php and wordpress. Thanks for everything!

  7. moshu
    Member
    Posted 8 years ago #

    Would it be on a Page or on a Category_Template?

  8. slyguyr3
    Member
    Posted 8 years ago #

    I am not sure what the difference would be but I am needing a more generic solution so am thinking for the page.

  9. slyguyr3
    Member
    Posted 8 years ago #

    I just need it to do this...

    if current page is child or grandchild of (specific page)
    then list posts' titles of given category...

  10. moshu
    Member
    Posted 8 years ago #

    OK.
    You make a Page template (see details here: Pages#Page_Templates) and replace the Loop with this:

    <?php query_posts('cat=XX&showposts=-1'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post">
    <h3 class="storytitle" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    </div>
    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>

    <?php endif; ?>

    XX = the category ID number;
    -1 = means show all posts;

    Of course, change the HTML tags around the template tags - I copied over what I have in my Page.

  11. moshu
    Member
    Posted 8 years ago #

    I can't help with the if... part - I am not a coder, sorry.
    Try Google search:
    site:wordpress.org/support keyword keyword

  12. slyguyr3
    Member
    Posted 8 years ago #

    I know pages don't have categories, but is it possible to assign a category to them? If so I could easily take care of the if part...

  13. moshu
    Member
    Posted 8 years ago #

    No, you cannot assign category to Pages.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags