TimThumb & htaccess : clean url

Cadeyrn’s code work probably for 1 specific size ( 200&w=350& etc) , the major problem with timthumb and the reason people use it, is that it allows for many dynamic sizes thus making .htaccess rewrite rules much more difficult, especially if you using friendly WordPress permalink structure. There is a guide here on how to … Read more

Custom URL rewrites work, but break my permalinks

Well I solved it – in a rather unsatisfactory way – by explicitly re-defining the default posts rule in my own code. i.e. $rewrite_keywords_structure = $wp_rewrite->root.”/%year%/%monthnum%/%postname%/”; ..etc.. I don’t really understand why this is necessary, but there you go.

How To Consistently Enforce Rewrite Rule in Plugin Development

Here’s a solution. See comments at the end… // I am a functions.php file of a plugin called “sample” — implement me slightly differently for a theme. // Note this code requires WP 3.0 or greater. class SAMPLE { public static function activatePlugin() { self::rewriteURL(); flush_rewrite_rules(); if (get_option(‘permalink_structure’) == ”) { self::updatePermalinks(); } // add … Read more

Optimal code for two add_rewrite_rule’s

This is the working code: add_action(‘init’, ‘rewrite_init’); // Rewrite add_action(‘query_vars’, ‘rewrite_query_vars’); add_filter(‘template_include’, ‘rewrite_template_include’); function rewrite_init(){ add_rewrite_rule(‘([^/]+)/([0-9]+)/?$’, ‘index.php?catname=$matches[1]&currentpage=$matches[2]’, ‘top’); add_rewrite_rule(‘cam/([^/]+)/?$’, ‘index.php?name=cam&perf=$matches[1]’, ‘top’); } function rewrite_query_vars($query_vars){ $query_vars[] = ‘currentpage’; $query_vars[] = ‘catname’; $query_vars[] = ‘perf’; return $query_vars; } function rewrite_template_include($template){ if(get_query_var(‘currentpage’) || get_query_var(‘catname’)){ $template = locate_template(array(‘category.php’)); } elseif(get_query_var(‘perf’)){ $template = locate_template(array(‘single.php’)); } return $template; }

Rewrite rule for a query string

Try this code: function geotags_add_rewrite_rules($wp_rewrite_rules) { global $wp_rewrite; $rule_key = ‘%cityid%’; $url_pattern = ‘([^/]+)’; $query_string = ‘cityid=’; $wp_rewrite->add_rewrite_tag($rule_key, $url_pattern, $query_string); $url_structure = $wp_rewrite->root . “cityid/$rule_key/”; $rewrite_rules = $wp_rewrite->generate_rewrite_rules($url_structure); $wp_rewrite_rules = $rewrite_rules + $wp_rewrite_rules; return $wp_rewrite_rules; } add_filter(‘rewrite_rules_array’, ‘geotags_add_rewrite_rules’); function geotags_add_query_var($query_vars) { array_push($query_vars, ‘cityid’); return $query_vars; } add_filter(‘query_vars’,’geotags_add_query_var’); NOTE: Remember to save permalinks so your new … Read more

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