Tag Info

New answers tagged

0

I found an answer to this at http://wordpress.stackexchange.com/a/105079/40536 I modified my code to the following: <form action="<?php bloginfo('url'); ?>/" method="get"> <?php $term_id = 279; $taxonomy_name = 'categories'; $termchildren = get_term_children( $term_id, $taxonomy_name ); $children = array(); foreach ($termchildren as $child) ...


1

Thanks Vancoder for your help!!! I have been ripping my hair out all day trying to figure it out. Funny enough your solution was one of half a dozen I wrote on my whiteboard, BUT I had no clue how to actually create an array with that as a key. I am a noob like that. Below is the code I ended up using with some comments for anyone else trying to do this! ...


1

Rather than outputting your terms in that initial loop, I would use it instead to build a new array, with your issue_date as the key: $my_new_array = array( ); foreach ( $terms as $term ) { $issue_date = get_field( 'issue_date', $term ); $my_new_array[$issue_date] = $term->name; } You can then loop through this new array in order: ksort( ...


2

You can make use of the hide_empty argument of get_terms(), it defaults to true. Do it somewhat like this: $args = array( 'hide_emty' => false ); $terms = get_terms( 'wpsc_product_category', $args );


0

You should be able to just the following: Just a couple of things to note: By using get_term_by() instead of term_exists(), you hit the term cache instead of the database for every retrieval of the term object. /** * Set terms for the given post type based on a meta value. */ function wpdocs_set_terms_for_post_types() { $posts = get_posts( array( ...


1

This not a complete and ready-made answer, but the below should get you started. First thing to note is, deleting and modifying are different functionalities, so different functions and hooks are relevant to it. Namely we are talking about wp_delete_term() - source and wp_update_term() - source - regarding the functions. So lets take a look at ...


0

The problem is that you are matching the title string in the entire content as whole and not word by word. e.g. if your title is 'blog' and content contains the word 'blogging', it will still match and pull 'blog' from 'blogging'. So, you can compare them word by word by exploding the content as follows: <?php // search for ...


1

I may suggest not combining each of these into hierarchical taxonomies, but setting up 3 distinct taxonomies. It seems like they are 3 unrelated properties of the photos, and thus, I would separate the code for them. Then you're not trying to code around nested taxonomy terms, but you can access them each individually. The taxonomies would be color, location ...


2

You cannot use the same object of WP_Query twice. Therefore you need to create another one with a tax_query parameter to fetch posts which are not assigned to any term. //fetch all reviews which have no assigned term in 'review-product' $taxonomy = 'review-product'; $post_type = 'reviews'; $args = array( 'post_type' => $post_type, 'tax_query' ...


0

I have found a solution. Thanks to @Tarukus as his answer was helpful. Again, my goal was to display terms (not posts) from my custom taxonomy via an on/off switch. To do this, I used Advanced Custom Fields and created a "Select" field with two values (on/off). Once this field was applied to my taxonomy I could select a value for each term. The default value ...


7

For starters let's dive into what is 5 really. It is the post's ID. But what is ID in turn? It is value in the MySQL table row which identifies the specific post record. Issues with using IDs So first there are some conceptual problems with it. It's not content. It's not something user creates, manipulates, or (most of the time) aware of. WP is (by design) ...


0

Hy, From what I understand you want a filter to display posts that belong to a specific list of terms. As default you display all posts making all terms enabled. In order to disable a term from being displayed you need to exclude it from the loop. <?php // we get all the terms of the taxonomy $terms = get_terms('mytaxonomy'); /* ...


7

This question is going to get some opinion based answers, but well, I'll give it a try. There are a couple of reasons why someone might've told you that, it would be great to know the context also. Upto version 3.4 or 3.5, that function only worked when the parameter was a var, that might be one of the reasons why someone told you that. I, myself, don't ...


0

You are looking for function get_term_link. Example $my_term_link = get_term_link($cat_lists); Here $cat_lists is term object. Official Documentation


2

There is no way easy way to do that. You have to query directly to achieve that. I am assuming, you only want the parent categories which don't have descendants or even if they have descendants, it's not used in any post global $wpdb; $categories = $wpdb->query("SELECT $wpdb->terms.* FROM $wpdb->terms ...



Top 50 recent answers are included