• 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

Viewing 12 replies - 1 through 12 (of 12 total)
  • Are we talking about categories or Pages.
    Categories cannot be children of a “page”.

    Thread Starter slyguyr3

    (@slyguyr3)

    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…

    Thread Starter slyguyr3

    (@slyguyr3)

    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.

    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

    Thread Starter slyguyr3

    (@slyguyr3)

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

    Would it be on a Page or on a Category_Template?

    Thread Starter slyguyr3

    (@slyguyr3)

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

    Thread Starter slyguyr3

    (@slyguyr3)

    I just need it to do this…

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

    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.

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

    Thread Starter slyguyr3

    (@slyguyr3)

    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…

    No, you cannot assign category to Pages.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘list titles of a category’ is closed to new replies.