How to add title attribute to archive items

If you look at the source, you will see that the HTML is generated by get_archives_link, which applies the filter get_archives_link. Applying a callback to that filter is probably the most straightforward way to add a title attribute. Unfortunately it is not one of the more friendly filters and requires you to regex the generated … Read more

Breaking up the results of a loop

Instance of WP_Query tracks number of current post in current_post property, zero based. So inside your loop you can check for something like if ( 2 == $subpages->current_post ) and output your additional content.

Adding first and last classes to three column layout in Bones boilerplate

I’ve just managed to resolve this now. This <?php $counter = 1; //counter tracks the number of the post we’re on ?> needed to be above <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query(‘showposts=3’ . ‘&paged=’.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> (not below). End code that works correctly is:- <?php $counter = … Read more

Print the whole page?

First of all, your page templates will normally include everything needed to make up a page, i.e. including this structure: <html> <head></head> <body></body> </html> which is not what you want over and over in your one-pager. However if you’ve built your templates using the get_template_part() function (described quite well over here) you can reuse it … Read more

Breaking up multiple words and inserting an image after first word

Assuming you know that there will always be two words separated by a space, you can use explode. Something like this: $pieces = explode(” “, get_the_title()); $word1 = $pieces[0]; $word2 = $pieces[1]; $output .= ‘<li><a href=”‘.get_permalink().'” class=”‘.$page_id->post_name.’-link”><div class=”‘.$page_id->post_name.’-info”><h2>’.$word1.'</h2><div class=”‘.$page_id->post_name.’-img”>’.get_the_post_thumbnail($page->ID,’icons’).'</div><h2>’.$word2.'</h2></div></a></li>’;

First post article different on Archives template

Just point to the first element of your list of articles using CSS pseudo class like this: PS. I’m so used to less that I’m gonna give you the .less syntax, but you can figure it out on your own right? .container-with-your-posts { > .post-container { &:first-child { h1 { your styles for the title … Read more