为什么图库插件的输出没有显示到我的 WordPress 自定义主题的页面中?

Why the oputput of an image gallery plugin is not displayed into a page of my WordPress custom theme?

我是 WordPress 开发人员的新手,我对自己从 0 开始开发的主题感到疯狂。

因此,在此 link 您可以下载整个主题,以便详细查看整个代码:http://www.asper-eritrea.com/AsperThemeV2.zip

在这个网站上,我尝试安装一个名为 GMedia Gallery 的图库插件(我也尝试过使用其他插件,但我遇到了类似的问题),这个:https://it.wordpress.org/plugins/grand-media/

我用这个插件创建了一个画廊,然后进入:

Appereance --> Menu --> GMedia Gallery ---> My Gallery 我将创建的图库作为页面添加到我的主菜单。

这里我遇到了一个大问题,因为使用我的自定义主题,点击相关的 link 进入主菜单,画廊没有显示,页面 appera 是空的,正如你在这里看到的:

http://www.asper-eritrea.com/gmedia-gallery/eventi-e-manifestazioni/

我很确定这是与我的主题相关的问题,因为切换到任何默认的 WordPress 主题(例如 Twenty Twelve)时,图库会完美地显示在页面,这里是证明此断言的屏幕截图:

所以问题必须与我的自定义主题有关,因为使用另一个主题它工作正常!!!

我真的不知道这个问题的原因。我认为这可能取决于我自定义了 content-page.php 文件,或者它可能与某些 JQuery 问题相关。

在具体的情况下,你可以看到打开主题项目,我将JQuery添加到/assets/js/目录中,然后我有在function.php文件中添加对主题的JQuery支持,这样:

/* Function automatically executed by the hook 'load_java_scripts':
 * 1) Load all my JavaScripts
 */
function load_java_scripts() {

    // Load JQuery:
    wp_enqueue_script('jquery');
    // Load FlexSlider JavaScript
    wp_enqueue_script('flexSlider-js', get_template_directory_uri() . '/assets/plugins/flexslider/jquery.flexslider.js', array('jquery'), 'v2.1', true);
    // Load bootstrap.min.js:
    wp_enqueue_script('bootstrap.min-js', get_template_directory_uri() . '/assets/bootstrap/js/bootstrap.min.js', array('jquery'), 'v3.0.3', true);

    // Load FancyBox:
    wp_enqueue_script('fancy-js', get_template_directory_uri() . '/assets/plugins/fancybox/jquery.fancybox.pack.js', array('jquery'), 'v2.1.5', true);
    // Load scripts.js:
    wp_enqueue_script('myScripts-js', get_template_directory_uri() . '/assets/js/scripts.js', array('jquery'), '1.0', true);
    // Load Modernizer:
    wp_enqueue_script('myodernizer-js', get_template_directory_uri() . '/assets/js/modernizr.custom.js', array('jquery'), '2.6.2', true);

}

add_action('wp_enqueue_scripts', 'load_java_scripts');

但我不太确定它是否正确,因为当我这样做时:

// Load JQuery:
wp_enqueue_script('jquery');

我没有指定 jquery.js 文件的路径,所以到底在做什么? (我已经做过很多次了)。

那可能是什么问题呢?我该如何尝试修复它?

非常感谢

编辑 1:按照建议,我将分析 content-page.php 文件的内容page.php 中使用的模板代表 CMS 中的通用页面(我认为可能是放置图库插件内容的地方):

<?php
/**
 * The default template for displaying content
 *
 * Used for both single and index/archive/search.
 *
 * @package WordPress
 * @subpackage AsperTheme
 * @since AsperTheme 1.0
 */
?>


<!-- Create a div with a unique ID thanks to the_ID() and semantic classes with post_class() 
     the_ID(): Print the numeric ID of the current post 
     post_class(): Print out and add various post-related classes to the div tag
-->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>                              

    <header>
        <h3 class="entry-title">
                <a href="<?php the_permalink(); ?>" 
                   title="<?php printf(__('Permalink to %s', 'your-theme'), the_title_attribute('echo=0')); ?>"
                   rel="bookmark"><?php the_title(); ?>
                </a>

        </h3>

        <div class="entry-meta-page">
            <span class="meta-prep meta-prep-author"><?php _e('By ', 'your-theme'); ?></span>
            <span class="author vcard">
                <a class="url fn n" href="<?php echo get_author_link(false, $authordata -> ID, $authordata -> user_nicename); ?>" 
                                    title="<?php printf(__('View all posts by %s', 'your-theme'), $authordata -> display_name); ?>"><?php the_author(); ?>
                </a>
            </span>
            <span class="meta-sep"> | </span>
            <span class="meta-prep meta-prep-entry-date"><?php _e('Published ', 'your-theme'); ?></span>
            <span class="entry-date">
                <abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>"><?php the_time(get_option('date_format')); ?></abbr>
            </span>
            <?php edit_post_link( __( 'Edit', 'your-theme' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t" ) ?>
         </div>     <!-- .entry-meta -->

    </header>

    <div class="entry-content">    
        <?php the_content(__('Continue reading <span class="meta-nav">&raquo;</span>', 'your-theme')); ?>
        <?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'your-theme' ) . '&after=</div>') ?>
    </div>      <!-- .entry-content -->

    <!--
    <div class="entry-utility">

        <span class="cat-links">
            <span class="entry-utility-prep entry-utility-prep-cat-links"><?php _e('Posted in ', 'your-theme'); ?></span>
            <?php echo get_the_category_list(', '); ?>
        </span>

        <span class="meta-sep"> | </span>

        <?php the_tags( '<span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links">' . __('Tagged ', 'your-theme' ) . '</span>', ", ", "</span>\n\t\t\t\t\t\t<span class=\"meta-sep\">|</span>\n" ) ?>
            <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'your-theme' ), __( '1 Comment', 'your-theme' ), __( '% Comments', 'your-theme' ) ) ?></span>
            <?php edit_post_link( __( 'Edit', 'your-theme' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t\n" ) ?>
    </div>      <!-- #entry-utility 
    -->

</article>  <!-- #post-<?php the_ID(); ?> -->

所以这里好像没有提到the_content()函数。但是为什么我必须使用 the_content() 函数来显示我的画廊?官方文档上说是用来显示post内容,那跟插件输出有什么关系?

在您的网站上,我在 entry-content 块中看到了画廊,但它有评论,因此没有显示。

查看下面的代码:

<div class="entry-content">
  <!--<div class="gmedia_gallery phantom_module" id="GmediaGallery_3" data-gallery="3" data-module="phantom"> ... </div>-->
</div>

在其他页面(例如here)您的内容显示两次:第一次有评论,第二次没有评论并正常显示。

尝试检查single.php内容中的the_content()函数-page.php.

这可能会有所帮助。

更新 1

这里是复制页面内容的代码。文件 contentPost.php [line:47]:

<!--<?php the_content(__('Continue reading <span class="meta-nav">&raquo;</span>', 'your-theme')); ?>-->

必须删除或正确注释此代码:

<?php //the_content(__('Continue reading <span class="meta-nav">&raquo;</span>', 'your-theme')); ?>

我正在激活您的主题并使用测试图库创建 post http://template.dev-city.me/gallery/

更新 2

更多关于 WordPress 主题开发的信息。