doupu2722 2013-08-28 04:04
浏览 22

如果在wordpress页面中是其他的 - 总是一个或另一个

Have a page showing videos from a custom post type. on the video upload page, users can decide if they want a video thumbnail, or their own photo.

I let them choose this with a radio button. variable is assigned as author or video (video as default).

I am trying to set it to display author when custom field = author and thumbnail when custom field = video.

all videos revert to the author thumbnail... maybe I'm missing something obvious...

<?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> 

  • 写回答

1条回答 默认 最新

  • duandie0884 2013-08-28 04:08
    关注
    <?php if ($pic_choice = "author"):?>
    

    should be:

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

    Assignment operator vs Comparision operator

    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端