Trying to sort and display categories(not posts) by custom field: 'order'

I'm a WordPress rookie. I've added a custom field to my "Category" taxonomy. The custom field is "custom_order" and its purpose is to hold a number so that my categories can be sorted and displayed in the order I choose. My problem is that I can't get them to sort; I can display the categories, and 'echo' each category's "custom_order" number, but I must be missing something when it comes to accessing and sorting the meta_value. Not sure if I'm …
Category: Web

How to set category correctly for a custom post created by a remote API call?

I'm using a plugin - "cleverness-to-do-list" (https://wordpress.org/plugins/cleverness-to-do-list/#description ). I'm aware that the plugin is closed, but I've updated it at my end and gotten it working with my self-hosted Wordpress edition (version 6). I'm trying to create a setup where a remote server calls a webpage on my server and POSTs some data. That custom PHP webpage is configured to create a new ToDo item (which is placed in the posts table). It does that fine except for setting the …
Category: Web

List only child categories a post is in, of a specific parent category in wordpress

I am building a quotes website and i have 2 main categories like Topic & Authors Every quote will have Author name and topic name and those are sub categories of Topic & Author. AND my question is i want to display only Author categories that is a sub category of a Authors category please help me... Topic - Love - Life - Friends etc Authors - Author1 - Author2 - Author3
Category: Web

Multiple Dropdown's with Submit Button

