首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wordpress短代码不是在文章(single.php)上工作,而是在页面上工作(page.php)

Wordpress短代码不是在文章(single.php)上工作,而是在页面上工作(page.php)
EN

Stack Overflow用户
提问于 2018-03-03 14:13:05
回答 1查看 1.6K关注 0票数 1

在没有找到解决办法的一天之后,我在寻求帮助。

我在我的活动插件中有短代码,它们在页面上工作得很好,但是不能在单个post页面(single.php)上工作。不工作的意思是完全不加载最终的前端源代码(没有所需的代码,甚至是短代码片段本身)。

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

注意:,我知道是这个主题阻碍了,因为当我将主题更改为二十五个时,这些短代码就起作用了。

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

对于如何在我的主题中找到bug,我真的很感激一些帮助或建议。

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

single.php

代码语言:javascript
复制
<?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

代码语言:javascript
复制
<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>

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-03-03 14:23:29

您实际上并没有输出页面内容(例如the_content());只是一个节选(the_excerpt())。

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49085043

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档