add a simple counter and conditional check:
$pages = get_pages('child_of=10');
$counter = 1;
if ($pages) {
echo '<ul class="projectthumbs">';
foreach ($pages as $page) {
if ($counter == 3){
$class=" class="YOUR_CLASS"";
$counter = 1
}else{
$class="";
$counter = $counter +1;
}
echo '<li'.$class.'><a href="'.get_permalink($page->ID).'">';
echo get_the_post_thumbnail($page->ID);
echo '<span class="projectthumbtitle">';
echo get_the_title($page->ID);
echo '</span>';
echo '</a></li>';
}
echo '</ul>';
}
Related Posts:
- Listing all sub-pages?
- WordPress function and string as variable?
- Automatically add images to a menu
- Insert page content into another page with a changed variable
- How Do I Find & Remove H1 From Site-Title-Wrapper? [closed]
- How to add elements to an empty array in PHP?
- Sending the reset password link programatically
- Getting only direct child pages in WordPress with get_pages
- How do I change/modify the_post_thumbnail(); html output?
- What’s the best way to use the Featured Image for responsive web design?
- Disable Attachment Pages Completely
- How to add a .php file to WordPress
- How to Remove all Instances of edit_post_link
- Any guides on creating custom admin pages?
- Where to get information about array fields in $_REQUEST?
- Multiple is_page() in page.php
- Pass a PHP variable to another file
- Only Showing Upcoming Events
- How to check if feed URL was requested?
- How to store the_title() into a variable to reutrn the value, not just echo it
- Variables declared in header not available in other includes
- How do I make my function add variables/values to the $post object?
- Create WordPress pages with PHP
- PHP/Manual use of images? – 2 Questions
- Is it possible to generate a page without create in the admin?
- How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
- WordPress admin never finishes saving page on site with large page count
- class=”parent” for wp_list_pages?
- Getting an alphabetic post list with two letters onclick on letter
- Adding Featured Image to Post programatically
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- PHP Script within wordpress theme
- How to upload imagick resource to media in wordpress
- How to add a featured image to a existing post via php?
- How to use SRCSET with get_the_post_thumbnail()?
- add_rewrite_rule with bottom priority doesn’t handle the WordPress pages
- where to include a php file
- How to link to a custom .php page in my folder
- Adding featured image via PHP
- How do I know what variables are passed in a filter/action and what their meaning is?
- WordPress loop specific thumbnail size
- How do I get images (with a thumbnail preview) to show in search results?
- Get only the grandchildren, not the direct children of page/current page?
- Help with a custom page template – listing contents of childpages?
- fallback image for featured image
- Print number of post (in reverse)
- How to get Poster (thumbnail) Image of Video
- WP Insert Post function – Insert Post Thumbnail
- Display All Post Attachments and Assign Class to the Last Image?
- How to make thumbnail image fit into a div where image dimentions are completely different?
- Assign a picture URL to a page via PHP
- Passing the page ID to a login php script
- When would you use $_post instead of $post?
- How to scale image with equal width and height without distortion?
- How can the plugin directory path be returned into ?
- Featured image fallback link to permalink
- is it possible to force wordpress to always save thumbnails as ‘jpg’ not ‘png’
- Add a Different CSS Class Into The Body Tag of Different WP Pages
- WordPress widget/sidebar dividers?
- How to Display Image Meta underneath EVERY image in EVERY post
- Limit get_pages to only show 5 items
- How can I show the post thumbnail from the most recent of a certain post type, in widget?
- syntax issue on php 7.4
- How do I publish only one page to production after making changes on staging?
- Custom Template 404 for specific custom post type
- Can’t load WP function into external function
- Locating Global Variables
- Pass PHP variable to JavaScript without inline JS
- How can I add pagination and how can I change thumbnail size?
- Custom category code not showing all posts
- Count the number of times the search form template gets included on a page
- Putting PHP variables into javascript [duplicate]
- Echo URL of large version of Featured Image
- Variable global scope [closed]
- How to rewrite URL with PHP variables with htaccess to a normal looking URL?
- Insert a button on a page with random number generation
- Using a variable in is_page(array())
- How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts
- Can’t get page content in WordPress
- Way to querry data (tags) from a wordpress database?
- Global variable $post returning incorrect object
- How can I load a PHP page without using a Template?
- Static variable and add_rewrite_rule?
- Trying to add attribute to my posts’ featured image
- How to put a variable in a instance in the widget
- Recent posts with featured image or fallback image with permalink
- Randomly Assign an Image’s Alt Text Based on Data From Post
- Call global variable array() in woocommerce child/template
- Best practice for migration friendly images in posts/pages?
- WP dynamic featured image – Can’t get second featured image url
- get_term_link() returns correct – But illogical error-messages disturb
- Set the background to a default image if there isn’t a specified “featured image”
- Page Automatically Generated from Theme?
- How can I Add a variable PHP in the Menu Nav
- How to add a php custom page to WordPress
- Sort query_posts for Parent Pages to menue order or the count?
- How to hide all child pages with post_query?
- Pass variable from one function to another
- Get value from shortcode to do something
- PHP variable = get_the_post_thumbnail_url outputting without slashes