Answer the question
In order to leave comments, you need to log in
How to "friend" Wordpress post cycles?
Good!
In a nutshell, I want to get the data of another record of an arbitrary type in the record.
For this I use:
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); // Начало цикла ?>
// контент записи
<?php
// Find connected pages
$connected = new WP_Query( array(
'connected_type' => 'post_to_page',
'connected_items' => get_queried_object(),
'nopaging' => true,
) );
// Display connected pages
if ( $connected->have_posts() ) :
?>
<h3>Related pages:</h3>
<ul>
<?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?> <?php the_ID(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php wp_reset_postdata(); endif;?> // Prevent weirdness
//КАК ПОКАЗАТЬ ПОЛУЧЕННЫЕ ДАННЫЕ ТУТ :) ?
<?php endwhile; // Конец цикла ?>
Answer the question
In order to leave comments, you need to log in
You do all the "dirty work" right in the template file.
You need to study the development documentation for Wordpress, find out in which files you need to write logic, do it there. Form an array with the data you need and pass it to the template. It remains to check whether this array was passed and display the data by running through the array in a loop.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question