Answers for "wordpress display posts"

PHP
1

wordpress show similar posts

<ul class="some-class">
  <?php
  $related = get_posts( array( 'category__in' => wp_get_post_categories($post->ID), 'numberposts' => 3, 'post__not_in' => array($post->ID) ) );
  if( $related ) foreach( $related as $post ) {
  setup_postdata($post); ?>
    <li>
    	<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
        <div><?php the_excerpt();?></div>
    </li>
  <?php }
  wp_reset_postdata(); ?>
</ul>
Posted by: Guest on October-17-2021
0

display a list of WordPress custom posts

<?php $loop = new WP_Query( array( 'post_type' => 'article', 'posts_per_page' => 10 ) ); ?>

<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

    <?php the_title( '<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?>

    <div class="entry-content">
        <?php the_content(); ?>
    </div>
<?php endwhile; ?>
Posted by: Guest on July-23-2021
0

PHP Display Posts by Category in WordPress

$espbc = get_sub_field('add_posts_by_category');
        
        $defaults_param = array(
          //'numberposts'      	=> -1,
          'post_type'        	=> 'post',
          'category' 			    => $espbc,
          'posts_per_page' 			    => 6,
          'suppress_filters'	=> false
        );
        $catPost = get_posts($defaults_param);
Posted by: Guest on July-24-2021

Code answers related to "wordpress display posts"

Browse Popular Code Answers by Language