How does WordPress redirect to WooCommerce shop page? [closed]

You could add a rewrite rule to improve the appearance of the URL while maintaining the same functionality: As an example: add_action(‘init’, ‘custom_shop_param’); function custom_shop_param() { add_rewrite_tag(‘%param%’,'([^&]+)’); add_rewrite_rule(‘^shop/([^/]+)/?$’,’index.php?page=shop&param=$matches[1]’,’top’); } When you visit http://site/wp/shop/{somevalue} the value that proceeds the /shop/ portion of the URL will be matched and stored in the query var param which is … Read more

How to add wordpress username after url?

You can do <?php if( get_current_user_id() ): // check if user is loggedin $current_user = wp_get_current_user(); //get user ?> <a href=”https://direktoriku.com/shopping/?user=<?php echo $current_user->user_login;?> <button>Click me</button> </a> <?php endif;?>

How to change page URLs to “www.site.com/page” instead of “example.com/blog/page” but keep post URLs as “example.com/blog/post”?

You just set the WordPress directory in your WP General Settings to your top-level URL (www.site.com/), then copy index.php to the root directory of your site and modify it to load content from your actual wp directory. Step by step instructions are here: http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory I did this for my personal web site: http://dannythorpe.com. The WP … Read more

remove post-name from title in custom post type

Fixing the 404 error So it’s because of the ([^&]+) in your add_rewrite_tag() calls: $wp_rewrite->add_rewrite_tag(‘%reference%’, ‘([^&]+)’, ‘reference=”); //$wp_rewrite->add_rewrite_tag(“%location%’, ‘([^&]+)’, ‘location=’); To fix the error, you should use ([^/]+) and not ([^&]+). I also intentionally commented out the second line because if the taxonomy’s slug is location, then WordPress should have already added the %location% rewrite … Read more

Change homepage url

i think this can help you: use the below code in your theme’s functions.php function redirect_homepage() { if( ! is_home() && ! is_front_page() ) return; wp_redirect( ‘http://siteurl.com/news’, 301 ); exit; } add_action( ‘template_redirect’, ‘redirect_homepage’ );

Tricky URL rewrite with custom values in url

As I mentioned in your other question, you don’t want to be touching the .htaccess file, you need an internal rewrite. So, given the URL: http://mysite.com/image/wp_username/3digitnumber we need to add the following rule to handle it: // set up the rewrite rule function wpa73374_setup_rewrites(){ add_rewrite_rule( ‘image/([^/]+)/([0-9]+)/?$’, ‘index.php?pagename=custompage&iuser=$matches[1]&iname=$matches[2]’, ‘top’ ); } add_action( ‘init’, ‘wpa73374_setup_rewrites’ ); Note … Read more

Custom rewrite rules for feeds of custom queries (query_var query strings in URL)?

You can use add_rewrite_rule hooked to the init action, instead of using the generate_rewrite_rules filter (where it gets a bit low-level). But the actual problem with your rewrite rules is the regex in place. Here’s what it’d look like: function wtnerd_edition_specific_categories() { add_rewrite_rule( ‘(.+?)/channel/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$’, ‘index.php?category_name=$matches[1]&channel=$matches[2]&feed=$matches[3]’, ‘top’ ); add_rewrite_rule( ‘(.+?)/channel/(.+?)/(feed|rdf|rss|rss2|atom)/?$’, ‘index.php?category_name=$matches[1]&channel=$matches[2]&feed=$matches[3]’, ‘top’ ); add_rewrite_rule( ‘(.+?)/channel/(.+?)/page/?([0-9]{1,})/?$’, ‘index.php?category_name=$matches[1]&channel=$matches[2]&paged=$matches[3]’, … Read more

Stop unwanted WP redirection to new url

WordPress uses a function called wp_old_slug_redirect() to find out if you’re looking for a post whose slug was recently changed and redirect you to its new home. If you want to prevent this behaviour for this specific post, delete the _wp_old_slug post meta entry from the database for that post. If you want to prevent … Read more