• Resolved revlimiter

    (@revlimiter)


    I have a couple of questions regarding WordPress Search Results:

    Have a look at this page on my blog.

    In this example, I searched for “website”.

    Is there any way to:
    -Number each result?
    -Have the keyword appear at the top (Search Results for “Website”)
    -Change the URL structure “?s=website&submit.x=0&submit.y=0&submit=Search”?

    Any help is greatly appreciated!
    Thanks!
    Cheers,

Viewing 9 replies - 16 through 24 (of 24 total)
  • Hi taghaboy,

    Using a condition like you do is a good idea, I always check if a custom field exists also. In order to achieve your standard image, you can just use the same structure as in line 3 of your code.

    Line 5 would be like this:

    else { ?>
    *your no-img html markup*
    <?php } ?>

    BUT, 2 things:
    1.
    Consider writing the get_post_custom_values() in a variable right after the wordpress loop starts (before the POST div), and echoing that variable. In PHP, it is always faster to echo something that’s pre-stored in a variable than it is to call it inline. I would also say it is a sign of good and clean code.

    2.
    What I do and I would recommend you do also is having a default background image for that defined in CSS. Then you can just leave the ELSE part out and simply close your PHP code after line 4 of your code above. If no image is there, the call doesn’t display anything and the background image is viewable. Just make sure to define width and height of the img in CSS so that it keeps its size.

    That’s cleaner, results in less code, and you can always change everything from CSS instead of having to go through every instance of your PHP call when you need to change the path or something else.

    Hope that helped.

    Thread Starter revlimiter

    (@revlimiter)

    Hey taghaboy,
    Can you share how you made the thumbnails work on your search results pages? I am interested in checking out your WordPress blog. ??

    Thanks!

    @ whooami

    I just tested out the plugin results-count 0.3

    Before this I was using (and I saved) results-count-updated 0.2. If I recall correctly this was an alternate version of the original plugin, which was modified by you (whooami) sometime earlier, some months ago.

    results-count-updated 0.2 WORKS on my search pages. For example, “Showing 43 results for the search terms: light.”

    results-count 0.3 DOES NOT WORK on my search pages. I get “Showing 0 results for the search terms: light.”

    I reverted back to the results-count-updated plugin since it works for me on Search pages. But I would like to upgrade to the new plugin and implement this counter on other pages like categories.

    Any idea what’s wrong with 0.3, for me? Do you recall what the fix was last time?

    I don’t want to post my link on here but I will email it to you if you want to see, whooami. Thank you very much for your help.

    Any idea what’s wrong with 0.3, for me? Do you recall what the fix was last time?

    I don’t want to post my link on here but I will email it to you if you want to see, whooami. Thank you very much for your help.

    nope, and yeah I remember all of that.

    maybe drop me an email, I want to ask a couple q’s that you might not want to answer here.

    I cant make any big promises though, I’m working all this weekend, and having some work done on my new “place to live”, and having a new roomate move in, and am previously committed to 2 other wordpress gigs right now.

    not enough hours in the day, right now, for me.

    revlimiter,

    If you follow the link I pasted to the custom fields page on WP above, you can see how to implement thumbnails. It’s not that hard at all.

    An overview for you:
    – Upload an image that you want to serve as a thumbnail to a post, but don’t embed it in the post
    – Get the image ID from the Media Library in your WordPress Admin
    – Back in the post, create a custom field named “thumbnail” and as a value, enter the image ID
    – In your search PHP file, put the code taghaboy posted above in the wordpress loop where you want the thumbnail to appear. Replace “petit” with “thumbnail”
    – That’s it

    Just check out the link I pasted.

    Hi nublooo,
    thanks for advice and help too, the idea behind the bg-img sound so good, i’ll use it in many project.
    some thing i dont understand it’s the code steel not work and it dont echo the url of img!!!

    <?php // if there's a img in my custom field
    if($value !== '') { ?>
    <img src="<?php $values = get_post_custom_values("petit"); echo $values[0]; ?>">
    <?php } // end if statement
    // if there's no img
    else { ?>
    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/no-img.gif" />
    <?php } ?>

    what the : if($value !== ”) { ?> do exactly.
    * – * – * – * – * – * – * – * – * – * – * – * – * – * – * – *
    The tips of “number each result” work perfectly, but whil i click for next result the number count to number one again( 1-2-3-4=page one ::: 1-2-3-4=page two… and other page result)
    her the code:

    <?php get_header($postnum = 1); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    
            <div class="count">
    <?php echo $postnum; ?>
    	</div>
    
    	<p>lorem ipsum dolar set</p>
    
    <?php $postnum++; ?>
    <?php endwhile; ?>
    
    	<div class="page-nav">
    		<span class="previous-entries"><?php next_posts_link('Next') ?></span>
    		<span class="next-entries"><?php previous_posts_link('Previous') ?></span>
    	</div>
    
    <?php else : ?>
    <?php endif; ?>
    <?php get_footer(); ?>

    ______________________________________________________________
    revlimiter : exactly as nublooo sad, her the code to only show the image url you set in the custom field named “thumbnail”, her i add a div “thumb” it help me to align img to the left of every search result with the style:
    .thumb {
    float:left;
    margin-right:15px;
    }

    <div class="thumb">
    <img src="<?php $values = get_post_custom_values("thumbnail"); echo $values[0]; ?>">
    </div>

    Thread Starter revlimiter

    (@revlimiter)

    Thanks nublooo and taghaboy! Your help has been fantastic, and I managed to get the search result thumbnails working.
    Check it out:
    https://www.kimstewart.ca/?s=skyline&submit.x=0&submit.y=0&submit=Search

    I think I’m gonna put them on my “Entries Tagged As” results pages also.

    Quick question about a plugin I’m using, Kimili Flash Embed. If you goto this page you will see it in there with the text:
    https://www.kimstewart.ca/?s=google&submit.x=0&submit.y=0&submit=Search

    Does anybody have any experience removing this from the search results page?

    Cheers,

    Happy that you we help you,
    for the video who appear in ur search result, i really don’t have any idea, sorry.
    _________
    tell me, did you have like this problem:
    The tips of “number each result” work perfectly, but whil i click for next result the number count to number one again( 1-2-3-4=page one ::: 1-2-3-4=page two… and other page result)

    did you revlimiter understand my question?
    thanks

Viewing 9 replies - 16 through 24 (of 24 total)
  • The topic ‘WP Search Results’ is closed to new replies.