Custom user profile URLs

Create an endpoint for EP_ROOT named profile. In your callback handler use get_user_by( ‘slug’, get_query_var( ‘profile’ ) ) to find the user data. Create a template file profile.php and use locate_template( ‘profile.php’, TRUE ) to load it. In your template show the user data.

URL Rewrite doesn’t work for nested pages

I have found my answer while searching. Thanks to this answer of @Milo: https://wordpress.stackexchange.com/a/50775/23214 pagename must include the full parent/child path. So, I had to change index.php?pagename=page-b… to index.php?pagename=page-a/page-b…. Changed it and works ok. Here is the Full code: add_filter( ‘query_vars’, ‘wpse26388_query_vars’ ); function wpse26388_query_vars( $query_vars ){ $query_vars[] = ‘var1’; $query_vars[] = ‘var2’; $query_vars[] = … Read more

expecting 404 but redirecting to post with url subdirectory in post title

The magic you’re referring to happens in redirect_canonical(). And more specifically, redirect_guess_404_permalink(). You can cut in ahead of redirect_canonical by hooking onto the template_redirect action with a slightly higher priority – in this case, anything lower than 10. function wpse_145210_redirect_canonical() { if ( is_404() && $name = get_query_var( ‘name’ ) ) { // The following … Read more

Load a template page based on part of slug in wordpress

You can filter template_include, check the request URL for your search words and return a custom template. Here is a primitive example: add_filter( ‘template_include’, function( $template ) { $template_map = [ ‘advice-on’ => ‘advice’, ‘links-‘ => ‘link-collection’, ]; foreach ( $template_map as $find => $match ) { if ( 0 === strpos( $_SERVER[ ‘REQUEST_URI’ ], … Read more

Is it possible to remove feeds from rewrites?

Why are you removing rewrite rules? These should not noticeably impact performance, unless there were thousands of entries. Yes, you can remove them, but you will break any functionality associated with those urls, and you won’t improve your site’s speed at all. If you’re concerned about site speed, check out YSlow and Google Page Speed … Read more

append url parameters to all links

1. Track Affiliate via Cookie To track the affiliate source you can use a Cookie for internal tracking. In that case you only need to modify external links. add_action( ‘plugins_loaded’, ‘so265278_affiliate_check’ ); function so265278_affiliate_check() { $is_affiliate = ! empty( $_GET[‘ref’] ); if ( $is_affiliate ) { setcookie( ‘affiliate’, $_GET[‘ref’], MONTH_IN_SECONDS ); } } Now you … Read more

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