Query categories that have a description

How about looping all available terms, if term has description, add to to an object_ids, something like this. add_filter( ‘wp_sitemaps_taxonomies_query_args’, function( $args, $taxonomy ) { // Show in sitemap categories and topics that have a description if ( $taxonomy == ‘category’ || $taxonomy == ‘post_tag’ ) { // get the terms of the taxonomy $terms … Read more

Is there a JavaScript equivalent of get_post_field?

The @wordpress/hooks package only gives you a JS-like equivalent to the PHP-based hook system in WordPress – they are entirely separate, and don’t bring any native WP PHP functions to the table. What you need (most likely) is an AJAX request to the WordPress REST API. Specifically, the GET posts endpoint, which by default is: … Read more

Append a code when at the current page in wp_list_pages()

I would use a custom walker and then extend the Walker_Page::start_el() method, like so: // Based on Walker_Page for WordPress v6.0 // @link https://github.com/WordPress/wordpress-develop/blob/6.0/src/wp-includes/class-walker-page.php#L105-L219 class My_Walker_Page extends Walker_Page { public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) { /* This checks if the current page in the list … Read more

Need to check is_archive during init

This is what I could come up with, within init like you said ! Even if you print the $GLOBALS array, there is no way to check if the current page is an archive, is_archive is also set to blank! But if you check the $_GET array, the q variable contains the current archive type … Read more

Looking for a hook for post.php

You can add your code to the init action hook and check global $pagenow variable: add_action( ‘init’, ‘wpse8170_check_from_var’ ); function wpse8170_check_from_var() { global $pagenow; if ( ‘post.php’ != $pagenow || ! isset( $_GET[‘post’] ) || ! isset( $_GET[‘from’] ) || 1 != (int) $_GET[‘from’] ) { return; } update_post_meta( (int) $_GET[‘post’], ‘EDITED’, ‘true’ ); }

Plugin init hook

There’s the plugins_loaded hook for normal Plugins and muplugins_loaded, which runs earlier. My best advice for hooks is making cross file searches for do_action or dump the content of the all hook with $GLOBALS[‘wp_filter’][ current_filter() ];.

Hook when new CPT published AND postmeta inserted

I believe you can do it using the save_post hook, than do a conditional check for the post’s post-type and the value of its post meta. add_action( ‘save_post’, ‘do_some_function’); function do_some_function($post_id) { global $post; $post_type_as_taxonomy = array(‘cpt-1′,’cpt-2′); // this is your hooked custom post types $post = get_post( $post_id ); if(in_array($post->post_type, $post_type_as_taxonomy) && $post->post_status==’publish’){ // … Read more