Filtering custom post type query

Yes, you can do that. Just remove the first foreach and give the General category ID and change the code like below- // Initiating shortcode. Place this code to any of your page to get your desired output. add_shortcode( ‘faq_page_content’, ‘the_dramatist_faq_page_content’); /** * Rendering function */ function the_dramatist_faq_page_content() { echo ‘<ul>’; $posts = get_posts( array( … Read more

redirect 301 old url to new url

Well, you would have to add some re-write rules in your .htaccess file (unless there’s a plugin that can allow more complex 301 redirect rules). But, in your situation, if I understand correctly, it’s simply not possible to do it in one generic rewrite rule, due to the logic of your new URLs… If all … Read more

WP Query for Posts (Products) in Specific Category that has 2 Specific Tags (*AND* both tags not *OR*)

Nevermind I (think) I got it… $args = array( ‘post_type’ => ‘product’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => array( ‘ring’ ), ), array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ => array( ‘black’, ‘men’ ), ‘operator’ => ‘AND’ ), ), ); Missing the ‘operator’ => ‘AND’ … Read more

Get the selected term in a dropdown search

To show dropdown with currently selected option, first you need to fetch current value. You can get that value from $_REQUEST variable. If you have grade variable then your current value is $_REQUEST[‘grade’]. Eg. if ($_REQUEST[‘grade’] == $term->slug) Recommended: Do not use REQUEST variable directly without sanitization. Use function like esc_attr. If you are sure … Read more

Sorting Attributes order when using get_the_terms

You will need to sort them yourself: $terms = get_the_terms( $post->ID, ‘category’); foreach ( $terms as $term ) { $newterms[$term->slug] = $term; } ksort($newterms); foreach ( $newterms as $term ) { echo “<li>” .$term->name. “</li>”; } Or, if you feel adventurous, the same with a filter: function alpha_sort_terms($terms) { remove_filter(‘get_the_terms’,’alpha_sort_terms’); foreach ( $terms as $term … Read more

Removed slug from CPT, now How/where do I hook the filter to the taxonomy term archive pages link?

This worked fine for me, except the whole system above has some issue with my configuration (I made my wp installation Multisite) that broke all the other posts. They are all not-found, although the permalink is retrieved correctly every time, as it was found. I’m opening a new question for that other issue here so … Read more