Answer the question
In order to leave comments, you need to log in
How to display the content of a post by clicking on its title?
There is a heading of posts through the while loop, I display the list of posts with an accordion, i.e. as planned, by clicking on the title of the entry, the content of the entry should appear.
The loop itself
<?php
$filter = array (
'post_type' => 'razion',
'taxnomy' => 'category_razion',
'category_razion' => 'racion-office',
'posts_per_page' => -1,
'meta_key' => 'date',
'orderby' => 'meta_value_num',
'order' => ASC
);
query_posts( $filter );
if ( have_posts() ){
while ( have_posts() ){
the_post();
?>
<div class="swiper-slide swiper-slidet">
<a class="tab-time" href="#tab-time">
<?php echo the_field('date'); ?>
</a>
</div>
<?php
}
}
?>
Answer the question
In order to leave comments, you need to log in
You can't use query_posts()
, it's a global query that is used by WP core, you will break it. For requests, use wp_query()
echo before the_field()
not used
Essentially, you can output the content right away, it doesn't make much sense to send ajax requests
<div class="swiper-slide swiper-slidet">
<span class="tab-time">
<?php the_field('date'); ?>
</span>
<div class="tab-content">
<?php the_content(); ?>
</div>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question