Krunal
Krunal

Reputation: 3277

is_front_page not working correctly on WordPress

I'm working on a wordpress project. I have few contents in header and sidebar that I want to display only on the main front-page of the website. I have a custom front-page.php as a front page template where I list posts from two categories using custom wp_query.

I have tried to put my conditional contents using is_front_page condition tag, but it doesn't seems to work, no clue why its not working?

Before, putting a custom front page template using front-page.php, it was working just nice, but after I implemented front page template it stops working.

Any clue how to fix this?

Upvotes: 0

Views: 724

Answers (2)

Colorful Tones
Colorful Tones

Reputation: 82

You may want to check to see what your Settings -> Reading : "Front Page Displays" is set to?

If you're trying to place the conditional in the sidebar.php or the header.php it should work fine.

This may help clarify: https://wordpress.org/support/topic/if-is_front_page-not-working#post-1290807

Upvotes: 1

Krunal
Krunal

Reputation: 3277

The issue was with using query_posts. We changed that part, and it started to work again.

Actually query_posts rewrites original query and it causes conditional tags to break, as per wp codex.

Upvotes: 0

Related Questions