Filter post_class
, use a static internal counter in the filter callback:
add_filter( 'post_class', 'wpse_100804_post_class' );
function wpse_100804_post_class( $classes )
{
static $counter = 0;
$counter += 1;
switch ( $counter )
{
case 4:
$counter = 0;
case 3:
$classes[] = 'extra';
}
return $classes;
}
In your loop template call post_class()
like this:
while ( have_posts() )
{
the_post();
?><li <?php post_class(); ?>>
<?php /* more stuff */ ?>
</li>
}
Related Posts:
- JavaScript Loading Screen while page loads
- Click button copy to clipboard
- How to make html table vertically scrollable
- How to make Bootstrap carousel slider use mobile left/right swipe
- bootstrap 3 navbar collapse button not working
- How to center image in carousel
- Can Twitter Bootstrap alerts fade in as well as out?
- Play/pause HTML 5 video using JQuery
- jQueryUI dialog width
- Random background images CSS3
- How do I remove a box-shadow effect from an element when another element is hovered?
- Slide right to left?
- Automatically decrease font size for long words
- Best approach for loading a sidebar Only if the screen max-width is >900px?
- Twitter Bootstrap Use Collapse in Custom Post Type
- Stylizing external SVG files with jQuery and CSS
- Gravity list field override and adding javascript [closed]
- WordPress ajax function parameter value not being passed
- Override theme style with other CSS on a specific page
- How can I make this custom menu work?
- Remove WordPress scripts
- Disable stored tags queries in admin page when posting a new post
- How to make an WordPress element sticky? [closed]
- Accordion scrolls page too low after clicking on the title [closed]
- show/hide div with simple jQuery script [closed]
- What is the propre way to include jQuery UI Datepicker’s CSS in plugin?
- Superfish Menu Not Loading
- Problem Implementing parallax in header of bp-default theme
- WordPress Insert not working with ajax
- Is it OK combined wp-include js, jquery, css? [closed]
- jQuery Drill Down iPod Menu FOUC and Selecting Current page
- jQuery Validation plugin and Bootstrap 4 CSS classes
- Getting click on item to open closest relevant element (popup) with jQuery
- How Do I change Markup of a link in WordPress
- jQuery for Fade Preload Causes My Site Favicon to Disappear from Tab of Browser
- Lightbox scroll page down on iPhone
- jQuery function not working in WordPress but works in jsfiddle
- Site images are fixed in front of my site content [closed]
- WP Media Uploader modal conflicts with Bootstrap modal
- :first-child applying to all links [closed]
- How to update scrollbar when using Jetpack’s Inifnite Scroller?
- Hide input field when second input field is in focus
- change the icon of a custom post type in WordPress to use twitter boostrap
- Drop Down Category Menu Not Working
- Ajax Query returns zero
- controlling the showing and hiding of the website logo
- How do I add Javascript and CSS files into WordPress?
- can’t make jQuery work (change image on time interval) [closed]
- Remove class using jQuery
- jQuery $(this) keyword
- Set timeout for ajax (jQuery)
- jquery loop on Json data using $.each
- How to read data From *.CSV file using javascript?
- Enqueue core jQuery in the footer?
- How to modify wp.media to get and display multiple images
- wp_mail script with jQuery post
- Including javascript for a shortcode
- adding the full image path to a wordpress javascript file
- wp_head() remove redundant scripts?
- How to add unique image class to WordPress
- Dropzonejs with WPCF7 [closed]
- Edit single attachment on click (WP-admin)
- Jquery conflict
- Ajax not posting form data to query in PHP function
- Enqueue WordPress jQuery after it’s been deregistered by a plugin
- gravity forms jQuery.load into modal [closed]
- Ajax, Permalinks and post_thumbnail
- How to embed JS data viz in a simple WordPress website
- First Attempt at AJAX and it keeps getting Canceled. Can’t Get Results to Show
- Enque Javascript in Footer?
- window.onload wont execute in wordpress
- Odd / Even posts add class minus first post
- How to return multiple arguments from AJAX callback function
- JS news ticker is not working on home page but working on other pages. How to solve this?
- jQuery function not working
- Remove swfobject.js in wp_head()
- Uncaught ReferenceError: jQuery is not defined: how to fix on a sunday? [closed]
- underscore template dynamically remove row Jquery
- echo do_shortcode for Contact Form 7 from within dynamically loaded php file
- including jquery
- Customizing the Jquery Calendar [closed]
- How to make JQuery load on top of head tag before everything
- Styling a specific post after hovering over it
- Dashboard controls have all stopped working
- $_POST empty in using new php file added to theme
- How to blur the_post_thumbnail() via blur.js (jquery)?
- Plugin preventing media buttons from working
- How to deregister scripts all at once
- Using jQuery DataTables and yadcf
- jQuery autcomplete not working
- Add jQuery function to media button
- Why won’t this jQuery work in WordPress?
- Change WooCommerce Checkout Manager Datepicker to Jalali
- jQuery append only works if I select html in admin section [closed]
- jQuery color picker function on change
- Can’t get this jQuery snippet to work with WordPress
- Javascript Loading Effect to URLs
- jQuery Add/Remove Classes Not Working
- jQuery datepicker not showing on admin menu
- Can’t seem to check off a category checkbox with jquery?