Retrieve query var within functions.php
function gqv() { echo get_query_var(‘user_login’); } add_action(‘parse_query’, ‘gqv’);
function gqv() { echo get_query_var(‘user_login’); } add_action(‘parse_query’, ‘gqv’);
Do not use the terms name and id. Because they are used by WP itself hence leading to a conflict. Use something specific like ch_id and ch_name, and you’ll have them in the $_GET array. Try it, I’m sure it will work!
Okay I figured it out. Instead of using this rewrite rule: add_rewrite_rule(‘^somepage/([^/]*)/([^/]*)/([^/]*)/?’,’index.php?p=27&target=$matches[1]&arrival=$matches[2]&departure=$matches[3]’,’top’); I now use this one: add_rewrite_rule(‘^somepage/([^/]*)/([^/]*)/([^/]*)/?’,’index.php?pagename=somepage&target=$matches[1]&arrival=$matches[2]&departure=$matches[3]’,’top’); And now everything works like I wanted it to. Obviously using the page id instead of the page name was the problem.
WordPress has two kinds of rewrite rules- internal and external. Internal rules are parsed by WordPress and routed to index.php. External rewrites get written to .htaccess and are not directed to WordPress. Right now your rule is a mix between internal and external- you have it structured as an internal rule, but you have it … Read more
You can use the Redirection plugin. This plugin supports full regular expressions and another interesting redirection functions.
Change custom-post-type in the following to the name of your CPT, both the slug and post_type= in the query vars. Visit your Permalinks Settings page to flush rewrite rules. You could also put this in a plugin and flush rules on plugin activation. function wpa83047_author_rewrite_rule(){ add_rewrite_rule( ‘^custom-post-type/author/([^/]+)/?$’, ‘index.php?author_name=$matches[1]&post_type=custom-post-type’, ‘top’ ); } add_action( ‘init’, ‘wpa83047_author_rewrite_rule’ );
At first, you shouldn’t use .htaccess directly when working with WordPress. WordPress has powerful rewrite API allowing you to do the stuff from plugins or theme’s functions.php If you need the id=floos on more than one page, consider using rewrite endpoints: function makeplugins_add_json_endpoint() { add_rewrite_endpoint( ‘floos’, EP_PAGES ); } add_action( ‘init’, ‘makeplugins_add_json_endpoint’ ); To determinate, … Read more
Copy the index.php and .htaccess file(Just copy it , do not move it ) from myblog directory to root directory. Open index.php file in any text editor and find the following code in the file. /** Loads the WordPress Environment and Template */ require(‘./wp-blog-header.php’); Replace it with the following code and save the file. /** … Read more
This should cover everything: function wpa_rewite_translate(){ global $wp_rewrite; $wp_rewrite->pagination_base=”pagina”; $wp_rewrite->author_base=”autor”; $wp_rewrite->comments_base=”comentarios”; $wp_rewrite->feed_base=”alimentar”; $wp_rewrite->search_base=”busqueda”; $wp_rewrite->set_category_base( ‘categoria/’ ); $wp_rewrite->set_tag_base( ‘etiqueta/’ ); } add_action( ‘init’, ‘wpa_rewite_translate’ ); Feel free to laugh at my translations, haha. Also, to flush rewrite rules when your theme is activated, add this: function wpa_flush_rewite(){ flush_rewrite_rules(); } add_action( ‘after_switch_theme’, ‘wpa_flush_rewite’ );
Any rewrite rules that appear before WordPress’s own rules will get parsed first. You just need an L flag for your custom rules to stop processing if a request matches. Then add the comments # BEGIN WordPress and # END WordPress where you want WordPress to add it’s rules, after your own, and WordPress won’t … Read more