How to set add_query_arg properly for home page?

Is there a problem with the code? Your code is already properly adding the lang query variable to the homepage URL. But you need to understand these points: On the homepage URL becomes http://localhost/mywebsitename/?lang=en which should be ok $wp->request is empty on the homepage, hence the above URL is expected. And you could use get_queried_object()->post_name … Read more

Gutenberg Editor: dynamically edit slug field based on ACF field

I’ve found the way to edit the slug’s field. Just simply use: wp.data.dispatch(‘core/editor’).editPost({slug: ‘my-slug-value-here’}); With an event listener like this, I can dynamically change the slug field based on a custom field: jQuery(document).ready(() => { const acfField = ‘field_61f8bacf53dc5’; const inputShortTitle = document.getElementById(‘acf-‘ + acfField); const slugify = (str) => { return str.toLowerCase().replace(/ /g, ‘-‘) … Read more

Display parent page URL for child page

$post->post_parent returns 0 when there’s no parent associated. You need to check if the value is greater than 0. <?php global $post; if ( $post->post_parent > 0 ) { ?> <a href=”<?php echo get_permalink( $post->post_parent ); ?>” > <?php echo get_the_title( $post->post_parent ); ?> </a> <Br><?php echo get_permalink( $post->post_parent ); ?> <?php } ?> Also, … Read more