How to "group" (categorize) the Pages together?

I have a lot of Pages which can be (need to be) grouped under a number of different Categories. ** Then the more important thing is, i need to control those pages (of different groups) programatically via functions.php. Lets say, i would have: Page A (Categorized as: Fruits) Page B (Categorized as: Vehicles) Page C (Categorized as: Vehicles) Page D (Categorized as: Fruits) Page E (Categorized as: Technology) Then from functions.php, there would be some logics, like: If Page is …
Category: Web

Visual composer custom element error

I am creating a custom element where I need to load woo-commerce product categories as dropdown (in visual composer element edit option) but I am getting this error. can someone tell me where is the problem? here is the code: <?php add_shortcode('woo_my_cat_sub_cat_show_element_code','woo_my_cat_sub_cat_show_element_functions'); function woo_my_cat_sub_cat_show_element_functions($atts,$content){ extract(shortcode_atts(array( 'woo_my_cat_list' => '', ),$atts)); ob_start();?> <!-- I will do the frontend here --> <?php return ob_get_clean(); } if(function_exists('vc_map')){ /*** * dynamic fields for the element */ $args = array( 'taxonomy' => 'product_cat', // 'number' => …
Category: Web

Link breadcrumbs to actual page – not the category archive

Status quo: the breadcrumbs show the following structure: home/parent-category/sub-category/post And click on parent-category or sub-category links to the default archive pages. This is also the correct hierarchy based on our navigation menu. So in the example above it is home/parent-page/sub-page/post. We want the breadcrumbs link to the actual page and not to the archive page of the category. In the Yoast-Settings > Search Appearance > Breadcrumbs under “Taxonomy to show in breadcrumbs for content types” I can set “Category” for …
Category: Web

get_adjacent_post by language

I am using Polylang plugin, which assigns each post to a taxonomy 'language'. While using get_adjacent_post() I want to bring only those posts that belong to the language currently displayed. So I am writing the following: $prev_post = get_adjacent_post( true, '', true, 'language' ); $next_post = get_adjacent_post( true, '', false, 'language' ); But this brings the next and previous posts independently from the language they are currently in. Why? I understand in the documentation $in_same_term (first value) specifies whether post …
Category: Web

Customize menu link for taxonomy in WP menu

I have a Taxonomy that I would like to change the link to in the WP menu. When clicking it goes to the Add Taxonomy page, like normal. What I would like to do is navigate to the Edit Page. In other words, the taxonomy navigates to edit-tags.php (as expected) /wp-admin/edit-tags.php?taxonomy=news_archive_options&post_type=news What I'd like to do is navigate to the term.php page /wp-admin/term.php?taxonomy=news_archive_options&tag_ID=10&post_type=news Thanks!
Category: Web

Display Custom Column in CPT Taxonomy

I am trying to add a column to one of my custom post types, but only on the edit taxonomy page. I have a taxonomy registered called "event-categories" for my custom post type "events". I can successfully add the custom column to the custom post type edit screen, but can't seem to get the hook to work on the edit taxonomy page. Digging through some of the core, I was able to locate the hook $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, …
Category: Web

How to automatically create a terms based on each post of a post type

I am working on a music site which has custom post types- 'artists', and 'releases'. I have about 3,000 artists, and about 19,000 Releases in my database. It's been suggested to me that I should create a taxonomy term for each release and each artist to eliminate some slow queries on my site. Anyway, I know how to create a new taxonomy, and how to make terms by hand. How can I auto create terms in my release taxonomy, where …
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

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

Hide product categories and taxonomy terms in menu if empty

I've been researching this and had no luck so far. I have a WooCommerce store with a main menu showing product categories (product_cat) and brands (yith_product_brand) which is a custom taxonomy. I want to hide categories and brands if they are empty. Do you know a way to achieve this, either by using a plugin or adding a function/filter to the functions.php file? If so any help would be much appreciated. Thanks in advance.
Category: Web

WordPress: Export/Import Yoast meta title & description to custom taxonomy

I want to export the Yoast meta title & description from a custom taxonomy with the WP All Export. Unfortunately there is no direct way with the plugin to do that. There is an extra WP All Export addon for Yoast but it doesn't work for custom taxonomies. I tried to use a custom function in the export to get the title and description. But my function doesn't work either. Im not sure why. Here's my current function: function yoast_wpseo_title($value) …
Category: Web

Attachment Metadata inside of Loop

Basically, I'm trying to call attachment info to display withing a loop, for use in an image gallery. I know I need to use wp_prepare_attachment_for_js($attachment_id) but I can't seem to get anything to show. Here's the HTML: <?php $the_query = new WP_Query(array( 'post_type' => 'attachment', 'post_status' => 'inherit' )); while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php attachment_meta = wp_get_attachment($id); echo '<figure class="gallery-photo" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject" data-groups='["all", "'.$attachment_meta['category_name'].'"]'><a class="photo-link" href="'.wp_get_attachment_image ().'">" itemprop="contentUrl" data-size="'.$attachment_meta[width].'"x"'.$attachment_meta[height].';?>"> <img src="'.wp_get_attachment_url ('fullsize').'" itemprop="thumbnail" /> <figcaption itemprop="caption …
Category: Web

Duplicate Custom Post Type and Taxonomy Slug

I've seen a few questions that are very similar, but I haven't been able to get an exact answer, so I'm going to explain my situation here. Quite simply, I need the following url structure: site.com/dining (custom post type) site.com/dining/restaurants (terms of custom taxonomy) site.com/dining/specific-location (actual post of the custom post type) This url structure will be repeated for multiple custom post types, such as lodging (terms of hotels, inns, B&B, resorts, etc), Bars, etc. My current setup is: Custom …
Category: Web

WP query taxonomy optimization

Is there any way to speed this query? Noob here. SELECT wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (9,11) ) AND wp_term_relationships.term_taxonomy_id IN (18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,151,152,169,170,171,172,173,174,175,177,178,179,181,182,183,184,185,187,191,192,195,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,721,724,726,728,729,742,743,744,747,750,758,759,760,781) ) AND wp_posts.post_type = 'product' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY RAND() LIMIT 0, 6 I'm using query monitor and this is from homepage of site. I think this is reading from Menu, because there …
Category: Web

