You'll see that we've used some functions beginning with the word "get"—get_the_author, get_avatar, get_the_author_meta, and get_the_author_description. These are functions WordPress provides to retrieve author info and avatars.

As a general rule, WordPress functions beginning with the_ include an echo statement, whereas those beginning with get_the_ don't. For example, WordPress includes both the_author15 and get_the_author16 methods. Both retrieve the same information, but get_the_author returns it for you to use in your PHP code, whereas the_author outputs it directly using echo.


is exactly the same as:

If you tried to use the_author by mistake in the wicked_showbio function, you'd end up with a mess: PHP would output the author name as soon as you called the_author, which is well before you return $content to the filter. This would result in the author names showing up at the top of the post, instead of where you wanted them.

In functions.php, a filter for thematic_post will take care of attaching our function to the end of the post content:

chapter_05/v5/wicked/functions.php (excerpt) add_filter('thematic_post',lwicked_showbiol, '70');

Remember to add some CSS to your theme to make that new div look sexy.

Posts with Excerpts

For our last trick, we'll take some more drastic action: we'll remove the default list of posts from the front page and replace it with a list of our own making. We'll grab the four most recent posts: the newest will live in a large feature area and display its post thumbnail, with the next three arranged chronologically beneath it. Imagine a similar layout to Figure 5.1.

Is there an echo in here?



Was this article helpful?

0 0

Post a comment