Remove slugs from custom posts type

if ( ! in_array( $post->post_type, array( ‘internal_doors’ ) ) || ‘publish’ != $post->post_status ) replace above with if ( ! in_array( $post->post_type, array( ‘internal_doors’,’custom post type name1′, ‘custom post type name2’ ) ) || ‘publish’ != $post->post_status ) and if ( ! empty( $query->query[‘name’] ) ) $query->set( ‘post_type’, array( ‘post’, ‘internal_doors’, ‘page’ ) ); replace … Read more

Bulk append URL (add word to slug)

Here is your code: if ( isset($_GET[‘slug-update’]) ) { $posts = get_posts(); foreach($posts as $singlepost) { if($singlepost->post_status === ‘publish’){ $post_id = $singlepost->ID; $current_slug = $singlepost->post_name; $updated_slug = $current_slug . ‘-word’; } wp_update_post( array( ‘ID’ => $post_id, ‘post_name’ => $updated_slug ) ); } die(‘Slug Updated’); } Add this to your theme’s function.php. Then run this with … Read more

How to add specific phrase to end of search url

This can be done in multiple ways But the easiest will be the following code. The key is the GET method that will allow us to inject what you want. You can try: <div class=”search-box”> <div class=”container”> <div class=”columns”> <form method=”get” class=”nt-search-form” action=”<?php echo home_url(); ?>”> <input type=”text” id=”search-text” class=”input-text” name=”s” placeholder=”<?php _e(‘Search &#8230;’, ‘customsearch’);?>” … Read more

Remove all stop words from old permalinks

This script will do the job: function wpse_287807_replace_url() { // Get all posts $query = new WP_Query(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, )); $posts = $query->get_posts(); foreach ($posts as $post) { // Get permalink $url = $post->post_name; // Stop words array $stop_words = array( ‘-a-‘, ‘-the-‘, ‘-of-‘, ); // Replacement $replacement=”-“; // Replace url … Read more

How to remove one specific category (uncategorized) from post permalinks

Adding this kind of rewrite rule is not a problem, you have to add only this code. /** * Add custom rewrite rule to handle posts with and without category prefix. * * Remember to flush rewrite rules to apply changes. */ function wpse_288675_add_post_handling_without_category_prefix() { add_rewrite_rule(‘([^/]+)(?:/([0-9]+))?/?$’, ‘index.php?name=$matches[1]&page=$matches[2]’, ‘top’); } These rewrite rules are working on … Read more