• Resolved george.brooks

    (@georgebrooks)


    Hi, I’m currently finishing up a lab website temporarily hosted here and I’m having all sorts of trouble. I’ve been gradually mutilating this awesome author list template to suit my own needs to produce the ‘Meet the Lab’ section

    Originally the template used a ‘foreach’ loop to produce a little biog for each member of the lab, based on their wordpress profile. However, a paragraph isn’t really enough for most of our lab, and the fact that the biog box on the user profile page doesn’t allow paragraphs is no good.

    SO, with that in mind, I’ll produce child pages for each member in the lab. But Now I want to get the page content (or at least the first paragraph) for each user and reproduce it in their biog.

    The problem I’m having is that the site must be dynamic enough to update with every user added without any tinkering, so simply calling page_ID is a no-no. What I want to do is choose pages that are a child of the ‘Meet the lab’ page, and then pull the content for each author to slot in with their biog.

    This is the code I’m starting from, it’s the ‘description’ section that I want to change.

    <?php
    // Template Name: Authors List
    get_header(); ?>
    <div id='content' role="main">
    <?php $authors = $wpdb->get_results('SELECT DISTINCT user_id FROM '.$wpdb->usermeta .' WHERE user_id<>"1"' );
    		if($authors):
    		foreach($authors as $author):
    		?>
    		<div class='author' id='author-<?php the_author_meta('user_login', $author->user_id); ?>'>
    
    <h1><?php the_author_meta('display_name', $author->user_id); ?></h1>
    
    <h5><?php echo the_author_meta('position', $author->user_id); ?> |
    			<a href='<?php the_author_meta('funding_source', $author->user_id); ?>'><?php echo the_author_meta('funding', $author->user_id); ?></a> | <?php echo the_author_meta('college', $author->user_id); ?></h5>
    
    <div class='description'>
    <?php echo get_avatar(get_the_author_meta('user_email', $author->user_id), 150); ?>
    <p><?php the_author_meta('description', $author->user_id); ?></p>
    			</div>
    			<?php endwhile; ?>
    			</div>
    		<?php endforeach; endif; ?>
    	</div>
    <?php get_footer(); ?>

    Any suggestions? I’m sure I need to use ‘get_pages’ with the ‘child_of’ and ‘author’ arguments, but I just can’t get it to work.

    I’d really appreciate any suggestions.

    Cheers,

    George Brooks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Since all childpages of “Meet the lab” are pages of authors can’t you do a normal loop with query posts or a get posts to show all the authors.

    not tested:

    <?php
    // Template Name: Authors List
    get_header(); ?>
    <?php query_posts('post_parent=2'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div id='content' role="main">
    
    		<div class='author' id='author-<?php the_author_meta('user_login'); ?>'>
    
    <h1><?php the_author_meta('display_name'); ?></h1>
    
    <h5><?php echo the_author_meta('position'); ?> |
    			<a href='<?php the_author_meta('funding_source'); ?>'><?php echo the_author_meta('funding'); ?></a> | <?php echo the_author_meta('college'); ?></h5>
    
    <div class='description'>
    <?php echo get_avatar(get_the_author_meta('user_email'), 150); ?>
    <?php the_content(); ?>
    
    </div>
    </div>
    </div>
    <?php endwhile; ?>
    <?php  endif; ?>
    <?php get_footer(); ?>

    change the post_parent (Page) ID (2) in the query_posts to the one of “Meet the lab”

    Thread Starter george.brooks

    (@georgebrooks)

    Thanks for the suggestion, but I’m going to try it a different way.

    I think I’ll repost a new thread to keep it simple. THis can be deleted i needs be.

    Cheers.

    Thread Starter george.brooks

    (@georgebrooks)

    Thread Starter george.brooks

    (@georgebrooks)

    This has been resolved in the thread above.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get page content from each child page to show on parent page.’ is closed to new replies.