Show portfolio category slug in url ( if exist)

I'm trying to achieve a two level portfolio structure, and it works fine in the breadcrumbs but not in the URL. The idea is to show the portfolio slug (destinations) followed by the portfolio category (if exist) and last the portfolio name. This is the file (portfolio-post.php) that needs to be altered, but i have no clue on how to do that, any help would be appreciated: <?php /******************************************************************************************************************* * Create and register Portfolio post type */ if ( !function_exists('ishyoboy_portfolio_post_type') …
Category: Web

Filter "get_terms" query

I'm currently getting the data from a custom taxonomy using this: $terms = get_terms(array( 'taxonomy' => 'my_custom_taxonomy_name', 'hide_empty' => true )); Now, this returns a lot of stuff in each WP_Term object; term_id, name, slug, term_group, term_taxonomy_id, taxonomy, description, parent, count and filter. I only need to get 2 of those: name and slug. How can I filter that query so it doesn't returns all that unused data?
Category: Web

Display only one level subcategory in wordpress

This code uses Taxonomy Images plugin to display images for categories. This code display subcategories of main category in parent category page (category.php), But I want to display only one level of subcategory in the page for example hardware (parent category) monitor (first level subcategory of harware) samsung (second level subcategory) lcd (third level subcategory ) When the user clicks on the hardware link, he should see only monitor subcategory link and in second time when he clicks on the …
Category: Web

how do you get one specific term from a shortcode attribute?

I'm working on a function where I just want to output a button that links to a specific term. I have used get_the_terms and have gotten it to work successfully, but I've been trying get_term and I've have no luck. I want the shortcode to look like this [see_all_products category="bakery"] and output a button that links to it. This is my function so far: function product_category_button($atts) { extract(shortcode_atts(array( 'category' => '', ), $atts)); // if( $category ) : // Vars …
Category: Web

Choose whether to automatically add a taxonomy with the same name as the post

I created a custom taxonomy within the blog post. It's called "FootNotes." I would like there to be a checkmark inside in the creation of the post that asks me "Are there any notes inside this post?" If I choose "yes" it automatically creates within the custom taxonomy this "note" with the same name as the published article. Thank you
Category: Web

About

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