Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter ameen.akbar

    (@ameenakbar)

    I think this is the part. I could not use this in Text part of post. Can you make this easy. I want to use only one tag, not genre and something else.

    Taxonomy Parameters
    Show posts associated with certain taxonomy. If specifying a taxonomy registered to a custom post type then instead of using 'category' you would use '{custom_taxonomy_name}'. For instance, if you had a custom taxonomy called "genre" and wanted to only show posts from the "jazz" genre you would use the below code.
    <?php
    $args = array(
    	 'posts_per_page' => 8,
    	 'orderby' => 'rand',
    	 'post_type' => 'albums',
    	 'genre' => 'jazz',
    	 'post_status' => 'publish'
    );
    $show_albums = get_posts( $args );
    ?>

    Following example displays posts tagged with ‘jazz’, under ‘genre’ custom taxonomy, using ‘tax_query’:

    $args = array(
    	'tax_query' => array(
    		array(
    			'taxonomy' => 'genre',
    			'field' => 'slug',
    			'terms' => 'jazz'
    		)
    	)
    );
    $postslist = get_posts( $args );
Viewing 1 replies (of 1 total)