显示循环中的所有帖子

时间:2013-02-19 作者:Danny Michel

此处显示此代码

<div class="col">
        <?php gab_dynamic_sidebar(\'Subnews1\');?>

        <?php
        $postnr = of_get_option(\'of_wn_nr8\') + of_get_option(\'of_wn_nr8a\');
        if (intval($postnr) > 0 ) { ?>
            <span class="catname"><a href="<?php echo get_category_link(of_get_option(\'of_wn_cat8\'));?>"><?php echo get_cat_name(of_get_option(\'of_wn_cat8\')); ?></a></span>
            <?php
            $count = 1;
            $args = array(
             \'post__not_in\'=>$do_not_duplicate,
              \'posts_per_page\' => $postnr,
              \'cat\' => of_get_option(\'of_wn_cat8\', 1)
            );
            $gab_query = new WP_Query();$gab_query->query($args); 
            while ($gab_query->have_posts()) : $gab_query->the_post(); if (of_get_option(\'of_dnd\') == 1) { $do_not_duplicate[] = $post->ID; }
            ?>
            <div class="featuredpost<?php if($count == of_get_option(\'of_wn_nr8\') or $count == $postnr) { echo \' lastpost\'; } ?>">


                <?php if ($count <= of_get_option(\'of_wn_nr8\')) { ?>

                    <h2 class="posttitle">
                        <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf( esc_attr__( \'Permalink to %s\', \'wpnewspaper\' ), the_title_attribute( \'echo=0\' ) ); ?>" ><?php the_title(); ?></a>
                    </h2>                       
                    <div class="opinion_wrapper">
                    <?php
                        gab_media(array(   \'imgtag\' => 1,   \'link\' => 1,
                            \'name\' => \'wn-subnews\',
                            \'enable_video\' => 0,
                            \'catch_image\' => of_get_option(\'of_catch_img\', 0),
                            \'enable_thumb\' => 1,
                            \'resize_type\' => \'c\',
                            \'media_width\' => 120, 
                            \'media_height\' => 103, 
                            \'thumb_align\' => \'alignleft\',
                            \'enable_default\' => 0
                        ));
                    ?>  
                    <div class="opinion_marker"><!-- opinion marker --></div>                   
                    </div>
                    <p><?php echo string_limit_words(get_the_excerpt(),27); ?>&hellip;</p>

                    <?php gab_postmeta(); ?>
                <?php } else { ?>

                    <a class="listtitle" href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf( esc_attr__( \'Permalink to %s\', \'wpnewspaper\' ), the_title_attribute( \'echo=0\' ) ); ?>" ><?php the_title(); ?></a>

                <?php } ?>

            </div><!-- .featuredpost -->
            <?php $count++; endwhile; wp_reset_query(); ?>
        <?php } ?>
    </div><!-- .col -->
,是吗,如图所示http://d.pr/i/7efk ,

在此网站上http://dev.dmichel.net/adv/ .

我需要做的是显示所有4个帖子,而不仅仅是1个。

我试图显示所有4篇帖子的内容是

<?php
            $count = 1;
            $args = array(
              \'posts_per_page\' => 4,
              \'cat\' => of_get_option(\'of_wn_cat8\', 1)
            );
            $gab_query = new WP_Query();$gab_query->query($args); 
            while ($gab_query->have_posts()) : $gab_query->the_post(); }
            ?>
但它似乎不起作用。

我想帮助显示标题上方的所有4个帖子

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

我为任何感兴趣的人制作了一把小提琴HERE.

下面是我用来为文章容器提供平滑滚动的javascript。

// clicking the links in the article link container
$(\'#article-links a\').click(function() {
    var $this = $(this);    // save this instance of the click for access inside the loop

    // loop through all the article links and store the numeric value
    $(\'#article-links a\').each(function(al) {
        // if the link being looked at currently matches the html/text of the link that was selected then
        if ($(this).html() == $this.html()) {
            // set the scroll position by multiplying the article previews height by the ordered number link
            // that was selected (i.e 500*1 will scroll the preview div up/down to scrollTop: 500)
            var articlePos = parseInt($(\'#article-preview\').height())*al;

            // animate the scroll for a smooth scroll               
            $(\'#article-preview\').animate({ scrollTop: articlePos });
        }
    }); 
});

结束

相关推荐

无法让jQuery进入编辑后脚本

在下面的代码中,除非我硬编码了对jQuery库的引用,否则页面上的jQuery位不会工作。我尝试使用的排队方法有什么问题?在函数中。php:if(is_admin()) { /* LOAD ADMIN SCRIPTS **********************************/ require_once(TEMPLATEPATH . \'/functions_private.php\'); } 在functions\\u pr