• Resolved pare81

    (@pare81)


    Hi Greg,

    since the last update, the rewrite from “advert” within URL doesn’t work anymore. I used the following snippet to show “kleinanzeigen” instead of “advert”.

    add_action("adverts_post_type", "customize_adverts_post_type");
    		add_action("adverts_register_taxonomy", "customize_adverts_taxonomy");
    
    		function customize_adverts_post_type( $args ) {
    		   if(!isset($args["rewrite"])) {
    			  $args["rewrite"] = array();
    		   }
    		   
    		   $args["rewrite"]["slug"] = "kleinanzeigen";
    		   return $args;
    		}
    
    		function customize_adverts_taxonomy( $args ) {
    		   if(!isset($args["rewrite"])) {
    			  $args["rewrite"] = array();
    		   }
    		   
    		   $args["rewrite"]["slug"] = "ad-category";
    		   return $args;
    		}
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi, the code is a bit incorrect it should be

    
    add_action("adverts_post_type", "customize_adverts_post_type", 10, 2);
    add_action("adverts_register_taxonomy", "customize_adverts_taxonomy");
    
    function customize_adverts_post_type( $args, $type = null ) {
    
        if( $type != "advert" ) {
            return $args;
        }
    
        if(!isset($args["rewrite"])) {
    	   $args["rewrite"] = array();
        }
    
    	$args["rewrite"]["slug"] = "kleinanzeigen";
        return $args;
    }
    
    function customize_adverts_taxonomy( $args ) {
        if(!isset($args["rewrite"])) {
    	    $args["rewrite"] = array();
    	}
    
    	$args["rewrite"]["slug"] = "ad-category";
    	return $args;
    }
    

    After updating the code, go to wp-admin / Settings / Permalinks panel and click “Save Changes” button to reset WP router.

    Thread Starter pare81

    (@pare81)

    many thanks 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Rewrite “advert” after last update’ is closed to new replies.