This repository was archived by the owner on Mar 21, 2023. It is now read-only.
forked from ericandrewlewis/WP_Query_Multisite
-
Notifications
You must be signed in to change notification settings - Fork 19
This repository was archived by the owner on Mar 21, 2023. It is now read-only.
Returning only main site posts #3
Copy link
Copy link
Open
Description
Hi,
I encounter a similar problem with other way like yours to query the network. Maybe you'll have an idea.
I use your class in a shortcode built for Visual Composer.
And it returns only posts from the main site.
Here's the code:
function events_vc( $atts, $content = null ) {
extract( shortcode_atts( array (
'compare' => '>=',
'posts_per_page' => '-1',
'order' => 'ASC',
'el_class' => '',
), $atts ));
include_once(TEMPLATEPATH . 'inc/multisite-query.php');
$all_events = new WP_Query( array(
'multisite' => '1',
'post_type' => 'events',
'post_status' => 'publish',
'meta_key' => 'date_debut',
'orderby' => 'meta_value',
'order' => $order,
'posts_per_page' => $posts_per_page,
'meta_query' => array(
array(
'key' => 'date_debut',
'value' => date('Ymd'),
'compare' => $compare == '<' ? '<' : $compare,
'type' => 'DATE',
),
),
));
$output = '';
if ( $all_events->have_posts() ) {
$output .= '<div class="events-list '.$el_class.'">';
$output .= '<h4>Test</h4>';
while ( $all_events->have_posts() ) : $all_events->the_post();
ob_start();
get_template_part('components/modules/event');
$output .= ob_get_clean();
endwhile;
$output .= '</div>';
wp_reset_postdata();
}
return $output;
}
add_shortcode( 'events_vc_output', 'events_vc');
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels