【问题标题】:wordpress the_content not showing videowordpress the_content 不显示视频
【发布时间】:2014-04-24 04:28:56
【问题描述】:

我正在开发一个单独的网站并显示我正在使用 worpress 的博客。我使用以下代码来显示博客。它可以正确显示文本内容,但对于视频它只显示播放器栏而不是点击。

我还检查了主题 index.php 没有 the_excerpt。

当我使用 wordpress 管理员检查帖子的预览时,它会正确显示视频。

谁能帮我解决这个问题?

这是我的代码..

<?php
global $more;
$posts = get_posts('category=3&numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : setup_postdata( $post ); ?>
<?php $more = 1; ?>
<?php the_date(); echo "<br />"; ?>
<span style="color:#1C1644;font-size:1.3em !important;font-weight: bold;">
<?php the_title(); ?> 
</span>   
<div id="lol"><?php the_content(); ?>
</div>
<hr>
<?php
endforeach;
?>

【问题讨论】:

  • 您究竟是如何包含视频文件的?
  • 您的 jquery 是否正确加载到您想要显示视频的页面上
  • 是的,它在 wordpress 上正确显示。inforeshatech.globat.com/dev/goodness/blog 我的自定义网站页面位于 inforeshatech.globat.com/dev/goodness/index.php?pg=videos,仅显示播放器栏
  • 我遇到了问题..当我添加小尺寸视频时,它可以正确显示,但对于大视频,它不显示..但是在 word press 上它可以正确显示大视频和小视频.. 有吗有什么办法解决吗?

标签: wordpress


【解决方案1】:

请试试这个

<?php
global $more;
$posts = get_posts('category=3&numberposts=10&order=ASC&orderby=post_title');
   foreach ($posts as $post) : 
   setup_postdata( $post ); ?>
     <?php $more = 1; ?>
     <?php the_date(); echo "<br />"; ?>
     <span style="color:#1C1644;font-size:1.3em !important;font-weight: bold;">
        <?php echo the_title(); ?> 
     </span>   
     <div id="lol">
        <?php echo the_content(); ?>
     </div>
     <hr>
     <?php
   endforeach;
?>

【讨论】:

  • the_content() 已经回显,所以这一行 &lt;?php echo the_content(); ?&gt; 应该只是 &lt;?php the_content(); ?&gt;
【解决方案2】:

要将某些内容嵌入到帖子或页面中,您只需将指向它的 URL 发布到您的内容区域即可。确保网址在单独的一行中且没有超链接(查看帖子时可点击)。

例如:

http://www.youtube.com/watch?v=dQw4w9WgXcQ

在查看帖子时,WordPress 会自动将其转换为 YouTube 嵌入。

您还可以选择将 URL 包装在 [embed] 短代码中。它将实现相同的效果,但不需要 URL 单独一行

它还允许您设置最大值(但不固定)widthheight,如下所示:

[embed width="123" height="456"]http://www.youtube.com/watch?v=dQw4w9WgXcQ[/embed]

如果 WordPress 未能嵌入您的 URL,您将获得指向该 URL 的超链接。

【讨论】:

【解决方案3】:

使用 wp 自定义字段。在您的帖子中添加 video_embed 自定义字段并添加代码。

<?php echo get_post_meta($post->ID, 'video_embed', true); ?>

编辑:

if(get_post_meta($post->ID, 'video_embed', true)){
    echo get_post_meta($post->ID, 'video_embed', true);
}
else
{
    the_content();
}

【讨论】:

  • 在帖子中添加了名为“video_embed”的自定义字段,并在显示 the_content..same 问题之前放置上面的代码。
  • 您是否在帖子中添加了自定义字段?
  • yes..自定义字段名为“video_embed”,帖子中的值相同
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多