Use the Index of the post currently being displayed to trigger when your custom content is rendered.
current_post
can be found on WP_Query
from within the loop.
<?php while( $archive_query->have_posts() ) :
$archive_query->the_post(); ?>
<article <?php post_class(); ?>>
The Content
</article>
<?php if ( $archive_query->current_post === 2 ): ?>
<div>Custom Content</div>
<?php endif; ?>
<?php endwhile; ?>
Related Posts:
- Get IDs of posts currently visible on archive
- Two differents queries in archive page
- How can I get the query that would be run for the archive page?
- Orderby event date (if it exists) or post date (if it doesn’t) – how to reorder posts based on meta value OR date
- My archives page won’t sort posts by month
- Archive query not working correctly
- How to Optimize WP site for millions of posts
- Differences between wpdb->get_results() and wpdb->query()
- Get Terms by IDs with IDs order
- Using WordPress public query variables
- How many WordPress SQL Queries per page?
- Slow wp_enqueue_media()
- Advanced Custom Fields – Query Efficiency
- How to display lastest post date in the homepage?
- $query->query_var[‘post_type’] not set for pages
- How to tell if $query_var isset?
- Sorting Grids with Essential Grid and Events Manger
- The use of including upgrade.php when building custom queries
- Custom query to get terms from post ids
- Get the timout value of a saved transient?
- Does meta_query work within get_posts array?
- Slow meta_query with about 4 milion record on wp_postmeta
- How to show more than 5 posts?
- WordPress Find Duplicate Post By Content
- How many queries are normal to execute on a WP site?
- WP Query Sort by meta value (date)
- How to optimize my query filtering out unwanted data?
- mySQL query. ORDER BY meta_key
- Remove posts from query for events whose start date has passed
- how to query multiple categories in wordpress?
- Disable the MySQL query in the main query
- Strange string in console from wpdb query
- Update slug (URL) of pending posts via phpMyAdmin
- How to run a mysql query when admin updates user role?
- Error when using setup_postdata()
- pre_get_posts : ‘post__not_in’ doesn’t work with global variable
- Getting post data from private page
- Missing posts in a query
- Alter a specific query on WordPress
- SQL query to select posts from multiple categories
- Why a URL with a query is always slower than that without a query?
- Maintaining Queries in URL
- Protect sequence of pages with same password for each of two groups of users
- How is it possible to get top comment from all children?
- Select Query demand excesive resources [closed]
- Create Indexes for Slow Queries
- Query to get number of posts last week
- MySql Query very slow
- I want to create a filter for the query string is this possible?
- Exclude categories from the_category();
- How can i show all categories using wp query?
- All in One Calendar Plugin Custom Post Type Query [closed]
- Get Posts from Last 24 hours and Sort them via GD Star Rating
- Query returning same results even though the ID changes
- Why my query ‘REPLACE INTO…’ does not work?
- Restrict query to last day with posts
- Custom query object with Simple-Fields custom date field
- Custom Post Type Query issue
- How to read the value of a WordPress $query associative array (hash) key
- Random Page Rewrite
- Query posts based on previous query
- Waypoints + infinite scroll with custom query
- Customizing the_tags output?
- Querying with WP query using meta key price
- Re-sort get_posts query results
- How do I get all results from my query
- Taxonomy filter under Polylang
- WordPress Mysql query and Duplicate
- How to create an overview of posts with the same tag?
- create a link to a random post within the current category
- How to “orderby” the first array in a meta_query that uses multiply keys?
- Pagination not working on custom post types with rewrite slug
- JetEngine Query Builder – order by value from repeater
- Change pure SQL database query to WordPress post query?
- Filter orders by modify date
- How to add url parameter to every search query in SearchWp?
- Display data from phpMyAdmin with WordPress
- Heavy meta query causing SQL crash
- SQL query to list all posts of specific post type with a specific set of associated postmeta values as a column
- Sort by postmeta on when searching
- Pulling an ACF into a query
- Speed up search query that searches in post meta?
- Category_in return empty
- modifying main query to query for ranges e.g. from 1999 to 2016
- Querying users by meta value and getting a strange answer
- Using cron for multiple queries
- very slow wordpress query with default query
- Multilingual WordPress page – using URL to determine language?
- Custom Query problem access the values
- Set posts per page for parent category and it’s all children
- Exclude sticky posts from query
- wordpress showing all posts instead of date range
- If more than 1 image show post link?
- Rewrite Query_Var URL Parameter with Slug
- How to query different categories on index?
- How to specify what kind of is_single post?
- Can’t See Media Queries with Inspect Tool [closed]
- Print data from wordpress sql query
- Can I create my own query in wordpress with traditional methods?
- How to show sticky posts on all pages of the pagination, not just the first page?