• Hello, I want to use the custom fields as a height and width for a div in my custom made news slider. What code should I put for example in

    <div style="width: <?fancyphpcode>px; height: <?anotherfancycode>px;">

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you have custom fields
    width 100px
    height 60px

    then the code as follows

    $width = get_post_meta($post->ID, 'width', true);
    $height = get_post_meta($post->ID, 'height', true);
    
    <div style="width: <?php echo $width; ?> height: <?php echo $height;?>">

    get_post_meta($post_id, $custom_filed_id, true); You can read more here http://codex.wordpress.org/Custom_Fields
    So, if you have custom field id width, then you would use this code to get a value in your template file

    <?php $myWidth = get_post_meta($post->ID, 'width', true);
     <div style="width: <?php echo $myWidth; ?>px; "></div>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to get just the text from custom fields ?’ is closed to new replies.