• I would like to ad my own content after the second category in the loop, but i don’t know PHP that well.
    I have tryed to ad <?php $count++; ?> and <?php if ($count == 2) : ?>, but without luck.
    If I just ad the content, it will show before every category in the loop.

    I’m really lost. Are there any sugetions?
    This is how it lokks right now:

    <?php
    function get_home_wide_cat( $cat_data ){
    $count = 0 ;
    $Cat_ID = $cat_data[‘id’];
    $offset = $Posts_num = $order = $rand = ”;

    if( !empty($cat_data[‘number’]) )
    $Posts_num = $cat_data[‘number’];

    if( !empty($cat_data[‘order’]) )
    $order = $cat_data[‘order’];

    if( !empty($cat_data[‘offset’]) )
    $offset = $cat_data[‘offset’];

    if( $order == ‘rand’) $rand =”&orderby=rand”;

    $cat_query = new WP_Query(‘cat=’.$Cat_ID.’&no_found_rows=1&posts_per_page=’.$Posts_num.$rand.’&offset=’.$offset);
    $cat_title = get_the_category_by_ID($Cat_ID);

    ?>
    <?php $count++; ?>
    <?php if ($count == 2) : ?>
    <section class=”cat-box wide-cat-box”>
    <div class=”cat-box-content”>
    <h2 class=”post-box-title”>Instagram</h2>
    <!– my own content –>
    </div>
    </section>
    <?php else : ?>
    <section class=”cat-box wide-cat-box tie-cat-<?php echo $Cat_ID ?>”>
    <!– loops of categories –>
    </section><!– List Box –>
    <?php endif; ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m not that great at WordPress, but it seems to me, that your missing the loop. That said, you need to put the if statement if($count == 2), along with the $count++ into the loop. Otherwise it will remain the same after each loop…

    // Ulrik McArdle

    Thread Starter Danny Bahl

    (@dannybahl)

    I’m not I understand …
    Like this?:

    <?php
    function get_home_wide_cat( $cat_data ){
    $count = 0 ;
    $Cat_ID = $cat_data[‘id’];
    $offset = $Posts_num = $order = $rand = ”;

    if( !empty($cat_data[‘number’]) )
    $Posts_num = $cat_data[‘number’];

    if( !empty($cat_data[‘order’]) )
    $order = $cat_data[‘order’];

    if( !empty($cat_data[‘offset’]) )
    $offset = $cat_data[‘offset’];

    if( $order == ‘rand’) $rand =”&orderby=rand”;

    $cat_query = new WP_Query(‘cat=’.$Cat_ID.’&no_found_rows=1&posts_per_page=’.$Posts_num.$rand.’&offset=’.$offset);
    $cat_title = get_the_category_by_ID($Cat_ID);

    if ($count == 2) :
    ?>

    <section
    and so on …

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Own content within the loop’ is closed to new replies.