1

I have the following doubt related to the WordPress posts showed in the home page.

I know that in the home page I can show the latest published posts. But can I also show (before the latest posts) a specified number of "important" posts?

What can I do to implement this feature in my blog?

Tnx

3

Yes of course. One of the ways to achieve this is by adding an extra category to your posts which you call 'sticky' or 'important' or something like that.

For the example I will choose 'important'. To only get the important posts you can write a loop which loops through this category.

For example:

<?php 
$args = array( //arguments for the loop
    'post_type' => 'post',
    'category' => 'important',
    'posts_per_page' => 1, //show one post from the important posts
    'order' => 'DESC' //order descending, show the lastest posts first
);

$query = new WP_Query( $args );
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
?>

HTML HERE, FOR EXAMPLE:

<div class="news important">
   <?php the_post_thumbnail(); ?>
   <h2><?php the title(); ?></h2>
   <?php the_excerpt(); ?>
</div>
(ofcourse you can also write this within the php, do what you prever)

And then close the loop

<?php endwhile; endif; ?>

I didn't test this, but I hope it can point you in the right direction to solve this. For more info: WP_Query

You can also go for a sticky posts plugin, but writing yourself gives you more flexibility.

1

This quite an opinionated question as there are many methods which you can use to reach your end goal.

There are a couple of questions you should ask yourself here first, like, do I need these posts to be part of my normal blog posts, what are these posts intended for, how often will I rotate them, or will they stay for a long length of time.

Based on the criteria that you decide upon, you have the options of sticky posts (which I personally don't like), custom category of posts, a custom widget which I've used with great success in conjuction with custom post types, and then there is my favorite, custom post type.

I think that using custom post types is by far superior to the other options, as the sky is the limit when it comes to options and flexibility, and it is non-intrusive as custom types are by default not included in the main query. So you can have your "important posts" separate from the rest of your blog posts.

All you need to do to display these posts is to run a custom query (with the use of WP_Query or get_posts) in the spot you need to display these posts.

But as I said, the option are there to be used, it is your duty to go and sit down and decide what is it exactly what you want to do and how are you going to do it

0

1.Download super post plugin

2.Go to Dashboard>Appearence>Widgets

3.Select the Super Post widget and drag it to sidebar

4.Expand Super post set IMPORTANT as title and select the type of post you want in it, the options are: Recent, most commented, sticky, related, Taxonomy: category or tags.

5.Choose category or tags, link the post that are important to the new category and it will show up. Hope that was what you were looking for

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.