WordPress.org

Ready to get started?Download WordPress

Forums

Custom Fields Nightmare... (2 posts)

  1. diceone
    Member
    Posted 6 years ago #

    I'm having serious troubles implementing a simple custom field usage.
    It makes me want to cry and burn down my house.
    Why wordpress... Why?

    I'd very much like to use a custom field to have a nice image header before my post title and title.

    I'm not sure why or how, but custom fields with images just do not seem to work.
    These things don't even need CSS.

    They just need to show up.
    I'd like the site to look like this:
    http://www.bedaandseanmakemesick.com/images/wpblog.jpg

  2. syncbox
    Member
    Posted 6 years ago #

    they will work. I use the c2c_get_custom() plugin to get the meta data but the big issue is to be sure to logically plan how you are writing the results...

    rather than entering the html associated with the image, just use the file name and in the code calling the field values, add the tag and such...

    for example, using c2c_get_custom plugin, let's assume I put the image file name "foo.jpg" into a custom key named "post-pic":

    <?php
    echo c2c_get_custom('post-pic','<img src="/wp-content/themes/mythemesname/images/','" />','','');
    ?>

    if you have several pictures, you'd add several fields (using the same key) and you'd place a space in the 4th parameter to tell WP to show more than one field.

    from the http://www.coffee2code.com website's information about the plugin:

    function c2c_get_custom ($field, $before='', $after='', $none='', $between='', $before_last='')

    * $field : This is the name of the custom field you wish to display
    * $before : The text/HTML to display before all field value(s)
    * $after : The text/HTML to display after all field value(s)
    * $none : The text/HTML to display in place of the field value should no field value exists; if defined as " and no field value exists, then nothing (including no $before and $after) gets displayed
    * $between : The text/HTML to display between multiple occurrences of the custom field; if defined as ", then only the first instance will be used
    * $before_last : The text to display between the next-to-last and last items listed when multiple occurrences of the custom field; $between MUST be set to something other than " for this to take effect

    HTH

Topic Closed

This topic has been closed to new replies.

About this Topic