Support » Fixing WordPress » Removing sidebar ads from pagination

  • Resolved Sierra81

    (@sierra81)


    I use pagination and, as you know, the pages like com/page/2/ com/page/3/ etc show the template of the homepage. How can I change the template of the “pages” or make them use the same template as archive pages? More exactly, I want to make the blogroll disappear from the pagination of the index.php and let it appear on the homepage only.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Are you referring to the Links widget?

    Thread Starter Sierra81

    (@sierra81)

    Yes, the blogroll. Mine is not a widget that I control from WordPress, but a block of code that I can add or remove/customize.
    I don’t even know how to name the “com/page/2/” type pages because they are not actually WordPress pages.
    I found this code in a blog article from 2006:
    <?php if(is_home() && $post==$posts[0] && !is_paged()) { ?>
    PLACE ADVERTISEMENT HERE.
    <?php } ?>
    but I don’t know how to use it; it doesn’t seem to work with what I have. I tried to place my blogroll code inside this code, where it says “PLACE ADVERTISEMENT HERE”, but it removes it even from the homepage, where I want it to appear.

    Mine is not a widget that I control from WordPress, but a block of code that I can add or remove/customize.

    What theme is this? Where did you download it from?

    Thread Starter Sierra81

    (@sierra81)

    It’s a theme I customized a long time ago, but I use the Page Numbers plugin to show page numbers for easy navigation. I use a sidebar for the homepage and a different sidebar for Pages and Posts. I need to be able to use a different sidebar for the paginated homepage (homepage pages starting with the second page). I read that this is not possible with WordPress because all the homepage pages (paginated) are treated as the homepage and use the same theme. You can’t create a different theme for them, like with Pages and Posts. So I have to find a way to leave the blogroll on the first page of the homepage (page number 1) and remove it from all the other pages (page 2, 3, etc).

    but a block of code that I can add or remove/customize.

    wrap that block of code into a php conditional statement using the conditional tag is_paged()

    http://codex.wordpress.org/Function_Reference/is_paged

    Thread Starter Sierra81

    (@sierra81)

    That’s what I tried to do but I get a parse error.
    The block of code is this (in sidebar.php):

    <div class="sidemenubar">
    <h2>Friends:</h2>
    </div>
    <div class="sidemenubox">
    <ul>
    <?php get_links(-1, '<li>', '</li>', '', FALSE, 'name', FALSE, FALSE, -1, FALSE); ?>
    </ul>
    </div>

    and if I wrap it I get a parse error:

    <?php if(is_paged()) {
    
    <div class="sidemenubar">
    <h2>Friends:</h2>
    </div>
    <div class="sidemenubox">
    <ul>
    <?php get_links(-1, '<li>', '</li>', '', FALSE, 'name', FALSE, FALSE, -1, FALSE); ?>
    </ul>
    </div>
    
    } ?>

    you need to close the php tags before going back to html; and vice-versa.
    the ! is the negation to check for 'is not paged' ;

    example:

    <?php if( !is_paged()) { ?>
    
    <div class="sidemenubar">
    <h2>Friends:</h2>
    </div>
    <div class="sidemenubox">
    <ul>
    <?php get_links(-1, '<li>', '</li>', '', FALSE, 'name', FALSE, FALSE, -1, FALSE); ?>
    </ul>
    </div>
    
    <?php } ?>

    Thread Starter Sierra81

    (@sierra81)

    Perfect! That fixed everything 🙂 Thank you very much, alchymyth!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Removing sidebar ads from pagination’ is closed to new replies.