Wordpress - Working with custom fields

/ Published in: PHP
Save to your folder(s)

We set a custom field named "thumbnail" and its value to "http://mydomain.com/img/img.jpg". And then we add the following code in our template where we want the thumnail to appear.

As this, we could use this code to show anything we want, not only thumnails. Just set a key and a value different.

Copy this code and paste it in your HTML
  1. //in our template, we put this code wherever we want the thumbail to appear
  3. <a class="myThumbClass" href="<?php the_permalink(); ?>">
  4. <img src="<?php echo get_post_meta($post->ID,'thumbnail',true); ?>">
  5. </a>

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.