WordPress.org

Ready to get started?Download WordPress

Forums

Display Posts Shortcode
[resolved] Feature Suggestion: Custom Field Values (3 posts)

  1. osseonews
    Member
    Posted 1 year ago #

    Hi there,
    Just a quick feature suggestions, it would be great if you could build into this plugin the ability to get Custom Field Values. Basically, you can add a Custom Field name (or multiple names as an array), and then the shortcode will display the values of for that name, as it loops thru the posts.

    http://wordpress.org/extend/plugins/display-posts-shortcode/

  2. Bill Erickson
    Member
    Plugin Author

    Posted 1 year ago #

    Can you give an example of how you'd use it?

    It's a good feature request, but I'm not sure if there's a generalized format that would work in the shortcode. For instance, you'd probably want to control its position (before/after the title, excerpt, image, content...).

    You might also want to add descriptive text to it. If the custom field holds an event's date, you might want to preface it with "Event Date: ".

    Right now I can't see a use of this that wouldn't require heavy customization. The best approach right now is to use an output filter. Here's an example (it's not using a custom field, but gives you an idea of how to do it): http://www.billerickson.net/code/add-time-to-display-posts-shortcode/

  3. osseonews
    Member
    Posted 1 year ago #

    Yes, your example is pretty much what I've been doing. But, it's a bit of pain to constantly need to update the functions.php file with output filters. What happens in that I have four or five custom post types and these custom post types have custom fields associated with them, so the function becomes a giant if/else for the output filter. It's not a big deal, but no optimal.

    It would be great if in the shortcode, we could just reference the custom fields we want to display for the particular custom post type (custom post types are already supported in the shortcode), and the shortcode will display the custom fields in the order they were entered in the short code (after the excerpt or title of the post). In terms of descriptive text or other formatting of the custom fields, I think that is best left to the functions file, but basic output of custom fields should be in the actual shortcode.

    Thank.s

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.