0

Has anyone had any luck manipulating the Post Loop to insert content between post data? I'm looking to post content in between my posts as they are displayed on the archive, and homepage templates.

if ( !empty($theme_option['archive-num-excerpt']) ) {
briad_set_gb_variable('briad_excerpt_length', 55);
add_filter('excerpt_length', 'briad_set_excerpt_length');
}
global $wp_query;
$briad_post_settings = briad_get_gb_variable('briad_post_settings');
$briad_post_settings['excerpt'] = 55;
$briad_post_settings['thumbnail-size'] = 'full';            
$briad_post_settings['blog-style'] = 'blog-full';                           
echo '<div class="blog-item-holder">';
if ($briad_post_settings['blog-style'] == 'blog-full') {
$briad_post_settings['blog-info'] = array('author', 'date', 'category', 'comment');
briad_set_gb_variable('briad_post_settings', $briad_post_settings);
echo briad_get_blog_full($wp_query);
} else {
$briad_post_settings['blog-info'] = array('date', 'comment');
$briad_post_settings['blog-info-widget'] = true;
briad_set_gb_variable('briad_post_settings', $briad_post_settings);
$blog_size = str_replace('blog-1-', '', $theme_option['archive-blog-style']);
echo briad_get_blog_grid($wp_query, $blog_size, $theme_option['archive-thumbnail-size'], 'fitRows');
}
echo '<div class="clear"></div></div>';
remove_filter('excerpt_length', 'briad_set_excerpt_length');
$paged = (get_query_var('paged'))? get_query_var('paged') : 1;
echo briad_get_pagination($wp_query->max_num_pages, $paged);
5
  • Please include the code of your template, so we can see if there are any hooks in your theme that could be used. There are no normal WP hooks to do this.
    – cjbj
    Commented Oct 12, 2016 at 14:16
  • Yes. This happens everyday with custom theme development. No luck required. As cjbj suggests, post some code for assistance, specifically the loop you are working with.
    – jdm2112
    Commented Oct 12, 2016 at 14:34
  • try working with the 'the_post' action ... codex.wordpress.org/Plugin_API/Action_Reference/the_post
    – Michael
    Commented Oct 12, 2016 at 16:58
  • Thanks @Michael, I'll definitely check that out. Thanks cjbj and jdm2112, as well! I've added what I believe is all of the relevant code that helps create the posts on my homepage. Please let me know if you have any questions? Thank you all again for all your help!
    – Brian
    Commented Oct 12, 2016 at 19:36
  • There's no visible code that actually processes your loop and displays your posts, so it's rather hard to help. Commented Oct 12, 2016 at 20:54

1 Answer 1

0

Just as the loop starts the action loop_start fires. Once each post is setup as the loop iterates, the_post fires. After the loop has finished, loop_end fires.

Each of these actions receives a reference to the queried object if you need to check for context.

If you are in control of the theme code it might be as easy to insert your inter-post code there, of course.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.