call php file from form and use wp functions
WordPress provides wp-admin/admin-post.php endpoint to work with form submissions. You should likely point your form to it, add an identifying action, and use hooks in the file to process submission.
WordPress provides wp-admin/admin-post.php endpoint to work with form submissions. You should likely point your form to it, add an identifying action, and use hooks in the file to process submission.
As I said in the question post, I finally solved it by looking into the $_POST global. There’s a $_POST[‘sticky’] field (valued as ‘sticky’) that is there just when a Post is sticky or is being made sticky, and it’s not when a post is not sticky or is being unsticked.
The earliest hook accessible from external code is muplugins_loaded. In order to use it, create a directory mu-plugins in your wp-content directory and put a PHP file into that directory. Sample code, will have side effects(!): add_action( ‘muplugins_loaded’, function() { print current_filter(); }); This is, of course, not “before anything else in WordPress executes”. WordPress … Read more
You want the has_action() function. add_action( ‘category_promo_header’, function () { echo ‘hi there’; } ); if (has_action(‘category_promo_header’)) { echo ‘<div>’; do_action(‘category_promo_header’); echo ‘</div>’; } Comment that add_action and you should see that nothing is printed at all.
Solution: First, Jeff Farthing of theme-my-login pointed out that I was using add_filter instead of add_action, and helped to craft the first code below, however it still has the same problem, so this is a step in the right direction but is not my solution: function tml_profile_errors( &$errors ) { if ( empty( $_POST[‘state’] ) … Read more
the_content_feed is the hook I needed. In my case I am running a regex to replace relative URLs to absolute ones, so I added the following code to functions.php add_action(‘the_content_feed’, ‘relative_to_absolute_links’); function relative_to_absolute_links($content) { return preg_replace(“/(src=[‘\”]){1}\/{1}([^\/][^’\”]+)([‘\”])/im”, “$1” . get_site_url() . “/$2$3”, $content); }
In your first code block try changing return $output; with echo $output; and that should work provided $output is not empty 🙂 If you are trying to append your custom field to the product summary, this can be very well achieved using woocommerce_short_description filter hook. Please see below code: function add_subtitle_to_product() { global $post; if … Read more
Your custom hook is never triggered because you are not subscribing to it the right way! Context Although you are calling it in your class function, it is never executed beyond that point. Place the add_action function somewhere else like in a plugins_loaded hook. Put it outside your class where it can be seen. Dependencies … Read more
It looks like you are trying to access the $lava_listing_posts_args array from a different file (and class). You would need to pass it as an argument of your action. Although you could do this with actions since you are simply modifying the array you should probably use filters (actions and filters are essentially the same … Read more
As long as the wp_head() function is still being called in the template, you should be fine. You’ve pretty much summed it up in your question; by not using get_header(), the get_header action will not be fired, but that wouldn’t matter for your particular use case. Using get_header() along with the name parameter would be … Read more