为主题挂钩增加功能

时间:2012-07-30 作者:Rasha Nour Eldin

我是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 foreach( $terms as $child ): ?>
<?php  if(array_key_exists( $child->term_taxonomy_id, $assoc )){echo wp_get_attachment_image( $assoc[$child->term_taxonomy_id], array(), false, \'thumbnail\');
                                                        } 
                                                    ?>
<a href="<?php echo get_term_link( $child->name, $taxonomyName );?>"><?php echo $child->name; ?></a ><br/>
<?php endforeach; ?>
<?php else: ?>
有什么帮助吗?

1 个回复
最合适的回答,由SO网友:Rasha Nour Eldin 整理而成

谢谢你的帮助我找到了解决方案

<?php
/**
 * Page Template
 *
 * …
 * 
 * @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" );

                    // calling the widget area \'page-top\'
                get_sidebar(\'page-top\');
                    $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 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
                            while ( have_posts() ) : the_post();
                            // action hook for placing content above #post
                                thematic_abovepost();
                        ?>

                        <?php
                                echo \'<div id="post-\' . get_the_ID() . \'" \';
                                // Checking for defined constant to enable Thematic\'s post classes
                                if ( ! ( THEMATIC_COMPATIBLE_POST_CLASS ) ) {
                                        post_class();
                                        echo \'>\';
                                } else {
                                        echo \'class="\';
                                        thematic_post_class();
                                        echo \'">\';
                                }
                                thematic_postheader();
                        ?>

                                <div class="entry-content">

                                    <?php the_content(); ?>

                                </div><!-- .entry-content -->

                        </div><!-- #post -->

            <?php
                // action hook for inserting content below #post
                thematic_belowpost();

                // action hook for calling the comments_template
                //thematic_comments_template();

                // end loop
                endwhile;
                        endif;

                // calling the widget area \'page-bottom\'
                get_sidebar( \'page-bottom\' );
            ?>

            </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();
?>

结束

相关推荐