Wordpress Shortcodes不用于帖子(single.php)但在页面上工作(page.php)

问题描述 投票:1回答:1

经过一天的努力寻找解决方案后,我正在寻求帮助。

我的活动插件中有短代码,它们在页面上工作正常但不适用于单个帖子页面(single.php)。通过不工作我的意思是完全没有加载到最后的前端源(没有所需的代码,甚至没有短代码片段本身)。

我正在使用全新安装的_underscores生成主题。

注意:我知道这是以某种方式阻碍短代码的主题,因为当我将主题更改为二十五个短代码时。

我尝试了大约30个解决方案(使用debug on,安装文件...没有错误,没有警告)

我真的很感激有关如何在我的主题中找到错误的一些帮助或建议。

这是我的设置:我的single.php和content.php

single.php中

<?php
/**
 * The template for displaying all single posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
 *
 * @package MyTheme
 */

get_header(); ?>

    <div id="primary" class="content-area">
        <main id="main" class="site-main">

        <?php
        while ( have_posts() ) : the_post();

            get_template_part( 'template-parts/content', get_post_type() );

            the_post_navigation();

            // If comments are open or we have at least one comment, load up the comment template.
            if ( comments_open() || get_comments_number() ) :
                comments_template();
            endif;

        endwhile; // End of the loop.
        ?>

        </main><!-- #main -->
    </div><!-- #primary -->

<?php
get_sidebar();
get_footer();

content.php

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

    <header class="entry-header">

        <?php the_title( sprintf( '<h3 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h3>' ); ?>

        <?php if ( 'post' == get_post_type() ) : ?>

        <div class="post-details">
            <div class="post-details-left">
                <i class="fa fa-user-circle"></i> <?php the_author(); ?>
                <i class="fa fa-history"></i> <time><?php the_date(); ?></time>
                <i class="fa fa-sticky-note"></i> <?php the_category(', '); ?>
                <i class="fa fa-tags"></i><?php the_tags('', ', ', ''); ?>
                <?php edit_post_link( 'Edit', '<i class="fa fa-pencil"></i>', '' ); ?>
            </div>

            <div class="post-details-right">
                <div class="post-comments-badge">
                    <a class="post-comments-badge-link" href="<?php comments_link(); ?>"><i class="fa fa-comments"></i> <?php comments_number( 0, 1, '%'); ?></a>
                </div>
            </div>

        </div>

        <?php endif; ?>
    </header>


    <?php if ( has_post_thumbnail() ) { ?>
    <div class="post-image">
        <div class="post-image-hvr">
            <?php the_post_thumbnail(); ?>
        </div>
    </div>
    <?php } ?>


    <div class="post-excerpt">
        <?php the_excerpt(); ?>
    </div>

</article>

再次,非常欢迎任何建议!

php wordpress shortcode underscores-wp
1个回答
2
投票

你实际上并没有输出页面内容(例如the_content());只是摘录(the_excerpt())。

你写过有问题的短代码吗?你有add a filter for the excerpt吗?

© www.soinside.com 2019 - 2024. All rights reserved.