Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS WordPress search output.

  • This topic is empty.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #34935
    Attila Hajzer
    Participant

    how 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?

    #89770
    Johnnyb
    Member

    Go 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.

    #89771
    Johnnyb
    Member

    I 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.

    #89777
    Johnnyb
    Member

    Depends 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.

    #89780
    Johnnyb
    Member

    Have a read through this part and see if you can figure it out:







    " title="" rel="bookmark">






    '' . __( 'Pages:', 'twentyten' ), 'after' => '' ) ); ?>


    #89783
    Johnnyb
    Member

    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.

    #89786
    Johnnyb
    Member

    I 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.

    #89788
    Johnnyb
    Member

    @attilahajzer, did you manage to get it to work ok?

    #89829
    Johnnyb
    Member

    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: .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{.

    #89877
    Johnnyb
    Member

    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.

    John

    #89902
    Johnnyb
    Member

    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.

Viewing 11 posts - 1 through 11 (of 11 total)
  • The forum ‘CSS’ is closed to new topics and replies.