Rewrite custom post & taxonomy to share same URL path

(Revised on March 7th 2020 UTC) So sharing the same permalink path (or rewrite slug/base as in example.com/<rewrite slug>/<term slug> and example.com/<rewrite slug>/<post slug>) is possible, and here’s the (updated) code which enables you to share the exact same rewrite slug between a taxonomy and a post type: function wpse_358157_parse_request( $wp ) { $path=”about-us/video-center”; // … Read more

Display Post by taxonomy and taxonomy child

You should query all accomodation posts in this country, and then sort them by accomodation-type and region. Then you loop through the posts, and compare the accomodation type and the region of each post with those of the previous post. If they are different you print the new accomodation type or region and then print … Read more

Create and move terms for taxonomies

wp_update_term() doesn’t changes taxonomy. It just updated the existing taxonomy. Say the below code- $update = wp_update_term( 1, ‘category’, array( ‘name’ => ‘Uncategorized Renamed’, ‘slug’ => ‘uncategorized-renamed’ ) ); if ( ! is_wp_error( $update ) ) { echo ‘Success!’; } This code finds the category which ID is 1, then updates it to the name … Read more

Query posts by taxonomy term name

I’m not sure if the get_posts function supports the tax_query. You might want to try creating a new WP_Query object instead. $args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘store’, ‘field’ => ‘name’, ‘terms’ => $mystorename ) ) ); $query = new WP_Query($args); if ( $query -> have_posts() ) : while ( $query -> … Read more

Adding a term name from a custom taxonomy assigned to a post link displayed by a wp_query loop based on another taxonomy

Something like this should help: <?php $post_type=”animals”; $tax = ‘vertebrate’; $tax_terms = get_terms($tax); if ( $tax_terms ) { foreach ($tax_terms as $tax_term) { $args = array( ‘post_type’ => $post_type, “$tax” => $tax_term->slug, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘caller_get_posts’ => 1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ ); // $my_query = null; <- REMOVE THIS, … Read more

Search for tags

Yes its very possible, you just need to create your own search form and processing function form: <form name=”tag-search” method=”POST” action=””> <input type=”text” vlaue=”” name=”tag-q” id=”tag-q”> <input type=”submit” name=”tag-submit” id=”tag-submit” value=”Search Tags”> </form> processing: <?php if (isset($_POST[‘tag-submit’]) && $_POST[‘tag-submit’] == “Search Tags” && isset($_POST[‘tag-q’]) && $_POST[‘tag-q’] != “”){ // @todo Sanity check and cleanup $_POST[‘tag-q’] … Read more

Get wordpress taxonomy archive and sort by year

You are over-complicating everything here. What you are doing is not just expensive (because you loose all caches which include post, post meta, term and thumbnail caches), it is totally wrong as well. You are running custom queries which replaces the main query. This in itself makes your page load slower You shouldn’t be running … Read more

Display Custom Taxonomy in Sidebar in Two Columns

As a follow up to @Rutwick Gangurde Answer, here’s an example. Notes: Put it in your functions.php file, call it in the template file. Alter the output by inspecting the $term inside the foreach loop Read the comments inside the function – function wpse25433_terms_list( $cat = array(‘categories’), $el=”li”, $echo = true ) { global $post; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)