WordPress.org

Ready to get started?Download WordPress

Forums

Magic Fields 2
How can i getting Custom field types from Related Types (2 posts)

  1. Quasimodo84
    Member
    Posted 9 months ago #

    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" />
        </a>
        <?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" />
        </a>
        <?php } ?>
        <?php } ?>
      </div>
    </div>
    <div class="views-field views-field-title">
      <h2 class="field-content">
        <a href="<?php echo get_permalink($article);?>">
        <?php echo get_the_title($article);?>
        </a>
      </h2>
    </div>
    <div class="views-field views-field-created">
      <h4 class="field-content">
        <?php the_time(get_option('date_format')); ?>
      </h4>
    </div>
    <div class="views-field views-field-body">
      <span class="field-content">
        <!-- insert content here -->
      </span>
    </div>
    </div>
    <?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?

    Thanks

    http://wordpress.org/plugins/magic-fields-2/

  2. Quasimodo84
    Member
    Posted 9 months ago #

    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.

Reply

You must log in to post.

About this Plugin

About this Topic