Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

get_post by category in wordpress

<?php

                            $args = array('posts_per_page' => 10, 'offset' => 0, 'category' => 11);

                            $myposts = get_posts($args);
                            $count=1;
                            foreach ($myposts as $post) : setup_postdata($post); ?>
                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-6 col-xl-6">
                                    <div class="portfolio-list" data-aos="fade-up">
                                        <div class="portfolio-image">
                                            <h6>Case Study - <?php echo $count ?></h6>
                                            <div class="portfolio-detail-image">
                                                <img src="<?php the_post_thumbnail_url() ?>" class="img-fluid" alt="Olam Solutions">
                                            </div>
                                        </div>
                                        <div class="portfolio-content" data-aos="fade-up">
                                            <h3><a href="<?php the_permalink();  ?>"><?php the_title(); ?></a></h3>
                                            <p>Website Design & Development</p>
                                            <a href="<?php the_permalink();  ?>" class="view-case-btn">View Case <span class="icon-right-arrow"></span></a>
                                        </div>
                                    </div>
                                </div>
                            <?php
                            $count= $count+1;
                            endforeach;
                            wp_reset_postdata();

                            ?>
Source by developer.wordpress.org #
 
PREVIOUS NEXT
Tagged: #category #wordpress
ADD COMMENT
Topic
Name
2+6 =