[resolved] exclude codes from different pages? how? (3 posts)

  1. s2pidkaspr
    Posted 4 years ago #

    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.

  2. MichaelH
    Posted 4 years ago #

    Didn't test this, but you could use something like the php in_array to test that condition:

    if(function_exists('the_views')) {
      if ( !in_array($post->ID, array(5,12,40,50)) ) { //if NOT in array
  3. s2pidkaspr
    Posted 4 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic