Using rewrite rule to access a view of a plugin from home page

This will create / handle your endpoint and attempt to load your php if the file is readable. Note: you won’t want to refresh the rewrite rules here but it’ll make sure you can test quickly. if (!class_exists(‘WPTestPluginEndpoint’)): class WPTestPluginEndpoint { const ENDPOINT_QUERY_NAME = ‘__my_test_plugin’; // WordPress hooks public function init() { add_filter(‘query_vars’, array($this, ‘add_query_vars’), … Read more

WordPress keeps writing rewrite rules to .htaccess

I am not sure why this happens, but you can stop all write access to your .htaccess with a simple filter: add_filter( ‘flush_rewrite_rules_hard’, ‘__return_false’ ); Neither WordPress nor any plugins calling flush_rewrite_rules() will write something into the file now. Other methods to access and change the file will still work, for example insert_with_markers().

flexible rewrite ‘ramble’ URLs with WordPress

You shouldn’t use the htaccess instead you should use the WordPress APIs e.g. function custom_rewrite( $wp_rewrite ) { $feed_rules = array( ‘archives/(\d+)(?:/.*)+’ => ‘index.php?p=’. $wp_rewrite->preg_index(1) ); // ( array merge must be done this way, to ensure new rule comes first ) $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; } // refresh/flush permalinks in the dashboard if … Read more

Rewrite Rule for Custom Page with Query Vars in URL

I manually deleted the .htaccess file and regenerated, which along with the code below, made the rewrite work. The second rewrite rule in the code below makes the pagination work properly. The .htaccess file doesn’t seem to be getting written with any rules though, but the rewrite is working now anyhow. function listen_rewrite_action() { add_rewrite_tag(‘%show%’,'([^/]*)’); … Read more

Custom Rewrite with Query vars

Add a rewrite endpoint instead of a rewrite rule and query var. This API function will do both of these things for you. function wpd_add_my_endpoint(){ add_rewrite_endpoint( ‘information’, EP_PAGES ); } add_action( ‘init’, ‘wpd_add_my_endpoint’ ); Now any page can have information appended to the end, and the value will be available via get_query_var(‘information’).

Rewrite custom post type url’s adding meta box values

It sounds like you’re very close here and your only remaining issue is that your permalinks for genres and movies collide. ‘movies’ CPT permalink /genres/%custom field meta box value%/%movie%/ ‘genres’ CPT permalink /genres/%genre%/ The issue here is using the add_permastruct. When it creates the rules for movies, they look something like this: genres/([^/]+)/([^/]+)(/[0-9]+)?/?$ => index.php?genre=$matches[1]&movies=$matches[2]&page=$matches[3] … Read more

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