WordPress 中来自两个不同类别的惊人帖子

Staggering posts in WordPress from two different categories

我正在制作一个 WordPress 主题,并希望在滑块和博客页面上按类别错开帖子。

到目前为止,这是我所拥有的:

$arg1 = array('category_name' => 'Photographs' );
$arg2 = array('category_name' => 'Quotes' );
$myposts1 = get_posts( $arg1 );
$myposts2 = get_posts( $arg2 );

我希望循环输出是这样的:

<article>
    Photographs
</article>
<article>
    Quotes
</article>
<article>
    Photographs
</article>
<article>
    Quotes
</article>
ect..

一旦我设置了结构,我就可以管理循环的输出。我知道如何在循环中添加以下标签,我只是不知道如何设置初始结构。

<?php
    the_title();
    the_permalink();
    the_post_thumbnail();
?>

为了使用 tempalte 标签,您必须在 WordPress 标准循环上循环。 我在滑块中添加了定制器选项以选择类别,并对模板进行了以下查询:

$st_portfolio_id = get_theme_mod( 'styledstore_slider_category' );
    $loop = new WP_Query( array( 'post_type' => 'product', 
        'tax_query' => array(
            array(
                'taxonomy' => 'product_cat',
                'terms'    => $st_portfolio_id
            ),
        )
    ) ); ?>

以下代码是从名为 Styled Store.

的 WordPress 免费主题中提取的

希望对您有所帮助