get_posts category
$defaults_param = array(
'numberposts' => -1,
'post_type' => 'post',
'category' => 40 ,
'suppress_filters' => false
);
$get_featured_post = get_posts($defaults_param);
get_posts category
$defaults_param = array(
'numberposts' => -1,
'post_type' => 'post',
'category' => 40 ,
'suppress_filters' => false
);
$get_featured_post = get_posts($defaults_param);
get category post in wordpress
echo '<p>'. get_the_category( $id )[0]->name .'</p>';
get post by category
<section class="films-tabs pd-40" id="portfolio">
<?php $film_genres = get_terms('portfolio_cat'); // get all the genres ?>
<div class="container">
<div class="row">
<!-- Nav tabs -->
<ul class="nav nav-tabs nav-justified">
<?php foreach($film_genres as $film_genre) { ?>
<li>
<a href="#<?php echo $film_genre->slug ?>" data-toggle="tab"><?php echo $film_genre->name ?></a>
</li>
<?php } ?>
</ul>
</div>
</div>
<!-- Tab panes -->
<div class="tab-content">
<?php foreach($film_genres as $film_genre) { ?>
<div class="tab-pane" id="<?php echo $film_genre->slug ?>">
<?php
$args = array(
'post_type' => 'portfolio',
'showposts' => -1,
'orderby' => 'title',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'portfolio_cat',
'field' => 'slug',
'terms' => $film_genre->slug
)
)
);
$films = new WP_Query( $args );
?>
<?php if ( $films->have_posts() ) : // make sure we have films to show before doing anything?>
<div class="table">
<div class="container">
<div class="row">
<?php while ( $films->have_posts() ) : $films->the_post(); ?>
<div class="table-cont"><a data-fancybox="gallery" href="<?php echo get_the_post_thumbnail_url();?>".><?php the_post_thumbnail() ?></a></div>
<?php endwhile; ?>
<?php wp_reset_query() ?>
</div>
</div>
</div>
<?php endif; ?>
</div>
<? } ?>
</div><!-- tab-content -->
</section><!-- film-tabs -->
show all posts from category
<?php
$args = array( 'category' => 7, 'post_type' => 'post' );
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post);
?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php endforeach; ?>
Get wordpress posts by category name..!
<?php query_posts('category_name=CATEGORYNAME&showposts=5');
while (have_posts()) : the_post(); ?>
the_title(); // To display the title of all posts that have category name selected
the_content(); // To display the content of all posts that have category name selected
<?php endwhile; ?>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us