Only show posts from a certain category?

You need to modify your WP_Query loop. Add a tax_query argument to filter the category you want. $portfolioloop = new WP_Query(array( ‘paged’ => get_query_var(‘paged’), ‘post_type’ => ‘news’, ‘posts_per_page’ => 4, ‘tax_query’ => array( // Note: tax_query expects an array of arrays! array( ‘taxonomy’ => ‘portfolio’, // my guess ‘field’ => ‘id’, ‘terms’ => 51, ), … Read more

Including Custom Meta with posts_where query

Well I managed to solve this sort of… The answer was to use separate search input boxes for each custom field being searched. Here is my working solution if anyone ever stumbles across this. function display_all_products() { global $term; $term = trim(strip_tags($_POST[‘s’])); $refnoterm = trim(strip_tags($_POST[‘ref’])); $yrterm = trim(strip_tags($_POST[‘yr’])); if(!empty($_POST[‘s’]) || !empty($_POST[‘ref’]) || !empty($_POST[‘yr’])) { if(!empty($_POST[‘s’])) … Read more

Remove fields on media uploader for custom page type – not working for “From Computer” or “From Url” tabs?

Version 1 Deals with filtering based on Post ID *From Computer* tab we need to retrieve the $attachment_parent_id: add_filter(‘attachment_fields_to_edit’, ‘wpse_53600_remove_media_upload_fields’, 10000, 2); function wpse_53600_remove_media_upload_fields( $form_fields, $post ) { $our_page_id = 4; $post_id = !empty( $_GET[‘post_id’] ) ? (int) $_GET[‘post_id’] : 0; $attachment_parent_id = !empty($post->post_parent) ? $post->post_parent : 0; if( $post_id == $our_page_id || $attachment_parent_id == … Read more

Custom Taxonomy Permalinks Redirection

What is the best way to allow http://www.domain.com/newtype/newtax-term/post-name/ to load, without redirecting? You have to add a custom rewrite rule to make this work. Otherwise WordPress doesn’t understand the newtax-term part of your permalink structure and redirects you to the URL which it does understand, which is %post_type%/%post_slug%. If you want to understand how WordPress … Read more

Sorting multiple custom post types without a meta key/value pair by sort order

What ended up working is adding the array key, “orderby” and adding menu_order: <?php // query for vidoes in the home page category $args = array( ‘post_type’ =>array(‘videos’, ‘podcasts’), ‘category_name’ => ‘Videos on Homepage’, ‘post_per_page’ => 4, ‘order’ => ‘DESC’, ‘orderby’ => ‘menu_order’, ); $loop = new WP_Query($args); // start loop for first set of … Read more

Should I use custom menu, C.P.T. or theme options, or something else for this?

On my website, I’ve used Custom Post Types to achieve a slightly more complex version of what you’re trying to do. My requirements were; Rich text on title JavaScript animation to flick between “Featured Items” (not covered here) Ability to edit the featured items easily from the back-end for admin users Ability to hyperlink the … Read more