WordPress.org

Support

Support » Plugins and Hacks » Custom Field List Widget » [Plugin: Custom Field List Widget] Need to put this widget in template

[Plugin: Custom Field List Widget] Need to put this widget in template

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author ntm

    @ntm

    Yes, I can:

    <?php customfieldlist(array('before_widget' => '<div>','after_widget' => '</div>', 'before_title'=>'<h2>', 'after_title'=>'</h2>' ), 5); ?>

    This function will print the content of a certain widget. In this example it is the content of widget 5.

    But it is really not good idea to call this function from the template file directly!
    It would be better if you would add a special sidebar to the template of of the single post view. If you do that you can add the widgets page in the admin area and you don’t have to worry about widget IDs (which may change when you rearrange the widgets) nor the HTML elements for the widget. This is as easy as calling the widget function directly, see http://codex.wordpress.org/Customizing_Your_Sidebar#New_way_of_adding_sidebars

    Tim

    ntm, thank-you for your rapid reply. Much appreciated! Maybe a quick exlanation from me: Because I am running a photo-portfolio, I want to replace the meta data for each post. Instead of meta data of post-date, tags, category, etc. I want to show CAMERA:, LENS:, SPEED:, APERTURE: I’m hoping this widget will be able to show those details and print them in my single.php template.

    Plugin Author ntm

    @ntm

    This plugin shows lists of custom field data. But usually not per post. One defines one or maybe more than one key in the widgets settings and the plugin displays a list of all custom field values with those keys. To make the plugin show the custom field data per post, you wuold need to set up a widget for each post and you would have to use individual custom field names for the custom fields of each post e.g. you would have to combine the custom field name camera with the post ID like camera_234.
    That would of course not practically.

    That is why I think that you should consider not using this plugin and maybe follow a different approach. In the WordPress Codex you can find this page: http://codex.wordpress.org/Custom_Fields#Displaying_Custom_Fields
    It has a lot of hints how to display the custom field data on the single post view. So if you know a little bit about PHP and about editing a template file then the way showed that page is how you could do what you want to achieve.

    Ah .. right, I did not appreciate that point. But thank-you very much for the lead to another way of doing this. Very generous of you. Best of luck with your plugin and thank-you again

    Plugin Author ntm

    @ntm

    (One last thought: If you want to have more control over the output of the custom field data then it is probably a good idea to use the function get_post_custom() instead of the_meta(). Or maybe there other plugins which are better suited to display the custom field data per post.)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Custom Field List Widget] Need to put this widget in template’ is closed to new replies.
Skip to toolbar