- Uncheck "Don't include current page in query results". This checkbox can cause problems when it's not needed. It's only needed if you want to display a View of some post type on a single post of the same post type. Your View and its placement are different post types, so the checkbox is not needed.
- I cannot see the Query Filter section. If you cannot see the Query Filter section, scroll to the top right corner of the screen and click "Screen Options". You can enable the panel here.
- Check the Query Filter settings. It should NOT include a post relationship filter. It should include a post ID filter, set by the shortcode attribute "ids". It should also include a custom field filter by the RFG date field, where the custom field date is greater than or equal to today's date, I assume, if you do not want to show old Event RFGs.
- Check the Order settings. I'm not familiar with your custom date field names, but this should be the Event RFG date field, not a date field on the Event post or any other date field.
- Check the Template. I'm not familiar with your custom date field names and locations, but remember this is a View of Event RFGs. To display information from the RFG, you can simply insert a Types field shortcode for the custom field. To display information from the parent Event, or the current Practice Area, you'll have to use the post selection tab when inserting those shortcodes.
Christian,
I unchecked the "Don't include current page in query results" box.
The Query filter is:
Include only posts with IDs set by the View shortcode attribute "ids" eg. [wpv-view name="view-name" ids="1"]
I'm leaving the custom field filter on date out right now so we can test with the full database of events.
Ordering is correct on the right date field.
Template should be fine.
Still no results though. How do we troubleshoot to see what's not working?
Let's try using a string in the ids parameter instead of a native PHP array:
$args2 = array(
'id' => 3224,
'ids' => implode(',', $pulsanti),
'showposts' => 3,
);
echo render_view( $args2 );
If this still doesn't work, please provide login credentials in the private reply fields here and I'll figure out what's going on.
We are very close to having this completed... thanks again!
The only issue I'm seeing right now is if there are no events associated to the array, it seems to be displaying the latest 3 events instead of nothing at all.
For example on this page hidden link, no events should be displaying.
The current code looks like this:
<?php
$posts = get_posts(array(
'post_type' => 'event',
'showposts' => 3,
'meta_query' => array(
array(
'key' => 'practice_areas', // name of custom field
'value' => '"' . $theid . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
)); ?>
<?php $pulsanti = array();
foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post);
$event_id = get_the_ID();
$event_ids .= "$event_id,"; ?>
<?php
$pulsanti[] = toolset_get_related_posts(
$event_id, // the parent RFG
'event_dates', // the RFG slug
'parent', // the sezioni role in this relationship is 'parent'
1000000, // the maximum number of results
0, // the offset
array(), // additional query arguments
'post_id', // return format
'child' // role to return
);
?>
<?php endforeach; ?>
<?php
$pulsanti = array_merge(... $pulsanti);
$pulsanti = array_slice($pulsanti, 0, 3);
?>
<?php
$args2 = array(
'id' => 3224,
'ids' => implode(',', $pulsanti),
'showposts' => 3,
);
echo render_view( $args2 );
$posts2 = get_posts(array(
'post_type' => 'event',
'showposts' => -1,
'meta_query' => array(
array(
'key' => 'practice_areas', // name of custom field
'value' => '"' . $theid . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
));
$num2 = count($posts2);
?>
<?php if ($num2 > 3) { ?><a class="button-secondary-blue" href="/events#search-news-capabilities-<?php echo "$pa_title"; ?>">View More</a><?php } ?>
Okay great, then I think you should set up a conditional to check the size of the $pulsanti array using sizeof() before you call echo render_view(). If the size is 0, do not call the render_view function. There's no reason to call it with an empty ID filter.
http://php.net/manual/en/function.sizeof.php
Thanks for helping fix the issue!