duangaixing1509 2015-09-27 10:44
浏览 113
已采纳

Wordpress画廊问题

I'm editing wordpress theme and I have a problem that theme shows all the images on the page I would like to immediately set up a data-filter = ". 1" that appears on when the page loads, and not to appear all images only images that are under data-filter = ". 1" I named the first filter with that name

I made data-filter=".1",data-filter=".2",data-filter=".3",data-filter=".4",data-filter=".5",data-filter=".6",data-filter=".7" I want page to show data-filter=".1" first as "active"

I want remove all'; and make default 1';

This is now http://postimg.org/image/x9atfq5of/

I want this http://postimg.org/image/729mjrnen/

here is code if I need more code let me know:

 <?php global $tx_switch ?>

<?php if($tx_switch['section_portfolio_display']) : ?>
    <!-- Portfolio Start
            ================================================== -->
    <section id="portfolio">
        <div class="container">
            <div class="row">
                <div class="section-title wow bounceIn" data-wow-delay=".2s">
                     <h1><?php echo $textarea = $tx_switch['section_portfolio_title']; ?></h1>
                    <p><?php echo $textarea = $tx_switch['section_portfolio_subtitle']; ?></p>
                </div> <!-- /.Section title -->
                <div id="portfolio-body" class="col-md-12  wow fadeInUp" data-wow-delay=".6s" >
                    <?php
                        $terms = get_terms('filters');
                        $count = count($terms);
                        if ( $count > 0 ){
                        echo '<ul class="portfolio-filter" id="projects-filter">';
                        echo '<li data-filter="*" class="active">all</li>';
                        foreach ( $terms as $term ) {
                            $termname = strtolower($term->name);  
                            $termname = str_replace(' ', '-', $termname);  
                            echo '<li data-filter="' . '.' . $termname . '">' . $term->name . '</li>';

                        }
                        echo '</ul>';
                        }
                    ?>
                    <div class="portfolio-container" >
                        <ul id="da-thumbs" class="da-thumbs " >
                        <?php 
                            $args = array(
                                    'post_type'         => 'portfolio',
                                    'post_status'       => 'publish',
                                );

                                $portfolio_query = new WP_Query( $args );?>
                            <?php while($portfolio_query->have_posts()): $portfolio_query->the_post(); ?>

                            <li <?php echo post_class();?>>
                                 <a>
                                    <img src="<?php echo $text = get_post_meta( $post->ID, '_tx_portfolio_img', true ); ?>">
                                    <div></div>    
                                </a>
                                <span class="portfolio-buttons">
                                    <a class="test-popup-link" href="<?php echo $text = get_post_meta( $post->ID, '_tx_portfolio_img', true ); ?>   " >
                                        <i class="fa fa-search"></i>
                                    </a>

                                </span>
                            </li>
                            <?php endwhile; ?>
                            <?php wp_reset_postdata(); ?>
                        </ul>  <!-- /.da-thumbs -->
                    </div>  <!-- /.portfolio container -->
                </div> <!-- /.col-md-12 -->

            </div> <!--/row -->
        </div> <!-- /.container -->
    </section> <!-- /#Portfolio -->
<?php endif ; ?>
  • 写回答

1条回答 默认 最新

  • duanlan4801 2015-09-27 19:32
    关注

    To remove the all options, you can remove the line

    echo '<li data-filter="*" class="active">all</li>';
    

    To limit the number of images you're showing, you can change your $args to

    $args = array(
        'post_type'         => 'portfolio',
        'post_status'       => 'publish',
        'posts_per_page'    => 7,
        'paged'             => $current_page // set this to whatever page the user clicks on, 1 by default
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计