Tagged: related posts
- This topic has 6 replies, 3 voices, and was last updated 6 years, 3 months ago by
Steve.
-
AuthorPosts
-
-
January 22, 2015 at 12:05 pm #3201
waterschaatsMemberI’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 ); -
January 22, 2015 at 2:00 pm #3203
SteveKeymaster@waterschaats — Please reference the examples at the bottom of this doc >
Let me know if that helps.
-
October 19, 2015 at 10:55 am #4619
AnthonyMemberI 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?
-
October 19, 2015 at 11:04 am #4621
SteveKeymaster@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 -
October 19, 2015 at 11:09 am #4622
AnthonyMemberYeah 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.
-
October 19, 2015 at 12:19 pm #4624
SteveKeymasterDoc updated. Thanks!
Closing ticket.
-
-
AuthorPosts
- The topic ‘get related post content’ is closed to new replies.