2017-01-27 93 views
0

我正在創建我的第一個主題,它的工作正常。主題Wordpress不顯示插件的內容短代碼

但是,當我安裝了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代碼顯示在控制檯,但屏幕應該顯示的位置變白圖像

+0

這很可能是你的jQuery覆蓋導致問題。你爲什麼'註銷'jQuery?請使用WP附帶的jQuery。你的'page.php'模板看起來是正確的,**假設**這是你遇到問題時正在渲染的模板。 –

+0

@cale_b默認的wordpress Jquery被添加到頭文件中並且引導程序沒有工作,我無法註冊jquery的另一個版本以使引導程序正常工作,所以我只是通過取消註冊默認的jquery來設法啓動引導程序。而且我也不能把默認的jquery放在頁腳 – Gislef

+0

上,我根據你的建議做了。我試圖使用默認的jquery,但它沒有添加到標題中,所以插件還沒有出現在頁面上,並且引導程序也沒有工作 – Gislef

回答

0

我終於發現了問題。 我忘了在我的自定義主題的footer.php文件中放置<?php wp_footer(); ?>

這是導致錯誤。

1

最有可能的事情是這兩件事情之一:

  1. 您安裝了模板的模板沒有正確調用內容。短代碼通過名爲the_contentfilter進行擴展。當您在模板中使用the_content()時,將自動應用此篩選器。 請注意,使用get_the_content()不適用此過濾器,並且簡碼不會呈現
  2. 你的主題是以某種方式刪除the_content過濾器。您的主題中是否有任何內容,例如remove_filter()

如果您需要進一步的幫助,編輯您的問題,發佈您的代碼,並擴展您在查了一下/測試

既然您已經添加了您的代碼,我相信您使用自己的本地jQuery是可疑的,並且可能會導致問題。刪除註銷jquery的代碼段,然後註冊自己的版本。

注:您的代碼應該是這樣的 - 一定要排隊jQuery的,但利用內置的WP的jQuery:

function my_theme_enqueue_jquery() { 
    wp_enqueue_script('jquery'); 
} 

add_action('wp_enqueue_scripts', 'my_theme_enqueue_jquery'); 
+0

感謝您的回答。我在我的問題中插入了'function.php'和'page.php'的詳細信息 – Gislef

+0

@Gislef - 請參閱我添加到有關jQuery的問題的註釋以及這可能如何導致問題。 –

+0

終於找到解決辦法,看我的答案。感謝您的幫助@cale_b – Gislef