You can ask the main query directly (which is, in fact, exactly what the is_front_page
function is doing).
<?php global $wp_query; ?>
<?php if ( $wp_query->is_front_page() ) : ?>
<div><?php the_content(); ?></div>
<?php endif; ?>
If you altered the main query, however, refer to the backup.
<?php global $wp_the_query; ?>
<?php if ( $wp_the_query->is_front_page() ) : ?>
<div><?php the_content(); ?></div>
<?php endif; ?>
Related Posts:
- Does get_template_part pull data once in a loop?
- Post Format single-loop.php using get_template_part
- How to get_template_part using AJAX?
- Problems with loop
- Conditional query that displays on Woo product attribute pages
- How to show “teaser” posts on blog / archive pages, otherwise full posts
- Detect if current page is front page within custom query
- How do I display an image before the first post of the loop when I’m using get_template_part?
- How do I make a variable available inside partials?
- how to replace get_template_part(‘loop’,’tag’) with explicit styled version?
- get_template_part() Not Working in Loop
- Get_template_part() problem with the_content()
- Problem with Front-Page.php loading recent posts
- Using has_tag() outside loop
- How to declare a variable in a loop and make it available in the template file
- Adding a second loop breaks everything
- Need a conditional to test if title of parent page matches title of child page
- get_template_part() to render single page Theme
- Using in_category for non standard loops
- strange parse error when including a loop template within another template
- How to show only specific tag in wordpress loop
- How to get Author ID outside the loop
- remove tags from the_content
- the_title() shows title of the first post instead of the page title?
- Why do themes rely on “The Loop”?
- What exactly defines a Main Loop and a Secondary Loop?
- Loop code is displaying pages but not actual posts
- How are both HTTP and HTTPS versions displaying?
- post loop causes wp_users and wp_usermeta DB queries for each users
- Ajax loop refresh on click
- the_excerpt(), get_the_excerpt() and the_content() all killing “the Loop”
- Is get_posts() more efficient than The Loop?
- loop through all posts memory error
- Creating a multi-taxonomy query, excluding the newest (read: highest ID) taxonomy term
- Targeting a Certain Post in Loop (CSS)
- Get post/page data outside the loop
- Display most viewed post from last 30 days is not working correctly
- What is the maximum number of posts a WordPress loop can work with?
- Split loop to load WordPress gallery into Bootstrap modal and carousel
- Trouble Formatting DateTime
- Order archive results by post id in custom taxonomy template
- pre_get_posts for two loops on same page
- Modify the main loop to display current month / year
- Modified loop-single-forum.php to work inside of a sidebar Widget, not working on some site pages
- Basic multiple loops only displaying first loop
- Problem with displaying HTML content after in_array [closed]
- Both a page loop and posts loop on the same page
- Get author_id in wordpress
- Is_single() conditional tag returns null in query
- Single.php different behaviour from admin to non-admin
- WordPress Blog has an infinite redirect loop
- Stepping through a foreach loop – adding +1 to the end of it so next time it loops it starts on item 2
- Can’t access PHP array inside script localization from javascript
- ACF – add a group inside a repeater [closed]
- How to create bootstrap grid loop?
- Is it possible to reverse the order of a list of posts pulled from a loop?
- Get post offset/posts page offset in single post page (outside the loop)
- First article : single column; Other articles : 2 columns
- How can I access specific posts brought back by query_posts?
- Put multiple custom loops on same page
- Contact information footer
- Multisite foreach loop returning only one result
- Content Visibility for WordPress is not working (Drafts, public etc.)
- Loop is crazy – one row displays wrong count of posts [closed]
- Generating a perfect loop
- I need to display all post in onepage
- WordPress loop not working only on home page, works on all other pages
- How to put a block of code between [shortcode][/shortcode] in do_shortcode()?
- current-user_can not working in loop
- For Each +1 WordPress Loop
- How can I access a post’s feature image outside the loop?
- Multiple loops for plugin
- WordPress: query pages except remove one page
- get_post_meta printing empty fields, but it shouldn’t be
- Is it possible to set archive.php instead of index.php to display blog?
- How to read taxonomy in loop?
- Custom wp_query inside a conditional stament inside a template part doesn’t work: why?
- Undefined index: page in loop load ajax content
- how to add 4 post in one carousel slide
- Only Show Excerpt After First 3 Posts
- How to insert content before pagination in loop?
- Is “the loop” a template tag?
- Deeply Nested Menu Loop with Twig using Timber [closed]
- WordPress redundant posts based on meta field
- WordPress with woocommerce custom query
- Continue loop after $queryObject
- Get featured image outside the loop using foreach
- Page gets displayed in post field
- pre_get_posts main_query not displaying after applying tax_query filters
- setup_postdata in “loop-handling” php file called via $.ajax
- Secondary loop cuts off at 10 posts?
- Same Loop on Multiple Pages
- get all page templates
- Previous Posts Link and Next Posts Link Show All The Same Articles?
- Posts Loops To Display Specific Posts Inside Page Template?
- Use callback function in AJAX pure javascript [closed]
- Undefined variable: woocommerce_loop [closed]
- title not being printed within html tag [closed]
- wp_mail function not working in user query loop
- How to set and retrieve cookies while in the loop