WordPress.org

Ready to get started?Download WordPress

Forums

Query posts by custom taxonomy term name (4 posts)

  1. NAIJADEALZ
    Member
    Posted 2 years ago #

    Hi,

    I would love to get the list of posts by their custom taxonomy (=store) name.

    Here is what I have so far, but it is not working.

    Please help with the code.

    $postslist = query_posts('numberposts=5&order=DESC&orderby=meta_value&showposts=5&meta_key=hits&post_type=post&store='.$mystorename); if(count($postslist) > 0){ ?>

    'Store' is the custom taxonomy
    $mystorename is a variable holding the name of the store i want to query by.

    Any help will be appreciated.

    Thank you

  2. Peter_L
    Member
    Posted 2 years ago #

    use get_posts for secondary loops
    http://codex.wordpress.org/Template_Tags/get_posts

  3. NAIJADEALZ
    Member
    Posted 2 years ago #

    Hi Peter,

    below is what i have now, it is still not working.

    What could be wrong with the code? I am trying to get posts by the name of taxonomy term

    $args = array(
    	'tax_query' => array(
    		array(
    			'taxonomy' => 'store',
    			'field' => 'name',
    			'terms' => $mystorename
    		)
    	)
    );
    
    $postslist = get_posts( $args );if(count($postslist) > 0){ ?>

    [No bumping. If it's that urgent, consider hiring someone.]

  4. Peter_L
    Member
    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic