Need to add rewrite rule that adds in additional information about the post to url

Sorry I took so long to write this up. Hope it’s still useful. This is based off of a tutorial found here and some general playing around. <?php //This function sets up the permastructure add_action(‘init’, ‘setup_permastruct’, 40); function setup_permastruct() { //Setup query vars add_rewrite_tag(‘%state%’,'([^/]+)’); add_rewrite_tag(‘%suburb%’,'([^/]+)’); //Permastruct for custom post type add_permastruct(‘venue’, ‘venue/%state%/%suburb%/%postname%’, false); } //This … Read more

.htaccess rewrite

It looks like you need to process the rewrite using query strings rather than a URI segment and pass your query through index.php. WordPress seems to be agnostic of what you’re trying to accomplish here. Try the following rule and visit your Settings->Permalinks page to flush previous rules and add this to the stack. add_rewrite_rule( … Read more

Monkey Man Rewrite Analyzer says my rule will trigger but it doesn’t [closed]

Honestly, can not debug your code, but this one works: function register_crr_jsonwebservice( $wp_rewrite ) { //Add the rewrite rule for this specific json controller add_rewrite_tag( ‘%ticket%’, ‘([a-zA-Z0-9]+)’); $wp_rewrite->rules = array( ‘cjson/fullticket/?([a-zA-Z0-9]{1,})/?$’ => $wp_rewrite->index . “?page_id=243&ticket=”.$matches[1] ) + $wp_rewrite->rules; } add_action( ‘generate_rewrite_rules’, ‘register_crr_jsonwebservice’ ); Do not call flush_rewrite_rules(); from this function – will lead to an … Read more

WordPress Rewrites – How can I pass a variable to Custom Post Type?

You can use add_rewrite_endpoint, which will add a query var and generate the necessary rewrite rules: function wpd_cid_endpoint() { add_rewrite_endpoint( ‘cid’, EP_PERMALINK ); } add_action( ‘init’, ‘wpd_cid_endpoint’ ); Don’t forget to flush rewrite rules after changing rules. You can do this quickly by visiting the Settings > Permalinks page in admin.

Display posts from Custom Post Type in category page on front-end

You are better off separating categories for posts and using custom taxonomy types for CPT categories. You’d add this line to your register cpt code ‘taxonomies’ => array( ‘bizdirectory-type’ ), Replacing this line in your code. ‘taxonomies’ => array( ‘category’ ), And then add this code in your functions.php add_action( ‘init’, ‘wpsites_custom_taxonomy_types’ ); function wpsites_custom_taxonomy_types() … Read more

WP is ignoring .htaccess rewritten URL

RewriteCond %{HTTP_HOST} dom1 [NC] RewriteRule ^((about\-us|etc).*) /dom1/$1 [NC,QSA,L] Your rewrite rule includes the L parameter, which makes it stop processing rewrites. So WordPress’s rules to redirect to index.php likely never come into effect. Which means WordPress is not even being run here. The 404 is likely from the webserver saying that the file at /dom1/about-us … Read more

Using WP Rewrite, but just not “getting it”

Your rewrite setting is good, but WordPress are redirect to the canonical url of the post. This is done by WodPress to prevent bad indexing for duplicate content (when an identical content is accessible via 2 different urls). You can prevent that removing the canonical redirect filter: add_action(‘wp_loaded’, function() { remove_filter(‘template_redirect’, ‘redirect_canonical’); }); However this … Read more

Is a permastruct possible on pages?

Yes this is possible using the $wp->add_query_var function used together with add_rewrite_rule . Here you have an example: Passing and retrieving query vars in wordpress If you want more help here is a cut from one of my old plugins: function createRewriteRules() { global $wp_rewrite; $new_rules = array( ‘(.?.+?)/(stenskott)$’ => ‘index.php?pagename=”.$wp_rewrite->preg_index(2).”&ort=”. $wp_rewrite->preg_index(1), “(.?.+?)/(bilclas)$’ => ‘index.php?pagename=”.$wp_rewrite->preg_index(2).”&ort=”. … Read more

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