Hi,
im new in using WordPress, but i want to code a plugin that allows to use the Monthname in the permalinks as wild-card %monthname% to.
The following code works, but if i dump the $rewrite object after calling the add_rewrite_tag method the %monthname% tag isnt replaced with the regex.
class monthname {
/* get_monthnames([$seperator])
* this function return all monthnames out of the local.php
* in a line seperted with the $seperator
*/
function get_monthnames($seperator='|') {
global $month;
$monthnames = '';
foreach($month as $name) {
// add seperator before the current monthname if this is NOT the first name
if(!empty($monthnames)) {
$monthnames .= $seperator;
}
$monthnames .= $name;
}
return $monthnames;
}
function replace_monthname($rewrite) {
$rewrite->add_rewrite_tag('%monthname%', '('.monthname::get_monthnames('|').')', 'monthname=');
var_dump($rewrite);
}
}
add_action('generate_rewrite_rules', array('monthname', 'replace_monthname'));
Any ideas?
For bettwer view:
http://rafb.net/paste/results/tdMfhx43.html
Example dump:
["([0-9]{4})/%monthname%/?$"]=>
string(49) "index.php?year=$matches[1]&%monthname%$matches[2]"