G
G
Gamer582018-05-04 12:24:05
WordPress
Gamer58, 2018-05-04 12:24:05

Tag_id link for current country?

<?php
/**
 * The template for displaying taxonomy pages for country
 *
 * 
 *
 *
 * @package toursgid
 */
 get_header(); ?>
 
  
 <h1><?php single_term_title('Страна: '); ?>.</h1>

 
<h1>CUISINE</h1>
<?php
global $wp_query;
$query = new WP_Query(
  array_merge(
    array(
 		'post_type' => 'countries',
      'tour-type'    => 'spa'
    ), // это параметр который добавили мы
    $wp_query->query // это массив базового запроса текущей страницы
  )
);
  
if ( $query->have_posts() ) :
    while ( $query->have_posts() ) : $query->the_post(); ?>

  <a href="<?php the_permalink(); ?>"><h3><?php the_title(); ?></h3></a>

<?php endwhile;
endif; ?>
      <a href="<?php echo get_tag_link(8); ?>">tag CUISINE only for this country</a> <!-- ПРИ этой ссылки выводит всю кухню стран как реализовать для текущей страны ? -->
<?php
// Reset Post Data
wp_reset_postdata(); ?>
 
 
<h1>NATURE</h1>

<?php
global $wp_query;
$query = new WP_Query(
  array_merge(
    array(
    'post_type' => 'countries',
      'tour-type'    => 'nature'
    ), // это параметр который добавили мы
    $wp_query->query // это массив базового запроса текущей страницы
  )
);
  
if ( $query->have_posts() ) :
    while ( $query->have_posts() ) : $query->the_post(); ?>

    

  <a href="<?php the_permalink(); ?>"><h3><?php the_title(); ?></h3></a>

<?php endwhile;
endif; ?>
<a href="<?php echo get_tag_link(7); ?>">tag NATURE only for this country</a> <!-- ПРИ этой ссылки выводит всю природу стран как реализовать для текущей страны ?  -->

<?php
// Reset Post Data
wp_reset_postdata(); ?>
    
<?php
get_footer();

How to make a link ( tag_id ) nature, or cuisine for the current country. With this output, it displays all the posts of all countries.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2018-05-04
@Gamer58

First, use the pre_get_posts filter to modify the parameters, and not crutches through the global scope.
Secondly, in order for a link to one term of one taxonomy to take into account another term of another taxonomy, you need to either combine them into a URL (hello, custom rewrite rules, or add a GET parameter at the very least), or save the selected term from the "country" taxonomy between pages - for example in cookies. Otherwise, WP absolutely cannot guess that when selecting by taxonomy=XXX&term_id=7, AND taxonomy=YYY&term_id=Z should also be applied

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question