How to check if the current page is the permalink page?

<?php // ‘current_screen’ action fires after the current screen has been set add_action( ‘current_screen’, ‘my_check_current_screen’ ); // $current_screen is WP_Screen object passed by the ‘current_screen’ action function my_check_current_screen( $current_screen ) { // compare current screen ID to the string of your choice if( ‘options-permalink’ === $current_screen->id ) { echo ‘I am on the “Permalink Settings” … Read more

Remove the parent name from permalink

Add this code to your functions.php, add_action( ‘init’, ‘build_taxonomies’, 0 ); function build_taxonomies() { register_taxonomy( ‘category’, ‘post’, array( ‘hierarchical’ => true, ‘update_count_callback’ => ‘_update_post_term_count’, ‘query_var’ => ‘category_name’, ‘rewrite’ => did_action( ‘init’ ) ? array( ‘hierarchical’ => false, ‘slug’ => get_option(‘category_base’) ? get_option(‘category_base’) : ‘category’, ‘with_front’ => false) : false, ‘public’ => true, ‘show_ui’ => true, … Read more

Get category URL knowing it’s id

If you have category ID you can create link to category like below : <a href=”https://wordpress.stackexchange.com/index.php?cat=7″>Category Title</a> For more details read from this link : https://codex.wordpress.org/Linking_Posts_Pages_and_Categories Thanks!

Update the permalink for one post via wp cli

If you mean the post name field, then we can update it for a post with: wp post update 123 –post_name=”new-slug” where 123 is the post ID. If we then try to update another post with the same post name: wp post update 321 –post_name=”new-slug” then it will be set to new-slug-2 in that case, … Read more

Add a permalink variable onto custom post type URL after post name slug

Here’s a complete working example that adds a post type, with extra rule to capture an additional parameter: function wpd_post_type_and_rule() { register_post_type( ‘mycpt’, array( ‘labels’ => array( ‘name’ => __( ‘mycpt’ ), ), ‘public’ => true, ‘rewrite’ => array( ‘slug’ => ‘mycpt’ ), ) ); add_rewrite_tag( ‘%mycpt_var%’, ‘([^/]*)’ ); add_rewrite_rule( ‘^mycpt/([^/]*)/([^/]*)/?$’, ‘index.php?mycpt=$matches[1]&mycpt_var=$matches[2]’, ‘top’ ); } … Read more