Skip to content
Public Ticket #18897

Infinite loop first post?

Conversation thread

PenciDesign Supporter replied

Staff Reply

Hi,

About your request, there 2 files you need to modify:

  • wp-content/themes/soledad/content-single.php
  • wp-content/themes/soledad/comments.php
  • wp-content/themes/soledad/inc/load_next_prev_posts.php: this file will render the content via AJAX. You can modify it here.

Regards,
PenciDesign.

maciek_l replied

Customer Reply

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.

PenciDesign Supporter replied

Staff Reply

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.



maciek_l started the conversation

Conversation Start

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

Want to join this conversation or access attachments? Sign in first.