Inject dynamic strings in urls

You have not stated if COUNTRY and CITY are categories, tags or something else. This information would help in giving you a complete answer. This is just an example of how it can be done. //Add a location variable to the post type’s rewrite rule function my_post_type_args( $args, $post_type ) { if ( ‘my_post_type’ == … Read more

Get userdata from url

WordPress already has a url structure for Author information. If you have pretty Permalinks enabled, the URL should read like http://www.website.com/author/username . You can make a new template file named author.php in your theme to manipulate what is shown on this page (add meta information and whatnot). You can get the author id in the … Read more

rebuilding/ rewriting a url to make it SEO friendly

You can create a rewrite rule using add_rewrite_rule() that will match a given path to query parameters: function wpse_283774_rewrite() { add_rewrite_rule( ‘^events/([^/]+)/?’, ‘index.php?pagename=events&country=$matches[1]’, ‘top’ ); } add_action( ‘init’, ‘wpse_283774_rewrite’ ); This rule will match whatever is after /events as the country query parameter. Setting the third argument to top means that it will match our … Read more

Need to Echo A Url path to show on a wordpress page

You can find that with somthing like the following add_shortcode( ‘url_path_number’, function ( $atts ) { // use an attribute or the current URL $a = shortcode_atts( array( ‘url’ => get_permalink(), ), $atts ); // get the path from the URL $path = parse_url($a[‘url’],PHP_URL_PATH); $parts = array_filter(explode(“https://wordpress.stackexchange.com/”, $path),function($v) { return $v !== ”; }); // … Read more