Add_query_arg + two times the same argument?

Nilambar’s comment solved this for me. “You can pass two values as comma separated in a single parameter events. And later parse value correctly in your page. – Nilambar” I use this to get posts with tag1 OR tag2: echo ‘<a href=”‘.esc_attr(add_query_arg( ‘events’, ‘tag1,tag2′)).'”>Linkname</a>’; And to get all posts with tag1 AND tag2 simply use … Read more

Create subpage /user/ or /my-profile/ like /author/ with additional query like /user/user123

If I understand you well, you can do that with add_rewrite_rule(); function to map the url to specific query variables. https://codex.wordpress.org/Rewrite_API/add_rewrite_rule function myfunc_rewrite_rules() { add_rewrite_rule(‘user/?([^/]*)’, ‘index.php?pagename=user&username=$matches[1]’, ‘top’); } function myfunc_username_query_vars($vars) { $vars[] = ‘username’; return $vars; } add_action(‘init’, ‘myfunc_rewrite_rules’); //add query vars (username) to wordpress add_filter(‘query_vars’, ‘myfunc_username_query_vars’); function myfunc_display() { $userpage = get_query_var(‘pagename’); $username = … Read more

Change website URL without breaking links or images? WP 3.3

There is a helpful codex article about moving WordPress: http://codex.wordpress.org/Moving_WordPress. Basically, you need to find/replace the DB for instances of your old domain, and swap them with your new domain. One additional trick I’ve learned when moving WordPress between environments: since WordPress stores the domain in several places as serialized data in the DB, you … Read more

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’ );

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