Replies: 1 comment 2 replies
|
Hi,
However, although I do not understand what you want to do and it seems that you are using an event custom post type, I quickly asked ChatGDP for a code review. Not tested it, but this is the answer: <?php
/**
* The template for displaying archive pages
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package Bootscore
* @version 6.0.0
*/
// Exit if accessed directly
defined('ABSPATH') || exit;
get_header();
$post_type = 'event';
$now = wp_date('YmdHis');
$posts_per_page = 12;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
// Unified query for upcoming and past events
$args = array(
'post_type' => $post_type,
'posts_per_page' => $posts_per_page,
'post_status' => 'publish',
'paged' => $paged,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'event_end',
'value' => $now,
'compare' => '>=',
'type' => 'DATE',
),
array(
'key' => 'event_end',
'value' => $now,
'compare' => '<',
'type' => 'DATE',
),
),
'orderby' => array(
'meta_value' => 'DESC',
),
);
$query = new WP_Query($args);
?>
<div id="content" class="site-content <?= apply_filters('bootscore/class/container', 'container', 'archive'); ?> <?= apply_filters('bootscore/class/content/spacer', 'pt-4 pb-5', 'archive'); ?>">
<div id="primary" class="content-area">
<div class="row">
<div class="<?= apply_filters('bootscore/class/main/col', 'col') ?>">
<main id="main" class="site-main">
<div class="page-header mb-4">
<?php the_archive_title('<h1>', '</h1>'); ?>
<?php the_archive_description('<div class="archive-description">', '</div>'); ?>
</div>
<?php if ($query->have_posts()) : ?>
<?php while ($query->have_posts()) : $query->the_post(); ?>
<div class="card horizontal mb-4">
<div class="row g-0">
<?php if (has_post_thumbnail()) : ?>
<div class="col-lg-6 col-xl-5 col-xxl-4">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('medium', array('class' => 'card-img-lg-start')); ?>
</a>
</div>
<?php endif; ?>
<div class="col">
<div class="card-body">
<?php bootscore_category_badge(); ?>
<a class="text-body text-decoration-none" href="<?php the_permalink(); ?>">
<?php the_title('<h2 class="blog-post-title h5">', '</h2>'); ?>
</a>
<?php if ('post' === get_post_type()) : ?>
<p class="meta small mb-2 text-body-secondary">
<?php
bootscore_date();
bootscore_author();
bootscore_comments();
bootscore_edit();
?>
</p>
<?php endif; ?>
<p class="card-text">
<a class="text-body text-decoration-none" href="<?php the_permalink(); ?>">
<?= esc_html(strip_tags(get_the_excerpt())); ?>
</a>
</p>
<p class="card-text">
<a class="read-more" href="<?php the_permalink(); ?>">
<?php _e('Read more »', 'bootscore'); ?>
</a>
</p>
<?php bootscore_tags(); ?>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e('No events found.', 'bootscore'); ?></p>
<?php endif; ?>
<div class="entry-footer">
<?php bootscore_pagination($query); ?>
</div>
</main>
</div>
<?php get_sidebar(); ?>
</div>
</div>
</div>
<?php
get_footer();ChatGDP is a great resource to quickly solve bugs instead spending hours of time to figure that out. I suggest to write your custom |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi, I have combined two wp_query().
When I write the result back to the main query, the second page is empty of all articles.
It is not a 404 error, the second page is prepared but everything is empty, including the_permalink() and the_title().
The $paged is "2" on the second page.
Why is this? Could you please tell me how to fix this?
I do not speak English well.
However, if further explanation is needed, I will make an effort to communicate.
Best regards. Thank you.
Code sytnax highlighter edited by maintainer
All reactions