WordPress.org

Support

Support » How-To and Troubleshooting » Displaying a category on a template so it matches the page name

Displaying a category on a template so it matches the page name

  • 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

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Displaying a category on a template so it matches the page name’ is closed to new replies.
Skip to toolbar