jeudi 21 avril 2016

WORDPRES apply_filters only home page

I have a simple function (in functions.php in my theme) which adds class to the navigation links

   add_filter('next_posts_link_attributes', 'posts_link_attributes');
   add_filter('previous_posts_link_attributes', 'posts_link_attributes');

  function posts_link_attributes() {
     if (is_home() || is_front_page()) {
        if (current_filter() == 'previous_posts_link_attributes') {
            return 'class="prevlink ajax"';
        }
        elseif (current_filter() == 'next_posts_link_attributes') {
            return 'class="nextlink ajax"';
        }
     }
  }

I need this to only work on my homepage but it does not work. Anyone can help me?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire