How can I check if a given entry is the first entry in the loop? Unfortunately, Disqus only works in the first post. I would like to loop through the "Go to Comments" button, but I do not know how to formulate a conditional statement so that it does not appear in the first entry.
I'd like to do this in /template-parts/single-content-main.php
Hi,
How can I check if a given entry is the first entry in the loop?
Unfortunately, Disqus only works in the first post. I would like to loop through the "Go to Comments" button, but I do not know how to formulate a conditional statement so that it does not appear in the first entry.
I'd like to do this in /template-parts/single-content-main.php
Regards
Hi,
The content on the template file below only shows the single post content & just 1 post only.
/template-parts/single-content-main.php
If you want to check the first entry in the loop, you can view the concept below:
<?php
$inc = 1;
$the_query = new WP_Query();
$the_query->query("posts_per_page=4");
if ($the_query->have_posts()) : while($the_query->have_posts()) : $the_query->the_post();
if($inc == 1){ //first post here
//do stuffs here
}
else{
//the rest of the posts
} $inc++; //counter
endwhile; endif; wp_reset_postdata();
?>
Regards,
PenciDesign.
Hmm ... so which file should I edit if not /template-parts/single-content-main.php?
I would like to get the effect like here:
https://antyweb.pl/black-week-allegro
The first post shows disqus, but in the next post, in the infinite loop, there is a button "Pokaż komentarze" in place of disqus.
Hi,
About your request, there 2 files you need to modify:
Regards,
PenciDesign.