Forums

wp_list_pages: show author and exclude certain pages? (6 posts)

  1. stufferino
    Member
    Posted 3 years ago #

    Hello!

    I'm quite new at the web design game and although things have been coming along nicely so far I seem to have hit a wall.

    This is the site I'm designing: nicksinger.com/blog . I intend to run the site as a CMS with many different users. Each "article" will be its own page.

    My two questions are:
    1. Is it possible for me to show the names of authors next to the titles of the articles? It's so strange that wp_list_pages has the ability to display the date that an article was posted but NOT the author's name. I can't seem to figure out how to do it.
    2. Can you set wp_list_pages to include only the five or six most recent articles? I have it so that it lists all the pages by date--now if only I could get it to show only the top five. I wrote an ugly bit of CSS that can just shrink the n+5 children of the list down to a pixel, but it seems like a quick fix that will end up biting me in the ass (and it still leaves the invisible but clickable links at the bottom of the div).

    Any and all help would be much appreciated, and I can explain things in more detail if it's unclear.

    Thanks!
    Stufferino

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    You could use authors=x (where x is the user id) with the template tag, wp_list_pages(), but you will likely need to resort to query_posts() to get just 5 pages.

  3. stufferino
    Member
    Posted 3 years ago #

    thanks for the response, MichaelH, but i still dont understand.

    the "authors=" parameter only works to include or exclude certain authors from the list of pages, right? i am trying to SHOW the author's name next to the title of the page. this will not be limited to one author though, it will probably include a few dozen different authors, so i can't simply add their names every time a new one appears. it needs to work automatically.

    query_posts doesnt seem to have much functionality with pages.

    thanks again,
    stufferino

  4. MichaelH
    Volunteer
    Posted 3 years ago #

    Sorry - look at using get_pages.

  5. stufferino
    Member
    Posted 3 years ago #

    get_pages seems to have even fewer parameters than wp_list_pages.
    what are you referring to?

  6. MichaelH
    Volunteer
    Posted 3 years ago #

    Just looked at the wp-includes/post.php. Here's a better list;

    $defaults = array(
    	'child_of' => 0, 'sort_order' => 'ASC',
    	'sort_column' => 'post_title', 'hierarchical' => 1,
    	'exclude' => '', 'include' => '',
    	'meta_key' => '', 'meta_value' => '',
    	'authors' => '', 'parent' => -1, 'exclude_tree' => ''
    );

    You may have to use a counter to limit the pages to 5.

    Don't forget if you are using something like:
    $pages = get_pages();
    you can use var_dump($pages); to 'look' at all the results returned.

Topic Closed

This topic has been closed to new replies.

About this Topic