I cannot get tax_query in get_posts() to work with custom taxonomy

I have been trying to achieve this for the past two days but nothing works. I am attempting to build functionality to search any post, page, and a couple other custom post-types by a tag. I have created a plugin which registers a taxonomy called search_tag. search-tags.php require_once __DIR__ . '/includes/search-tags.class.php'; function search_tags_closure() { $search_tags = new Search_Tags; $search_tags->create_taxonomy(); } add_action('init', 'search_tags_closure'); search-tags.class.php class Search_Tags { const NAME = 'search_tag'; const LABEL = 'Search Tags'; protected function get_post_types() { $args …
Category: Web

How do I make a request in my browser to search the CPT taxonomy?

How do I make a request in my browser to search the CPT taxonomy? Custom post type "portfolio" Taxonomy "portfolio_entries" Tag "new" The request in the browser of the form site.ru/?s=&post_type=portfolio&taxonomy=portfolio_entries&field=slug&terms=new It does not work, please help me make a correct request. Thanks in advance.
Category: Web

Display and register custom categories for custom post types

Ok here we go. I have 2 different custom post types. The first is called 'portfolio', the second one 'games'. All the game reviews I write are 'games' posts. To have a better overview I created custom categories like reviews, playstation xbox etc. Unfortunately everytime I would like to display the posts of one categorie (http://www.zock-around-the-clock.com/games_category/testcategory) I just get an 404 Error Page. I dont really use the 'portfolio' posts but with them the arrengement into categories would work just …
Category: Web

Yoast - Custom Taxonomy - primary category

I have a Custom Taxonomy with the name country. I would like to display the primary category only. I have the yoast plugin installed and that is how I'm setting the primary category. I'm using this code I found to do the same thing but with post categories and it works well. <?php $primaryCat = new WPSEO_Primary_Term('category', get_the_ID()); $primaryCat = $primaryCat->get_primary_term(); $primaryCat = get_cat_name($primaryCat); $categories = get_the_category(); foreach( $categories as $category ) { $defaultCat = $category->name; $defaultCatLink = get_category_link( $category->term_id …
Category: Web

Is there a template file to list all terms of a given custom taxonomy?

Suppose we registered the composers and the interprets custom taxonomies. The composers taxonomy could have the following terms: Wolfgang Amadeus Mozart Ludwig van Beethoven Richard Wagner The interprets taxonomy could have the following terms: Glenn Gould Daniel Barenboim Vienna State Opera I am wondering whether the WordPress template hierarchy has a special file , like taxonomy-terms.php, to list taxonomy terms with a simple loop: <?php while ( have_posts() ) : the_post(); the_title(); endwhile; ?> This would print (assuming the /%postname%/ …
Category: Web

How to pass taxonomy terms to WP_Query along with $args?

I created a cpt and custom taxonomy associated with it. Lets say custom taxonomy name is Sports. I added terms to it - football, basketball. Now, i want to fetch post titles tagged under football and basketball separately on same page.(Note:- i am using a custom page template to show list of articles from CPT). $args = array( 'post_type' => 'sports', 'tax_query' => array( array( 'taxonomy' => 'sports_category', 'field' => 'slug', 'terms' => 'football' ), ), ); $myquery = new …
Category: Web

custom taxonomy and custom post type url conflict

i am having one serious url issue. there is news custom post type. it's slug is news. News taxonomy slug: news_category News taxonomy url is: http://domain.com/news_category/press-release i want to change the url of the news_category to news news . so url of news taxonomy would be: http://domain.com/news/press-release i tried to rewrite the slug news_category to news but that's creating conflict issue. news shows news url but all the posts of news post type are returning 404 not found News post's …
Category: Web

Get product categories and add them to a custom taxonomy

I'm working on a WooCommerce webshop. I have divided all my products into categories. Example: Clothing: -Tshirts -Jeans -Etc. Likewise, all brands are also divided into categories. Example: Brands -Brand1 -Brand2 -Etc. I want to copy or mirror the category and sub-categories of "Brands" to a custom taxonomy. So when I have a product in the "Brand 1" category, then this product must be automatically entered into a custom taxonoy with the same name: "Brand 1" The products in woocommerce …
Category: Web

Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?

I'm trying to create a dropdown selector on my CPT and CT archive page for a custom taxonomy called "location". I've managed to get the form to submit, however, it does not direct me to the archive page, rather it directs me to a URL that looks something like this https://example.com/?location=11 I'm wanting the destination URL to be this: https://example.com/location/term-name Bare with me as I have no background in Computer Science / IT so I'm learning on my own. Below …
Category: Web

WordPress import not importing custom taxonomy

I've posted this already in the WP Support Forum hoping to have more luck here. I'm trying to import a custom post type from one blog to another. (126 posts in the custom post type). I've exported using WordPress' export function from WP version 3.3.2 and trying to import into 3.2.1. I can get all the posts to import into the correct custom post type, but none of my custom taxonomy or meta information is being imported in. In both …
Category: Web

Multiple tag cloud filtering

I am writing a plugin which creates a custom post type and two associated custom taxonomies. The custom post type list/archive page should be filterable by terms in one or both taxonomies i.e not just a filter by one taxonomy term. The filters should be displayed as two separate tag clouds. Does anyone have experience of implementing this functionality and can recommend any suitable plugins?
Category: Web

list/consult Taxonomy only for the respective author/creator in dashbboard

I'm trying to filter so that only the creators of the respective categories can edit them. I created a cat_author meta field and associated it to the taxonomy. In this way, every taxonomy has an author. And I tended to filter with add_filter( 'pre_get_terms', 'filter_cat_by_u_id', 99, 1 ); function filter_cat_by_u_id( $query ) { if ( ! is_admin() ) { return $query; } global $pagenow; if ( 'edit-tags.php' === $pagenow ) { $meta_query = array( array( 'key' => 'cat_author', 'value' => …
Category: Web

How to Implement Search Functionality?

<div class="col-lg-8"> <div class="row"> <?php $search_term = get_search_query(); $term = get_term_by('slug', $search_term, 'blog_taxonomy'); $term_name = $term->name; $args = array( 'post_type' => 'blog', // 'title' => $search_term, 'tax_query' => array( array( 'taxonomy' => 'blog_taxonomy', 'field' => 'slug', 'terms' => $search_term, 'orderby' => array( 'date' => 'DESC', ), ), ), ); $loop = new WP_Query($args); if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); ?> <div class="col-lg-6 col-md-6"> <div class="blog-content radius30 cB-shadow cBorder mw-100"> <div class="blog-img text-center position-relative"> <div class="date-time position-absolute"> <div class="date"> <h6><?php …
Category: Web

How to add custom meta to 'pre_get_terms'?

I have a custom taxonomy with custom meta. I have added the custom meta values to columns in the admin list page just fine. But if I search for values that are in these columns nothing is found. I'm assuming I need to use pre_get_terms, but am having trouble figuring out how to include the meta in the query. Here is what I am trying to do to test one of the fields, but results are still negative. add_action( 'pre_get_terms', …
Category: Web

How do I disable the built-in editor and automatically configure the properties of new pages?

I use a Builder plugin on the site. Members are editors and can create their own page. I want to disable Gutenberg so that they can only edit pages with Buldir. I would also disable the properties of the page for them and I would enter it automatically. When I create a new page, I disable comments, the template is Blank Page, do not access the Custom fields. You can practically just add a featured image and title to your …
Category: Web

title tag for custom post type remove taxonomy name from title tag

So it appears I am missing a vital pice of information somehow to make my custom post type title tag behave. everything else works fine. my current - simple - scenario is this : wordpress 3.8, twentytwelve theme, wpizza plugin (I'm the author of this , so that's what the questions relates to really), nothing else I registered the wppizza custom post type and taxonomies like so: /******************************************************* [register custom post type] ******************************************************/ public function wppizza_register_custom_posttypes(){ $labels = array( 'name' …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.