2015-01-21, 03:12:12
(2015-01-21, 02:35:25)mvlcek Wrote:(2015-01-20, 13:57:38)sarnaiz Wrote: Hi Martin,
I am having trouble with getting an image to show in my results display.
I have a news special page with several fields which are working, but the image "thumb" does not appear.
...
I am using the following code in my search:
PHP Code:<h3 class="search-entry-title">
<a href="<?php get_special_field('link','',false); ?>">
<?php get_special_field('title','',false); ?>
</a>
</h3>
<?php get_special_field_image($thumb, $title=true, $width=200, $crop=false); ?>
<div class="search-entry-news-summary"><?php if (return_special_field('summary')=='') { get_special_field_excerpt('content', $numWords); } else { get_special_field('summary','',true); } ?></div>
If the name of the field containing the link to the image ist "thumb", the code would be
In your code you use the variable $thumb, which is probably empty, instead of the string "thumb". The second parameter is the title, which you could set to a fixed text like "Image illustrating the topic" or to another field, e.g. to have the page title as image title:Code:<?php get_special_field_image("thumb", null, 200); ?>
You only need the third parameter, if the image does not have the correct size. The fourth optional parameter is the height (which in your call is false = 0, because you forgot it).Code:<?php get_special_field_image("thumb", return_special_field('title','',false), 200); ?>
Thank you very much Martin. This code worked. I will style the image later on when I know people will not be visiting the site.
I appreciate you taking the time to write the code out with the proper syntax for me. Since I am not a programmer I tend to take instructions literally because I don't know any better!
Sherri