Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wpdocs_custom_excerpt_length( $length ) {
- return 25;
- }
- add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );
- add_image_size( 'featured-post-image', 500 );
- function wp_featuredposts($catID, $numberOfPost){
- $args = array( 'posts_per_page' => $numberOfPost, 'offset'=> 0, 'category' => $catID, 'post_status' => 'publish' );
- global $post;
- $myposts = get_posts( $args );
- ?>
- <div class="featured-container">
- <?php
- foreach ( $myposts as $post ) : setup_postdata( $post )
- ?>
- <?php
- $src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'featured-post-image' );
- ?>
- <div class="featured outer" style="background-image: url(<?php echo $src[0]; ?>); background-size: cover;">
- <div class="featured inner">
- <?php //var_dump($post); ?>
- <div class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
- <div class="excerpt">
- <?php the_excerpt(); ?>
- </div>
- </div>
- </div>
- <?php endforeach;
- wp_reset_postdata();
- ?>
- </div>
- <?php
- }
- add_filter( 'featuredposts', 'wp_featuredposts' );
- ?>
Add Comment
Please, Sign In to add comment