heres some starter code
function custom_markup_before_every_fifth_activity() {
global $activities_template;
$item_5 = $activities_template->activities[4];
if ( $item_5->id === $activities_template->activity->id ) {
echo '<li>';
echo '<div class="activity-content">';
echo 'place add code here';
echo '</div>';
echo '</li>';
}
};
add_action( 'bp_before_activity_entry', 'custom_markup_before_every_fifth_activity' );
Thanks for that. I tried writing a for loop using the modulus operator for every 5th post, but it doesn’t seem to be working. Is there a better way to do this?
Fifth post? here’s what code looks like
Yes, it has to be every 5th update. so the 5th, 10th, 15th and so on… I can’t get it to loop through that way. I appreciate your help.
I’m still confused, the code I gave you will add content above every 5th item. when you click load more it adds to the 5th item in the response.
If you have 20 items and you want every 5th item. then you can check array
function custom_markup_before_every_fifth_activity() {
global $activities_template;
$items = array(
$activities_template->activities[4]->id,
$activities_template->activities[9]->id,
$activities_template->activities[14]->id,
);
if ( in_array( $activities_template->activity->id, $items, true ) ) {
echo '<li>';
echo '<div class="activity-content">';
echo 'place add code here';
echo '</div>';
echo '</li>';
}
};
add_action( 'bp_before_activity_entry', 'custom_markup_before_every_fifth_activity' );