WordPress Custom URL Rewrites

I do something similar with custom records called shops and their specific ID number. In my case I want http://example.com/shops/UNIDrecordthatsreallylong to load with the variable shop_unid being the UNID record. Here’s my working function: //Shop page rewrites function shop_rewrite() { add_rewrite_rule(‘^shops/([^/]*)/?’,’index.php?pagename=shops&shop_unid=$matches[1]’,’top’); add_rewrite_tag(‘%shop_unid%’,'([^&]+)’); } add_action(‘init’, ‘shop_rewrite’); Note that I used pagename instead of the post number. … Read more

Rewrite url for custom post type

this will not work: ‘en/index.php?post_type=vinos’ there is no en/index.php, it has to be: ‘index.php?post_type=vinos’ if you need to detect en in the path, add a query var, then set that query var in your rewrite: function wpa_query_vars( $qvars ) { $qvars[] = ‘wpa_lang’; return $qvars; } add_filter( ‘query_vars’, ‘wpa_query_vars’ ); then in your rewrite rule: … Read more

URL Rewrite + Page + Custom Post Type = Unusual Redirect

You should try setting ‘slug’ ( in the ‘rewrite’ parameter/option) to ‘our-firm/shareholders’, just like the structure you have set in the add_rewrite_rule() function. The first parameter of add_rewrite_rule() and the ‘rewrite’ setting of the custom post type must be equal in order to get the rewritting actually working. So, in case you choose coding the … Read more

Disable wordpress pagination URL rewrite for specific page

The redirect_canonical filter is responsible for this, which you can selectively disable depending on the requested page. This is untested, but should work: function wpa66273_disable_canonical_redirect( $query ) { if( ‘design-jobs’ == $query->query_vars[‘pagename’] ) remove_filter( ‘template_redirect’, ‘redirect_canonical’ ); } add_action( ‘parse_query’, ‘wpa66273_disable_canonical_redirect’ );

add_rewrite_rule, plugin activation and plugin deactivation

The problem with calling flush_rewrite_rules() is that the rules instantly get regenerated, while your plugin’s hooks are still active. What I usually do, because it’s the simplest route to success, is delete the rewrite_rules option on activation/deactivation. The rules will then get regenerated on the next pageload instead of the current one: register_deactivation_hook( __FILE__, ‘my_plugin_deactivation’); … Read more

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