The $post object provides the property:
$post->post_name
Typically, scoping $post
to global will make all of a post’s table records available to your plugin.
Thread Starter
davy27
(@davy27)
I just echo’d $post and it doesn’t show.
add_filter('the_content', 'DEPortfolio_the_content');
function DEPortfolio_the_content($content)
{
$content = 'I am the content. Marvel at my simplicity!' . $post;
return $content;
}
I’ve got this horrible feeling I’m handling this from the wrong direction. I want to have a blog on the index, but on the portfolio page I want to list all blog entries with category ‘portfolio’. I figured I could use a plugin and filter out all the unnecessary parts then format the posts I want then echo it all back onto the page.
Would I be able to do this via plugin?
First, $post would be an array (or rather, an object). So it should be more like:
$content = 'I am the content. Marvel at my simplicity! ' . $post->post_content;
Also note I said you need to scope $post to global (before using it):
global $post;
Finally, return
will not actually echo anything. But you knew that, right?
Thread Starter
davy27
(@davy27)
Yeah I have no idea why I said that about return not echoing. As I understand it, [code]return[/code] just literally ‘returns’ the outcome of the function to wherever requests it.
I didn’t cover functions much and the complexity of WP is driving me nuts!! The lack of documentation for the hooks doesn’t help, either.
Thank you for the help, I found the solution to my current problem. No doubt I’d need more help in future.