Jump to content

Wordpress list categories preg replace


Djoris

Recommended Posts

I use the following code to output individual categories in the wordpress navigation:

 

<?php echo preg_replace('@\<li([^>]*)>\<a([^>]*)>(.*?)\<\/a>@i', '<li$1><a$2>$3</a>',wp_list_categories('echo=1&orderby=id&title_li&include=1897')); ?>

 

This works great and gives the output:

 

<li class="cat-item cat-item-1897"><a href="http:www.test.org/category/category-name/">category</a></li>

 

For some categories I would like to add ?gpc_sortby=views to the end of the url. Does anybody know how I can change the preg replace to get this right.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/239017-wordpress-list-categories-preg-replace/
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.