Add a functionality to quickly filter custom posts in Admin Area

I am creating a website for a doggie rescue, basically configuring the backend so they can manage dogs, volunteers, etc.

The legacy system had a feature where the user could start typing into an input field and all matching results would be displayed as you typed, most likely making ajax calls.

They would like to have this feature in WordPress. I tried using Admin Columns but you have to create the filter, modify the value and then click the Filter button and wait for it to load the results. I want to avoid the "click filter button and wait for page to come back with results" part.

One of the CPT that I am creating, volunteers, apparently has 40K records, and they would like to filter through them by using this "filter as you type" idea.

Is this possible from WPAdmin? I mean, adding a text input field that would filter all the posts using AJAX?

Thanks!

Add term of current custom post type to admin body class using admin_body_class

I am trying to add the current custom post type term to the body class of my WordPress admin page. So when I am viewing an existing custom post type that has been assigned a term it will add that term to the body class.

I have found the following code but cannot get it to work for me:

add_filter( 'admin_body_class', 'rw_admin_body_class' ); function rw_admin_body_class( $  classes ) {     if ( 'post' != $  screen->base )         return $  classes;      global $  post;     $  terms = wp_get_post_terms( $  post->ID, 'product_cat', array( 'fields' => 'all' ) );     $  terms = wp_list_pluck( $  terms, 'slug' );     foreach ( $  terms as $  term )     {         $  classes .= ' my_taxonomy-' . $  term;     }      return $  classes; } 

Any pointers on how to get this working?

Admin only taxonomies?

I’m building a marketplace site using woocommerce, wcvendors pro, buddyboss marketplace and buddypress.

I’d like for the admin to have an admin-only taxonomy that she can use to tag/categorise certain products for use in featured blocks on the home page, for example.

What would be the best approach for this? Thanks!

Is “document loaded” different on admin side than public side?

