ThemeShaper Forums » Thematic

[closed]

Adding custom fields to post content within a category

(3 posts)
  • Started 4 years ago by JerryRobinette
  • Latest reply from tzShaper
  • This topic is not resolved
  1. JerryRobinette
    Member

    I have two categories of posts that have custom fields attached to. For example, I have a category called "events" and I have created the following custom fields:

    event_location
    event_address
    event_phone
    event_website

    I want to display the the custom field data after the post title but, I only if the post categorized as "events".

    Can someone please give me some guidance please?

    Posted 4 years ago #
  2. JerryRobinette
    Member

    OK. I got the below to work. But it there has to be a more efficient way to do this.

    if(get_post_meta($post->ID, "event_location", $single = true) != "") :

    echo 'Location: ';
    echo get_post_meta($post->ID, "event_location", $single = true);
    echo '
    ';

    endif;

    if(get_post_meta($post->ID, "event_address1", $single = true) != "") :

    echo 'Address1: ';
    echo get_post_meta($post->ID, "event_address1", $single = true);
    echo '
    ';

    endif;

    if(get_post_meta($post->ID, "event_address2", $single = true) != "") :

    echo 'Address2: ';
    echo get_post_meta($post->ID, "event_address2", $single = true);
    echo '
    ';

    endif;

    if(get_post_meta($post->ID, "event_city", $single = true) != "") :

    echo 'City: ';
    echo get_post_meta($post->ID, "event_city", $single = true);
    echo '
    ';

    endif;

    if(get_post_meta($post->ID, "event_state", $single = true) != "") :

    echo 'State: ';
    echo get_post_meta($post->ID, "event_state", $single = true);
    echo '
    ';

    endif;

    if(get_post_meta($post->ID, "event_zip", $single = true) != "") :

    echo 'Zip: ';
    echo get_post_meta($post->ID, "event_zip", $single = true);
    echo '
    ';

    endif;

    if(get_post_meta($post->ID, "event_phone", $single = true) != "") :

    echo 'Phone: ';
    echo get_post_meta($post->ID, "event_phone", $single = true);
    echo '
    ';

    endif;

    if(get_post_meta($post->ID, "event_tty", $single = true) != "") :

    echo 'TTY: ';
    echo get_post_meta($post->ID, "event_tty", $single = true);
    echo '
    ';

    endif;

    if(get_post_meta($post->ID, "event_email", $single = true) != "") :

    echo 'Email: ';
    echo get_post_meta($post->ID, "event_email", $single = true);
    echo '
    ';

    endif;

    if(get_post_meta($post->ID, "event_website", $single = true) != "") :

    echo 'Website: ';
    echo get_post_meta($post->ID, "event_website", $single = true);
    echo '
    ';

    endif;

    Please help this nOOb.

    Posted 4 years ago #
  3. tzShaper
    Member

    You should have a look at wefunction.com articles.
    Just posted is a revision to "custom write panels".
    The example shows an events venue setup.
    It may be a better route for you, it's similar to using the flutter plugin.

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.