我从存档创建了一个分类页面。php,基于主题框架工作。我尝试了很多使边栏工作,但它什么也没有显示,甚至使用firebug它也不存在!
<?php
/**
* Template Name: MEDIT
*
* …
*
* @package Thematic
* @subpackage Templates
*/
// calling the header.php
get_header();
// action hook for placing content above #container
thematic_abovecontainer();
?>
<div id="container">
<?php
// action hook for placing content above #content
thematic_abovecontent();
// filter for manipulating the element that wraps the content
echo apply_filters( \'thematic_open_id_content\', \'<div id="content">\' . "\\n" );
?>
<?php
$term_slug = get_query_var( \'term\' );
$taxonomyName = get_query_var( \'taxonomy\' );
$current_term = get_term_by( \'slug\', $term_slug, $taxonomyName );
$args = array( \'child_of\' => $current_term->term_id, \'hide_empty\'=>false);
$terms = get_terms( \'tagportifolio\', $args);
$assoc = taxonomy_image_plugin_get_associations();
if (!empty($terms)):
?>
<?php /*?><?php
// calling the standard sidebar
dynamic_sidebar(\'cs-project-main-category\');
?><?php */?>
<?php foreach( $terms as $child ): ?>
<?php thematic_abovepost(); ?>
<div id="cat-<?php echo $child->term_id; ?>">
<?php
if(array_key_exists( $child->term_taxonomy_id, $assoc )){
echo wp_get_attachment_image( $assoc[$child->term_taxonomy_id], array(), false, \'thumbnail\');
}
?>
<h1 class="entry-title"><a href="<?php echo get_term_link( $child->name, $taxonomyName );?>">
<?php echo $child->name; ?></a ></h1><br/>
</div>
<?php thematic_belowpost();?>
<?php endforeach; ?>
<?php
else:
// start the loop
?>
<?php /*?><?php
// calling the standard sidebar
dynamic_sidebar(\'cs-sub-cat-sidebar\');
?><?php */?>
<!--</div> #content -->
<?php
endif;
?>
<?php
// action hook for placing content below #content
thematic_belowcontent();
?>
</div><!-- #container -->
<?php
// action hook for placing content below #container
thematic_belowcontainer();
// calling the standard sidebar
thematic_sidebar();
// calling footer.php
get_footer();
?>
你知道我的代码缺少什么吗?
SO网友:Rasha Nour Eldin
这是正确的模板,代码我应该使用,谢谢你的帮助
<?php
/**
* Archive Template
*
* Displays an Archive index of post-type items. Other more specific archive templates
* may override the display of this template for example the category.php.
*
* @package Thematic
* @subpackage Templates
*
* @link http://codex.wordpress.org/Template_Hierarchy Codex: Template Hierarchy
*/
// calling the header.php
get_header();
// action hook for placing content above #container
thematic_abovecontainer();
?>
<div id="container">
<?php
// action hook for placing content above #content
thematic_abovecontent();
// filter for manipulating the element that wraps the content
echo apply_filters( \'thematic_open_id_content\', \'<div id="content">\' . "\\n\\n" );
$term_slug = get_query_var( \'term\' );
$taxonomyName = get_query_var( \'taxonomy\' );
$current_term = get_term_by( \'slug\', $term_slug, $taxonomyName );
$args = array( \'child_of\' => $current_term->term_id, \'hide_empty\'=>false);
$terms = get_terms( \'tagportifolio\', $args);
$assoc = taxonomy_image_plugin_get_associations();
if (!empty($terms)):
foreach( $terms as $child ):
?>
<div id="cat-<?php echo $child->term_id; ?>">
<?php
if(array_key_exists( $child->term_taxonomy_id, $assoc )){
echo wp_get_attachment_image( $assoc[$child->term_taxonomy_id], array(), false, \'thumbnail\');
}
?>
<h1 class="entry-title"><a href="<?php echo get_term_link( $child->name, $taxonomyName );?>">
<?php echo $child->name; ?></a ></h1><br/>
</div>
<?php
endforeach;
endif;
?>
</div><!-- #content -->
<?php
// action hook for placing content below #content
thematic_belowcontent();
?>
</div><!-- #container -->
<?php
// action hook for placing content below #container
thematic_belowcontainer();
// calling the standard sidebar
thematic_sidebar();
// calling footer.php
get_footer();
?>
SO网友:jhussey
如果您已将侧栏文件命名为侧栏。php然后应该使用get\\u sidebar()而不是thematic\\u sidebar()。您是否在其他模板文件上使用了thematic\\u sidebar(),这是否有效?
EDIT
想帮助您调试,所以我编辑了我的答案
ok下载主题并安装在本地IDE中,
thematic_sidebar(){
$show = TRUE;
$show = apply_filters(\'thematic_sidebar\', $show);
if ($show)
get_sidebar();
return;
}
由于您是在线开发的,测试这一点的一种方法是回显语句,以确认您是否进入该函数
e、 g。echo \'<div>You made it into the sidebar function</div>\';
把这个放在上面$show = TRUE;
如果没有回音,则必须测试以前的函数,如果没有回音,则必须测试侧栏的路径。php文件可能已损坏。在本地测试,echo可以工作,所以请尝试一下,将代码复制并粘贴到侧边栏中,然后检查,在其他函数中尝试,以确保这些函数正在执行。希望这有帮助