How to get current post user id

To show author avatar per post inside loop you need to modify a little: $current_post_author_id = get_the_author_meta( ‘ID’ ); <?php if (!empty(get_user_meta($current_post_author_id, ‘user_avatar’, true))): ?> <img src=”https://wordpress.stackexchange.com/questions/317789/<?php echo get_user_meta($current_post_author_id,”user_avatar’, true); ?>” alt=”some text”> Try, if it works for you.

Custom REST API endpoint returns rest_no_route when called via wp-json permalink

The problem is with the bbe_sortables&replace in the permalink: <My URL>/wp-json/bridge/v1/test-data/process/bbe_sortables&replace&_wpnonce=<thenonce> which results in an invalid route, where the supposedly query string is seen as part of the route: /bridge/v1/test-data/process/bbe_sortables&replace&_wpnonce=<thenonce> (the valid route for that URL is /bridge/v1/test-data/process/bbe_sortables) and eventually the REST API throws the rest_no_route error. To fix the problem, use add_query_arg() when generating … Read more

How to check if you are on widget.php page?

You may use the global variable $pagenow to figure out if you are on a particular admin page, in your case this would be checking if you are on the widgets.php admin page: <?php global $pagenow; if( $pagenow === ‘widgets.php’ ) { ?> <script> // JavaScript goes here </script> <?php }   Furthermore, it will … Read more

Self deactivate plugins after an action occurs

The deactivate_plugins() function is available only after the admin_init action is executed, you will either need to register ‘admin_init’ filter and run the deactivate_plugins() function there or manually include the wp-admin/includes/plugin.php file. I updated your code with the second solution below. class WP_X_Plugin{ public function __construct(){ register_activation_hook( __FILE__, array( $this , ‘activate’ ) ); $url … Read more

Add Product Subtitle to Woocommerce Product Page

This is what I have used to show the product category as a subtitle on my shop archive page add_action( ‘woocommerce_shop_loop_item_title’, ‘woocommerce_shop_loop_item_subtitle’, 20 ); function woocommerce_shop_loop_item_subtitle() { global $post, $product; $categ = $product->get_categories(); echo $categ; } and this is what I used to display it on the single product page add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_single_item_subtitle’, 5 ); … Read more

Woocommerce plugin for minimum order and add-to-card-step

I think YITH Woocommerce Minimum Maximum Quantity plugin is the best solution for your purpose. It enables you to set a minimum or maximum quantity for product selection. It also shows quantity/amount error messages to your customers. Moreover, you can use the plugin to set a different minimum quantity for each of the product. So, … Read more