主题Wordpress没有显示插件的内容短代码

时间:2017-01-27 21:34:10

标签: wordpress wordpress-theming

我正在创建我的第一个主题,并且它正常工作。

但是当我安装2个插件并在我的主题中插入短代码时,网站上没有任何内容。

我选择了另一个主题,它通常是插件,可能会发生什么?

function.php

 <?php

require_once('inc/redux-framework-master/redux-framework.php');
require_once('inc/office-master-theme-options.php');


add_theme_support( 'post-thumbnails', array( 'post','page' ) );

function enqueue_jquery() {

    wp_deregister_script('jquery' ); 


    wp_register_script( 
         'jquery', 
         get_template_directory_uri() . '/js/jquery.js',
         array(), 
         '1.11.1', 
         false
    );


    wp_enqueue_script( 'jquery');
} 
add_action('wp_enqueue_scripts', 'enqueue_jquery');



function enqueue_styles_scripts() {


    wp_enqueue_style(
        'style-theme',
        get_stylesheet_uri(),
        array('bootstrap-css')
    );


    wp_enqueue_style(
        'bootstrap-css',
        get_template_directory_uri() . '/css/bootstrap.min.css'
    );


    wp_enqueue_style(
        'stylish-portfolio',
        get_template_directory_uri() . '/css/stylish-portfolio.css'
    );


    wp_enqueue_style(
        'font-awesome',
        get_stylesheet_directory_uri() . '/css/font-awesome.css'

    ); 



    wp_enqueue_script(
        'bootstrap-js',
        get_template_directory_uri() . '/js/bootstrap.min.js',null
    );


} 
add_action('wp_enqueue_scripts', 'enqueue_styles_scripts');



function wpse_ie_conditional_scripts() { ?>
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <?php
}
add_action( 'wp_head', 'wpse_ie_conditional_scripts' );





require_once('wp_bootstrap_navwalker.php');
register_nav_menus( array(
     'primary' => __( 'Main Menu', 'THEMENAME' ),
) );


?>

page.php文件

<?php get_header(); ?>


            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                <div class="article">
                    <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
                    <p><?php echo do_shortcode('[meta_gallery_slider]'); ?></p>
                    <p><?php the_content(); ?></p>
                </div>
            <?php endwhile; else: ?>
                <div class="article">
                    <p>Error 404</p>
                </div>          
            <?php endif; ?>



        <?php get_sidebar(); ?>

<?php get_footer(); ?>

图库图像的htmls和src标签显示在控制台中,但屏幕在应显示图像的位置变为白色

2 个答案:

答案 0 :(得分:1)

最可能的事情是这两件事之一:

  1. 您安装模板的模板未正确调用内容。短代码通过名为filterthe_content进行扩展。在模板中使用the_content()时,系统会自动应用此过滤器。 请注意,使用get_the_content()不会应用此过滤器,并且不会呈现短代码
  2. 您的主题以某种方式移除the_content过滤器。你的主题中是否有remove_filter()运行的内容?
  3. 如果您需要进一步的帮助,编辑您的问题并发布您的代码,并展开您已检查/测试过的内容

    由于您已经添加了代码,我相信您使用自己的本地jQuery是可疑的,并且可能导致问题。删除取消注册jquery的代码段,然后注册自己的版本。

    注意:您的代码应如下所示 - 确保将jQuery排入队列,但利用内置的WP jQuery:

    function my_theme_enqueue_jquery() {
        wp_enqueue_script( 'jquery' );
    } 
    
    add_action('wp_enqueue_scripts', 'my_theme_enqueue_jquery');
    

答案 1 :(得分:0)

我终于找到了问题。 我忘记将<?php wp_footer(); ?>放入自定义主题的footer.php文件中。

这导致错误。