How to replace custom post type with custom taxonmy in permalinks

WordPress is a query based system, you need to first understand that if using permalinks and when a link http://domain.com/hospital/hospitalname is submitted, WP analyses it internally as post type = hospital name = hospitalname And then create a query to look up. It is likewise for other links such as http://domain.com/cityname/hospitalname Assumptions Before a custom … Read more

Custom Taxonomies Archive Page 404

I solved it with this workaround. I created a new page (“Movies” with the URL domain.cc/movies) and added this via shortcode: <?php $taxonomy = ‘artists’; $tax_terms = get_terms( $taxonomy, array( ‘post_type’ => ‘artwork’, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’ ) ); ?> <?php foreach ($tax_terms as $tax_term) { ?><div class=”artistslist”> <a href=”https://wordpress.stackexchange.com/<?php echo $taxonomy;?>/<?php echo … Read more

Order get_terms by count using a custom taxonomy hierarchy

Don’t know if it’s the best solution but I ended up using a custom query to show all categories ordered by count. $cats = $wpdb->get_results(” select tt.term_id, count, name, slug from “.$wpdb->prefix.”term_taxonomy as tt inner join “.$wpdb->prefix.”terms as terms on tt.term_id = terms.term_id where taxonomy = ‘product_cat’ order by count desc limit 10 “); echo … Read more

How to exclude woocommerece product category in search results?

function exclude_product_category( $query ) { if ($query->is_search()) { $tax_query = (array) $query->get(‘tax_query’); $tax_query[] = array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => array(‘excluded-category’), ‘operator’ => ‘NOT IN’ ); $query->set(‘tax_query’, $tax_query); } return $query; }

Remove custom taxonomy slug from URL

Why don’t you try to create a slug of your own. And then link it up to your desire things. Just use this function: function slugify($str){ $search = array(‘Ș’, ‘Ț’, ‘ş’, ‘ţ’, ‘Ş’, ‘Ţ’, ‘ș’, ‘ț’, ‘î’, ‘â’, ‘ă’, ‘Î’, ‘Â’, ‘Ă’, ‘ë’, ‘Ë’); $replace = array(‘s’, ‘t’, ‘s’, ‘t’, ‘s’, ‘t’, ‘s’, ‘t’, ‘i’, … Read more