Rewrite function

Go to Settings->Permalinks Add this to Custom Structure: /%postname%/ Update WordPress generates .htaccess-files for this. Just go to your root and activate the show invisable files on your computer. Here is the htaccess for the structure: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d … Read more

How to Add Rewrite Ruled Argument Into Permalink Properly

I’m affraid this “nasty” solution would be the most effective than trying to write some cool function that will translate your permalinks into pretty permalinks: $permalink = rtrim( get_permalink( $id ), “https://wordpress.stackexchange.com/” ) . ‘/foo’ . ‘/2’; The rtrim part (removing trailing slash) is just for to be sure there are not going to be … Read more

Append custom parameter to taxonomy/term URI

You can try this: function my_car_rewrite_rules( $rules ) { $newrules = array(); // add a rule for this kind of url: // http://myhost.com/cars/ferrari/used/123 // => http://myhost.com/index.php?post_type=cars&ferrari=used&p=123 $newrules[‘^cars/([^/]+)/([^/]+)/([^/]+)$’] = ‘index.php?post_type=cars&$matches[1]=$matches[2]&p=$matches[3]’; return $newrules + $rules; } add_filter(‘rewrite_rules_array’,’my_car_rewrite_rules’); and remember to “save the permalinks” when testing. I added /cars/ so this rewrite will not overwrite your other pages. … Read more

Rewrite URL variable to custom path

You could add the path via add_rewrite_endpoint, then alter the query via the pre_get_posts action. Here’s a proof-of-concept example that alters the posts_per_page when domain.com/highest-rated/ is requested: // add the endpoint function wpa85664_add_endpoint(){ add_rewrite_endpoint( ‘highest-rated’, EP_ALL ); } add_action( ‘init’, ‘wpa85664_add_endpoint’ ); // check if the endpoint is in the current request // and alter … Read more

Rewrite rule help for gallery plugin

I finally got my rewrite rules to work here: $home = get_post(Sunshine::$options[‘page’]); // Gallery add_rewrite_rule($home->post_name.”/gallery/([^/]+)/page/?([0-9]{1,})/?$”,’index.php?pagename=”.$home->post_name.”&sunshine_gallery=$matches[1]&paged=$matches[2]’,’top’); add_rewrite_rule($home->post_name.”/gallery/([^/]+)/?$”,’index.php?p=’.$home->post_name.’&sunshine_gallery=$matches[1]’,’top’); add_rewrite_rule($home->post_name.”/gallery/([^/]+)/?$”,’index.php?pagename=”.$home->post_name.”&sunshine_gallery=$matches[1]’,’top’); // Image add_rewrite_rule($home->post_name.”/image/([^/]+)/?$”,’index.php?pagename=”.$home->post_name.”&sunshine_image=$matches[1]’,’top’);

URL rewrite breaking pagination

This works: mysite.com/sermon/term/childterm/page2/ This does not: mysite.com/sermon/term/childterm/page2/ according to your rewrite rule, I guess what you mean is This works: mysite.com/sermon/term/page2/ This does not: mysite.com/sermon/term/childterm/page2/ I’m not a regex expert so I only come up with adding another rewrite rule to handle the childterm situaion add_rewrite_rule( ‘sermon/(.*?)/(.*?)/page/?([0-9]{1,})/?$’, ‘index.php?post_type=”.$cpt.”&’.$tax.’=$matches[2]&paged=$matches[3]’, ‘top’ );

Custom rewrites for pages and categories

If you want to have domain.tld/PAGE-NAME.php then you could just use %postname%.php as custom structure. // Edit As this approach seems to work for posts only, you might have a try with the structure /%postname%/. In addition, you put the following lines to your .htaccess: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*).php /$1/ [R=301,L] </IfModule> // … Read more

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