是否有可能追加#到添加散列到WordPress wp_listcategories
wp_list_categories('include=13&title_li=&style=none&echo=0')?
在最后一个环节类别链接需要看起来像:domain/categories/somepost#
是否有可能追加#到添加散列到WordPress wp_listcategories
wp_list_categories('include=13&title_li=&style=none&echo=0')?
在最后一个环节类别链接需要看起来像:domain/categories/somepost#
添加过滤器用于wp_list_categories的输出可以在做到这一点PHP。 您需要使用preg_replace和正则表达式来查找网址。 例如:
add_filter('wp_list_categories', 'filter_categories', 10, 2);
你的“filter_categories”功能添加到过滤器 - 不要把它过滤类别,称之为独特的像sjn_filter_categories东西。
function filter_categories($output, $args=array()){
return preg_replace('/(\<a\shref=\"?[^\>]+?)\"/', '$1#"', $output);
}
将采取输出,搜索href网址,删除'''并添加'#'和'''回来。 我希望这有助于!
看起来很复杂:-( 我很乐意帮助我 – user642523 2011-06-08 18:39:43
好的,我已经改变了它:) – Sean 2011-06-09 10:21:13
您可以复制WP的函数(wp-includes/category-template.php,第417行)并添加散列,或者在DOMReady上使用附加的JS。 – 2011-06-08 11:25:29
@konzepz不知道在哪里复制WP功能? – user642523 2011-06-08 17:24:36