Catchable fatal error: Object of class WP_Term could not be converted to string

Your problem isn’t line 780 of ../wp-includes/class-wp-query.php So it’s a little bit hard to help because you’re not showing the actual code that’s at fault. But you’re probably trying to reference a post category by its data object instead of using the integer id. For example you might have something like this: $mycategory=get_category_by_slug(‘a-category-slug’); $args = … Read more

Get ID of current taxonomy in register_rest_field

The get_callback part is generated within the WP_REST_Controller::add_additional_fields_to_object() method with: $object[ $field_name ] = call_user_func( $field_options[‘get_callback’], $object, $field_name, $request, $this->get_object_type() ); That means the callback has four input arguments: ‘get_callback’ => function ( $object, $field_name, $request, $object_type ) { // … } and for the requested category object, we can get the term id with: … Read more

Output link to category from WP_Query loop of woocommerce products

You can use get_the_term_list() to output a comma-separated list of links to product categories: <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <li class=”product-list__item”> <a href=”https://wordpress.stackexchange.com/questions/274473/<?php the_permalink() ?>”> <?php the_title(); ?> </a> <?php echo get_the_term_list( get_the_ID(), ‘product_cat’, ”, ‘, ‘ ); ?> </li> <?php endwhile; ?> Note that when you’re inside ‘the loop’ (i.e. between … Read more

What’s the difference between “parent” and “category_parent” in a WP_Term object?

The properties prefixed with category_ or cat_ are there for backwards compatibility. Taxonomies and terms were introduced in WordPress 2.3 (11 years ago) and categories were converted into a taxonomy at that time. Prior to this categories had their own properties (the ones with the aforementioned prefixes). For backwards compatibility, the _make_cat_compat() function is used … Read more

Can paginate_links() be customized for a specific category or tag?

The tag template page began displaying posts for specific tags once I replaced the argument statement with the following, which is great!!: $tags = get_the_tags(); $tag = $tags[0]->name; $args = array( ‘post_type’ => ‘post’, ‘post_status’=>’publish’, ‘category_name’ => ‘NEWS’, ‘tag_slug__and’ => $tag, ‘posts_per_page’ => 2, ‘paged’ => $paged ); However, when I click on a pagination … Read more

Show post only if match all categories

Here’s an updated version of your code that will get posts that have the Post Format Video and that have the same Categories as the current post in the loop. You’ll call wpse_get_video_posts_with_matching_categories() to execute the function. function wpse_get_video_posts_with_matching_categories() { $categories = get_the_category( get_the_ID() ); if ( empty ( $categories ) ) { return; } … Read more