• Resolved s2pidkaspr

    (@s2pidkaspr)


    Hello,
    I’m running a site using pages as posts..
    and i want to insert wp postviews code on page.php to have it available on pages..however, there are certain pages that I dont want to have views on. How can I exclude those pages so that only pages that I want have the code that I have with wp postviews?

    To make it more easy to understand,
    Whenever I put this code

    <?php if(function_exists(‘the_views’)) { the_views(); } ?>

    on page.php
    All pages have been visible for views. (for example 203 Views)
    But I only want that code to be on pages that I want views only NOT ALL of them. But how? I can’t even put that code on pages itself. =/

    This also for my other codes that I want not only for this code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Didn’t test this, but you could use something like the php in_array to test that condition:

    <?php
    if(function_exists('the_views')) {
      if ( !in_array($post->ID, array(5,12,40,50)) ) { //if NOT in array
        the_views();
      }
    }
    ?>
    Thread Starter s2pidkaspr

    (@s2pidkaspr)

    Thanks..I already found a way much easier 😉 I appreciate the help..

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘exclude codes from different pages? how?’ is closed to new replies.