add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico

But I want change url to https://cdn.domain.com/favicon.ico, How setting this url with rewrite rules in PHP. You can’t. That’s not how WordPress rewrite rules work. add_rewrite_rule is used for mapping pretty permalinks into the form /index.php?queryvar=value&etcetc. Most servers don’t even load WordPress to handle requests like that for assets and skip PHP/WordPress completely for performance … Read more

Dynamic WordPress rewrite rules for multiple custom post types

Jacob’s comment got me on the right track. Here’s what worked for my issue: add_action(‘init’, ‘cpt_rewrite’); function cpt_rewrite(){ $args = array( ‘public’ => true, ‘_builtin’ => false, ); $post_types = get_post_types( $args ); if ( $post_types ) { foreach ( $post_types as $post_type ) { add_rewrite_rule(‘^’.$post_type.’/([0-9]{4})/([0-9]{2})/?’,’index.php?post_type=”.$post_type.”&year=$matches[1]&monthnum=$matches[2]’,’top’); add_rewrite_rule(‘^’.$post_type.’/([0-9]{4})/?’,’index.php?post_type=”.$post_type.”&year=$matches[1]’,’top’); } } } I used get_post_types() to get … Read more

wordpress category rewrite rule with pagination

I was able to solve it doing these rewrites in the following order. So I specified 3 category url in the beginning then 2 category url below that and in the and single category url /combine/brand/category1/category2/page/1-9/ add_rewrite_rule( ‘^combine/([^/]*)/([^/]*)/([^/]*)/page/([0-9]*)$/’,’index.php?category_name=$matches[1]+$matches[2]+$matches[3]&paged=$matches[4]’, ‘top’ ); /combine/brand/category1/page/1-9 add_rewrite_rule( ‘^combine/([^/]*)/([^/]*)/page/([0-9]*)$’,’index.php?category_name=$matches[1]+$matches[2]&paged=$matches[3]’, ‘top’ ); /combine/brand/category1/ add_rewrite_rule( ‘^combine/([^/]*)/?([^/]*)/([^/]*)/?’,’index.php?category_name=$matches[1]+$matches[2]+$matches[3]’, ‘top’ );

WordPress picks a wrong template if ?cat= is used as URL parameter

Why? This is because the pretty permalink: /tag/online-lectures/?cat=7 gets translated to the ugly permalink: index.php?tag=online-lectures&cat=7 And as you can see the /tag/online-lectures part no longer has the emphasis it once had. Afterall /category/arrester?tag=online-lectures would boil down to exactly the same ugly URL. Since the resulting query is an archive, and the most specific template available … Read more

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