WordPress.org

Forums

Adding / Subtracting / Dividing Custom Field values (1 post)

  1. anthonyabraira
    Member
    Posted 2 years ago #

    I was trying to quickly create a way for me to construct an or for YouTube or Vimeo additions to my post. I got it to work doing this:

    <?php <br />	// you might want to check the aside as it might need a calculation after creating variables.
    // make sure that advanced custom fields is installed
    // (nab the width and height for embedding)
    $video_h = get_field('video_h');
    $video_w = get_field('video_w');
    
    // (nab the videos id of origin)
    $vimeo_id = get_field('vimeo_id');
    $youtube_id = get_field('youtube_id');
    $facebook_id = get_field('facebook_id');
    
    // check for vimeo first
    if(get_field('vimeo_id'))
    {
    echo '	echo '?title=0&byline=0&portrait=0&color=ff0179"' . 'width="' . get_field('video_w');
    echo '" height="' . get_field('video_h') . '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen>
    ';
    } elseif (get_field('youtube_id')) // then youTube
    {
    echo '	'" src="http://www.youtube.com/embed/' . get_field('youtube_id') . '" frameborder="0" allowfullscreen>';
    } elseif (get_field('facebook_id')) // then Facebook
    {
    echo '	'" " /> ';
    }
    
    ?>

    But now I want to create an aside post format that basically reduces that embed by either a 1/3rd or 1/2. I looked through basic php and found some basic stuff that led me to believe this might work:

    $video_h = get_field('video_h')/2;
    $video_w = get_field('video_w')/2;
    
    // (nab the videos id of origin)
    $vimeo_id = get_field('vimeo_id');
    $youtube_id = get_field('youtube_id');
    $facebook_id = get_field('facebook_id');
    
    echo $video_h;
    echo $video_w;
    
    This returned: 00

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by anthonyabraira
  • This topic is not resolved
  • WordPress version: 3.3.2