Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. $args = array(
  2.  
  3. function wptuts_custom_tags() {
  4. add_rewrite_rule("^brand-([^/]+)?",'index.php?post_type=products&brand_name=$matches[1]','top');
  5.  
  6. flush_rewrite_rules();
  7.  
  8. function my_post_type_link_filter_function($post_link, $id = 0, $leavename = FALSE) {
  9. if (strpos('%brand_name%', $post_link) === FALSE) {
  10. $post = &get_post($id);
  11. $brand_name =get_post_meta($post->ID,'brand',true);
  12.  
  13. if(empty($brand_name)){$brand_name = 'default';}
  14. $post_link = str_replace('%brand_name%',$brand_name, $post_link);
  15.  
  16. return $post_link;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement