如果在wordpress页面中为else,则始终为一个或另一个


if else in wordpress page - always one or the other

有一个页面显示自定义帖子类型的视频。在视频上传页面上,用户可以决定是想要视频缩略图,还是自己的照片。

我让他们用单选按钮来选择这个。变量被指定为作者或视频(默认为视频)。

我正在尝试将其设置为当自定义字段=作者时显示作者,当自定义字段=video时显示缩略图。

所有视频恢复为作者缩略图。。。也许我错过了一些显而易见的东西。。。

<?php  
    if (have_posts()) : while (have_posts()) : the_post();
        $video_post_type = get_custom_fields('video_post_type');
    endwhile;
    else:
    endif; 
?>
    <?php 
    <?php 
    $x = 1;
    $loop = new WP_Query( array ( 
        'post_type' => 'video',
        'posts_per_page' => 12,
        'paged' => get_query_var( 'paged')
    ) );
    if ($loop->have_posts()) : while ($loop->have_posts()) :
    $loop->the_post();
    $do_not_duplicate = $post->ID;
    $video_url=get_post_custom_values('video-url');
    $thumb_url=null;
$pic_choice=get_post_custom_values('video-image');

    if(strpos($video_url[0], 'youtube.com')!==false){ 
        $url_string = parse_url($video_url[0], PHP_URL_QUERY);
        parse_str($url_string, $args);
        $vid_id = isset($args['v']) ? $args['v'] : false;
        if($vid_id){
            $thumb_url='http://img.youtube.com/vi/'.$vid_id.'/hqdefault.jpg';
        }
    }
    if(strpos($video_url[0], 'vimeo.com')!==false){
        $vid_id = basename($video_url[0]);
        $thumb_url = getVimeoInfo($vid_id,"thumbnail_medium");
    }        
    if(!$thumb_url){
        $thumb_url= get_bloginfo('template_directory').'/img/vid-thumb.png'; 
    }
    ?>
    <div class="video-thumb">
    <a href="<?php custom_fields('video-url'); ?>">
    <?php if ($pic_choice = "author"):?>
    <?php userphoto_the_author_photo();?>
    <?php else:?>
    <img src="<?php echo $thumb_url; ?>" width="200" height="150"/>
    <?php endif; ?>
       </a> 
        <div style="text-align:center;" class="video-meta">
            <a href="<?php custom_fields('video-url'); ?>"><strong>
        <?php the_title(); ?></strong></a> <br/>
            <span class="vid-date"><?php custom_fields('video-date'); ?></span> <br/>
            <span class="vid-date"><?php custom_fields('video-speaker'); ?></span> 
    <br/>
    <span class="vid-date"><?php custom_fields('video-image'); ?></span> <br/>
        </div>
    </div>        

    <?php 
        endwhile;
        else:
        endif; 
    ?>

    <div class="page-nav"> 
        <?php wp_pagenavi(array( 'query' => $loop ) ); ?>   
    </div> 

<?php if ($pic_choice = "author"):?>

应该是:

<?php if ($pic_choice == "author"):?>

赋值运算符与比较运算符