Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to add some content (slider) only on the home page. I don't want it to apear on the other pages. I am trying following:

<?php if(is_home()) { ?>
<div>
...
<div>
} ?>

But the content still appears on the second page (in pagination). How can i show some content to homepage only, so that id does not appear on second page? Thanks.

share|improve this question
add comment

4 Answers

The following lines should speak for themselve:

global $paged;

$max_page = (int) $wp_query->max_num_pages;
if ( $max_page > (int) 1 )
    $paged = ! $wp_query->query_vars['paged'] ? (int) 1 : $wp_query->query_vars['paged'];

// If not on the first page, not on the home or static front page and not if paged should (for some) reason be zero
if ( (int) 1 !== $paged && (int) 0 !== $paged && ( ! is_home() || ! is_front_page() ) )
{
    // display stuff
}
share|improve this answer
add comment
<?php if(is_home() && !is_paged()) { ?> 

http://codex.wordpress.org/Conditional_Tags

share|improve this answer
add comment

Have you tried <?php if(is_front_page()) { ?> I believe this is for using with sites that use a static home page.

share|improve this answer
add comment

I always use home.php instead of index.php if I want a completely different home page than the other pages.

I put this code in just before The Loop on home.php: <?php query_posts('cat=X&showposts='.get_option('posts_per_page')); ?> where cat=X is the category ID of a category I created and usually call Homepage or Frontpage.

Then on the index page place this code: <?php query_posts($query_string . '&cat=-X'); ?> before the loop where &cat=-X is the same ID of your Homepage category. Notice the minus sign.

Now just pick the Homepage or Frontpage category for the posts you want only on the home page.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.