Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a note about Largo's category featured posts functions to category.php #1595

Closed
1 task
benlk opened this issue Dec 10, 2018 · 1 comment
Closed
1 task

Comments

@benlk
Copy link
Collaborator

benlk commented Dec 10, 2018

The function largo_category_archive_posts messes with the category posts query in order to facilitate the category featured posts. If someone modifies category.php to remove one section of the featured header, but doesn't modify largo_category_archive_posts, then posts will go missing on the category page.

For sites experiencing this issue, the simple fix is to check "Hide the featured posts area on category pages" in Theme Options > Layout > Category Options, but that doesn't preserve the featured header.

Long-term, we should stop using this query hack and instead should use CSS Grid to make the featured header, falling back to the mobile layout of posts in a queue with the sidebar beneath.

Short-term:

  • add a comment before the secondary-featured area of the template, linking to largo_category_archive_posts and explaining how to change the number of posts excerpted from the top of the query :

https://github.com/INN/largo/blob/d167efce9c2cb3f4a2a15a0d95705a24bca8470b/category.php#L47-L61

The comment should explain that if you're gonna do something that isn't either of "no featured posts" or "5 featured posts", you'll have to remove_action( 'pre_get_posts', 'largo_category_archive_posts', 15 ) and then reregister a similar function that does what you need it to do. There are two primary approaches to replacing that function:

  1. Modifying the function to not perform the featured post removal on certain queries
    • requires remove_action'ing this function and then add_action'ing the replacement function
  2. Modifying the function to use a different largo_get_featured_posts_in_category that returns a different selection of posts for that category.
    • requires remove_action'ing this function and then add_action'ing the replacement function
    • requires making a modified largo_get_featured_posts_in_category and replacing that function in templates wherever it is used.
@benlk
Copy link
Collaborator Author

benlk commented Dec 10, 2018

Starting this in 0.6.2 for the comment issue, but in 0.7 or later we should remove the weird hacks and instead just do CSS Grid with a mobile-layout fallback for the outdated 40% of US-based browsers that don't support Grid.

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

No branches or pull requests

2 participants