Tagged: 

Viewing 5 reply threads
  • Author
    Posts
    • #3201
      waterschaats
      Member

      I’m using the post-relate metabox in the admin section, which works awesome!

      piklist('field', array(
          'type' => 'post-relate'
          ,'scope' => 'locaties'
          ,'template' => 'field'
          ,'description' => 'An Un-grouped field. Data is saved as individual meta and is searchable.'
        ));

      Now I have trouble with retrieving the related info. This is what I have so far. I retrieve the post including its meta-data.

      
      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
      $args = array(
        'post_status' => 'publish',
        'post_type'   => array('events'),
        'posts_per_page' => 30,
        'paged'=>$paged,
        'order' => 'ASC',
        'orderby'=> array('from'=>'ASC' ),
        'meta_type' => 'DATE',
        'meta_key'  => 'from'
      );
      				
      $wp_query = new WP_Query( $args );
    • #3203
      Steve
      Keymaster

      @waterschaats — Please reference the examples at the bottom of this doc >

      Let me know if that helps.

    • #4619
      Anthony
      Member

      I have tried something similar to no avail using your reference code.

      	<?php
      							
      							$sponsor_call = get_posts(array(
      							'post_type' => 'sponsor' // Set post type you are relating to.
      							,'posts_per_page' => 1
      							,'post_belongs' => $post_id
      //							,'post_status' => 'publish'
      							,'suppress_filters' => false // This must be set to false
      							));
      							
      
      							
      		foreach ($sponsor_call as $the_sponsor):
      		echo '<h6 class="the_sponsor" style="margin-top:4em;">' . $the_sponsor->post_title . '</h6>';
      		endforeach;
      							
      							?>

      This appears to grab the first sponsor off my list. It doesn’t get the one that is check marked. Side question that would be great once this is figured out is whether or not post-relates can behave like radio buttons instead?

      • #4620
        Anthony
        Member

        Alright i see that $post_id doesn’t have a value set. Now the question is why?

    • #4621
      Steve
      Keymaster

      @anthonyabraira– Are you trying the new 0.9.9.x beta? The relationship field got an overhaul and is much for flexible. Check out the file in piklist/add-ons/piklist-demos/parts/meta-boxes/field-relate.php

    • #4622
      Anthony
      Member

      Yeah I am using the beta. Figured it out … just had to change to $post->ID. Gotta update your support doc to reflect that change — I suspect.

    • #4624
      Steve
      Keymaster

      Doc updated. Thanks!

      Closing ticket.

Viewing 5 reply threads
  • The topic ‘get related post content’ is closed to new replies.