Answer the question
In order to leave comments, you need to log in
Get_posts. Output tag outside the loop if there are posts of the specified type?
I send posts throughget_posts
$lastposts = get_posts( array(
'numberposts' => $numberPost,
'tag' => $tag->slug,
'orderby' => 'menu_order',
'order' => 'DESC',
'post_type' => 'video'
) );
?>
<div class="video-wrapper">
<?
if(have_posts( )) {
?>
<h2>qwe</h2>
<?
}
?>
<?
foreach( $lastposts as $post ){ setup_postdata($post);
?>
<div class="portfolio-item video-item">
<div class="video-content">
<?the_content();?>
</div>
<h2>
<? the_title() ?>
</h2>
</div>
<?php
}
wp_reset_postdata();
?>
</div>
if(have_posts( )) {
I am trying to display the title of the post type, but it does not work, what construction should be applied here so that if there are posts with the video type, the h2 title is displayed?
Answer the question
In order to leave comments, you need to log in
<?php if ($post->post_type == 'video'): ?>
<h2>
<? the_title() ?>
</h2>
<?php endif; ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question