Give help. Get help.

  • # October 27, 2011 at 12:51 pm

    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?

    # October 27, 2011 at 1:44 pm

    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.

    # October 27, 2011 at 2:02 pm

    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.

    # October 27, 2011 at 2:36 pm

    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.

    # October 27, 2011 at 3:03 pm

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

    # October 27, 2011 at 3:19 pm

    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.

    # October 27, 2011 at 3:43 pm

    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.

    # October 27, 2011 at 4:48 pm

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

    # October 28, 2011 at 11:08 am

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

    # October 29, 2011 at 12:23 am

    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.


    # October 29, 2011 at 6:36 pm

    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)

You must be logged in to reply to this topic.