Marius, I have been in this situation before as well. Haven’t found a good solution though. Answer provided by Laxmana won’t work as the $isFrontPageOrSearch wont be accessible inside the template-part file. Although using the approach provided by Laxmana, you could be using PHP include(locate_template(‘your-template-name.php’));, instead of using get_template_part function. Then the variable would be accessible.
Related Posts:
- Problem with Front-Page.php loading recent posts
- Output shows a page instead of a list of blog postings
- 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?
- Create static front-page with 3-5 recent posts
- Loop first six posts in carousel, next eight in grid
- Problems with loop
- How to show “teaser” posts on blog / archive pages, otherwise full posts
- Page-loop is looping content from custom loops on the same site. How to avoid that?
- 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?
- How do I put my frontpage featured image in a page template for home.php?
- get_template_part() Not Working in Loop
- Get_template_part() problem with the_content()
- Frontpage pagination by week
- How can have a conditional template tag based on the main loop within a secondary loop with new WP_Query(), using get_template_part()
- How to declare a variable in a loop and make it available in the template file
- Adding a second loop breaks everything
- get_template_part() to render single page Theme
- strange parse error when including a loop template within another template
- Get date of last update outside of loop
- WordPress category & taxonomy loop with pagination
- Changing behavior of the loop twice in one page
- wp_insert_posts Fatal error: Maximum function nesting level of ‘100’ reached, aborting!
- Post Loop not Returning Permalink
- Displaying child page content of a certain parent
- Pagination adding extra posts only on page 2
- If Loop has odd number of posts on last page Custom style for last post in it
- Custom page template
- Get posts that matches specific terms of multiple custom taxonomies
- How can I use get_permalink() outside the loop?
- Two loops by pre_get_post on same page
- How to check for specific content in comments in the loop
- Problem the_permalink
- Sort Posts By Category?
- Can’t access login screen, wp-login.php 404’s
- get latest 5 posts and a specific post and sort in a specific order
- Loop within a loop (Again) for template
- How to use current_post to open a new unordered list every five posts
- Rating system and changing the loop
- Display Authors in a grid loop
- Infinite Scroll and DFP
- Sanitize Custom Field Value in Meta Query
- Default ‘post’ post type archive slug?
- show random image in loop if image is not set
- Get Page content to displayin Bootstrap Modal
- need help looping add_action in wp
- Does WordPress Loop have a function like Shopify’s cycle?
- How to show more random posts if Tag has less than 3 posts
- Add leading zero to current post display [closed]
- Distribute Gallery Images Every nth in Loop
- WordPress Image Slider Looping Title Not Working
- Output meta into arrays
- Is there any good reason for two CSS files to @import each other?
- Moving wordpress to different url/server creates redirect loop
- Second Loop Showing Only One Post on Single Post Page
- Random post link generator messes up the loop
- Modify loop output for a specific list of categories
- how can i order the category by date
- Change position of entry title
- Print the whole page?
- excerpt not showing up
- Pagination for two loops
- Announces with different formatting dependently on a number
- Override orderby to create list of users by custom meta_value
- Thumbnail Image Rounded Corners w CSS (or any other good method)
- Several loops in sidebar issues
- List page is showing 404
- Adding $args to wp_schedule_event() causes hook to add infinitely to WP Cron
- $post is undefined in wordpress loop [ajax]
- Duplicated tag in loop
- Loop only shows first two posts
- Why is my archive page looping through all but one post?
- Loop two different category WP_Query
- Use ACF Category Image for all Taxonomy Archive Views
- Loop with custom posts, to include information from different custom post type
- Check value of post meta within IF statement
- My WordPress installation doesn’t load correct template
- Work arounds for conditional checks inside the loop in search.php?
- Transient not working for external data
- adding tax_query to $query_string
- Get Sticky User in user loop based on user role
- Popular posts with Varnish ESI
- Querying posts from only one category and exluding the latest post
- Remove posts_orderby filter then add it back in
- the_title() Returns the page title instead of the post
- WP update_post_meta link loop
- Need some help with “the_widget()” function
- Conditional Check in The Loop’s Parameters
- How does the JSON API work to parse incoming JSON and fetch a post based on an ID?
- How to add excerpt in loop in Twenty Eleven theme?
- Exclude Authors based off date of last post
- How to implement template file and the loop
- Show only posts from todays date [duplicate]
- I need to update the post query? [closed]
- Multiple loop with pagination in same page
- Why did my most recent article fall behind an older one on my site?
- Use Base-URL with Query-Loop