• Resolved tagtag

    (@tagtag)


    Hello,
    I can’t reopen the ticket so I create a new one.
    I’d like to display folder slug on body class to make out different group of page. Could you tell me how could I do ?
    However, the code you gave me doesn’t seem to work anymore with the latest version of the module….
    Can you tell me if there’s anything to update?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author wickedplugins

    (@wickedplugins)

    Hi @tagtag,

    We changed the prefix of the folder taxonomies from wicked_ to wf_ to correct a bug with the taxonomy names being too long in certain cases. So, to get the previous code to work, you just need to change the prefix to wf_.

    Here is the updated code:

    // Add body class filter
    add_filter( 'body_class', 'custom_body_classes' );
    
    function custom_body_classes( $classes ) {
    
    	// Folder taxonomies are named in the format 'wicked_{$post_type}_folders'
    	$taxonomy = 'wf_' . get_post_type() . '_folders';
    
    	// Get slugs of folders that the current post belongs to
    	$folders = wp_get_object_terms( get_the_ID(), $taxonomy, array( 'fields' => 'slugs' ) );
    
    	// Merge the folder slugs into the body classes array
    	$classes = array_merge( $classes, $folders );
    
    	return $classes;
    
    }

    Hope this helps! Let me know if you still have trouble.

    Thread Starter tagtag

    (@tagtag)

    Thank you for your quick feedback!
    I’m sorry, but it doesn’t work either. Isn’t it possible to force this class addition on the body?
    Also, the latest version of this plugin overwrites some other rules to add more class to the body….
    Do you have any idea?

    Thanks

    Thread Starter tagtag

    (@tagtag)

    Okay, it was my fault! I found my problem 😉
    It now works well with this new taxonomy!!

    Thanks again

    Plugin Author wickedplugins

    (@wickedplugins)

    Great, glad to hear it worked!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘folder taxonomy in blody_class’ is closed to new replies.