How do I assign a custom post to all terms in a custom taxonomy?
With functions like get_terms, there is an argument hide_empty that will allow terms without associated posts to be shown. Set hide_empty to 0 and you will see your terms.
With functions like get_terms, there is an argument hide_empty that will allow terms without associated posts to be shown. Set hide_empty to 0 and you will see your terms.
First thing’s first — You’ll have to add that table. The way you do that if you were writing this in a plugin is as follows: function customtaxorder_init() { global $wpdb; $init_query = $wpdb->query(“SHOW COLUMNS FROM $wpdb->terms LIKE ‘term_order'”); if ($init_query == 0) { $wpdb->query(“ALTER TABLE $wpdb->terms ADD `term_order` INT( 4 ) NULL DEFAULT ‘0’”); … Read more
To get post info outside the regular loop, you can use WP Query Reference In your example you can try something like; $firstsentance = new WP_Query(); $firstsentance->query(‘posts_per_page=-1′); // add additional query parameters as needed, this will query all posts $old_content = the_content()’; //do your php stuff here endwhile;
$term = ‘audi’; $term = get_term_by(‘name’,$term,’your taxonomy’); $args=array( ‘post_type’ => ‘gallery’, ‘taxonomy’ =>’images’, ‘term’ => $term->term_id, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘caller_get_posts’=> 1 );
I have written this function some time ago, it may be a bit sloppy but it does it’s job: function get_low_level_term( $taxonomy ) { $term = null; if( is_single() ) { global $post; $terms = get_the_terms( $post->ID, $taxonomy ); if( count( $terms ) == 1 ) { foreach( $terms as $t ) { $term = … Read more
It all depends on how you’re trying to do it. When it comes to filtering results, i usually setup the form to use $_GET and filter the results when the page loads again: if (isset($_GET[‘term’])) { $term = $_GET[‘term’]; } else { $term = ‘defaultTerm’; } if (isset($_GET[‘childterm’])) { $childterm = $_GET[‘childterm’]; } else { … Read more
In the second set of args, you set both include and child_of to 58, which effectively eliminates any possible return.
You can do it easily. Your query should be: $querystr = “SELECT `term_id` AS `id`, `name` AS `value`, `slug`, `term_group` FROM {$wpdb->terms} WHERE lower($wpdb->terms.name) like ‘%$s%'”; See, here i’ve mentioned the name of the fields needed. For any other fields, you need to explicitly mention the field names.
Try this: <?php $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); $parent = get_term($term->parent, get_query_var(‘taxonomy’) ); echo $parent->name; ?> You have to get the current term slug and then use get_term by the slug and then echo the name.
If you want one template that looks the same for all of your categories, you do not need to do anything with regexes or $_GET variables. Just use an archive.php template within your theme, as detailed in the Codex.