Skip to content

Conversation

@jasonbahl
Copy link
Collaborator

Closes #786

This adds a new graphql_include_sticky_posts filter. Default is false, but if set to true WPGraphQL will include sticky posts at the top of Post Object queries (of the "post" post_type).

For paginated queries, the sticky post will only be included in the first query of forward paginated queries.

jasonbahl added 2 commits May 22, 2019 22:40
- This introduces a filter `graphql_include_sticky_posts` which will include sticky posts in the first query in a post connection query if the filter is set to true. Subsequent pages of a paginated query will not include the sticky post at the top of the results.
- This introduces a filter `graphql_include_sticky_posts` which will include sticky posts in the first query in a post connection query if the filter is set to true. Subsequent pages of a paginated query will not include the sticky post at the top of the results.
@esamattis
Copy link
Collaborator

Wouldn't this be more flexible as a query arg?

@jasonbahl
Copy link
Collaborator Author

Is it already morning there? 😱

@jasonbahl
Copy link
Collaborator Author

jasonbahl commented May 23, 2019

@epeli maybe both. 🤔

My thought was that as a maintainer of a server you may not want to support exposing sticky posts.

But on the flip side, as a consumer you may want to be able to ask for them 🤔

I’m open to feedback for sure.

My thought still is that it feels a bit more like the domain of the server to decide rather than the consumer.

🤔

@esamattis
Copy link
Collaborator

esamattis commented May 23, 2019

8.30am ;)

Consider this scenario:

I want to list all posts whether they are sticky or not by the publish date and create a second list of only sticky posts to a sidebar. If server makes this decision that would be impossible with a single graphql query.

@AlbertoAbruzzo
Copy link

Any news about that? I can't query for sticky posts...

@stale
Copy link

stale bot commented Aug 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 2, 2022
@stale
Copy link

stale bot commented Sep 1, 2022

This issue has been automatically closed because it has not had recent activity. If you believe this issue is still valid, please open a new issue and mark this as a related issue.

@stale stale bot closed this Sep 1, 2022
@justlevine justlevine reopened this Sep 2, 2022
@stale stale bot removed the stale label Sep 2, 2022
@stale
Copy link

stale bot commented Dec 1, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale? May need to be revalidated due to prolonged inactivity label Dec 1, 2022
@stale
Copy link

stale bot commented Mar 1, 2023

This issue has been automatically closed because it has not had recent activity. If you believe this issue is still valid, please open a new issue and mark this as a related issue.

@stale stale bot closed this Mar 1, 2023
@justlevine justlevine reopened this Mar 1, 2023
public function get_items() {
return ! empty( $this->query->posts ) ? $this->query->posts : [];

$sticky = [];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces must be used to indent lines; tabs are not allowed

$sticky = [];

/**
* Sticky posts are only supported for the 'post' post_type, and

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces must be used to indent lines; tabs are not allowed


/**
* Sticky posts are only supported for the 'post' post_type, and
* should only be added to the first query for posts in a paginated

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces must be used to indent lines; tabs are not allowed

/**
* Sticky posts are only supported for the 'post' post_type, and
* should only be added to the first query for posts in a paginated
* query

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces must be used to indent lines; tabs are not allowed

* should only be added to the first query for posts in a paginated
* query
*/
if ( 'post' === $this->post_type && 0 == $this->get_offset() && ! isset( $this->args['last'] ) ) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces must be used to indent lines; tabs are not allowed

@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit 089d3f3 and detected 31 issues on this pull request.

Here's the issue category breakdown:

Category Count
Style 31

View more on Code Climate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale? May need to be revalidated due to prolonged inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sticky Posts are not being handled anymore in 0.3.0

4 participants