I’m writing a plugin to support Google Graphs. It’s working fine on the public side, but is intermittently rendering weirdly on the admin side, and also intermittently throwing errors that make me think the JS is running too soon. (for example, TypeError: null is not an object (evaluating 'document.getElementById(colControlId).appendChild'), but when I go inspect the page, that element is absolutely there.

The function that drives everything is registered to the Google library as a callback:

// Load the Visualization API and the corechart package. google.charts.load('current', {'packages':['corechart', 'controls']});  // Set a callback to run when the Google Visualization API is loaded. google.charts.setOnLoadCallback(initializeData);  // Query a CSV for the data function initializeData() {         let graphs = document.getElementsByClassName("cwraggbp_chart"); 

The Google docs say, "When the packages [loaded above by google.charts.load] have finished loading, this callback function will be called with no arguments. The loader will also wait for the document to finish loading before calling the callback."

But, I can’t see how I can be getting this error intermittently if the DOM is fully loaded, and I don’t know what "document loaded" means. So, since this works flawlessly on the public side, but not in admin, I’m wondering if … something is different.

I’m loading the scripts thusly:

    public function enqueue_scripts() {              wp_enqueue_script( $  this->plugin_name . '-public',                 plugin_dir_url( __FILE__ )                     . 'js/cwra-google-graph-block-public.js', // this is where the JS above is                 array( $  this->plugin_name . 'googlecharts', 'jquery' ),                 $  this->date_version(                     'js/cwra-google-graph-block-public.js'), false );             wp_localize_script( $  this->plugin_name . '-public',                 'cwraggbp',                 array(                     'contentdir' => wp_upload_dir()['baseurl']                         . '/cwraggb'                 ));              wp_enqueue_script( $  this->plugin_name . 'googlecharts',                 'https://www.gstatic.com/charts/loader.js',                 array(), $  this->version, false );      } 

how to set post order by custom field in admin area wordpress

Hello friends

I have some posts that I have made in custom post type. working with Ajax Pagination. I want to post these orders by show, so I have a plugin "ACF" for custom fields . When I give the number to any post, that 1, 2, 3, then that post should be shown in the same order.

Can anyone tell me how it is possible.

Image 1

enter image description here

Image 2

enter image description here

Image 3

enter image description here

Plugin or standalone script for wordpress automatic generate passwords for admin users with 24h regenerate

I have clean wordpress installation with one admin user. I want some script or plugin with autogenerate passwords for WordPress’s admin and sent automatically to email notification. Is possible? Example : i have user’s admin with password ‘test’ – i want generate random passwords for this admin once at 24h and send automatically thsi fact to email.

WordPress add page under admin submenu and retaining the active status of the parent submenu page in the menu

I have added a page in the admin menu(pxmag-menu) and a submenu(pxmag-plans). There is another page(pxmag-plans-edit) set under the submenu(pxmag-plans) as the parent page.

public function __construct() {     require('pxMagAdminPlans.class.php');     $  this->admPlanObj= new pxMagAdminPlans();      add_action('admin_menu', array($  this, 'add_plan_admin_menu')); }  public function add_plan_admin_menu() {     add_menu_page(__('Dashboard', 'textdomain'), get_bloginfo('name'), 'manage_options', 'pxmag-menu', array($  this, 'pxmag_dash'), 'dashicons-welcome-view-site', 6);              add_submenu_page('pxmag-menu', __('Subscription Plans', 'textdomain'), 'Plans', 'manage_options', 'pxmag-plans', array($  this->admPlanObj, 'plan_admin_menu_page'));     add_submenu_page('pxmag-plans', __('Add/edit Plans', 'textdomain'), 'Add/edit plans', 'manage_options', 'pxmag-plans-edit', array($  this->admPlanObj, 'plan_admin_menu_edit')); } 

All the menu and submenu pages load fine.

But, when I open this page(pxmag-plans-edit), the menu selection in the WordPress admin shows nothing as current item, whereas the pxmag-plans is supposed to be the current selection.

(It is supposed to work like: when I click ‘Posts > Categories‘ and subsequently open the ‘edit category‘ page, the ‘Posts > Categories‘ option in menu keeps selected).

What is going wrong? What is the correct process?

how to know when the user is in specific part of the website and when he leaves that part and display the data in the admin dashboard

I want to display for the admin when a user visits a page and when he leaves that page

the page is for example test.test/my-dashboard. and it’s only available for the logged in users. the admin knows to know the time when the user is in that page and the time the user leaves that page.

thanks in advance and excuse my language.

WordPress Admin Post Search extend to one custom field

I would like to extend the WordPress admin post search (so in back-end) in order to look at keywords in post title but also in one custom field.

I find this thread interesseting (except the custom post type because I don’t use it) : Extending the search context in the admin list post screen and adapt my function like below :

function rel_search_join( $  join ) {     global $  pagenow, $  wpdb;     if ( is_admin() && $  pagenow == 'edit.php' && $  _GET['post_type'] == 'post' && $  _GET['s'] != '') {             $  join .= 'LEFT JOIN ' . $  wpdb->postmeta . ' ON '. $  wpdb->posts . '.ID = ' . $  wpdb->postmeta . '.post_id ';     }     return $  join; } add_filter('posts_join', 'rel_search_join' );  function rel_search_where( $  where ) {     global $  pagenow, $  wpdb;     if ( is_admin() && $  pagenow == 'edit.php' && $  _GET['post_type']=='post' && $  _GET['s'] != '' ) {         $  where = preg_replace( "/\(\s*".$  wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/", "(".$  wpdb->posts.".post_title LIKE $  1) OR (".$  wpdb->postmeta.".my-custom-field-meta-key LIKE $  1)", $  where );         $  where = str_replace( "OR wp_posts.post_status = 'pending'", "", $  where );         $  where = str_replace( "OR wp_posts.post_status = 'private'", "", $  where );         $  where = str_replace( "OR wp_posts.post_status = 'draft'", "", $  where );         $  where = str_replace( "OR wp_posts.post_status = 'future'", "", $  where );     }     return $  where; } add_filter( 'posts_where', 'rel_search_where' ); 

But this does not work at all, the search was no longer working at all.

I feel like there is a way easier solution but I am not able to find it on any forums.

I know there are other solutions like custom field filters but it is not suitable for my custom field which can have thousands of values.

PS : I use Advanced Custom Field but I don’t think there is any connection.

Can I masschange all admin emails for a multisite instance?

I am managing a multi-site instance of Wp with 300 sites and so I am trying to see if this can be done automatically.

I know individually I can go to each site and change the admin email value in the settings but is there a way to affect all sites? I have tried searching for this and can’t seem to find a post discussing this exact topic.