为什么有些Wordpress主题没有';没有标题图像部分
我是Wordpress的新手。我想知道。为什么有些Wordpress主题在主题自定义中没有标题图像部分?如何将此部分添加到主题定制器?有什么办法吗 还有一个问题。如何在主题定制器中修改上载文件图像? 我想添加更多的田地并更改作物大小为什么有些Wordpress主题没有';没有标题图像部分,wordpress,Wordpress,我是Wordpress的新手。我想知道。为什么有些Wordpress主题在主题自定义中没有标题图像部分?如何将此部分添加到主题定制器?有什么办法吗 还有一个问题。如何在主题定制器中修改上载文件图像? 我想添加更多的田地并更改作物大小 这取决于WordPress主题开发人员如何设计和开发主题,但您可以通过在定制器区域中添加自己的选项(图像、文本区域、输入)字段来实现 下面是在function.php文件中添加此代码的示例 // Header Logo function add_logo_
这取决于WordPress主题开发人员如何设计和开发主题,但您可以通过在定制器区域中添加自己的选项(图像、文本区域、输入)字段来实现 下面是在function.php文件中添加此代码的示例
// Header Logo
function add_logo_customizer($wp_customize) {
$wp_customize->add_section(
'logo_image',
array(
'title' => 'Logo Image',
'priority' => 45,
)
);
$wp_customize->add_setting( 'Logo-upload' );
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'lp-image_selector',
array(
'label' => 'Logo Image',
'section' => 'logo_image',
'settings' => 'Logo-upload'
)
)
);
}
add_action('customize_register', 'add_logo_customizer');
您可以将其称为
上面的代码经过测试,可以正常工作
这取决于WordPress主题开发人员如何设计和开发主题,但您可以通过在定制器区域中添加自己的选项(图像、文本区域、输入)字段来实现 下面是在function.php文件中添加此代码的示例
// Header Logo
function add_logo_customizer($wp_customize) {
$wp_customize->add_section(
'logo_image',
array(
'title' => 'Logo Image',
'priority' => 45,
)
);
$wp_customize->add_setting( 'Logo-upload' );
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'lp-image_selector',
array(
'label' => 'Logo Image',
'section' => 'logo_image',
'settings' => 'Logo-upload'
)
)
);
}
add_action('customize_register', 'add_logo_customizer');
您可以将其称为
上面的代码经过测试,可以正常工作
首先,您需要添加对自定义标题的支持 见法典: 显然,您需要使用代码创建一个php文件并包含在functions.php中,或者直接将代码添加到functions.php文件中
function themename_custom_header_setup() {
$defaults = array(
// Default Header Image to display
'default-image' => get_template_directory_uri() . '/images/headers/default.jpg',
// Display the header text along with the image
'header-text' => false,
// Header text color default
'default-text-color' => '000',
// Header image width (in pixels)
'width' => 1000,
// Header image height (in pixels)
'height' => 198,
// Header image random rotation default
'random-default' => false,
// Enable upload of image file in admin
'uploads' => false,
// function to be called in theme head section
'wp-head-callback' => 'wphead_cb',
// function to be called in preview page head section
'admin-head-callback' => 'adminhead_cb',
// function to produce preview markup in the admin screen
'admin-preview-callback' => 'adminpreview_cb',
);
}
add_action( 'after_setup_theme', 'themename_custom_header_setup' );
然后在header.php上获取图像并将其放入所需的位置
<?php if ( get_header_image() ) : ?>
<div id="site-header">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
<img src="<?php header_image(); ?>" width="<?php echo absint( get_custom_header()->width ); ?>" height="<?php echo absint( get_custom_header()->height ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
</a>
</div>
*functions.php位于主题文件夹的根目录下,如果主题使用“子主题”,请使用此文件夹进行更改
回答您的问题,当您上传图像时,您可以裁剪图像并调整其大小。Wordpress无法作为编辑器编辑照片,只能调整大小和裁剪。首先,您需要添加对自定义标题的支持 见法典: 显然,您需要使用代码创建一个php文件并包含在functions.php中,或者直接将代码添加到functions.php文件中
function themename_custom_header_setup() {
$defaults = array(
// Default Header Image to display
'default-image' => get_template_directory_uri() . '/images/headers/default.jpg',
// Display the header text along with the image
'header-text' => false,
// Header text color default
'default-text-color' => '000',
// Header image width (in pixels)
'width' => 1000,
// Header image height (in pixels)
'height' => 198,
// Header image random rotation default
'random-default' => false,
// Enable upload of image file in admin
'uploads' => false,
// function to be called in theme head section
'wp-head-callback' => 'wphead_cb',
// function to be called in preview page head section
'admin-head-callback' => 'adminhead_cb',
// function to produce preview markup in the admin screen
'admin-preview-callback' => 'adminpreview_cb',
);
}
add_action( 'after_setup_theme', 'themename_custom_header_setup' );
然后在header.php上获取图像并将其放入所需的位置
<?php if ( get_header_image() ) : ?>
<div id="site-header">
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
<img src="<?php header_image(); ?>" width="<?php echo absint( get_custom_header()->width ); ?>" height="<?php echo absint( get_custom_header()->height ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>">
</a>
</div>
*functions.php位于主题文件夹的根目录下,如果主题使用“子主题”,请使用此文件夹进行更改
回答您的问题,当您上传图像时,您可以裁剪图像并调整其大小。Wordpress不能作为编辑器编辑照片,只能调整大小和裁剪。谢谢。关于第二个问题。我想知道上传时如何修改裁剪尺寸让我了解一下,您想在上传时为所有图像指定默认裁剪尺寸吗?我希望你的主题图片在他们的卡片上有一个大小(例如300x250),并且你希望所有的图片在上传后显示为300x250,而与原始大小无关。。。对吗?对,对。我想知道在哪里设置这个配置:设置->媒体我认为媒体设置只是一个最大参数,而不是一个精确的裁剪。如果你需要精确裁剪,你可以尝试使用插件或使用TimThumb()之类的脚本来创建精确的大小、压缩和其他过滤器。谢谢。关于第二个问题。我想知道上传时如何修改裁剪尺寸让我了解一下,您想在上传时为所有图像指定默认裁剪尺寸吗?我希望你的主题图片在他们的卡片上有一个大小(例如300x250),并且你希望所有的图片在上传后显示为300x250,而与原始大小无关。。。对吗?对,对。我想知道在哪里设置这个配置:设置->媒体我认为媒体设置只是一个最大参数,而不是一个精确的裁剪。如果您需要精确裁剪,您可以尝试使用插件或使用TimThumb()之类的脚本来创建精确的大小、压缩和其他过滤器。