PDA

View Full Version : Loop Customization : the_* function shortcomings


sams
February 20th, 2006, 08:38
I am trying to create a less blog like look to my site. I have found a few articles such as this (http://ifelse.co.uk/archives/2005/04/08/query_posts-redux/) and this (http://ifelse.co.uk/archives/2005/03/31/query_posts/)

I have just found the that the_title() accepts three params (http://codex.wordpress.org/index.php?title=Template_Tags/the_title&redirect=no), great. A before and after, and a boolean option to return or echo the result. However comparetive functions the_exceprt() the_meta() etc (hence the title of this post 'the_*') don't accept these params.

In order to what I plan I would like to return the values of each of the functions within the loop.

for example



$ex = the_excerpt("", "", false);
$dt = the_date("<span class=\"newsItemDate\">", "</span>", false);
$tt = the_title("<span class=\"newsTitle\">", "</span>", false);

// the mix it together
$newsItem = str_replace("<p>", "<p>" . $tt . "<br />" . $dt, $ex);

// further loop process
....




Is there a way to do this?

steveo
February 20th, 2006, 11:20
you can access all the post data in the loop with using $post->columnname. replace columnname with the data you seek. For example, the content is post_content. So to access the raw content, use $post->post_content. You can take a peak at all the data by adding print_r($post); in theloop.php at line 48:

/* Start The Loop */ while (have_posts()) { the_post(); print_r($post);