Rewrite /category/cars into /topics/cars
If you go to Settings->Permalinks and change Category Base to topics, you won’t even have to write any code to make the change, as wordpress includes this functionality by default.
If you go to Settings->Permalinks and change Category Base to topics, you won’t even have to write any code to make the change, as wordpress includes this functionality by default.
You should be using a filter outside of your template for this: add_filter( ‘template_include’, ‘wpa62226_template_include’, 1, 1 ); function wpa62226_template_include( $template ){ if( is_page( ‘some-page’ ) ) : global $wp_query; $wp_query->set_404(); status_header( 404 ); $template = locate_template( ‘404.php’ ); endif; return $template; } Your code is executed before the template is loaded, so it becomes … Read more
The .htaccess is parsed before WordPress is loaded, so you don’t get access to WordPress data. You can make the redirect in WordPress, in a plugin: Hook into 404_template and inspect $_SERVER[‘REQUEST_URI’] with parse_url(). You should be able to find the matching post for the image then. You did not write how the permalinks for … Read more
I’m sure there is a more elegant way of achieving your desires, however this method does work. Just tested it. /** * Redirect pages from array. * * @author Michael Ecklund * @author_url https://www.michaelbrentecklund.com/ * * @return void */ function redirect_pages() { // Page from => Page to $redirect_pages = array( ‘wordpresspage’ => ‘/wordpress-page’ ); … Read more
By far the easiest fix is to edit wp-config.php to define two constants. (s)FTP into your site, or use a host supplied file manager, and add: define( ‘WP_SITEURL’, ‘http://www.abc.com/folder’ ); define( ‘WP_HOME’, ‘http://www.abc.com/folder’ ); Those will be used instead of the information in the database. That will get your site up and running again. You … Read more
I don’t know what your definition of “simple” is, so not sure this qualifies. It’s not really a simple task to do this dynamically. First, we register a new query var to pass the alternate identifier: function wpd_portfolios_query_var($query_vars){ $query_vars[] = ‘portfolio_key’; return $query_vars; } add_filter(‘query_vars’, ‘wpd_portfolios_query_var’); Next, we add a rewrite rule to handle incoming … Read more
See Changing The Site URL « WordPress Codex for recovery instructions on how to reset the URLs without database access, i.e. by editing either the wp-config.php file or the theme’s functions.php file with FTP: 1) by adding lines to wp-config.php (which can be left in place): define(‘WP_HOME’,’http://example.com’); define(‘WP_SITEURL’,’http://example.com’); 2) or the theme’s functions.php file (but … Read more
You can make a custom template for a custom post type. Generally I use the single.php file and duplicate it. Then I rename it to single-{custom-post-type}.php as per Post Type Templates. In your case the template file should look like this single-uslugi.php. As far as saving the old URLs and fixing things I don’t quite … Read more
Yes, this is achievable and quite simple to do so. Go to Settings > Permalinks in your admin area. There you should be able to select Custom and use a value like (if you want all URLs to start with /carhire/uk/) /carhire/uk/%postname%/ If your logic is more complex, I suggest using a plugin such as … Read more
You have to do it in a loop: $p = $post; while ( $p->post_parent ) { $p = get_post( $p->post_parent ); } $parent_page_link = get_permalink( $p->ID ); Another way is to use get_ancestors function: $ancestors = get_ancestors( $post->ID, ‘page’, ‘post_type’ ); $root = ( ! empty( $ancestors ) ) ? end($ancestors) : $post->ID; $parent_page_link = … Read more