I am pulling 2 categories into 2 dropdown lists. When I click submit the URL is showing the filtering but its just loading the homepage. I want the user to be able to select multiple categories and submit to show results. <?php $price = array( 'show_option_all' => '', 'show_option_none' => 'Price Range:', 'orderby' => 'ID', 'order' => 'ASC', 'show_count' => 1, 'hide_empty' => 1, 'child_of' => 110, 'exclude' => '', 'echo' => 1, 'selected' => 0, 'hierarchical' => 1, 'name' …
Category: Web

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

How to add Pagination to foreach loop to page

I create a page in wordpress series.php and here it the code where I block! <?php $categories=get_categories( array( 'parent' => $cat->cat_ID) ); foreach ($categories as $c) { // what you really want instead of var_dump is something to // to create markup-- list items maybe, For example $idp = $c->term_taxonomy_id; //then i get the data from the database $cat_data = get_option("category_".$idp); ?> <div class="wide-box"> <!-- Content Detail Box --> <a href="<?php echo get_category_link( $idp ); ?>" class="wb-image"><img src="<?php echo $cat_data['original_img']; …
Category: Web

get_object_term_cache duplicate terms after update to wordpress 6

After WordPress update to 6 versions receives an issue. receive duplicated terms on function echo wp_kses_post(get_the_term_list($product->get_id(), 'product_cat', '', ', ', '')); and echo wp_kses_post( get_the_term_list( $product->get_id(), 'pa_material', '<li class="material">', ', ', '</li>' )) ? : ''; All work correctly before the update. I found that get_object_term_cache( $post->ID, $taxonomy ); give me duplicated terms What can cause this issue? Plugin or function change? (unable to find detail WP 6 changelog)
Category: Web

How to get related category/categories in WordPress archive page

I am using WooCommerce in WordPress. I have few categories of products like these, Example: Product 1 Category (//parent) -- Category 1 -- Category 2 -- Category 3 -- Category 4 Product 2 Category (//parent) -- Category 10 -- Category 11 -- Category 12 -- Category 13 If I am in a archive page for Category 2(sub) How can I get all other category name under the parent category (Product 1 Category) as a list. what i'm trying $args = …
Category: Web

Show matching categories in search page

my current search only shows POSTS as results. http://newslines.org/?s=george My site has categories for George Clooney, George R.R. Martin etc. How do I get a list of categories that match the search term to show at the top of the results page? I have tried this: <?php $search_query = get_search_query(); $term = get_term_by( 'name', $search_query, 'category' ); if ( !empty( $terms ) && !is_wp_error( $terms ) ){ echo "<ul>"; foreach ( $terms as $term ) { echo "<li>" . $term->name …
Category: Web

Wordpress Child Category Display All Posts

I am creating a Wordpress page where all my posts in the child categories of team are displayed in a grid. I got this working with the below code. The formatting and general layout is great however it only shows the 5 most recent posts in the child category instead of all of them. In my Wordpress account I have 7 posts which should be displaying. How should I retrieve the posts so it displays them all. <ul class="faces"> <?php …
Category: Web

Show posts from a single category by default using wordpress.com

I have a blog at wordpress.com on the legacy "Personal" plan. I blog about different but related subjects and categorise the posts accordingly. The blog was originally about one subject but, over time, the content diverged. One subject is more generally accessible while the second is more specialized. When someone visits my blog, can it show posts only from the more general category by default? For example, I could create a new page containing the "Blog Posts" block to show …
Category: Web

How to show posts only for the last subcategory?

I have a hierarchical categories tree, meaning up to 3-4 subcategories with posts. When clicking on a category link in the home page, I am redirected to the category page. I need to check if there are no subcategories for the current category, then show posts, BUT if there are subcategories, then show only subcategories titles and descriptions with no posts at all. Next, if I click on a subcategory title, check again if there are child categories to that …
Category: Web

WordPress - List Sub Categories and Sub-Sub Categories, With Posts

I have the following code. It allows me to show sub categories and documents within them. The thing is, a sub category may contain further sub categories. The code below will show documents belonging to a sub-sub (grand child) category at sub (parent) level. Please can anyone shed light on how to solve this so document only show underneath the category they are directly under? In addition, highlighting what is a sub-sub (grandchild) category as well? All posts titles should …
Category: Web

How to add a post without assigning to a category?

Can any one please explain how to add a post in WordPress without assigning it to any category. Actually I want to display some news or some quick information. So, it does not come to any category in my blog. In this type of time, I do not want to assign to any category. for example, http://www.someSiteURL.com/this-is-news-about-something-awesome/ http://www.someSiteURL.com/wordpress-themes/Anan-wordpress-theme-review/ The first url is what i want to have. But by default, it automatically add "uncategorized". My permalink structure is "/%category%/%postname%/" and …
Category: Web

Sort categories by meta value

How can I make a list of categories with 4 last posts in each where every category is sorted by meta_value. For example, template without sorting by meta_value is http://pastebin.com/AeH6vx9b It displays parent categories only. Few days I am searching something related to categories extra fields but can't find something workable. This is my best search result. What I have to do with this? I don't understand it. Is it possible to do what I want?
Category: Web

Count posts in category including child categories

I have found this code somewhere, it counts posts but only which are under specific category. I would appreciate if someone could expand this so it would count all posts which also belong to its child categories? function wp_get_cat_postcount($id) { $cat = get_category_by_slug( $id ); $count = (int)$cat->count; $taxonomy = 'category'; $args = array( 'child_of' => $id, ); $tax_terms = get_terms($taxonomy,$args); foreach ($tax_terms as $tax_term) { $count +=$tax_term->count; } return $count; }
Category: Web

How to get product count with respect to categories in WooComerce

Hi I want to display all the categories of products in a loop to display them in category menu along the numbers of products each category contains. Some thing like that so far I have done this to get all categories $args = array( 'number' => $number, 'orderby' => $orderby, 'order' => $order, 'hide_empty' => $hide_empty, 'include' => $ids ); $product_categories = get_terms( 'product_cat', $args ); foreach( $product_categories as $cat ) { echo $cat->name; } But I want to know …
Category: Web

How do I add a tag slug to a category URL to filter posts?

I want to add an option to my site to filter posts by one specific tag on the category page and at the same time have a nice URL (no query strings). So something like this: https://example.com/%category%/ - standard category link (currently) https://example.com/%category%/%tag%/ - a page like the above, but displaying posts from a specific category AND tag. Is this possible? If so, how can I achieve this? I would also like to note that for posts I have such …
Category: Web

About

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