WordPress.org

Ready to get started?Download WordPress

Forums

Remove classes from post_class() (2 posts)

  1. jrandomh
    Member
    Posted 2 years ago #

    Hi folks,

    I'm trying to remove two classes from my post_class() output array - I don't think I've got it quite right, can anyone throw an eye over this and let me know what I'm doing wrong?

    function jrh_post_names($classes) {
    	$classes[] = array_diff($classes, array('tag-link', 'tag-links'));
    	return $classes;
    }
    add_filter('post_class','jrh_post_names');

    I don't want either 'tag-link' or 'tag-links' appearing in the classes list, regardless of whether "link" or "links" are tags on this post.

    TIA,
    JRH.

  2. jrandomh
    Member
    Posted 2 years ago #

    Here's the fix - minor tweaks are double quotes and removal of brackets.

    function jrh_post_names($classes) {
    	$classes = array_diff($classes, array("tag-link", "tag-links"));
    	return $classes;
    }
    add_filter('post_class','jrh_post_names');

Topic Closed

This topic has been closed to new replies.

About this Topic