Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Wordpress在不重新加载页面的情况下显示内容_Javascript_Jquery_Wordpress - Fatal编程技术网

Javascript Wordpress在不重新加载页面的情况下显示内容

Javascript Wordpress在不重新加载页面的情况下显示内容,javascript,jquery,wordpress,Javascript,Jquery,Wordpress,我有下一个代码: $('.left article')。在('click',函数(事件){ var article_content=$(this).children('.article content').html() $('.right').html(文章内容); }); *{ -webkit框大小:边框框; 框大小:边框框; } 部分{ 显示器:flex; } 分区>分区{ 弹性:0.50%; 填充:15px; 宽度:50%; } .左.文章内容{ 显示:无; } 我的职称 这是第一篇文

我有下一个代码:

$('.left article')。在('click',函数(事件){
var article_content=$(this).children('.article content').html()
$('.right').html(文章内容);
});
*{
-webkit框大小:边框框;
框大小:边框框;
}
部分{
显示器:flex;
}
分区>分区{
弹性:0.50%;
填充:15px;
宽度:50%;
}
.左.文章内容{
显示:无;
}

我的职称
这是第一篇文章的内容

另一个职位名称 第二篇文章的内容

第三职称 这是第三篇文章的内容


看起来您的循环不正确。试试这个:

 <section>
        <div class="left">
           <?php global $post;
                        $wpposts = get_posts('numberposts=3&post_type=>book');
                        foreach($wpposts as $post):
                            setup_postdata($post);?>
            <article>
                <h2>
                    <ul>
                            <li>
                                    <?php the_title(); ?>
                            </li>

                    </ul>
                </h2>
                <div class="article-content">
                    <p>
                    <?php the_content(); ?>
                    </p>
                </div>
            </article>
           <?php endforeach; ?>
        </div>


        <div class="right">

        </div>
    </section>


现在,每个帖子都将被包装在

中,看起来您的循环不正确。试试这个:

 <section>
        <div class="left">
           <?php global $post;
                        $wpposts = get_posts('numberposts=3&post_type=>book');
                        foreach($wpposts as $post):
                            setup_postdata($post);?>
            <article>
                <h2>
                    <ul>
                            <li>
                                    <?php the_title(); ?>
                            </li>

                    </ul>
                </h2>
                <div class="article-content">
                    <p>
                    <?php the_content(); ?>
                    </p>
                </div>
            </article>
           <?php endforeach; ?>
        </div>


        <div class="right">

        </div>
    </section>


现在,每个帖子都将被包装在

@designtcode中,如何更改代码以添加第三列(div)以及其他constum帖子类型的帖子标题(例如:testpostype),什么包含特定标记?您可以复制
.left
列,并将
post\u type=>book
更新为
post\u type=>testpostype
。我希望这是有意义的?@designtcode,是的,但是如果我有下一种情况:我在左边有一个特定标签的书籍的标题,通过点击标题,除了内容之外,我应该从我的(testpostype)中获得具有相同标签的文章列表。“怎么做?”我想我明白了。但不确定标签是什么,你是如何得到标签的?您可以发布另一个问题,我可以提供帮助。@designtcode,如何将添加第三列(div)的代码与其他constum post类型(例如:TestPostType)的文章标题一起更改,哪些内容包含特定的标记?您可以复制
.left
列,并将
post\u type=>book
更新为
post\u type=>TestPostType
。我希望这是有意义的?@designtcode,是的,但是如果我有下一种情况:我在左边有一个特定标签的书籍的标题,通过点击标题,除了内容之外,我应该从我的(testpostype)中获得具有相同标签的文章列表。“怎么做?”我想我明白了。但不确定标签是什么,你是如何得到标签的?你可以发布另一个问题,我可以提供帮助。