• Hi there,

    I’ve got on my site a news category. It displays on my front page my latest news.

    I want it to display from the 4th news article, and not from the first.

    So it won’t be smthing like this: 1-2-3-4-5-6-7-8-9-10, but rather smthing like this: 4-5-6-7-8-9-10.

    The offset solution is no good.

    Can somebody help me with this ?

Viewing 15 replies - 1 through 15 (of 19 total)
  • Why is the offset solution no good? Sounds like exactly what you want?

    Thread Starter dorinspoaller

    (@dorinspoaller)

    Because it bugs the hell out of older and newer entries. Pages 2,3 and so on display the frontpage, and not the correct archive.

    So just skip over them in the loop then.. , find this..

    if( have_posts() ) : while( have_posts() ) : the_post();

    .. change to..

    if( have_posts() ) :
    $counter = 0;
    while( have_posts() ) : the_post();
    $counter++;
    if( $counter < 4 ) continue;

    Ideally you should use the offset, but if that’s not an option the above should suffice.

    continue;

    ..basically means, move onto the next item in the loop (so essentially just skipping the given result).

    What do you exactly mean by this, pagination doesn’t work correctly when you use the offset paramter? All pages are displaying posts that are on the first page?

    Are you using any other query before displaying your posts?

    I mean you could set something up using some PHP if you like, such as:

    <?php
    $postnum = 0;
    the wp loop here
    
    $postnum ++;
    if($postnum > 4){
    Then display what you want from the posts here
    }
    
    end loop

    So the first 4 posts will be retrieved but nothing is displayed from them because of the if statement.

    But i’m sure there would be a WP based solution with offset.

    you may want to work through these results: https://www.google.co.uk/search?sourceid=navclient&hl=en-GB&ie=UTF-8&rlz=1T4SNYK_en-GBIE248IE248&q=pagination+query+problems+wordpress?

    or you could post the relavant code of your index.php (?) here for someone to look at it ??

    Thread Starter dorinspoaller

    (@dorinspoaller)

    @t31os

    I don’t find it. Where does that go ?

    @xdesi

    All pages display the front page articles if I use offset

    @alchymyth

    The code that interests me is in the home.php file (I think). index.php is empty ??

    The home.php file cand be found at https://anilumina.com/cod.txt

    Featured 1 and 2 are OK, the news section is the one with the problem.

    When you set an offset, yes it does screw up paging, the reason for this is because the paging system usually sets and moves this offset as required, when you set your own offset, you have to adjust the paging to account for it or alternatively write your own paging…

    My suggestion above simply skips over the first 3 posts..

    It may actually be wise to check it’s the first page to..

    Where does it go?…

    Well that all depends which template file (in your theme) handles display of the given page you wish to effect.

    Have you tried adding offset into the $news_query array?

    Thread Starter dorinspoaller

    (@dorinspoaller)

    @t31os

    The template file that handles the display of the given page I wish to effect is home.php. Unfortunately, the section that interests me is:

    <!-- News Articles -->
    <?php
    $news_query = array(
    	'cat' => arras_get_option('news_cat'),
    	'paged' => $paged,
    	'showposts' => ( (arras_get_option('index_count') == 0 ? get_option('posts_per_page') : arras_get_option('index_count')) )
    );
    
    // if you are a WP plugin freak you can use 'arras_news_query' filter to override the query
    wp_reset_query(); query_posts(apply_filters('arras_news_query', $news_query));
    
    arras_get_posts('index') ?>

    And it is not something that I can fix ??

    @xdesi

    Yes, but it bugs the pagination ??

    Sorry you’ll have to ask someone familiar with the theme, i’m not acustom to the functions for that particular theme.

    Thread Starter dorinspoaller

    (@dorinspoaller)

    Thanks anyway. I’ve been on Arras Theme forum and everybody has this problem, but nobody knows how to fix it :))

    Can you post up function arras_get_posts, it’s probably in functions.php

    Thread Starter dorinspoaller

    (@dorinspoaller)

    Hi XDESI,

    This is the only arras_get_posts I found.

    arras_get_posts('index') ?>
    
    <?php if(function_exists('wp_pagenavi')) wp_pagenavi(); else { ?>
    	<div class="navigation clearfix">
    		<div class="floatleft"><?php next_posts_link( __('Older Entries', 'arras') ) ?></div>
    		<div class="floatright"><?php previous_posts_link( __('Newer Entries', 'arras') ) ?></div>
    	</div>
    <?php } ?>
    
    <?php arras_below_index_news_post() ?>

    And it is in home.php ??

    that is the function from /arras-theme/library/template.php

    https://wordpress.pastebin.com/m7637f1c4

    Thread Starter dorinspoaller

    (@dorinspoaller)

    Nobody ? ??

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘PHP Code’ is closed to new replies.