CodeHQ

Posts Tagged ‘Query’

|

Custom query on taxonomy page | WordPress

Thursday, June 14th, 2018

This will go in taxnonomy.php or taxonomy-name.php templates.

$term = get_term_by( 'slug', get_query_var('term'), get_query_var('taxonomy') ); 

$customField = get_field('custom_field_name')];
$args = array(
	'posts_per_page' => '-1',
	'post_type' 	 => 'service_centres',
	'tax_query' => array (
		array (
			'taxonomy' => 'regions',
			'field' => 'slug',
			'terms' =>  $term->slug
		)
	),
	'meta_key'	 => 'custom_field_name',
	'meta_value'	 => 'custom_field_value_value'
);

Tags: , , , , ,
Posted in PHP, WordPress | No Comments »

Echo thumbnail URL and size | WordPress

Monday, October 24th, 2016

Use the PHP in the query below – and then the HTML example below to echo the URL out.

the_post_thumbnail_url();                  // without parameter -> 'post-thumbnail'
 
the_post_thumbnail_url( 'thumbnail' );       // Thumbnail (default 150px x 150px max)
the_post_thumbnail_url( 'medium' );          // Medium resolution (default 300px x 300px max)
the_post_thumbnail_url( 'large' );           // Large resolution (default 640px x 640px max)
the_post_thumbnail_url( 'full' );            // Full resolution (original size uploaded)
 
the_post_thumbnail_url( array(100, 100) );  // Other resolutions

Tags: , , , ,
Posted in PHP, WordPress | No Comments »

Display taxonomy term name | WordPress

Thursday, August 18th, 2016

Tags: , , , , , , ,
Posted in PHP, WordPress | No Comments »

Display only child posts of parent | WordPress Query

Monday, July 27th, 2015

$args = array(
	'post_type' => 'page',
	'post_parent' => $post->ID,
);

Tags: , , , ,
Posted in PHP, WordPress | No Comments »