Advertisement
asadsuman

Custom Fields

Mar 20th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. <!------------------------------------------------------Custom Fields--------------------------------------------------------------->
  2. <?php
  3. /*
  4. This page contain most important parts wordpress theme development.
  5. like(custom field)
  6. */
  7. /*==================================Custom Field====================================*/
  8. /*single custom field*/
  9.  
  10. <?php echo get_post_meta($post->ID,'url',true); ?>
  11.  
  12.  
  13. /*=======================Display custom field(if custom field exist than show otherwise keep it empty)=============*/
  14. <?php $sumon=get_post_meta($post->ID,'sumon_description',true);?>
  15. <?php if($sumon) : ?>
  16. <p><?php echo $sumon;?></p>
  17. <?php endif;?>
  18.  
  19. /*========================Conditional Custom Field===============================================*/
  20. <?php $sumon=get_post_meta($post->ID,'sumon_description',true);?>
  21. <?php if($sumon) : ?>
  22. <p><?php echo $sumon;?></p>
  23. <?php else :?>
  24. <p>You have to choose a text</p>
  25. <?php endif ;?>
  26.  
  27. /*
  28. when you set up images in custom field your image must be form localhost or your server.
  29. */
  30. <?php $picture=get_post_meta($post->ID,'url',true);?>
  31. <?php if($picture) : ?>
  32. <p><img src="<?php echo $picture; ?>" alt="" /></p>
  33. <?php else :?>
  34. <p>You have to set up author image</p>
  35. <?php endif;?>
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement