1

I've created a custom post type "projects" that has a meta box for additional information (client name, type of project, budget, etc). I'd like to be able to display this information on the front-end.

The custom post type is available to be added to custom menus if desired ('show_in_nav_menus' => true), but when you view each project, all you see is the title and the description.

Ideally, I'd like the meta data to show with the title and description in whatever theme that is being used for the site, but I don't know if that's possible.

Is there a way to display the meta box information on the front-end without having to either (a) touch the theme files (since themes can change so I don't want to do that) or (b) calling my own function that returns my own page template for the projects (because then it won't use the theme that is active)?

Thanks!

ETA - This is all done within my plugin.

6
  • 1
    Take a look at get_post_custom().
    – kaiser
    Commented Apr 17, 2012 at 23:40
  • Thanks, I have retrieved the meta box data to display. But how do I get it in the content area through my plugin? I'm using wp_head in my add_filter at the moment to see what I'm echoing out, but obviously I want it within the content area after the title. Commented Apr 18, 2012 at 2:26
  • 1
    Nevermind, this has been solved. Use 'the_content' of course. :) Commented Apr 18, 2012 at 5:31
  • 1
    Add this as answer. You can mark it as solution later, so the Q doesn't stay open. Thanks.
    – kaiser
    Commented Apr 18, 2012 at 12:39
  • Yes I tried to earlier, but I had to wait to be allowed to do so. Commented Apr 18, 2012 at 15:56

1 Answer 1

0

Solution:

Inside a function, retrieve meta box field values using get_post_custom_values() and added it to $content passed to the function. Use 'the_content' in the add_filter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.