how can i customize the way the search return looks?
searching “s” because i know there would be multiple results.
my sample post shows up, as well as my pages, how can i encorperate the sidebar? am i going to need a page template?
Have a read through this part and see if you can figure it out:
< ?php /* How to display all other posts. */ ?>
< ?php else : ?>
" title="< ?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">< ?php the_title(); ?>
< ?php twentyten_posted_on(); ?>
< ?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
< ?php the_excerpt(); ?>
< ?php else : ?>
< ?php the_content( __( 'Continue reading →', 'twentyten' ) ); ?>
< ?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'twentyten' ), 'after' => '' ) ); ?>
< ?php endif; ?>
That should work yep, but I’d move the closing
to before the last endif, as at the moment it’s within the if statement which is checking whether it’s an archive or search. If it isn’t one of those 2 then it wouldn’t close the div. Give it a go and then view your source and see whether it successfully wraps a div with a unique class around each post.
Move the ending
to after the last ‘endif’ in the code above and you should be golden.
You can then target each post by their id or class name eg:
However if you ever deleted/rewrote a post it would have a different post number and therefore a different class, therefore it would be better practice to style them by category. Just give each post a category and then style them like so
You can. You can give it whatever class you like within the loop. The loop is simply the PHP which produces the HTML markup for each post, so you can wrap it in whatever HTML tags you like. You mentioned in your 2nd post though that you wanted to select posts individually, and using the WordPress post_class() function gives each post a unique class you can use to target it with.
Just a thought, but have you ever considered investing in Chris’s book Digging into WordPress? This is all explained very thoroughly in there. I’d highly recommend it.
Well that’s what the code above does, it doesn’t wrap the whole set of posts, it wraps each post in a div so that you can style them however you like. If you wanted to wrap the whole set in a div you’d do that outside of the loop, if it’s inside the loop though then that div will be produced multiple times – once for each post. I just checked your link again and it looks like you have it figured out now.
You must be logged in to reply to this topic.