Assign a class other than .sticky for sticky posts

WordPress automatically adds a class called .sticky to posts that are marked as a sticky post. The front-end framework Foundation uses a .sticky class to make items stick to the page which presents an obvious conflict.

The ideal solution would be to modify the WordPress class. Is it possible to change the class that WordPress assigns to sticky posts to something other than .sticky?

Related posts

1 comment

  1. Try this please and include it in your functions.php

    function change_sticky_class($classes) {
      if (in_array('sticky', $classes, true)) {
        $classes = array_diff($classes, array("sticky"));
        $classes[] = 'wp-sticky';
      }
      return $classes;
    }
    add_filter('post_class','change_sticky_class');
    

Comments are closed.