WordPress.org

Ready to get started?Download WordPress

Forums

list pages with description (4 posts)

  1. sagebrown
    Member
    Posted 5 years ago #

    I'm trying to get a list of my wordpress pages in the sidebar, along with a custom key from each page, that I'm using to create a description.

    The list would look like this:

    Page title - description here
    Page title2 - another description

    The description would come from a custom key that I add to each page.

    I've searched EVERYWHERE and can't seem to find an easy way to do this. Any ideas?

  2. MacDoodle
    Member
    Posted 5 years ago #

    Sage, did you ever get this resolved?

    I need the same thing, except want to generate the list w/ description on an archive page.

    Anybody?

  3. MacDoodle
    Member
    Posted 5 years ago #

    Figured out a solution based on code samples found here:
    http://codex.wordpress.org/Function_Reference/get_pages

    <?php
    
    $pages = get_pages('child_of='.$post->ID); // selects all children of current page
    
    	foreach($pages as $page) {
    
     		$custom_blurb = get_post_meta($page->ID, 'custom_blurb', true); // grabs description from custom field
    
    	echo "<h3><a href=\"".get_page_link($page->ID)."\">$page->post_title</a></h3>";
    	echo $custom_blurb;  
    
    	}
    ?>
  4. CowboyFrank
    Member
    Posted 4 years ago #

    Thanks for posting this! Exactly what I needed!

Topic Closed

This topic has been closed to new replies.

About this Topic