Loading a plugin’s js file from functions.php

It feels slightly fragile, but you can probably just do: wp_scripts()->add_data( ‘gpvb-admin-scripts’, ‘group’, 1 ); in a low-priority admin_enqueue_scripts hook, since that’s what wp_register_script does with the $is_footer flag. However this risks a future version of WordPress changing how this is saved internally (although it’s been stable for 5+ years). Alternatively you could query for … Read more

Add value to new attribute inside WordPress menu items

I already had this need, I found this code somewhere in the web. up to you to customize it with your needs. I tested it on the Twenty Nineteen theme: Put this in functions.php : class themeslug_walker_nav_menu extends Walker_Nav_Menu { // add classes to ul sub-menus function start_lvl(&$output, $depth) { // depth dependent classes $indent … Read more

WordPress Stock Update Programatically

WordPress stores three levels of stock information on the wp_postmeta. Each product has manage stock enabled Stock Quantity Stock Status Since the products on the above questions were imported, few of them didn’t had manage stock enabled so updating the stock quantity to 0 didn’t work well. Solution: I forcefully updated the manage stock to … Read more

Variables not showing in short code

Try this: function banner_shortcode() { $banner = esc_url( get_stylesheet_directory_uri() . ‘/images/banner.jpg’ ); $banner__feature = esc_url( get_stylesheet_directory_uri() . ‘/images/banner__feature–easter.jpg’ ); return ‘<div class=”banner banner–call-now” data-parallax=”scroll” data-bleed=”100″ data-image-src=”‘ . $banner . ‘”> <div class=”banner__left”> <img class=”img-responsive” src=”‘ . $banner__feature . ‘”> </div> <div class=”banner__center”> <h2 class=”banner__title”>Call Now!</h2> <h1 class=”banner__phone”><strong><a href=”tel:1-570-877-8595″><strong>570-877-8595</strong></a></strong></h1> </div> <div class=”banner__right”> <img class=”img-responsive” src=”‘ . … Read more

Noindex Posts From Certain Authors In WordPress

From codex: is_author() is a conditional tag which determines whether the query is for an existing author archive page. so it does not work for your scope. Best solution, instead of using the template file header.php is to write a function in functions.php hooking the proper action wp_head: add_action(‘wp_head’,’AS_exclude_author_from_indexing’); function AS_exclude_author_from_indexing(){ $toIndex = array(111,112,113); $user_id … Read more

WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank

If you haven’t done so already, I would recommend you to turn on debug logging in wp-config.php as it makes it easier to trace the error in your code. // added to wp-config.php define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_LOG’, true ); // find error.log in /wp-content, shows backtrace for errors define( ‘WP_DEBUG_DISPLAY’, false ); // … Read more

How to parse a shortcode within a shortcode?

The function you are looking for is named do_shortcode (there will also be a function apply_shortcode in WordPress 5.4 that does the same). Codex Page For your example, this will work: function content_for_logged_in($atts,$content){ $logged_in_content = “”; if(is_user_logged_in()){ $logged_in_content = do_shortcode($content); } return $logged_in_content; } add_shortcode(‘logged-in-content’,’content_for_logged_in’); Happy Coding!

Remove the month and year from a WordPress Date?

You’ll need to write your OWN function that will take the post_date and return it reformatted to the style you’re looking for. function my_date($input_date) { return date(“S”, strtotime($input_date)); } And then you would call it within your Pods Template like {@post_date, my_date} All rights goes to Jim True. More infomations : https://pods.io/forums/topic/date-formatting-using-magic-tags/