【发布时间】:2016-02-28 11:55:31
【问题描述】:
作为 WordPress 开发人员,我很新,我对自己从 0 开始开发的主题感到疯狂。
因此,您可以在此链接下载整个主题,以便在详细信息中查看整个代码:http://www.asper-eritrea.com/AsperThemeV2.zip
在这个网站上,我尝试安装一个名为 GMedia Gallery 的图片库插件(我也尝试过使用其他插件,但我遇到了类似的问题),这个:https://it.wordpress.org/plugins/grand-media/
使用这个插件,我创建了一个画廊,然后进入:
外观 --> 菜单 --> GMedia 画廊 ---> 我的画廊 我将创建的画廊作为页面添加到我的主菜单中。
这里我有一个大问题,因为使用我的自定义主题,点击相关链接进入主菜单,画廊没有显示并且页面是空的,你可以在这里看到:
http://www.asper-eritrea.com/gmedia-gallery/eventi-e-manifestazioni/
我很确定这是与我的主题相关的问题,因为切换到任何默认 WordPress 主题(例如 二十十二)画廊都完美地显示在页面中,这里是屏幕截图这证明了这个断言:
所以问题必须与我的自定义主题有关,因为使用另一个主题可以正常工作!!!
我真的不知道这个问题的原因。我认为这可能取决于我自定义了 content-page.php 文件的事实,或者它可能与某些 JQuery 问题有关。
在具体情况下,如您所见,打开主题项目,我已将 JQuery 添加到 /assets/js/ 目录中,然后将主题的 JQuery 支持添加到 function.php 文件,这样:
/* 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 文件的路径,那么究竟在做什么呢? (我以前做过很多次)。
那么可能是什么问题?我该如何尝试修复它?
太多了
EDIT 1:按照建议,我将分析 content-page.php 文件的内容,该文件应该代表 页面中使用的模板。 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">»</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() 函数来显示我的画廊呢?这里官方文档说是用来显示帖子内容,这和插件输出有什么关系?
【问题讨论】:
标签: php wordpress content-management-system wordpress-theming