Support » Fixing WordPress » determine if permalink is category or not in header.php

  • Resolved nearlythere


    i’m trying to make a header only build a submenu on pages and category archives… i use a permalink structure, /%cateory%/%posttitle%/

    if a word is typed in the URL, it should display no menu, but instead i’m getting database errors. i can’t figure out how to determine if a word is a category or page title or not.

    this is the order of events:

    if (!$wp_query->is_admin || is_home()) {
    // do stuff you can't do in wp-admin
    // new loop if/else within this:
    if (is_page()) {
    // this must be a page
    } else if (is_category()) {
    // this must be a category
    //get values from database for parent, and category info

    BUT, it’s not working as expected…

    If I type in i get the database error, because it defaults to the category.php

    how can i determine if a word is/isnot a category? my brain is fried 😉

Viewing 1 replies (of 1 total)
  • well, i don’t know if i even explained the problem very well…

    but i figured out i needed to add a check for 404 after the check for wp-admin…

    if (is_404()) {
    // put all in here

    mental amount of trouble that caused me! 😉

Viewing 1 replies (of 1 total)
  • The topic ‘determine if permalink is category or not in header.php’ is closed to new replies.