Forums

Problem with query_posts (6 posts)

  1. grafx
    Member
    Posted 6 months ago #

    Hi,

    I've got problems with query_posts in my index.php page on my personal template.

    I want to display my personnal post type called "pub" (advert in french), my categoryname : "accueil" (home), and who has the tag "carre".

    I've got 2 another loop before who dispay the 4 firsts posts, in all category, then the 4 firts posts another personal post type.
    That's not working, this is my code :

    <div id="publicite">
    <?php
    query_posts("post_type=pub&category_name=accueil&tag=carre");
    if (have_posts()) :
    while (have_posts()) : the_post();
    the_content();
    endwhile;
    endif;
    ?>
    </div>

    Thanks a lot.

  2. grafx
    Member
    Posted 6 months ago #

    No idea ?

  3. keesiemeijer
    moderator
    Posted 6 months ago #

    Try it with this:

    $args = array(
      'post_type' => 'pub',
      'tax_query' => array(
        'relation' => 'AND',
        array(
        	'taxonomy' => 'category',
        	'field' => 'slug',
        	'terms' => array( 'accueil')
        ),
        array(
        	'taxonomy' => 'post_tag',
        	'field' => 'slug',
        	'terms' => array('carre'),
        )
      )
    );
    query_posts($args);
  4. grafx
    Member
    Posted 6 months ago #

    THANKS YOU !

    Can you explain, or give me a link who explan that.

  5. keesiemeijer
    moderator
    Posted 6 months ago #

  6. grafx
    Member
    Posted 6 months ago #

    You're awesome dude.

Reply

You must log in to post.

About this Topic