Pass parameter to hooked function using custom page template
you make a mistake in the call of add_action the last parameters must be changed from 1 to 2 add_action(‘pre_get_posts’,’shop_filter_cat’,10,2);
you make a mistake in the call of add_action the last parameters must be changed from 1 to 2 add_action(‘pre_get_posts’,’shop_filter_cat’,10,2);
Functions and shortcodes that are never used, eat some processor time at launch, as WP is registering their existence. Deregistering them would take up some additional (and minimal) processor time. Because they are loaded with functions.php they will reside in memory, either registered or deregistered. Which amounts to the same, as the code is never … Read more
First of all you need to register a action callback for you ajax request. Secondly you need to send all ajax request to wp-admin/admin-ajax.php (both GET and POST). And lastly you need to modify your javascript a little to pass the action parameter which will trigger the callback. and var post_link = $(this); doesn’t gives … Read more
Your code is based on jQuery and you are including it to a PHP file. So you need to call it between <script></script> tag and obviously either you must end and start PHP tags before <script> and after </script> or echo the full script. Now come to how you are gonna execute the code. You … Read more
Generally functions hooked with init action will be available on every page and posts with in WordPress. it will immediately fire upon WP load. so maybe something like below will work. function ao_check_cookie() { //Your code here. } add_action( ‘init’, ‘ao_check_cookie’ );
Rather than attempting to modify a core file of woocommerce, make use of their filter hook. First of all, make sure you are using an up to date version of woocommerce. From the woocommerce documentation Add a custom currency / symbol: To add a custom currency in WooCommerce 2.0+, copy and paste this code in … Read more
I think you’re looking for the img_caption_shortcode_width filter, within the img_caption_shortcode(): /** * Filters the width of an image’s caption. * * By default, the caption is 10 pixels greater than the width of the image, * to prevent post content from running up against a floated image. * * @since 3.7.0 * * @see … Read more
You need to add a the edit_published_posts capability for the contributor role in the functions.php add_filter(‘init’, function () { $role = get_role(‘contributor’); $role->add_cap(‘edit_published_posts’); });
I’ve always found that the best way to learn about how WP works and how you can modify it is to search the Codex at https://codex.wordpress.org/ For example, first I find the Codex page for the_archive_title() and there I see that it’s a wrapper for get_the_archive_title() and there, looking at the source code, I see … Read more
The main reason it’s not working is that the onclick() attribute is not an allowed attribute in the editor. Probably for security reasons. The alternative is to add the click event in the script. So instead of the onclick=”myFunction()”, add an ID, myButton to the button, then these lines: var myButton = document.getElementById( ‘myButton’ ); … Read more