Featured another news in wordpress
To feature another news in WordPress, you can use the following methods:
Method 1: Using the Featured Image
- Go to the post or page you want to feature.
- Click on the "Set featured image" button.
- Upload a new image or select an existing one from your media library.
- Click "Set featured image" to save the changes.
Method 2: Using the Featured Post Widget
- Install and activate a featured post widget plugin, such as "Featured Posts" or "WP Featured Posts".
- Go to the widget area of your WordPress dashboard.
- Drag and drop the featured post widget to the desired location.
- Configure the widget settings, such as the number of posts to display and the categories to include.
- Click "Save" to save the changes.
Method 3: Using a Custom Code
- Add the following code to your theme's functions.php file:
function featured_news() { $args = array( 'post_type' => 'post', 'posts_per_page' => 1, 'meta_key' => '_thumbnail_id', 'meta_value' => get_post_thumbnail_id(get_the_ID()) ); $featured_post = new WP_Query($args); if ($featured_post->have_posts()) { while ($featured_post->have_posts()) { $featured_post->the_post(); ?> <h2><?php the_title();?></h2> <p><?php the_excerpt();?></p> <?php } } wp_reset_postdata(); }
- Add the following code to your theme's template file (e.g. index.php):
<?php featured_news();?>
This code will display the featured news post at the top of your page.
Method 4: Using a Plugin
- Install and activate a plugin, such as "News Carousel" or "Featured Posts Slider".
- Configure the plugin settings, such as the number of posts to display and the categories to include.
- Add the plugin's shortcode to your page or post:
[featured-posts]
This will display the featured news post in a carousel or slider format.
Note: The above methods may require some customization to fit your specific needs. You may need to modify the code or plugin settings to achieve the desired result.