Have Woocommerce show product price if id, when not logged in

If you know the id, you can simply check current product id in your woocommerce_get_price_html action: add_action(‘after_setup_theme’,’activate_filter’) ; function activate_filter() { add_filter(‘woocommerce_get_price_html’, ‘show_price_logged’); } function show_price_logged($price) { global $product; // get current product if(is_user_logged_in() || $product->id === 8) { // check product id return $price; } else { remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’ ); remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, … Read more

How to use wp_nav_menu to create custom dropdown menu?

Use wp_nav_menu() with proper parameters to add the dropdown-menu forAnimate class, to remove the wrapper and to add the role attribute: <ul class=”nav navbar-nav”> <li class=”active”><a href=”https://wordpress.stackexchange.com/questions/255497/index.html”>Home</a></li> <li><a href=”category.html”>Category Page</a></li> <li><a href=”article.html”>Article Page</a></li> <li class=”dropdown”> <a href=”#” class=”dropdown-toggle” data-toggle=”dropdown”> Category Type A <span class=”caret”></span></a> <?php wp_nav_menu(array( ‘menu’ => ‘my_menu_name’, // specify the menu name ‘menu_class’ … Read more

How can I include the user id inside of a shortcode php output?

So I’m assuming the “current commenter” is actually the current user logged into WP. So to get the current user ID, you can simply use get_current_user_id: echo do_shortcode(“[theplugin_user_data user_id='” . get_current_user_id() . “‘]”); UPDATE Ok, so we want, then, the comment’s author ID: //$comment = get_comment(); // in your case, it seems you already have … Read more

Calling function in loop causes repeat data

first of all, you could delete the return $ranking += 1; and replace by $ranking += 1;. We don’t know what happend in the template-parts/content, but don’t forget to add a little <?php wp_reset_postdata(); ?> just after your endwhile;.

calling function in external js file

i think the script.js file is not loading properly. if its loading then the function should work as expected. are you referencing the complete path of script in your script.js call? like <script type=”text/javascript” src=”https://wordpress.stackexchange.com/questions/256287/some-domain.com/path/widget.js”></script> try opening that file from page source and see if its loading the correct js file? its always best practice … Read more

Alter Woocommerce product archive structure

I think the subcategory thing get generated with this function woocommerce_product_subcategories();. But as you said for this layout there is no specific template file. Also, if I remember right, you cannot do this with css alone. A little while ago I created a little plugin for a customer who also wanted a product overview structured … Read more

Output category list inside array

Try something like the following. Notice that the hide_empty argument is set to false. $args = array( ‘orderby’ => ‘id’, ‘hide_empty’=> false, ); $cats = get_categories($args); foreach ($cats as $cat) { // Your code to populate new array here } And then assign your newly created array to values.