- This topic is empty.
-
AuthorPosts
-
October 27, 2011 at 12:51 pm #34935
Attila Hajzer
Participanthow can i customize the way the search return looks?
http://attilahajzer.host-ed.net/?s=s
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?
October 27, 2011 at 1:44 pm #89770Johnnyb
MemberGo into the loop which produces those posts and wrap them in this:
>If you give each post a category it’ll give it a class like ‘category-resume’ which you can then style accordingly.
October 27, 2011 at 2:02 pm #89771Johnnyb
MemberI didn’t see your earlier questions. Search results are displayed using the search.php file. Within that you can add get_sidebar to display it.
October 27, 2011 at 2:36 pm #89777Johnnyb
MemberDepends on how your set up, but usually the search results page template will be search.php and the loop for outputting the posts will be in loop.php. The appropriate loop from loop.php will be called from within search.php.
October 27, 2011 at 3:03 pm #89780Johnnyb
MemberHave a read through this part and see if you can figure it out:
" title="" rel="bookmark">
'' . __( 'Pages:', 'twentyten' ), 'after' => '' ) ); ?>
October 27, 2011 at 3:19 pm #89783Johnnyb
MemberThat 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.
October 27, 2011 at 3:43 pm #89786Johnnyb
MemberI didn’t, I copied and pasted right from the code you posted. It must have been removed by the css-tricks code formatting when you posted it.
October 27, 2011 at 4:48 pm #89788Johnnyb
Member@attilahajzer, did you manage to get it to work ok?
October 28, 2011 at 11:08 am #89829Johnnyb
MemberMove 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:
.search-results .post-69{
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.search-results .category-resume{
.October 29, 2011 at 12:23 am #89877Johnnyb
MemberYou 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.
John
October 29, 2011 at 6:36 pm #89902Johnnyb
MemberWell 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.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.