Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Yea, it's easy with php and the WordPress loop to affect only the first post in a query. Just Google around for WP functions to do it.
<?php if ( 1 == $i ) { $firstclass="firstpost"; }
else{ $firstclass = ''; } ?>
Awesome I'll test it out and see what happensYea, but it's easier if you just hook into your queries through functions.php (if you ask me).
This will add a class to the first post if that's what you're looking for. You just put this in functions.php (already tested it). https://gist.github.com/anonymous/17260b543e9854d7c894
If you want like a different shaped thumbnail and bigger in size (which would be recommended for speed) you want to look for another hook to display a thumbnail if the first post. This would depend on your theme for the ease of doing it.
<div class="post-wrap" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
<?php } ?>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<div class="pagination-wrapper">
<?php echo paginate_links(); ?>
</div>
<?php else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.', 'buso-lightning' ); ?></p>
<?php endif; ?>
</div>
After spending the whole night trying things, I finally realized what some of the functions meant and how it displayed the thumbnail, title etc.Eh, actually take multiple cracks at it first before asking questions. How else are you going to learn?
If you really want to edit the theme file directly then just look at the line 5 for what you just posted and put a conditional statement there.
I don't believe there is a native WP way to hook into what you posted and what you want to do through functions.php (what I prefer because I see it as easier). Usually themes include added actions that allow you to hook into.
<?php $c++;
if( !$paged && $c == 1) :?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<?php the_excerpt(); ?>
<?php else :?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a>
<?php the_excerpt(); ?>
<?php endif;?>
<a href="<?php the_permalink(); ?>">
<?php
if ( !$paged && $c == 1)
the_post_thumbnail('large'); // 'large' is one of the WordPress default thumbnail sizes)
else
the_post_thumbnail('thumbnail');
?>
</a>
<?php the_excerpt(); ?>
Thanks for the tips and help, I really appreciate it. I learnt a lotCode:<a href="<?php the_permalink(); ?>"> <?php if ( !$paged && $c == 1) the_post_thumbnail('large'); // 'large' is one of the WordPress default thumbnail sizes) else the_post_thumbnail('thumbnail'); ?> </a> <?php the_excerpt(); ?>
Functions is kind of a catch-all term with WP and some programming, so I apologize if I misused it and sent you on a goose chase. Not sure what you mean if it's stable, if it works then it works.
This does the same thing but it's less characters (I just cleaned up what you wrote). With coding there's something called the DRY method which means Don't Repeat Yourself, it's just for best practice.