Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm creating my pages links in wordpress, using wp_list_pages(). each link contains an <i> tag which displays retina icons. I want to set a different class for each link in order to display a different retina icon. my code so far is this:

<?php wp_list_pages('link_before=<i class="A RETINA ICON CLASS NAME"></i>&link_after=<br >'); ?> 

How can I do that using pages meta data?or other ways?

share|improve this question
add comment

1 Answer

You can do it easily with jQuery by using .eq() to add a specific class to each i element.

Example:

Add a class to your i element from PHP.

<?php wp_list_pages('link_before=<i class="retina_icon"></i>&link_after=<br >'); ?> 

Then add another class to it with jQuery.

jQuery('.retina-icon:eq(0)').addClass("retina-icon-1");
jQuery('retina-icon:eq(1)').addClass("retina-icon-2");
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.