echo php in <?php wp_list_pages( $args ); ?>
-
Hi,
I have a WordPress site with a lot of pages. I’m loading this in the sidebar:
<?php if($post->post_parent) { $children = wp_list_pages("depth=2&&title_li=&child_of=".$post->post_parent."&echo=0"); $titlenamer = get_the_title($post->post_parent); } else { $children = wp_list_pages("depth=2&title_li=&child_of=".$post->ID."&echo=0"); $titlenamer = get_the_title($post->ID); } if ($children) { ?>You see, to keep the overview, I’m using the ‘&depth=2‘.
Now I want to do something and I’ll try to explain this.I want to echo a code what I’ve written in PHP, in the code:
$children = wp_list_pages("depth=2&title_li=&child_of=".$post->ID."&echo=0");The code what I want to echo is:
<?php $exclude = ''; if($_GET['page_id'] == 33 ) $exclude='&exclude=17,38'; ?>So, to echo the code, I have to put the code
<?php echo $exclude;?>
somewhere in the ‘&children‘ code.Something like this:
$children = wp_list_pages("depth=2<?php echo $exclude;?>&title_li=&child_of=".$post->post_parent."&echo=0");But, as I had expected, this doesn’t work.
My question: how can I echo PHP in the WordPress code? Of course I know I can use the ‘exclude’ code in the &children, but I want to exclude some pages ONLY when I load 1 page (when I load Page ID 33).
Thanks for helping!
The topic ‘echo php in <?php wp_list_pages( $args ); ?>’ is closed to new replies.