Best way to flush_rewrite_rules for custom post type, in a mu-plugins plugin?

The flush_rewrite_rules function is reliable in some contexts like a theme or a plugin based on hooks but I’m not sure if it works for a mu-plugin My statement is based on the fact that WordPress is initialized in this way: call the wp-settings.php file call the do_action( ‘muplugins_loaded’ ); hook, here your plugin is … Read more

Custom Post Type Permalink / Rewrite not working immediately

Use the function flush_rewrite_rules() for set the rewrite rules new, but not with your code on init-hook, only on activation plugin or theme! See more in my post: http://wpengineer.com/2044/custom-post-type-and-permalink/ global $wp_rewrite; $wp_rewrite->flush_rules(); Flush rules only on activation (and deactivation). Don’t do it on any other hook. register_activation_hook()

Rewrite Rule for Multilingual Website, Like qTranslate?

I got it now , After searched many resources : function lang_support() { return array(‘en’,’fr’); // Add your support lang-code (1st place is a default) } function rewrite_lang(){ $langs = lang_support(); foreach($langs as $lang) { add_rewrite_endpoint($lang,EP_PERMALINK|EP_PAGES|EP_ROOT|EP_CATEGORIES); } } add_action(‘init’,’rewrite_lang’); function lang(){ global $wp_query; $langs = lang_support(); $lang_r = “”; foreach($langs as $lang) { if(isset($wp_query->query_vars[$lang])) { … Read more

web.config conflict on IIS

I don’t have the reputation to comment so I’m sure this may be dumped if not totally complete/accurate; but, doesn’t WP work in a way that it goes through the core’s index.php file using rewrites and such. This being the case, if you don’t specify a specific file that you are accessing, you aren’t really … Read more

Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?

The best place to flush rewrite rules is on plugin activation/deactivation. function myplugin_activate() { // register taxonomies/post types here flush_rewrite_rules(); } register_activation_hook( __FILE__, ‘myplugin_activate’ ); function myplugin_deactivate() { flush_rewrite_rules(); } register_deactivation_hook( __FILE__, ‘myplugin_deactivate’ ); See the codex article Apologies in advance, I didn’t make it all the way through your question, so this is a … Read more

Understanding add_rewrite_rule

A basic rule that would work for your example: function wpd_foo_rewrite_rule() { add_rewrite_rule( ‘^foo/([^/]*)/?’, ‘index.php?pagename=$matches[1]&param=foo’, ‘top’ ); } add_action( ‘init’, ‘wpd_foo_rewrite_rule’ ); This takes whatever comes after foo/ and sets that as pagename for the query, and then param gets the static value foo. If you need different URL patterns, you’ll need extra rules for … Read more

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