Support » Plugins and Hacks » Magic Fields 2 » How can i getting Custom field types from Related Types

How can i getting Custom field types from Related Types

  • Hi I’m having a hard time on pulling out custom fields from custom post type using related_type provided by magic fields.

    I already did try the following solution :

    It only can pull what wordpress helper provided but not the custom fields one.

    Example :

    <?php while(have_posts()) : the_post(); ?>
    <?php $news = mf_get_field('related_news');foreach($news as $article){ ?>
    <div class="views-field views-field-field-image">
      <div class="field-content">
        <?php $videos = mf_get_field('video_news'); ?>
        <?php if(count($videos) != 0 ){ ?>
        <?php foreach($videos as $video) {?>
        <?php //if ($video != '') { ?>
        <a href="<?php the_permalink(); ?>">
          <div class="play-button2"></div>
          <img typeof="foaf:Image" class="img-responsive show-single" src="http://img.youtube.com/vi/<?php echo $video ?>/hqdefault.jpg" width="480" height="270" />
        <?php } ?>
        <?php } else { ?>
        <?php $img = mf_get_field('image_news'); foreach($img as $imgs){ ?>
        <a href="<?php the_permalink(); ?>">
        <img  typeof="foaf:Image" class="img-responsive show-single" src="<?php echo $imgs['thumb']; ?>" width="480" height="270" />
        <?php } ?>
        <?php } ?>
    <div class="views-field views-field-title">
      <h2 class="field-content">
        <a href="<?php echo get_permalink($article);?>">
        <?php echo get_the_title($article);?>
    <div class="views-field views-field-created">
      <h4 class="field-content">
        <?php the_time(get_option('date_format')); ?>
    <div class="views-field views-field-body">
      <span class="field-content">
        <!-- insert content here -->
    <?php } ?>
    <?php endwhile; ?>

    Just for notes i change the get_field into mf_get_field so i can differentiate.

    I’m also going to try the solution probably using wp_query inside of it..by logic maybe i can get the meta key or value..if it’s possible.

    Is there anyone already found out how to get the custom field types from related types?



Viewing 1 replies (of 1 total)
  • Nevermind i already figure it out.

    all you gotta do is use the get_post() inside the loop of the related type and call out the respected field//attribute to call out the value of each post.

Viewing 1 replies (of 1 total)
  • The topic ‘How can i getting Custom field types from Related Types’ is closed to new replies.
Skip to toolbar