Support » Themes and Templates » WP_Query issue/question?

WP_Query issue/question?

  • I am trying to create links to only pages found in section 11, but seem to not be able to with what I have so far. I am trying to do it via the following, but I think something is not quite right the way I have the array in the beginning? What am I doing wrong?

    	$query = array (
    		'child_of' => 11,
    		 'sort_column' => 'post_title',
    	   	 'post_type' => 'page'
    	$queryObject = new WP_Query($query);
    	if ($queryObject->have_posts()) {
    		while ($queryObject->have_posts()) {

    Thank you very much for any help with this!!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael
    Forum Moderator


    what is the code doing?

    obvioulsly, there is no link html code in the above, so far.

    is it showing the titles of the child pages of page 11?

    link to your site?

    I am trying to generate links. So where it now says the_title(), it will later generate li tags, like so:

    while ($queryObject->have_posts()) {
    	echo '<li><a href="'; the_permalink(); echo '">'; the_title(); echo '</a></li>';

    But for simplicity, I took that out. I was thinking keeping the post simple might make it easier to grasp. Sorry if I wasn’t clear, I guess it did the opposite.

    Yes, I would like to show all the subpages of page 11. This is for a sub navigation only on pages of section 11.

    Thanks a lot!

    Forum Moderator



    post_parent (int) – use page id. Return just the child Pages.

    try to use the above parameter instead of ‘child_of’

    withour checking, i went with the idea that ‘child_of’ should work ( as it does in get_pages() ), however, it does not seem to be a (valid) parameter of wp_query()

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WP_Query issue/question?’ is closed to new replies.