New answers tagged

0

Add Meta key value: function my_pre_get_posts( $query ) { // do not modify queries in the admin if( is_admin() ) { return $query; } // only modify queries for 'model' post type if ( $query->is_tax( 'model-year' ) && $query->is_main_query() ) { $query->set('orderby', 'meta_value'); // Add ...


2

As far as capabilities are concerned there is no distinction between creating new terms and assigning them to posts. So it's not possible through capabilities alone to only allow users to assign pre-defined terms. This likely has its roots in the UI which, especially for tags, is designed around creating terms when writing posts. The UI does not have a ...


0

@ricardio-de-penning I think you are going on wrong direction. You just want to get only those posts which is related to current category right? If yes then you need to filter post using tax_query like below. $args = array( 'post_type' => 'post', 'tax_query' => array( array( 'taxonomy' => 'category', 'field' ...


0

Well, I did it like this. Maybe it will help someone. add_filter( 'pre_get_posts', function () { global $wp_query; // article type - change posts per page. If webinars then change order to webinar_date if ( isset( $wp_query->query['article_type'] ) ) { set_query_var( 'posts_per_page', 12 ); if ( $wp_query->is_tax('article_type', 'webinar'...


0

Sorted using this: To set to active: <?php $post_id = 58; $tag = array( 661 ); wp_set_post_terms( $post_id, $tag, 'status' ); ?> To set to inactive: <?php $post_id = 58; $tag = array( 662 ); wp_set_post_terms( $post_id, $tag, 'status' ); ?>


0

In recent versions of WP you are going to have unique term IDs. Evidence of this is the fact that the methods get_terms and get_term don't require you to pass a taxonomy name. If terms Ids were not unique across taxonomies then passing a taxonomy name would be necessary. As a side note, there used to be the concept of shared terms but not anymore: https://...


0

If you facing the same issue so please go to the reading option page in settings and check how many numbers were set in the "Blog pages show at most" field value. if "Blog pages show at most" values are set greater than compared to your custom archive page or default page query string per page post parameter so you need to change the ...


0

@agon-xheladini is totally correct with his answer. But this did not work for me as the WPML API wants to have the term_taxonomy_id instead: element_id(bool) Use term_taxonomy_id for taxonomies, post_id for posts So, you should always ensure that you do not use the term_id: $originalElementId = get_term($original_term_id)->term_taxonomy_id; $trid = $...


0

Try this! function get_term_top_most_parent( $term_id, $taxonomy ) { $ancestors = get_ancestors( $term_id, $taxonomy ); if(!empty($ancestors)){ $parentID = end( $ancestors ); }else{ $parentID = $term_id; } return $parentID; }


0

You have passed incorrect name($_POST key) in the function. Please use below code for saving the taxonomy: wp_set_post_terms($post_id,array($_POST['cat_servicios']),'categorias_servicios',true); You passed cat-servicios instead of cat_servicios Thanks.


0

You can change the sort order on a category archive page to show posts by title (A-Z) by adding this code to your child theme's functions.php: /* Sort posts by title for a specific category */ function change_category_order( $query ) { //Sort all posts from category with id=3 by title if($query->is_category('3') && $query->is_main_query(...


0

What you show on the image is the post status, not a taxonomy. But a filter already exists to do what you want. Go where you wrote your categories and on the right must be numbers. It's the number of post_type in each category. Click that number and you'll see the pages for the clicked category. If you really want to add a filter, you can add a select (for ...


0

The solution for now is : create a plugin re-creating the shortcode with the current page slug. Naming the page slug like the category slug. And manually add the category to dflip. Couldn't find better so far. // Disable direct access defined('ABSPATH') or die('No script kiddies please!'); // use page slug to call dflip book in same slug dflip_category ...


Top 50 recent answers are included