how to use post format as widget
-
hi guys i have layout of 4 post to show 4 post in the index and i am using WP query to display the layout but i want to make my theme more easier buy selecting the category from the back-end rather than modifying the code i mean from the Customizer I WANT TO CHANGE cat=9 in the query to something else which can make me able to select the category i want from the customizer (widget area)
here is my code<?php // android posts loop begins here.
$opinionPosts = new WP_Query(‘cat=9&posts_per_page=5’);
$category_list = get_the_category_list( __( ‘, ‘, ‘simone’ ) );
if ( simone_categorized_blog() ) {
echo ‘<div class=”f”>’ . $category_list . ‘</div>’;
}if ($opinionPosts->have_posts()) :
while ($opinionPosts->have_posts()) :
$opinionPosts->the_post(); ?>
<?php if (has_post_thumbnail()) {
if ($opinionPosts->current_post == 0) {
echo ‘<div class=”firstpost”>’;
echo ‘<a href=”‘ . get_permalink() . ‘” title=”‘ . __(‘Read ‘, ‘simone’) .
get_the_title() . ‘” rel=”bookmark”>’;
echo the_post_thumbnail(‘firstxpost’);
echo ‘<div class=”title1″>’;
echo the_title();
echo ‘</div>’;
echo ”;
echo ‘<div class=”post-on”>’;
echo simone_posted_on();
echo ‘</div>’;
echo ‘<div class=”exerp”>’;
echo the_excerpt();
echo ‘</div>’;
echo ‘</div>’;
};if ($opinionPosts->current_post == 1) {
echo ‘<div class=”seacondpost”>’;
echo ‘<a href=”‘ . get_permalink() . ‘” title=”‘ . __(‘Read ‘, ‘simone’) .
get_the_title() . ‘” rel=”bookmark”>’;
echo the_post_thumbnail(‘xxxpost’);
echo ‘<div class=”title2″>’;
echo the_title();
echo ‘</div>’;
echo ”;
echo ‘<div class=”post-e”>’;
echo simone_posted_on();
echo ‘</div>’;
echo ‘</div>’;};
if ($opinionPosts->current_post == 2) {
echo ‘<div class=”seacondpost”>’;
echo ‘<a href=”‘ . get_permalink() . ‘” title=”‘ . __(‘Read ‘, ‘simone’) .
get_the_title() . ‘” rel=”bookmark”>’;
echo the_post_thumbnail(‘xxxpost’);
echo ‘<div class=”title2″>’;
echo the_title();
echo ‘</div>’;
echo ”;
echo ‘<div class=”post-e”>’;
echo simone_posted_on();
echo ‘</div>’;
echo ‘</div>’;
};if ($opinionPosts->current_post == 3) {
echo ‘<div class=”seacondpost”>’;
echo ‘<a href=”‘ . get_permalink() . ‘” title=”‘ . __(‘Read ‘, ‘simone’) .
get_the_title() . ‘” rel=”bookmark”>’;
echo the_post_thumbnail(‘xxxpost’);
echo ‘<div class=”title2″>’;
echo the_title();
echo ‘</div>’;
echo ”;
echo ‘<div class=”post-e”>’;
echo simone_posted_on();
echo ‘</div>’;
echo ‘</div>’;
};if ($opinionPosts->current_post == 4) {
echo ‘<div class=”seacondpost”>’;
echo ‘<a href=”‘ . get_permalink() . ‘” title=”‘ . __(‘Read ‘, ‘simone’) .
get_the_title() . ‘” rel=”bookmark”>’;
echo the_post_thumbnail(‘xxxpost’);
echo ‘<div class=”title2″>’;
echo the_title();
echo ‘</div>’;
echo ”;
echo ‘<div class=”post-e”>’;
echo simone_posted_on();
echo ‘</div>’;
echo ‘</div>’;
};
}
?><?php endwhile;
else: ?>
no post is found sorry
<?php endif;?><?php wp_reset_postdata(); ?>
The topic ‘how to use post format as widget’ is closed to new replies.