Advertisement
arnabkumar

Wp_Custom Field use

Mar 29th, 2014
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1.    
  2.  
  3.            
  4.      
  5.         <!--Custom post default -->
  6.          
  7.         <?php $your_variable= get_post_meta($post->ID, 'your_custom_field_id', true); ?>
  8.        
  9.        
  10.         <!-- use -->
  11.         <?php echo $your_variable; ?>
  12.          
  13.          
  14.         <!-- Custom post if exists -->
  15.          
  16.         <?php if($your_variable) :  ?>
  17.                 <a href="<?php echo $your_variable; ?>" class="job_pdf">Download Instructions</a>
  18.         <?php endif; ?>
  19.          
  20.          
  21.          
  22.        <!-- Custom post dynamic -->
  23.          
  24.         <?php if ( $your_variable ) : ?>
  25.                 <a href="<?php echo $your_variable; ?>" class="job_pdf">Download Instructions</a>
  26.         <?php else : ?>
  27.                 <p style="float:right">no job instructions available</p>
  28.         <?php endif; ?>
  29.        
  30.        
  31.         <!-- use Custom  Field in idex.php -->
  32.         <div class="slider">
  33.    
  34.     <?php
  35.     // Determine context
  36. $page_id = ( 'page' == get_option( 'show_on_front' ) ? get_option( 'page_for_posts' ) : get_the_ID );
  37.  
  38. // Echo post meta for $page_id
  39. $your_variable = get_post_meta($page_id, 'your_variable', true);
  40. $your_variable = get_post_meta($page_id, 'your_variable', true);
  41.  
  42.  ?>
  43.    
  44.         <h2><?php echo $your_variable; ?></h2>
  45.         <h3><?php echo $your_variable; ?></h3>
  46.     </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement