Creé un ‘seminario web’ de publicación personalizada y ahora quiero mostrar el próximo seminario web en una sección separada y el seminario web anterior en una sección separada usando categorías de wordpress.
aquí está mi tipo de publicación personalizada: –
// webinar post type
$labels = array(
'name' => _x( 'Webinars', 'post type general name', 'impactqa' ),
'singular_name' => _x( 'Webinar', 'post type singular name', 'impactqa' ),
'menu_name' => _x( 'Webinars', 'admin menu', 'impactqa' ),
'name_admin_bar' => _x( 'Webinar', 'add new on admin bar', 'impactqa' ),
'add_new' => _x( 'Add New', 'Webinar', 'impactqa' ),
'add_new_item' => __( 'Add New Webinar', 'impactqa' ),
'new_item' => __( 'New Webinar', 'impactqa' ),
'edit_item' => __( 'Edit Webinar', 'impactqa' ),
'view_item' => __( 'View Webinar', 'impactqa' ),
'all_items' => __( 'All Webinars', 'impactqa' ),
'search_items' => __( 'Search Webinars', 'impactqa' ),
'parent_item_colon' => __( 'Parent Webinars:', 'impactqa' ),
'not_found' => __( 'No Webinars found.', 'impactqa' ),
'not_found_in_trash' => __( 'No Webinars found in Trash.', 'impactqa' )
);
$args = array(
'labels' => $labels,
'description' => __( 'Description.', 'impactqa' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'webinar', 'with_front' => false ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt' )
);
register_post_type( 'webinar', $args );
$labels = array(
'name' => _x( 'Webinar Categories', 'impactqa' ),
'singular_name' => _x( 'Webinar Category', 'impactqa' ),
'search_items' => __( 'Search Webinar Categories' ),
'all_items' => __( 'All Webinar Categories' ),
'parent_item' => __( 'Parent Webinar Category' ),
'parent_item_colon' => __( 'Parent Webinar Category:' ),
'edit_item' => __( 'Edit Webinar Category' ),
'update_item' => __( 'Update Webinar Category' ),
'add_new_item' => __( 'Add New Webinar Category' ),
'new_item_name' => __( 'New Webinar Category' ),
'menu_name' => __( 'Webinar Categories' ),
);
$args = array(
'labels' => $labels,
'rewrite' => array( 'with_front' => false ),
'hierarchical' => true,
);
register_taxonomy( 'webinar_category', 'webinar', $args );
y aquí está mi código de plantilla: –
<section class="section-padding">
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<h2 class="pb-30">Upcoming Webinars</h2>
<hr class="serprate-line" style="background-image: linear-gradient(to right, transparent, grey, transparent);">
</div>
</div>
</div>
</section>
<section class="page-wrapper">
<div class="container">
<div class="row justify-content-center">
<?php
$query = new WP_Query(
array(
'post_type' => 'webinar',
'post_status' => 'publish',
'order' => 'ASC',
)
);
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
$date_posted = get_field('date_posted');
$date_posted = strtotime($date_posted);
$date_current = date('Ymd'); // the date format should be same as the date format on $date_posted
$date_current = strtotime($date_current);
if ($date_posted >= $date_current) : // compare date
$featured_img_url = get_the_post_thumbnail_url(get_the_ID(), 'full');?>
<div class="col-lg-4 col-md-6">
<div class="webinar-wrapper">
<a href="<?php echo get_the_permalink(); ?>"><img src="<?php echo $featured_img_url; ?>"></a>
<div class="webinar-title">
<h5><a href=""><?php echo get_field('webinar_heading'); ?></a></h5>
</div>
<span class="pDate"><?php echo get_the_date('d M, Y'); ?></span> <!-- <span class="pipe">|</span> -->
<!-- <span class="pTime"><?php echo get_the_time(); ?></span> -->
<!-- <span class="minRead">
<?php
$words = str_word_count(get_the_content());
$perMinutes = 200;
$minutes = ceil($words/$perMinutes);
echo $minutes.' MIN';
?>
</span> -->
</div>
</div>
<?php
endif;
endwhile;
endif; ?>
</div>
</div>
</section>
<section class="section-padding">
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<h2 class="pb-30">Past Webinars</h2>
<hr class="serprate-line" style="background-image: linear-gradient(to right, transparent, grey, transparent);">
</div>
</div>
</div>
</section>
<section class="page-wrapper">
<div class="container">
<div class="row justify-content-center">
<?php
$query = new WP_Query(
array(
'post_type' => 'webinar',
'post_status' => 'publish',
'order' => 'ASC',
)
);
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
$date_posted = get_field('date_posted');
echo $date_posted;
$date_posted = strtotime($date_posted);
$date_current = date('Ymd'); // the date format should be same as the date format on $date_posted
$date_current = strtotime($date_current);
if ($date_posted < $date_current) : // compare date
$featured_img_url = get_the_post_thumbnail_url(get_the_ID(), 'full');?>
<div class="col-lg-4 col-md-6">
<div class="webinar-wrapper">
<a href="<?php echo get_the_permalink(); ?>"><img src="<?php echo $featured_img_url; ?>"></a>
<div class="webinar-title">
<h5><a href=""><?php echo get_field('webinar_heading'); ?></a></h5>
</div>
<span class="pDate"><?php echo get_the_date('d M, Y'); ?></span> <!-- <span class="pipe">|</span> -->
<!-- <span class="pTime"><?php echo get_the_time(); ?></span> -->
<!-- <span class="minRead">
<?php
$words = str_word_count(get_the_content());
$perMinutes = 200;
$minutes = ceil($words/$perMinutes);
echo $minutes.' MIN';
?>
</span> -->
</div>
</div>
<?php
endif;
endwhile;
endif; ?>
</div>
</div>
</section>
Problema: cuando coloco algunos eventos en el backend, se muestra en la sección de eventos pasados y la sección próxima está en blanco.
.