Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2010
    Posts
    207
    Thanks
    30
    Thanked 0 Times in 0 Posts

    PHP / Wordpress Question

    Not sure if anyone here knows enough about Wordpress to help me or not, but it is worth a shot. Thanks in advance.

    I am trying to exclude a page in the nav menu on my site. I am using the Mensa Theme, and the

    <?php wp_list_pages('exclude=17,38' ); ?>

    Method is not working. Any ideas?

    Here is some code from:

    header.php

    Code:
    <!-- BEGIN header -->
    	<div id="header">
    
    		<div class="search">
    			<form action="<?php echo get_option('home'); ?>/">
    				<input type="text" name="s" id="s" value="<?php the_search_query(); ?>" />
    				<button type="submit">S</button>
    			</form>
    		</div>
    		<div class="logo">
    			<h1><a href="<?php echo get_option('home'); ?>"><?php bloginfo('name'); ?></a></h1>
    		</div>
    
    		<ul>
    			<li><a href="<?php echo get_option('home'); ?>">Home</a></li>
    			<?php dp_list_pages(); ?>
    		</ul>
    
    		<div class="break"></div>
    
    	</div>
    	<!-- END header -->
    functions.php

    Code:
    # Displays a list of pages
    function dp_list_pages() {
    	global $wpdb;
    	$querystr = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'page' ORDER BY $wpdb->posts.ID ASC";
    	$pageposts = $wpdb->get_results($querystr, OBJECT);
    	if ($pageposts) {
    		foreach ($pageposts as $post) {
    			?><li><a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a></li><?php
    		}
    	}
    }

  • #2
    New Coder
    Join Date
    Oct 2009
    Posts
    26
    Thanks
    2
    Thanked 1 Time in 1 Post
    Hi,

    Please refer to the Function Reference:

    http://codex.wordpress.org/Function_.../wp_list_pages

    However to exclude a page from being displayed by wp_list_pages(); you need to know the correct page ids which can be found in the address bar when editing the pages in the Admin Panel on WordPress.

    Example:

    http://www.example.org/wp-admin/page...=edit&post=309

    The end bit is the Page ID (post=309) so say I wanted to exclude 309 & 308 I would simply use the exact method you used:

    PHP Code:
    <?php wp_list_pages('exclude=308,309' ); ?>
    That would then exclude those two pages, I know this isn't much help but your right on tracks but it could possibly be that your not using the correct Page ID.

    Hopefully this solves your issue.

  • #3
    Regular Coder
    Join Date
    Apr 2010
    Posts
    207
    Thanks
    30
    Thanked 0 Times in 0 Posts
    I did this already as I explained in my original post. It is not working for some reason. Also, I used a plugin that is supposed to do this, as well, but it did not work wither. The functions.php for this theme does not call

    wp_list_pages();

    but rather dp_list_pages();

    I tried to add the exclude argument, but nothing.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •