WordPress的发帖网格简码不会在类别模板中显示最新的发帖,而是显示所有其他发帖

我创建了一个post_type“案例研究”,创建了一个类别模板替代页面,并在该类别模板替代中调用了Post Grid Shortcode,但是它总是忽略了该类型的最新帖子。正确显示所有“案例研究”。

就像偏移量= 1 ...

代码-名为“ category-case-studies.php”的页面:

<?php
    get_header();
?>
<div <?php echo apply_filters('shrk-page-cover-atts','page-cover'); ?> >
<div class="container">
    <header class="page-header">
        <h1 class="page-title">Case Studies</h1>
    </header>
</div><!-- .entry-header -->
<?php do_action('shrk-page-cover-after'); ?>
</div>

<div class="container container-main-content">
<div class="row">
    <div class="main-content-inner">
        <div class="col-xs-12 col-sm-12 breadcrumb-inner">
            <?php
            if (function_exists('yoast_breadcrumb')) {
                yoast_breadcrumb('<nav id="woocommerce-breadcrumb">','</nav>');
            }
            ?>
        </div>
    </div>
</div>
</div>

<div class="container container-main-content">
<div class="row after-breadcrumb">
    <div class="main-content-inner col-12 <?php echo esc_attr(shrk_get_main_inner_class()); ?>">

        <?php
        echo do_shortcode('[vc_row][vc_column][vc_basic_grid post_type="post" max_items="10" element_width="6" grid_id="vc_gid:1575382949300-f7c10d1d-4924-6" taxonomies="96" offset="0"][/vc_column][/vc_row]');
        ?>

        <?php get_sidebar(); ?>

    </div><!-- close .*-inner (main-content or sidebar,depending if sidebar is used) -->
</div><!-- close .row -->
</div><!-- close .container .container-main-content -->

<?php get_footer(); ?>

虽然有点奇怪...其他类别类型显示该类别类型的所有帖子(只要选中,是的...)

我有一种感觉(尽管我不禁吸管),这与与类别类型具有相同名称/类型的类别页面有关……

任何建议表示赞赏。

##更新包含do_shortcode()
/**
 * Search content for shortcodes and filter shortcodes through their hooks.
 *
 * If there are no shortcode tags defined,then the content will be returned
 * without any filtering. This might cause issues when plugins are disabled but
 * the shortcode will still show up in the post or content.
 *
 * @since 2.5.0
 *
 * @global array $shortcode_tags List of shortcode tags and their callback hooks.
 *
 * @param string $content Content to search for shortcodes.
 * @param bool $ignore_html When true,shortcodes inside HTML elements will be skipped.
 * @return string Content with shortcodes filtered out.
 */
function do_shortcode( $content,$ignore_html = false ) {
    global $shortcode_tags;

    if ( false === strpos( $content,'[' ) ) {
        return $content;
    }

    if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) {
        return $content;
    }

    // Find all registered tag names in $content.
    preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@',$content,$matches );
    $tagnames = array_intersect( array_keys( $shortcode_tags ),$matches[1] );

    if ( empty( $tagnames ) ) {
        return $content;
    }

    $content = do_shortcodes_in_html_tags( $content,$ignore_html,$tagnames );

    $pattern = get_shortcode_regex( $tagnames );
    $content = preg_replace_callback( "/$pattern/",'do_shortcode_tag',$content );

    // Always restore square braces so we don't break things like <!--[if IE ]>
    $content = unescape_invalid_shortcodes( $content );

    return $content;
}
dukx95 回答:WordPress的发帖网格简码不会在类别模板中显示最新的发帖,而是显示所有其他发帖

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2984582.html

大家都在问