WordPress.org

Ready to get started?Download WordPress

Forums

Displaying a category on a template so it matches the page name (3 posts)

  1. alvarix
    Member
    Posted 5 years ago #

    The idea is to have a template where each page can pull in posts whose category name is the same as that of the page.

    This is the ugly hack I've got going so far, where I sniff the url, and use the string to build the category query:

    if (preg_match('/about/',$query_string)) {
    	$mycat=substr($query_string,22);
    }
    query_posts("category_name=$mycat);

    I'm sure someone out there can do this better.

    Thanks!
    alvar

  2. esmi
    Forum Moderator
    Posted 5 years ago #

  3. alvarix
    Member
    Posted 5 years ago #

    Thanks esmi. That isn't much different from what I am doing though.
    I was hoping some sort of efficiency could be achieved from the fact that the page name and cat name are the same.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags