Is it possible to filter the wp_footer() scripts, read the content, and insert them inline?

For scripts you can use the script_loader_tag filter, which is run right before the script tag is output. It filters the HTML <script> tag, but it also passes the handle and URL that you can use to extract the contents and replace the script tag with a version that has the script inline: function wpse_292955_inline_script( … Read more

Post Admin – Filter by posts without tags

The first part is to add a dropdown using restrict_manage_posts filter, and the second one is to actually get posts without tags using pre_get_posts filter: function wpse147471_add_no_tags_filter() { if ( ‘post’ !== get_current_screen()->post_type ) { return; } $selected = ( isset( $_GET[‘tag-filter’] ) && ‘no-tags’ === $_GET[‘tag-filter’] ); ?> <select name=”tag-filter”> <option value=””>&mdash; Select &mdash;</option> … Read more

Modify custom Users Manage page

Here’s how I managed to modify the page. For the submenu highlighting, however, I haven’t managed to figure it out, so I resort to jQuery. Here’s the code: /* – Set user filter links according to users pages * – Set Role Change dropdown menu * */ function custom_user_filter_links( $views ) { global $wp_roles; // … Read more

Enforcing canonical URLs with multiple custom post types

I tackled subordinate post types with a similar vein but was not as strict on the canonical url aspect; however, I ran into a similar situation with deeplinking custom WooCommerce product type links. I leveraged the template_redirect hook to push a 404 if it didn’t match the route and the post_type_link to ensure the meta … Read more

How can I control the comment counts filtering my CPT replies?

Here are three different methods to modify the trash count, to 999 as an example: Method #1 The views_edit-comments filter: add_filter( ‘views_edit-comments’, function( $views ) { $trash_count = 999; // <– Adjust this count // Override the ‘trash’ link: $views[‘trash’] = sprintf( “<a href=%s>%s <span class=”count”>(<span class=”trash-count”>%d</span>)</span></a>”, esc_url( admin_url( ‘edit-comments.php?comment_status=trash’) ), __( ‘Trash’ ), $trash_count … Read more

How to modify posts_where filter only for the search query

Problem: The problem with your current snippet is that you are just checking the global main query object, no matter what the current query object is. Workaround: Note that the second input argument for the posts_where filter callback, is the current query object. Use that to determine if it’s the main search query on the … Read more