我想包括相关帖子后的广告代码

时间:2012-10-18 作者:Smart Shovon

我想在相关的贴子插件之后加入广告HTML代码。My site 我的single.php 代码如下:

            <?php if ( get_option(\'wap8_author_gravatar\') == \'true\' ) { ?>
            <div id="post-header"><!-- Begin post header -->
                <div class="post-title clear"><!-- Begin post title -->
                    <div class="header-gravatar">
                        <p><?php echo get_avatar( get_the_author_meta(\'email\'), \'50\' ); ?></p>
                    </div>

                    <div class="header-title">
                        <h1><?php the_title(); ?></h1>
                    </div>
                </div><!-- End post title -->
                <div id="post-data">
                    <p><?php _e(\'Written by\',\'periodic\'); ?> <?php the_author(); ?>. <?php _e(\'Posted in\',\'periodic\'); ?> <?php the_category(\', \'); ?>
                </div>
            </div><!-- End post header -->

            <?php } else { ?>
            <div id="post-header-wide"><!-- Begin post header -->
                <div class="header-title">
                    <h1><?php the_title(); ?></h1>
                </div>

                <div id="post-data">
                    <p><?php _e(\'Written by\',\'periodic\'); ?> <?php the_author(); ?>. <?php _e(\'Posted in\',\'periodic\'); ?> <?php the_category(\', \'); ?></p>
                    <?php the_tags(\'<p>Tagged: \', \', \', \'</p>\'); ?>
                </div>
            </div><!-- End post header -->              
            <?php } ?>

            <?php if ( get_option(\'wap8_post_img\') == \'true\' ) { ?>         
            <div id="lead-image"><!-- Begin lead image -->
            <?php if ( has_post_thumbnail() ) { ?>
                <p><?php the_post_thumbnail(\'thumbnail-leadimg\'); ?></p>
            <?php } else { ?>
                <p><img src="<?php echo get_template_directory_uri(); ?>/images/thumbnails/thumbnail-leadimg.jpg" width="610" height="225" alt="<?php the_title_attribute(); ?>" /></p>
            <?php } ?>
            </div><!-- End lead image -->
            <?php } ?>

            <div class="published"><!-- Begin published -->
                <p><?php _e(\'Published on\',\'periodic\'); ?> <?php the_time(\'F d, Y\'); ?> <?php _e(\'with\',\'periodic\'); ?> <a class="scroll-it" href="#comments" title="<?php comments_number(__(\'No Comments\',\'periodic\'),__(\'1 Comment\',\'periodic\'),__(\'% Comments\',\'periodic\')); ?>"><?php comments_number(__(\'No Comments\',\'periodic\'),__(\'1 Comment\',\'periodic\'),__(\'% Comments\',\'periodic\')); ?></a></p>
            </div><!-- End published -->

            <?php if ( get_option(\'wap8_share_show\') == \'true\' ) { ?><!-- Begin posts with share column option -->              
            <div class="post-columns clear"><!-- Begin post columns -->
                <div <?php post_class( \'post-460 post-entry\' ); ?>><!-- Begin post entry -->
                <?php the_content(); ?>

                <?php wp_link_pages(\'before=<p class="post-pager">\' . __(\'<span>Pages:</span>\', \'periodic\') . \'&after=</p>&next_or_number=number&pagelink=%\'); ?>
                </div><!-- End post entry -->

                <div class="post-left-column"><!-- Begin post left column -->
                    <h3 class="widget-head"><?php echo( stripslashes ( get_option(\'wap8_share_title\') ) );?></h3>
                    <ul class="share-actions">
                        <?php if ( get_option(\'wap8_show_twitter\') == \'true\' ) { ?><li><a href=<?php echo wap8_twitter_share_url(); ?> class="twitter-share-button" data-count="horizontal" data-via="<?php echo( stripslashes ( get_option(\'wap8_twitter_user\') ) );?>"><?php _e( \'Tweet\', \'periodic\' ); ?></a></li><?php } ?>
                        <?php if ( get_option(\'wap8_show_su\') == \'true\' ) { ?><li><script src="http://www.stumbleupon.com/hostedbadge.php?s=1"></script></li><?php } ?>
                        <?php if ( get_option(\'wap8_show_digg\') == \'true\' ) { ?><li><a class="DiggThisButton DiggCompact"></a></li><?php } ?>
                        <?php if ( get_option(\'wap8_show_gbuzz\') == \'true\' ) { ?><li><a title="Post to Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="small-button"></a></li><?php } ?>
                        <?php if ( get_option(\'wap8_show_email\') == \'true\' ) { ?><li><a class="share-button" href="mailto:?subject=<?php the_title_attribute(); ?>&amp;body=<?php _e(\'Thought you might like this:\',\'periodic\'); ?> <?php the_title_attribute(); ?> &#150; <?php the_permalink(); ?>" title="<?php _e(\'Email\',\'periodic\'); ?> &#147;<?php the_title_attribute(); ?>&#148; <?php _e(\'to a friend\',\'periodic\'); ?>"><?php _e(\'Email This\',\'periodic\'); ?></a></li><?php } ?>
                        <?php if ( get_option(\'wap8_show_print\') == \'true\' ) { ?><li><a class="share-button" href="JavaScript:window.print();" title="<?php _e(\'Print\',\'periodic\'); ?> &#147;<?php the_title_attribute(); ?>&#148;"><?php _e(\'Print This\',\'periodic\'); ?></a></li><?php } ?>
                    </ul>
                </div><!-- End post left column -->
            </div><!-- End post columns -->
            <?php } else { ?><!-- End post share column option -->
                <div <?php post_class( \'post-620 post-entry\' ); ?>><!-- Begin post entry -->
                <?php the_content(); ?>

                <?php wp_link_pages(\'before=<p class="post-pager">\' . __(\'<span>Pages:</span>\', \'periodic\') . \'&after=</p>&next_or_number=number&pagelink=%\'); ?>
                </div><!-- End post entry -->
            <?php } ?>

            <?php if ( get_option(\'wap8_post_author\') == \'true\' ) { ?>
            <div id="author-box" class="clear"><!-- Begin author box -->
                <h3><?php _e(\'About\',\'periodic\'); ?> <?php the_author(); ?></h3>
                <div class="post-gravatar">
                    <p><?php echo get_avatar( get_the_author_meta(\'email\'), \'50\' ); ?></p>
                </div>
                <div id="author-text">
                    <p><?php the_author_meta( \'description\' ); ?></p>

                    <p class="last"><?php _e(\'Browse Archived Articles by\',\'periodic\'); ?> <a class="right-arrow" href="<?php echo home_url(); ?>/author/<?php the_author_meta(\'user_nicename\'); ?>" rel="bookmark" title="<?php _e(\'Browse Archived Articles by\',\'periodic\') ?> <?php the_author(); ?>"><?php the_author(); ?></a></p>
                </div>
            </div><!-- End author box -->
            <?php } ?>

            <?php if ( get_option(\'wap8_post_rel\') == \'true\' ) { locate_template( \'/includes/relatedposts.php\', true, true ); } ?>

            <?php comments_template( \'\', true ); ?>
        <?php endwhile; endif ?>
        </div><!-- End left column -->

        <?php get_sidebar(\'right\'); ?>
    </div><!-- End column container -->
</div><!-- End inner wrapper -->

1 个回复
最合适的回答,由SO网友:Daniel Sachs 整理而成

我在这里完全是在猜测,但您可能希望将代码放在以下两者之间:

<?php if ( get_option(\'wap8_post_rel\') == \'true\' ) { locate_template( \'/includes/relatedposts.php\', true, true ); } ?> // these are your related posts
以及

<?php comments_template( \'\', true ); ?> //these are the comments 

结束