Support » Plugin: Permalink Manager Lite » Filter Permalink Structure Tag

  • Resolved elfigos

    (@elfigos)


    My media permalink structure is attachments/%attachment%

    How can I filter the %attachment% before saving the url?

    I want to hash substr(md5(%attachment%), 0, 8)

    I found permalink_manager_filter_default_term_uri but I’m not really getting what’s going on inside.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Maciej Bis

    (@mbis)

    Hi @elfigos,

    You should rather use ‘permalink_manager_filter_permastructure’ filter:

    function pm_encode_slug($full_custom_slug, $post, $post_name) {
    	if(!empty($post->post_type) && $post->post_type == 'attachment') {
    		$full_custom_slug = substr(md5($post_name), 0, 8);
    	}
    
    	return $full_custom_slug;
    }
    add_filter('permalink_manager_filter_default_post_slug', 'pm_encode_slug', 99, 3);

    Best regards,
    Maciej

    Thread Starter elfigos

    (@elfigos)

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.