Search attachments in custom post type only

I think I’ve cracked it. Replace the top 14 lines of code with Class SellMediaSearch { private $query_instance; /** * Init */ public function __construct(){ add_filter( ‘posts_join’, array( &$this, ‘terms_join’ ) ); add_filter( ‘posts_search’, array( &$this, ‘search_where’ ), 10, 2 ); add_filter( ‘posts_request’, array( &$this, ‘distinct’ ) ); add_filter( ‘pre_get_posts’, array( &$this, ‘search_query’ ) ); … Read more

custom post type loop

There may be cleaner ways to do it, but I think this will work: <?php $args = array(‘post_type’ => ‘music-playlist’); $query = new WP_Query($args); $cntr = 0; while( $query -> have_posts() ) : $query -> the_post(); $cntr++; ?> <section class=”row-wrap”> <div class=”row-inner”> <?php if ($cntr % 2 == 1) { // first or third items, … Read more

How to add parameters for custom post type

You want posts_per_page but you would have to create 2 queries to pull in 4 of each tag as the default code will pull in posts from either of the tags, not an equal amount between them. $args = array( ‘post_type’ => ‘customer-stories’, ‘tag’ => ‘microsoft’, ‘posts_per_page’ = ‘4’ ); $args2 = array( ‘post_type’ => … Read more

How do I set a specific size for my image?

Use Add_image_size in your functions.php function theme_sizes(){ add_image_size( ‘custom-size’, 800, 600); } in your code above use something like: wp_get_attachment_image( 42, ‘custom-size’ ); Add_image_size adds a new option when you upload an image, which will then crop the image to the dimensions you need, so you would have thumbnail, medium, full size and your custom-size