WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] determine if permalink is category or not in header.php (2 posts)

  1. nearlythere
    Member
    Posted 8 years ago #

    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
    demo2.sligoarts.com/anything 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 ;)

  2. nearlythere
    Member
    Posted 8 years ago #

    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! ;)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.