Prikazivanje postova koji sadrže određene tagove

Bok… probavao sam neke tehnike al nejde… znači napravio sam php datoteku trgovacki-lanci.php u toj stranici bi mi trebalo prikazivati zadnje objavljene postove koji u sebi imaju tagove: metro, billa, interspar. … znači samo te postove koje imaju te tagove…

ovo mi je kod iz archive.php

<?php
/*
Template Name: Trgovački Lanci
*/
?>

<?php

// Exit if accessed directly
if( !defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Archive Template
 *
 *
 * @file           archive.php
 * @package        Responsive
 * @author         Emil Uzelac
 * @copyright      2003 - 2014 CyberChimps
 * @license        license.txt
 * @version        Release: 1.1
 * @filesource     wp-content/themes/responsive/archive.php
 * @link           http://codex.wordpress.org/Theme_Development#Archive_.28archive.php.29
 * @since          available since Release 1.0
 */

get_header(); ?>

<div class="page-kutija-lijevo">

<div class="fil-art-logo2">
<a href="http://www.fil-art.hr/">
<img border="0" src="http://www.fil-art.hr/wp-content/uploads/2014/03/filart-logo.png" alt="Fil Art Logo" >
</a>
</div>

<div class="kategorija-izbornik">

<?php 
 // Custom widget Area Start
 if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('lijevi-stupac') ) : ?>
<?php endif;
// Custom widget Area End
?>

</div>

        
<div class="podstranica-sadrzaj-crveno">
<img border="0" src="http://www.fil-art.hr/wp-content/uploads/2014/03/crveno.png" alt="Crveno" >
</div>

        
<div class="podstranica-sadrzaj-crveno2" style="">

<div class="podstranica-sadrzaj-info-sadrzaj"><h13><?php single_cat_title('',true); ?></h13></div>
</div>

</div>


<div class="podstranica-ambalaza-sadrzaj2">






<?php
// code to display a number of posts in multi columns top-to-bottom left-to-right
?>
<?php global $query_string; ?>
<?php
$set_number_of_columns = 4; // enter numbers of columns here;
$set_number_of_rows = 30; // enter numbers of rows here
$set_showpost = $set_number_of_columns * $set_number_of_rows ;
//setup query with parameter for paged
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts($query_string.'&showposts='.$set_showpost.'&paged='.$paged);
// get number of posts for this,
$num_of_posts = $wp_query->post_count;
// make adjustment for paged to get three equaly long columns even on last paged page
// divide by $set_number_of_columns to get number per column,
// round up to next integer to make $ppc posts per column variable, or $set_number_of_rows whatever is smaller
$ppc = min(ceil($num_of_posts/$set_number_of_columns),$set_number_of_rows);
// calculates number of rows, i.e. showposts for the following query_posts and get_posts
?>
<?php for ( $col = 1; $col <= $set_number_of_columns; $col += 1) { ?>
<?php
$row = 1;
$noffset = ($col -1) * $ppc + ($paged - 1) * $set_showpost ; //calculate offset parameter if paged
$posts = get_posts($query_string.'&numberposts='.$ppc.'&offset='.$noffset);
foreach ($posts as $post) : start_wp(); ?>
<div id="post" class="post-item-referenca">
<!-- start of anything to do with post -->

<div class="referenca-item-slika">
<a href="<?php echo $cfs->get('link_do_slike'); ?>" rel="lightbox[ambalaza]" title="<h12><?php the_title(); ?></h12>">
<div class="referenca-item-naslov">
<div class="item-naslov">
<h11><?php the_title(); ?></h11>
</div>
</div>
<img  alt="<?php echo $cfs->get('lightbox_naziv'); ?>" src="<?php echo $cfs->get('link_do_slike'); ?> " >
</a>
</div>

<!-- end of anything to do with post -->

<?php
$row++;
endforeach; ?>
</div>
<?php } ?>
<?php // close the for-loop // ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
</div>




</div>













</div>


<?php get_footer(); ?>

http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters

Nacelno, proslijedis ID tagova koji ti trebaju u query_posts ili WP_Query objekt, i to je to.
Stovise, u primjeru malo nize od hedera sekcije imas primjer kako lancati vise tagova (slugs) ko parametre u pozivu.
Malo mi je kaoticna skripta za kasno ovak iscitat, al to bi bilo to.
Ako nemas tag IDs; razumljivo moras ih iscupat ranije, sad el ces hardkodirano ili kak - ovisi o tebi.

Kod je da glava zaboli xD

Uglavnom to je to sto je nosf rekao

 <?php $tagovi = new WP_Query("tag=metro,bila,interspar"); while($tagovi->have_posts()) : $tagovi->the_post();?> 
// Sadrzaj ono kako zelis da izgleda
<?php endwhile; ?>

Copyright © 2020 WM Forum - AboutContact - Sponsored by: Mydataknox & Profit Monkey