我需要将其用作背景图像,但这让我很痛苦,因为:
show_media_header()
将打印<a href="#">http://url/of/the/header</a>
我如何检索该值?所以我可以像我需要的那样打印出来?我需要将其用作背景图像,但这让我很痛苦,因为:
show_media_header()
将打印<a href="#">http://url/of/the/header</a>
我如何检索该值?所以我可以像我需要的那样打印出来?尝试此动态标题插件功能:
get_media_header_url()
而不是这个:show_media_header()
其定义为function get_media_header_url() {
global $post;
$post_id = $post->ID;
//Declare the wpdb var and table name and run the query to see if there is a media object associated with this post
global $wpdb;
$table_name = $wpdb->prefix . "custom_headers";
$check_q = $wpdb->get_row("SELECT * FROM $table_name WHERE post_id=\'$post_id\' AND header_type=\'media\' LIMIT 1");
//This large chunk of code determines what page we are on and whether to load a fixed or random header.
if(!is_home()){
if($check_q->url == \'Default\' || $check_q->url == \'\') {
$initial_file_value = get_option(\'dhnd_default\');
} else {
$initial_file_value = $check_q->url;
}
} else {
$initial_file_value = get_option(\'dhnd_homepage\');
}
$load_this_media = process_media_header($initial_file_value);
return $load_this_media;
}
我在@s\\u ha\\u dum提供的插件源代码中找到了它:http://plugins.trac.wordpress.org/browser/dynamic-headers/tags/3.5.3/custom-header.php#L394
它还具有以下功能dh_get_page_image_url()
和dh_get_page_link_url()
.是否可以使页面模板可用于多个或所有主题,而不必将页面模板保存在每个主题文件夹中?可能类似于:themes/globalform.php 而不是针对每个主题执行此操作themes/twentyten/globalform.php