W
W
WebforSelf2019-10-15 08:47:41
css
WebforSelf, 2019-10-15 08:47:41

How to display posts by tag_id in wordpress?

Friends, I installed the
Custom Post Type UI plugin, created a separate post type and taxonomy
I started posts there and the taxonomy is tagged. tag_id
it's time to display them via wp_query

$count = $titan->getOption( 'set-team-count' ); 
$query = new WP_Query( array('post_type' => 'fitnes_programs', 'tag_id' => '38',  'showposts' => $count ) );
  while ( $query->have_posts() ) : $query->the_post(); ?>     
тело цикла
</div>
<?php endwhile; ?>
 <?php wp_reset_query(); ?>

Specified post type and a specific tag, but does not display anything. I remove tag_id , displays all posts that belong to
this post type. How to be?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Violetta Morozova, 2018-07-26
@vilka_2009

As one of the options - Mask:
1) Prepare a white wave in Photoshop
2) Use a double background under the test background, for example:

background: url("image/pic-mask.png") no-repeat bottom, #000 top;
background-size: 100% auto, auto;

3) An example can be found here in the first block https://vilka-vk.github.io/sedona/

H
hrenly, 2018-07-26
@hrenly

Do one repetition of the wave (bitmap) bet on background, point background-repeat: repeat-xto , then play around with different proportions background-size. Specifically, set the desired height in pixels, and the width as a percentage is possible.

W
WP Panda, 2019-10-15
@WebforSelf

1. Custom Post Type UI - infernal evil, all the points below stem from its thoughtless use, which does not imply knowledge of how it works under the hood.
2. 'showposts' - obsolete parameter, use posts_per_page instead
3. 'tag_id' - applies only to the standard tag taxonomy - post_tag
4. In your case, you need to operate with the 'tax_query' parameter

$query = new WP_Query( [
      'post_type' => 'fitnes_programs',
      'posts_per_page' => (int)$count,
      'tax_query' => [
        [
          'taxonomy' => 'fitnes_program',
          'field'    => 'id',
          'terms'    => [38]
        ]
      ]
    ] );

W
WebforSelf, 2019-10-15
@WebforSelf

5da562d2c45d0899973845.png
For example, here is one of the sections with ID 39 , similar to what I presented above in the code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question