Category Meta plugin
Php help (2 posts)

  1. willvbcfc
    Posted 5 years ago #

    I'm totally stuck with the php here, but I hope I'm being pretty clear with what I need and someone will kindly help me!

    I'm using the following category loop to create a schedule for a radio station:

    <div id="showcatheaders"><img src="<?php bloginfo('template_url'); ?>/images/lunchtime_show_title.png" /></div>
                <div id="lunchtimeshows">
      'orderby' => 'name',
      'order' => 'ASC'
      foreach($categories as $category) {
        echo '
          <div class="showboxtitle" style="background:url('. $category->description . ') no-repeat;">
          <a href="' . get_category_link( $category->term_id ) . '" class="nct" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>
    } ?>

    I'm calling up the category description for a background at the moment, but I would like to change that to a category meta called 'catimg'.

    I also need to display a day & time meta called 'timeandday' one line break after the category name within the div class named 'showboxtitle'.

    I'm totally stuck on how to modify the if (function_exists('get_terms_meta')) { $metaValue = get_terms_meta($category_id, $meta_key); } template into this category loop, so please, please help!

  2. robertjakobson
    Posted 5 years ago #

    Theoritically this should work, however in practice, the plugin seems to be corrupt and not work all the time. Try inserting the following somewhere above:

    <?php if (function_exists('get_terms_meta')) {
    $category = get_the_category();
    $catid = $category[0]->cat_ID;
    $catimage = get_terms_meta($catid, 'catimg');
    $cattime = get_terms_meta($catid, 'timeandday');
    } ?>

    In order to get the timeandday metadata to display as you desire, please add this straight after the div "showboxtitle"

    <br/><p class="timeandday"><?php echo $cattime; ?></p>

    And replace the category description inside the style=""
    with <?php echo $catimg; ?>

    I will try to post an use-case scenario with an example wordpress template to http://www.themesteam.com this week, if you are interested!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Category Meta plugin
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic