Do not want sticky post show in latest post widget

Hi,

As the title, the latest post widget is now picking up my sticky post.
However, I do not want to show sticky post in my latest post, the default is set to show 3 latest posts, but it is now showing my 3 latest post and ALL my sticky posts…

How can I turn off the displaying of sticky posts in the latest post widget.

Hello there,

To exclude the sticky posts from the Perth FP: Latest News widget, you should modify its query parameters. Edit the widgets/fp-latest-news.php file. Then find the following code block:


$r = new WP_Query( array(
	'no_found_rows'       => true,
	'post_status'         => 'publish',
	'posts_per_page'      => 3,
	'category_name'	      => $category
) );

Then add this line:


'ignore_sticky_posts' => true

The final code will look like this:


$r = new WP_Query( array(
	'no_found_rows'       => true,
	'post_status'         => 'publish',
	'posts_per_page'      => 3,
	'category_name'	      => $category,
        'ignore_sticky_posts' => true
) );

Regards,
Kharis

Hi,
Thank you for the reply, but I have already tried this, and I tried it again.
After I placed in the code, the site is down, showed that the page isn’t working and there’s error.

Another question, if I keep the sticky post, can the posts display be sticky posts+latest posts= 6 post?
So, if there is 2 sticky posts, the system will display 4 latest posts, and if there is 3 sticky posts, 4 latest posts will be display, something like this.
Is this possible?

Thank you.

Hello there,

Is there any error message be displayed on your page? If so, could you please share it here?

> Another question, if I keep the sticky post, can the posts display be sticky posts+latest posts= 6 post?

You have to change the posts_per_page parameter value to 6.

Regards,
Kharis