I need the code for the .htaccess
https://www.ads-software.com/plugins/w3-total-cache/
]]>I have added some custom quer vars and those work fine so far:
function add_custom_query_vars($vars) {
$vars[] = "tdhm";
$vars[] = "tdht";
return $vars;
}
add_filter('query_vars', 'add_custom_query_vars');
Then I added a custom rewrite rule
function add_rewrite_rules($aRules) {
$aNewRules = array('tdh2015/danke/([^/]+)/([^/]+)/?$' => 'index.php?pagename=danke&tdhm=$matches[1]&tdht=$matches[2]');
$aRules = $aNewRules + $aRules;
return $aRules;
}
add_filter('rewrite_rules_array', 'add_rewrite_rules');
And made sure, it was activated
$wp_rewrite->flush_rules( );
I then tested this rewrite rule with the monkeyman-rewrite-analyzer tool within wordpress and all looks fine so far. But when I try to access the variables within my custom page template, they never seem get populated.
actually the routing
“tdh2015/danke/myfirstparam/mysecondparam”
should translate to:
page: tdh2015/danke/
with the local variables
tdhm: myfirstparam
tdht: mysecondparam
available. I tried to access the variables via
if(isset($wp_query->query_vars['tdhm'])) {
$tdhm = urldecode($wp_query->query_vars['tdhm']);
}
if(isset($wp_query->query_vars['tdht'])) {
$tdht = urldecode($wp_query->query_vars['tdht']);
}
Has anyone here worked successfully with a similar setup?
Thanks in advance! Cheers, Matt
]]>function create_new_custom_post_type() {
register_post_type( ‘POST_TYPE’,
array(
‘labels’ => array(
‘name’ => __( ‘listing’ ),
‘singular_name’ => __( ‘listing’ )
),
‘public’ => true,
‘has_archive’ => true,
‘rewrite’ => FALSE,
)
);
}
add_action( ‘init’, ‘create_new_custom_post_type’ );
i have some costume field for this post type like location, property type. i just want to add this costume field in the url structure. i just want to create url like this :
https://www.mydomain.com/location/property_type/propertyid
How can i rewrite the url like that. ? location and property_type is varying according to the post.
]]>I need a structure as follows:
https://example.com/courses/nc/charlotte
Where /nc/ (or whatever is inputted/sent) would be accessible as a state variable later on, and the same for /charlotte/ as a city.
My code so far is as follows:
https://pastebin.com/PNHudKg5
Currently, the echo ‘<h2>’.$course->post_title.'</h2>’; works as it is outputted before the rest of WP loads. However, if I move the code from the query parse function to a shortcode, the query params /nc/charlotte disappear off of the url and are inaccessible by my shortcode.
Am I missing some function that will keep the query parameters so I can use them on page? It seems like when the page loads, it strips the url, but before the page loads, they are still accessible.
Or maybe I’m doing it wrong altogether? I’ve found so many different ways of using WP’s rewrite rules that my head is spinning. WP provides documentation on the functions, but not how to hook them all together to build something with them.
Also, I’m using Jan Fabry’s Rewrite Analyzer plugin. When I type in https://example.com/courses/nc/charlotte, I get the correct match in the window below. So I know I’ve got something right.
]]>Things have veen working extremely well until I updated worpdress to 3.1. It seems that all of the custom rewrites for categories do not work now. We have a few filters for some pages and those still work.
Here is a sample code of what I’m using:
$newrules[‘(‘.$category_nicename.’)/(‘.$filter_name.’)-(‘.$filter_id.’)/?$’] = ‘index.php?category_name=$matches[1]&ss_filter=$matches[2]&filter_id=$matches[3]’;
So up until 3.1, everything worked. I am flushing the rules and adding the new variables to the query_var filter as well. See below
add_filter(‘rewrite_rules_array’,’ss_rewrite_rules_array’); Where I’m adding the new rules
add_filter(‘query_vars’,’ss_query_vars’); Adding the new vars (ss_filter and filter_id)
add_filter(‘admin_init’,’ss_flushRules’); Flushing rules when going to admin area.
I’ve searched around and seems a few more people are having the same issue.
Anyone with advise is greatly appreciated.
]]>