Using custom fields check/call in a function
-
Here what i do, the following function is created in functions.php. I use that function to check if a video is embedded into post using custol field, if video return false, to check for post thumbnail, and if post thumbnail return false, to call a custom image.
<?php function thumb_video($test_fnname,$test_w,$test_h,$test_align) { $test_video = get_post_meta($post->ID, 'video', TRUE); if ($test_video !== '') { ?> show video <?php } elseif ( has_post_thumbnail() ) { ?> display thumbnail <?php } else { ?> display custom thumbnail <?php } } ?>
in home.php inside loop, this function is being called as
<?php thumb_video(‘featured’,’200′,’200′,’aligncenter’); ?>
The problem is;
Whether there is a video or not, it will always think that there is a video and i will get show video part as resultAnyone got an idea?
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Using custom fields check/call in a function’ is closed to new replies.