我从以前的开发人员那里接管了一个网站,该开发人员构建了该网站的大部分内容。因为主题是自定义的,所以他选择使用Toolbox. 这个网站已经存在了一年多,是给我的,所以我们可以完成它。
我有一个问题,我无法使用Advanced Custom Fields 还有这个主题。我已经确定它不是ACF,因为我已经将主题更改为Wordpress默认的214主题,然后图像上传可以很好地用于该帖子。
经过一些研究,我意识到主题没有缩略图的主题支持,所以我通过放置add_theme_support(\'post-thumbnails\');
给我的toolbox_setup
my中的方法functions.php
文件当前该方法如下所示:
function toolbox_setup() {
/**
* Make theme available for translation
* Translations can be filed in the /languages/ directory
* If you\'re building a theme based on toolbox, use a find and replace
* to change \'toolbox\' to the name of your theme in all the template files
*/
load_theme_textdomain( \'toolbox\', get_template_directory() . \'/languages\' );
$locale = get_locale();
$locale_file = get_template_directory() . "/languages/$locale.php";
if ( is_readable( $locale_file ) )
require_once( $locale_file );
/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support( \'automatic-feed-links\' );
/**
* This theme uses wp_nav_menu() in one location.
*/
register_nav_menus( array(
\'primary\' => __( \'Primary Menu\', \'toolbox\' ),
) );
/**
* Add support for the Aside and Gallery Post Formats
*/
add_theme_support( \'post-formats\', array( \'aside\', \'image\', \'gallery\' ) );
// Enable support for Post Thumbnails, and declare two sizes.
add_theme_support( \'post-thumbnails\' );
set_post_thumbnail_size( 672, 372, true );
add_image_size( \'toolbox-full-width\', 1038, 576, true );
}
由于我是WordPress的新手,我不知道这样做是否能解决这个问题。我需要重新加载主题吗?我必须在其他地方添加这个吗?如何解决此问题?
UPDATE 1
我打开了调试,这就是我得到的错误。这只是在我打开媒体上载程序时。我注意到它确实上传了文件,只是没有显示/加载它们。
[06-Oct-2014 06:55:41 UTC] PHP Notice: Trying to get property of non-object in /Users/me/Server/intune/wp-content/themes/toolbox/functions.php on line 303
[06-Oct-2014 06:55:41 UTC] PHP Notice: Trying to get property of non-object in /Users/me/Server/intune/wp-content/themes/toolbox/functions.php on line 305
[06-Oct-2014 06:55:41 UTC] PHP Notice: Trying to get property of non-object in /Users/me/Server/intune/wp-content/themes/toolbox/functions.php on line 303
[06-Oct-2014 06:55:41 UTC] PHP Notice: Trying to get property of non-object in /Users/me/Server/intune/wp-content/themes/toolbox/functions.php on line 305
以下是代码中的对应行:
/**
* Filter in a link to a content ID attribute for the next/previous image links on image attachment pages
*/
function toolbox_enhanced_image_navigation( $url ) { //300
global $post, $wp_rewrite; //301
$id = (int) $post->ID; //303
$object = get_post( $id ); //304
if ( wp_attachment_is_image( $post->ID ) && ( $wp_rewrite->using_permalinks() && ( $object->post_parent > 0 ) && ( $object->post_parent != $id ) ) ) //305
$url = $url . \'#main\'; //306
return $url; //308
}
add_filter( \'attachment_link\', \'toolbox_enhanced_image_navigation\' ); //310