exclude pages by id in this script?
-
Hi,
I came across this piece of code to show some random pages in a little “related pages” section on a specific template. The problem is, this code chooses from every page on my website. I want to exclude pages such as my sitemap, contact page, … from displaying because they are irrellevant. Any idea how and where i should adapt this code to exclude a couple of pages by id? It would be appreciated!
working example:
https://www.preciamolen.be/info/een-weegschaal-voor-iedere-sector/
[ Moderator Note: Please post code or markup snippets between backticks or use the code button. Not the single quote, that doesn’t work. ]
<? $args=array( 'orderby' => 'rand', 'post_type' => 'page', 'post_status' => 'publish', 'posts_per_page' => 3, 'caller_get_posts'=> 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { echo '<div class="relatedpagesbox"><p>Bekijk ook onze andere producten en diensten:</p>'; while ($my_query->have_posts()) : $my_query->the_post(); ?> <p class="relatedpage"><a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p> <?php endwhile; } wp_reset_query(); // Restore global post data stomped by the_post(). ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘exclude pages by id in this script?’ is closed to new replies.