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.

There is a function in a theme that I am using that does some pagination stuff. I do NOT want that function to show up on my home page (only), so I'm trying to set up an if/else statement but can't for the life of me can't get it to work right. Using the following code, the function shows up not only on the homepage but also on the category pages. I am using this code in my index.php file and my site is setup to show posts from a custom post type.

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div>My Loop Stuff Here</div>
<?php endwhile; ?>

<?php if (!( is_home() || is_front_page() )) : function_to_NOT_show_on_homepage(); endif; ?>

<?php else: ?>
    [else stuffs]
<?php endif; ?>

<?php wp_reset_query(); ?>
share|improve this question

2 Answers 2

up vote 1 down vote accepted

Based on your pastes, i think what you're going for is..

function cp_do_pagination() {   

    if( is_home() || is_singular() /* || is_front_page() */ )
        return;

    global $post; // <-- do you need this for something in particular?

    if( !function_exists('appthemes_pagination') )
        return;

    appthemes_pagination();
}

The is_singular() function covers is_page(), is_single() and is_attachment(), so no need for the additional conditionals.

Info on that function here, for reference.
http://codex.wordpress.org/Function_Reference/is_singular

share|improve this answer
    
face palm clearly my statement was false with regard to is_singular, either the function has changed or i misunderstood it's usage to begin with, is_singular does in fact compare against a post type or post types... (i really should read the page i'm linking to)... –  t31os Aug 18 '11 at 22:04
    
Thanks t3los, but that doesn't work either. It shows up on the blog pages and the custom post pages, but it also shows up on the homepage, which is what I am trying to remove it from. –  RodeoRamsey Aug 18 '11 at 22:11
    
Ok! :) So.... what if we change it to is_home? –  RodeoRamsey Aug 18 '11 at 22:16
    
BTW this whole pagination situation (ha ha) from this theme is really ticking me off... –  RodeoRamsey Aug 18 '11 at 22:17
    
Whoops, forgot the is_home condition, adjusted the code sample. –  t31os Aug 18 '11 at 22:31

i think you need <?php if (is_home()) { ?> this worked for me i dont think is_front_page is required

share|improve this answer
    
If I use is_home, it echos only on the homepage and nowhere else. I want the opposite of that. –  RodeoRamsey Aug 18 '11 at 17:30
    
Did you try adding is_home to your function? –  Jeremy Love Aug 18 '11 at 17:32
    
I tried adding the conditional statement around the function itself, as well as in my index page around the CALL to the function, but neither seem to work. –  RodeoRamsey Aug 18 '11 at 17:45
    
please post your function –  Jeremy Love Aug 18 '11 at 18:00
    
pastebin.com/KgV6NJMd and the second function included in that one is here pastebin.com/KJd9GWiQ –  RodeoRamsey Aug 18 '11 at 18:14

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.