Skip to main content

get posts wordpress

    <ul>

<?php $the_query = new WP_Query( 'posts_per_page=1' ); ?>
<?php //$the_query = new WP_Query( 'showposts=10&offset=1' ); ?>

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



<div>
<div style="width:104%;"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail();?></a></div><br>
<li><div style="font-size: 23px; text-align: center;text-transform: none;"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></div></li>
<li><div style="margin-bottom: 92px;text-align: center;">

<?php
   
    //$trimtitle = get_the_title();     style="border:1px solid #dedede;margin-bottom: 35px;width:105%;"
   
    //$shorttitle = wp_trim_words( $trimtitle, $num_words = 4, $more = '… ' );
   
    //echo '<h6 class="info-title">' . '<a href="' . get_permalink() . '">' . $shorttitle . '</a></h6>';
   
    $trimexcerpt = get_the_excerpt();
   
    $shortexcerpt = wp_trim_words( $trimexcerpt, $num_words = 50, $more = '… ' );
   
    echo '<p>' . $shortexcerpt . '</p>';
   
    ?>
   
    <a class="more-link button" href="<?php the_permalink() ?>" style="margin: 23px 0px -24px;">Read More</a>
   
    </div>

</div></li>
     <?php
   
    //$trimtitle = get_the_title();
   
    //$shorttitle = wp_trim_words( $trimtitle, $num_words = 4, $more = '… ' );
   
    //echo '<h6 class="info-title">' . '<a href="' . get_permalink() . '">' . $shorttitle . '</a></h6>';
   
    //$trimexcerpt = get_the_excerpt();
   
    //$shortexcerpt = wp_trim_words( $trimexcerpt, $num_words = 10, $more = '… ' );
   
    //echo '<a href="' . get_permalink() . '"><p>' . $shortexcerpt . '</p></a>';
   
    ?>

<?php
endwhile;
wp_reset_postdata();
?>
</ul>

Comments

Popular posts from this blog

add custom post type

/**  *  * add custom post type  *  */ function my_custom_post_product() {   $labels = array(     'name'               => _x( 'Products', 'post type general name' ),     'singular_name'      => _x( 'Product', 'post type singular name' ),     'add_new'            => _x( 'Add New', 'book' ),     'add_new_item'       => __( 'Add New Product' ),     'edit_item'          => __( 'Edit Product' ),     'new_item'           => __( 'New Product' ),     'all_items'          => __( 'All Products' ),     'vi...

Toolset conditional

[wpv- if evaluate= "'[wpv-current-user info='id']' = '[wpv-post-author format='meta' meta='ID']' OR '[wpv-current-user info='role']' = 'administrator'" ]      //the content you want to hide goes here [/wpv- if ]