help to remove last trailing slash using add_rewrite_rule

Replace all your above code with the one below: <?php function master_load_ads_txt_template_include( $template ) { $is_load_ads_txt = (bool) get_query_var( ‘ads-txt’ ); if ( $is_load_ads_txt ) { $template = locate_template( ‘template-parts/ads-txt.php’ ); } return $template; } add_filter( ‘template_include’, ‘master_load_ads_txt_template_include’ ); function master_load_ads_txt_rewrite() { add_rewrite_rule( ‘ads.txt’, ‘index.php?ads-txt=true’, ‘top’ ); // The line below doesn’t work and it’s … 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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)