Use get_pages and something like this in your loop:
if ($post->post_parent != 116 ) {
Thread Starter
slee
(@slee)
i have tried this:
$args=array(<br />
'post_type' => 'page',<br />
'orderby' => $orderby,<br />
'posts_per_page' => 50,<br />
'child_of' => 116,<br />
'order' => $order<br />
);<br />
get_pages($args);
with if ($post->post_parent != 116 ) {
as you suggested in the loop,
but that is only returning a link to the page that this is running on???
can i use it with the normal loop or doi have to use a foreach loop?
You would need a loop of some kind to iterate through the array of pages returned by get_pages.
Could use the same code I gave you in your other thread, but use this instead of the get_posts/query_posts
$args=array(
'post_type' => 'page',
'post_parent' => 116,
'meta_key' => $key,
'meta_value' => $mvalue,
'orderby' => $orderby
);
$pages = get_pages($args);
Thread Starter
slee
(@slee)
i really appreciate your help but using that with the previous code doesn’t output anything even before i put the if ($post->post_parent != 116 ) {
i hav added two pages that are children of two different pages that have the parent of 116 so i should get 2 pages outputted.
if i remove the meta_key, meta_value and the orderby then i get every single page.
Well I used this with success:
<?php
echo 'get pages';
$parent = 93;
$args=array(
'child_of' => $parent
);
$pages = get_pages($args);
if ($pages) {
foreach($pages as $post) {
setup_postdata($post);
if ($post->post_parent != $parent ) { ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
}
} // foreach($pages
} // if ($pages
?>
Thread Starter
slee
(@slee)
ah it was because i still had:
‘post_type’ => ‘page’,
which obviously isnt needed any more
thanks for the help 🙂
Thread Starter
slee
(@slee)
i have hit a problem with this, i want to be able to filter the results by using meta_key and meta_value but when i use the meta_value it does not work.
i have simply got `’meta_key’ => $key,
‘meta_value’ => $mvalue,`
which then using get capture the value but even if i hardcode them they don’t work.
i have a custom field called location and i have 1 page with the value Greece but if i use meta_value greece with meta_key location nothing is outputted am i doing something wrong?
This works okay for me:
<?php
echo 'get pages';
$parent = 93;
$args=array(
'child_of' => $parent,
'meta_key' => 'cf1',
'meta_value' => 'cf1 value'
);
$pages = get_pages($args);
if ($pages) {
foreach($pages as $post) {
setup_postdata($post); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
} // foreach($pages
} // if ($pages
?>
Thread Starter
slee
(@slee)
i tried your code replacing he cf1 with location and greece for the value but nothing was outputted. when you tested it did you try it with the grandchildren?