How to list all categories and their IDs using SQL query?

I finally got the solution. Below SQL Query gets the list of all categories with it’s ID from WordPress table – SELECT wp_term_taxonomy.term_id, wp_terms.name FROM wp_term_relationships LEFT JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id) LEFT JOIN wp_terms ON (wp_terms.term_id = wp_term_taxonomy.term_taxonomy_id) WHERE wp_term_taxonomy.taxonomy = ‘category’ GROUP BY wp_term_taxonomy.term_id order by wp_terms.name Hope this could help others.

Change the Default Plugin page filter to Active intead of All

There is no WordPress hook to filter the current status on the plugins admin, but if you must, you can use $_REQUEST[‘plugin_status’] to change the default status. See example below where I use the load-plugins.php hook to ensure we’re changing the status (or modifying the superglobal $_REQUEST) only on the plugins.php page: function wpse_373622() { … Read more

Redirect to a page for only logged in user

You can make more readable, like. Small notes at the code. As a hint, the template tag is_page() supports an array of values – is_page( [ ‘login’, ‘register’ ] ). add_action( ‘template_redirect’, ‘login_redirect’ ); function login_redirect() { // If user is NOT logged in, doing nothing. if ( ! is_user_logged_in() ) { return; } // … Read more