robertlove
Forum Replies Created
Viewing 4 replies - 1 through 4 (of 4 total)
-
Forum: Fixing WordPress
In reply to: How to show page children links ONLY when viewing parentSlight correction to last post!
You don’t need to
get_the_IDin the loop, and you should check if$page_childrenis empty, not an array. So, with that said:<?php $page_children = get_page_children(get_the_ID(), ''); if (!empty($page_children)) { echo '<ul>'; foreach ($page_children as $child) { echo '<li><a href=\"' . $child->guid . '\">' . $child->post_title . '</a></li>'; } echo '</ul>'; } ?>Forum: Your WordPress
In reply to: review pleaseWTF also. You suck goodman48.
Forum: Fixing WordPress
In reply to: How to show page children links ONLY when viewing parentYes.
In your Page template file (page.php), get the ID of the parent page (this code must be in the loop):
<?php $page_id = get_the_ID(); ?>Then, wherever you want to output the list of links to child pages:
<?php $page_children = get_page_children($page_id, ''); if (is_array($page_children)) { echo '<ul>'; foreach ($page_children as $child) { echo '<li><a href="' . $child->guid . '">' . $child->post_title . '</a></li>'; } echo '</ul>'; } ?>Forum: Themes and Templates
In reply to: How to assign the_author_description to variableIn the loop:
<?php $author_id = get_the_author_ID(); ?>Then, wherever you want to output:
<?php $userdata = get_userdata($author_id); ?> <?php if ($userdata->description != '') { ?> <h2>About the Author</h2> <p><?php _e($userdata->description); ?></p> <?php } ?>Thanks for the heads up on get_the_author_ID() Ei Sabai. Who needs the experts when I have you sitting in the next office 🙂
Viewing 4 replies - 1 through 4 (of 4 total)