• Where is the LOOP in the index.php file?

    I’m trying to limit the posts on the FRONT page only, why that category is still X amount of posts.

    “If you want this on JUST the home page, try adding this:

    <?php //new query to limit number of posts
    	$wp_query = new WP_Query();
    	$wp_query->query($query_string."&posts_per_page=2&paged=".$paged);
    ?>

    to index.php, just before the loop.”

Viewing 6 replies - 1 through 6 (of 6 total)
  • that depends on the theme

    https://codex.www.ads-software.com/The_Loop_in_Action

    if you, after reading the docu, still don’t know, you could paste the code of index.php into a https://wordpress.pastebin.com/ and post the link to it here.

    Thread Starter JDNGuru

    (@jdnguru)

    Do I need to have a certain plugin before using that code? I believe I put that code before the header and it’s still not working.

    index.php code:
    https://wordpress.pastebin.com/rsa2ddmp

    Thread Starter JDNGuru

    (@jdnguru)

    Anyone?

    you theme has several loops, so it is difficult to say in which line you want to limit the number of posts.

    one loop is from line 78 of your code:

    <?php
                    global $myOffset;
                    $myOffset = 1;
                    $temp = $wp_query;
                    $wp_query= null;
                    $wp_query = new WP_Query();
                    $wp_query->query(array(
                                    'offset' => $myOffset,
                                    'category__not_in' => array($ar_headline,$ar_featured),
                                    'paged' => $paged,
                                    )); ?>
    
                    <?php if (have_posts()) : ?>

    you might be able to add you limiting number into the query
    'posts_per_page' => 2,

    the other loop is from line 164:

    <?php
                    global $myOffset;
                    $myOffset = 1;
                    $temp = $wp_query;
                    $wp_query= null;
                    $wp_query = new WP_Query();
                    $wp_query->query(array(
                                    'offset' => $myOffset,
                                    'category__not_in' => array($ar_headline,$ar_featured),
                                    'paged' => $paged,
                                    )); ?>
    
                    <?php if (have_posts()) : ?>

    same thing there with your posts limit.

    always make a backup copy of your theme files before editing

    a link to your site might help to illustrate your challenge.

    Thread Starter JDNGuru

    (@jdnguru)

    My site is: themusicofdavidsides.com

    I am trying to limit the video category on the first page. I want it so it only SHOWS about 20 recent videos, while the true Video category shows all of them.

    I have tried going to Settings > Readers and set it to 200, but that also limits the true Video category AND the Front page.

    I would like to limit the front page video category to 20 posts only.

    Thanks, alcymyth. I’ll try playing around with this.

    Thread Starter JDNGuru

    (@jdnguru)

    Tried inserting the code, no luck.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Where to find the LOOP in index.php?’ is closed to new replies.