WordPress.org

Ready to get started?Download WordPress

Forums

if category slug = page slug - do something useful (4 posts)

  1. checksum
    Member
    Posted 8 years ago #

    Hey up,
    I'd like to do something with wordpress that I imagine is possible as this system is so adaptable.

    I use both the blog and static pages. In the blog I need to be able to display links to sub pages whose parent page has the same SLUG as the present blog category SLUG.

    So If I have a blog category with slug "life-2006" and create a static parent page that has the slug "life-2006", then all its sub page links would appear when viewing that coresponding blog category.

    So I'd need to query the parent category slug and then look in the pages for a matching slug and if this is found - output links to the sub-pages.

    sligowaths wrote this function:

    function get_the_slug() {

    global $post;

    if ( is_single() || is_page() ) {
    return $post->post_name;
    }
    else {
    return "";
    }

    }

    Not sure if any of it can be used.

    Help :0

  2. checksum
    Member
    Posted 8 years ago #

    In my primitive php head, the logic works along these lines and I'm very aware the syntax is totally off:

    <?php if (is_category()) & category_slug == is_page() post_slug {
    <ul>
    <?php wp_list_pages('title_li=&child_of='. $parent_id); ?>
    </ul>
    }

    if (is_single()) & category_slug == is_page() post_slug {
    <ul>
    <?php wp_list_pages('title_li=&child_of='. $parent_id); ?>
    </ul>
    }
    ?>

    The $parent_id really has no place there - I guess this would require some kind of function.

    Any thoughts?

  3. checksum
    Member
    Posted 8 years ago #

    Any plugin authors up for this one?

  4. freddymungo
    Member
    Posted 8 years ago #

    I'm looking for this same thing-- it could be massively useful if it worked. Anybody?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags