Custom post type archive sorted and grouped by date in post meta field

OK, so this problem has two parts: Make WordPress to sort these posts properly. Make WordPress to display them with all that grouping. 1. Sorting CPT by meta value on archive You can use pre_get_posts to achieve this. add_action( ‘pre_get_posts’, function ( $query ) { if ( is_post_type_archive( ‘event’ ) && $query->is_main_query() ) { $query->set( … Read more

Intercept request to /wp-content/uploads/random.file

I just ran a test where I uploaded an image to media library, then renamed my root index.php file to break WordPress, but the image I uploaded was still available by accessing it directly with its wp-content/uploads/… URL. There are no .htaccess files in wp-content or uploads either, which means that, barring any plugins that … Read more

How to remove action from plugin?

You want: remove_action(‘um_post_registration_approved_hook’, ‘um_post_registration_approved_hook’, 10, 2); … to run after the original add_action, but before the action triggers the function um_post_registration_approved_hook The easiest way to do this, but I haven’t tested it, might be to just give your removal an earlier priority on the same hook: add_action( ‘um_post_registration_approved_hook’, ‘remove_my_action’, 9 ); function remove_my_action(){ remove_action(‘um_post_registration_approved_hook’, ‘um_post_registration_approved_hook’, … Read more

How to add a checkbox inside the “Publish post” widget?

Hook into post_submitbox_misc_actions and print the checkbox: add_action( ‘post_submitbox_misc_actions’, function() { ?> <div class=”misc-pub-section”> <label><input type=”checkbox”> click me</label> </div> <?php }); Wrap the code in a <div class=”misc-pub-section”>, otherwise the spacing looks a little bit weird. Examples: language selector, noindex checkbox, public preview checkbox.

Hook before inserting user into database [duplicate]

If you examine the wp_insert_user() function, you can see there are a myriad of filters and actions that are called throughout the process. The first is a filter called pre_user_login on the username. Line 1304 of wp-includes/user.php: $user_login = apply_filters(‘pre_user_login’, $user_login); You could hook onto that and throw your own custom error message. Edit: The … Read more

Call to undefined add_action() in theme’s functions.php

register an ajax action for submitting email: Note handle_form is the name of your action in this example add_action(‘wp_ajax_handle_form’,’handle_form_submit_111605′ ); also add this in order to make it work for non logged in users add_action(‘wp_ajax_nopriv_handle_form’,’handle_form_submit_111605′ ); do validation and mail sending job in the callback function handle_form_submit_111605 In functions.php function handle_form_submit_111605() { } User simply … Read more