...

View Full Version : PHP / Wordpress Question



CarlMartin10
07-03-2010, 04:47 AM
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


<!-- 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


# 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
}
}
}

bennyy007
07-03-2010, 06:03 AM
Hi,

Please refer to the Function Reference:

http://codex.wordpress.org/Function_Reference/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.php?action=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 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.

CarlMartin10
07-03-2010, 07:58 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum