WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page

I’ll preface this by saying I think it’s a really bad idea, but you could circumvent the admin UI by hooking an action that happens after things are initialized, but before any output occurs: function my_admin_ui(){ if( isset( $_GET[‘page’] ) && ‘myPlugin-ui’ == $_GET[‘page’] ){ include( plugin_dir_path( __FILE__ ) . ‘views/myPlugin-ui.php’ ); exit; } } … Read more

wp_trash_post function to only apply to posts, not pages!

You could just add something like: // Remove 1 point if their post get removed function deletePointFromUser($post_id) { $post = get_post($post_id); if( $post->post_type != ‘post’ ) return;//added code $authorid = $post->post_author; $currentQPointNumber = get_user_meta($authorid, ‘points’, true); // Delete 1 to the current Point Score update_user_meta($authorid, ‘points’, $currentQPointNumber-1); } add_action(‘wp_trash_post’, ‘deletePointFromUser’); Then your point subtraction will … Read more

How can I use wp_insert_comment to write a comment when a post is edited?

Try using the following code in the functions.php file of your child theme theme. function add_comment_on_post_update( $post_id, $post_after, $post_before ) { // If this is just a revision, don’t send the email. if ( wp_is_post_revision( $post_id ) ) return; if (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) return; if (isset($post_before->post_status) && ‘auto-draft’ == $post_before->post_status) { return; } if (‘post’ … Read more

Insert HTML inside link in a walker

You can try to skip the CategoryThumbnailWalker and use instead the list_cats filter. Here’s an untested example: add_filter( ‘list_cats’, ‘wpse_149898_list_cats’, 99, 2 ); wp_list_categories(array( “child_of” => get_queried_object_id(), “depth” => 1, “hide_empty” => false, “hierarchical” => 1, “orderby” => “name”, “pad_counts” => 0, “post_type” => “projects”, “show_count” => 0, “show_option_none” => “”, “taxonomy” => “project-category”, “title_li” … Read more

Run a filter when a walker runs

If all of it is your own code then it would be reasonable to just implement that as part of walker. If you need to add a filter while third party walker runs you could probably: Add it at wp_nav_menu_args hook, checking if walker is set to that: add_filter( ‘wp_nav_menu_args’, function( $args ) { if … Read more