Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2772
    kangooloss3
    Member

    Dear Developer,

    I have two questions about placing the content between specific posts:

    1) I want to place content after specific posts on the homepage – say after 1st and 3rd post.
    The code I’d use would look like this:

    <?php if (($count == 1) || ($count == 3)): ?>
    CODE HERE
    <?php endif; $count++; ?>

    Where should I place the code precisely, so that the content is displayed “inside” the post box (right under the text: Posted in Uncategorized| Leave a reply), and not under the post, but outside the post area (between the two post boxes). Normal location for the code – inside the main loop, results in the content being displayed between the posts, but outside the post area.

    Second case – placing the content between the posts, but outside the post area: how to center it, so that left and right margins are the same, as well as the top and bottom margins (so that the spacing above and below the content is equal)?

    2) How to center the above content so it is displayed with the same left and right padding inside the post box? What code should I use and where? Placing the content code inside the <div style=”text-align: center;”></div> ruins the layout of the sidebar.

    Thank you

    Best regards

    #2776
    kangooloss3
    Member

    Since another question I’d like to ask is similar, I’ll ask it in this post:

    3) How to place content at the end of every post? Where to place it, exactly – by default done in single.php after <div class=”entrytext”>

    Thank you.

    #2832
    Sakin
    Keymaster

    @kangooloss3: you will need to edit index.php and do it like below:


    <?php $count=1; while ( have_posts() ) : the_post(); $count++; ?>
    <?php if ( $count == 2 || $count == 4 ): ?>
    <div class="hentry" style=" text-align: center;">
    <?php echo $count ; ?> CODE HERE
    </div>
    <?php endif; $count++; ?>
    <?php get_template_part( 'content', get_post_format() ); ?>
    <?php endwhile; ?>

    #2947
    kangooloss3
    Member

    Thank you.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Placing the centered content between the posts’ is closed to new replies.