如何在视频模式中传递帖子ID以在WordPress中执行简码功能?

问题描述

我认为我的$ id变量正在某个地方被覆盖,或者无法以某种方式在视频模式划分标签中访问更新后的值。请注意,当我在echo之前iframe提出想法时,我可以获取当前帖子的正确ID。但是,即使代码处于循环中,在所有帖子中都只会提取一个ID。请参考下面的代码,让我知道我所缺少的内容。要关注的代码<div id="videoModal" class="modal fade">开始。但是我已经粘贴了整个代码以供参考。

任何帮助将不胜感激。谢谢!

<?PHP
$theme_options = theme_options();
$page = $theme_options['title'];

$args = array($theme_options['testimonial1'],$theme_options['testimonial2'],$theme_options['          testimonial3']);
$featured = new WP_Query(array('post_type' => 'post','post__in' => $args,'post__not_in' => array(0)));
$loop = 0;
?>

<div class="blog-section section">
    <div class="container">
        <div class="row">            
            <?PHP
            if ($featured->have_posts()) {
                while ($featured->have_posts()) : $featured->the_post();
                    global $post;
                    $id = get_the_ID();
                    if ($loop <= 2):
                        ?>
                        <div class="col-md-4">
                            <div class="post-wrap">
                                <div class="post-review">
                                    <?PHP
                                    if (get_post_format($id) != "video")
                                    {
                                        echo '<p class="post-description">'.esc_html(get_the_excerpt()).'</p>';
                                    }
                                    else
                                    {
                                    ?>
                                    <div id="videoModal" class="modal fade">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-body">
                                                    <?PHP echo ($id); ?>
                                                    <iframe id="testimonialVideo" width="560" height="315"
                                                    src="<?PHP
                                                        echo wp_kses_post(fn_execute_shortcode($post_id));
                                                        ?>"
                                                    frameborder="0" allowfullscreen>
                                                    </iframe>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <video class="cssVideo" controls>
                                      <source src="<?PHP 
                                            echo wp_kses_post(fn_execute_shortcode($id));
                                        ?>" type="video/mp4">
                                        <source src="<?PHP 
                                            echo wp_kses_post(fn_execute_shortcode($id));
                                        ?>" type="video/ogg">
                                    </video>
                                    
                                    <div class="btn-wrap">
                                    <a href="" id="<?PHP echo($id);?>" class="btn btn-default" data-toggle="modal" data-target="#videoModal">
                                        <?PHP echo esc_html__('View Video','new-theme-option'); ?></a>
                                    </div>

                                    <h5 class="post-title">
                                        <a
                                            href="<?PHP echo esc_url(get_the_permalink()); ?>"><?PHP echo esc_html(get_the_title()); ?>
                                        </a>
                                    </h5>
                                        
                                    <?PHP
                                    }
                                    ?>

                                    <ul class="post-info">
                                        <li class="post-date">
                                            <a href="<?PHP echo esc_url(fn_archive_link($post)); ?>">
                                                <?PHP echo esc_html(get_the_date('F d,Y')); ?>
                                            </a>
                                        </li>

                                        <li class="author vcard">
                                            <a href="<?PHP echo esc_url(get_author_posts_url(get_the_author_Meta('ID'))); ?>"><?PHP echo esc_html(get_the_author()); ?></a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <?PHP $loop++; endif; endwhile;
                wp_reset_postdata();
            }
            ?>
        </div>
    </div>
</div>
<?PHP

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)