go41

Re: quick question on custom field for adding images :: Reply by Joern

von Joern am 12. Jun. 2010 | Keine Kommentare

so you managed the category 3 problem, okay.
Here it’s about the post thumbnail, where you could easily use the function like in arthemia to query for a custom field and load an image if there is.
basicly you have to replace this code from sample above:

Code:

<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(200,160), array("class" => "alignleft post_thumbnail")); } ?>

with a code as in arthemia. I give you a sample without that timthumb stuff, but you should size the image manually to 200x160px
Modified Arthemia code looks like this:
Code:

<?php $values = get_post_custom_values("Image"); if (isset($values[0])) { // checks for custom field Image and shows it if there is ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
<img src="<?php $values = get_post_custom_values("Image"); echo $values[0]; ?>" alt="<?php the_title(); ?>" class="alignleft post_thumbnail" width="200px" height="160px" /></a>
<?php } ?>

Above code links the image to the post, the ‚a href‘ stuff is around.
Without link like this:

Code:

<?php $values = get_post_custom_values("Image"); if (isset($values[0])) { // checks for custom field Image and shows it if there is ?>
<img src="<?php $values = get_post_custom_values("Image"); echo $values[0]; ?>" alt="<?php the_title(); ?>" class="alignleft post_thumbnail" width="200px" height="160px" />
<?php } ?>

you should be able to create a custom field ‚Image‘ and paste in the value either a path on your site like /wp-content/uploads/picture.jpg and it should also work with a path including http:/ … in front.

The img class I used as in your code, so styling should be the same, try it!
____________________
you find me on Google+, Twitter and Facebook

(von: Joern)

Hier noch 1 weitere Ergebnisse dieses Threads:

quick question on custom field for adding images

12. Jun. 2010 (von: omerkhan02)

I figured out my last issue. I am using realpress a property search and listing plug in for wordpress. The problem is that when you enter a search for a particular property, the resulting listing only gets you the title…

Autor:

Du findest mich auch auf Google+, Twitter und Facebook!

Schreibe einen Kommentar

Pflichtfelder sind mit * markiert.


weitere forum Beiträge: