• Resolved drphil9001

    (@drphil9001)


    I have a custom home template with no explicit query anywhere on the page. I do have a query on the sidebar, but directly on home.php.

    When I go to the homepage however, WP is returning categories in get_the_category(). I would not have expected there to be any categories since there are no queries on the page.

    This results in my header (custom) being rendered improperly and the wrong side bar is being selected. I have custom is_xxxxx() functions that depend on get_the_category() returning expected results.

    Any idea what could result in categories being returned in get_the_category on a home.php page that has no queries or how I can explicitly clear these results at the top of home.php.

    Thanks,
    Phil

Viewing 2 replies - 1 through 2 (of 2 total)
  • I have a custom home template with no explicit query anywhere on the page.

    Perhaps not explicit, but there is always an implicit query occuring in the background in regards to the $post object. Try resetting $post to a null value in your home.php:

    $post = 0;

    Just make sure this is only done where you require no $post object.

    Thread Starter drphil9001

    (@drphil9001)

    I figured that there was an implicit query happening. Your solution works like a charm.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom home template returns wrong get_the_category’ is closed to new replies.