Support » Plugins » Page name hook?

  • Resolved Davy27


    I’ve created a page titled ‘Portfolio’ with slug ‘portfolio’, is there a hook to ‘pull the ‘portfolio’ part from the below URL?

    I’m creating my first plugin and I’ve not touched PHP in 3 years so this may be a silly question, but I can’t seem to find much from WP documentation.

    Thanks for your time =)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The $post object provides the property:


    Typically, scoping $post to global will make all of a post’s table records available to your plugin.

    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?

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Page name hook?’ is closed to new replies.