所以我在做这样一个查询:
$the_query = new WP_Query( array( \'meta_key\' => \'homepage\', \'meta_value\' => \'yes\',
\'post_type\' => \'page\', \'orderby\' => \'modified\', \'posts_per_page\' => 1 ) );
要获取具有特定键值的单个页面,如何从这样的查询中获取页面模板(如果有)?非常感谢。
所以我在做这样一个查询:
$the_query = new WP_Query( array( \'meta_key\' => \'homepage\', \'meta_value\' => \'yes\',
\'post_type\' => \'page\', \'orderby\' => \'modified\', \'posts_per_page\' => 1 ) );
要获取具有特定键值的单个页面,如何从这样的查询中获取页面模板(如果有)?非常感谢。
这应该对你有好处。这将显示存储在中的模板文件post_meta
, 如果在管理面板中选择了一个:
$template_name = get_post_meta( $the_query->post->ID, \'_wp_page_template\', true );
is_home()
或is_front_page()
.如果要查看生成页面的文件,请在函数中使用此选项。php:
// Returns a list of files used to generate the page. Best called in footer.php before </body>
function _dump_files()
{
# @todo Aufrufende Datei kann im Array manchmal fehlen!
add_action( \'all\', create_function( \'\', "echo \'<pre>\'; print_r( get_included_files() ); echo \'</pre>\'; return;" ) );
}
我用在footer.php
像这样:if (is_user_logged_in()) {
_dump_files() ;
}
我使用的一种快速方法是WordPress global$template
. 我也在页面源代码中输出它。
就在收盘前</body>
标签global $template;
echo \'<!-- the template is:\' . $template . \'-->\';
或作为一种功能:
add_action(\'wp_footer\', \'show_template\');
function show_template() {
global $template;
echo \'<!-- the template is:\' . $template . \'-->\';
}
我正在使用wp\\u enqueue\\u脚本来执行此操作。如果我尝试做其他事情,比如弹出一个对话框,它会工作,但下面的代码不会。谁能告诉我这个问题吗。谢谢var $j = jQuery.noConflict(); $j(\'#mystuff\').hide(); var mouseLastYPos = null; $j(document).mousemove(function(e){ if(mouseLastYPos){