change WordPress permalinks and redirect new urls 301
Just choose Plain permalink settings on /wp-admin/options-permalink.php page. Wordoress would auto redirect all posts.
Just choose Plain permalink settings on /wp-admin/options-permalink.php page. Wordoress would auto redirect all posts.
For permalinks to work, you need mod_rewrite module enabled on Apache server. Check your Apache configuration and make sure mod_rewrite is installed and enabled. Here is the easy to follow tutorial for Ubuntu 16.04 to enable Rewrite module: How To Rewrite URLs with mod_rewrite for Apache on Ubuntu 16.04
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
The easiest option would be to install a plugin called better search replace, this will only work for the database. You can then search the database for instances of x and replace with y – x obviously being the URL on the old site and y being the URL of the new website. Be sure … Read more
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
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 …’, ‘customsearch’);?>” … Read more
Remove the htaccess file and then regenerate it by hitting save at settings->permalinks Also make sure to change site_url and home (options table), to reflect the updated path. P.S.: You should really have a local dev env.
I’ve solved my problem, there is solution: https://webdevdoor.com/php/mod_rewrite-windows-apache-url-rewriting
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
the_content() is probably rendering a link ( or maybe your browser may be auto formatting one ). You can test if this is so by instead of using the_content(); using // Get the Content of the post $postContent = get_the_content(); // Escape all the HTML $postContent = htmlentities($postContent); // Print it to screen and verify … Read more