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

Hooking in to replace the Sidebar/Widget areas

You should look into having your sidebars utilize the remove action function. Then you can remove a sidebar and replace it in a function any number of ways. For instance (this examples using a conditional based on a page called some-page. function change_sidebar_yay() { if ( is_single(‘some-page’) ) { remove_action( ‘old_sidebar’, ‘your_function’ ); //this is …

Read more

Pass variable to hook. Its possible?

Ok i can pass variables to hook but i was doing it wrong. Code should be: function encrypt_password_function($pass, $id){ global $wpdb; $encrypted=sha1($pass); $wpdb->query($wpdb->prepare(“UPDATE wp_users SET iphone_pass = %s WHERE ID = %d”,array($encrypted, ’10’))); } function encrypt_password($var1, $var2) { do_action(‘encrypt_password’,$var1, $var2); } add_action(‘encrypt_password’, ‘encrypt_password_function’, 1,2);

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