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

fix: custom post type tags excluded from archive pages #124

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

dustin-jw
Copy link
Contributor

@dustin-jw dustin-jw commented Oct 27, 2023

Description

This fixes an issue where posts from custom post types were excluded from archive pages, such as by date, category, or tag, as well as the home page which lists recent posts. It requires a little bit of manual intervention from developers when they generate post types, but it's a one-liner, and instructions were updated to make it clear what to do on post type creation.

Closes #115

To Validate

  1. Make sure all PR Checks have passed
  2. Pull down this branch
  3. Run npm start
  4. Run npm run generate:post-type and answer the prompts to create a new custom post type, like "Recipes"
  5. Confirm that the output of the generator includes a message about how to enable the post type on archive pages
  6. Follow the instructions in the message/comments to add the post type to the enable_custom_posts_in_archives function
  7. Add some categories and/or tags to regular posts
  8. Create posts for the new post type and give some of them the same tags and categories as the other posts
  9. Check the home page and confirm that your custom posts are listed along with regular posts
  10. Check tag archives (?tag=<tag-slug>) to confirm all posts with that tag are rendered
  11. Check category archives (?cat=<category-id>) to confirm all posts with that category are rendered
  12. Check date archives (?m=2023) to confirm all posts authored in the given year are rendered
  13. Check custom post type archives (?post_type=<post-slug>) and confirm that only posts from the custom post type are rendered

@dustin-jw dustin-jw force-pushed the fix--custom-post-type-tags branch 3 times, most recently from c6f9061 to 44ede79 Compare November 7, 2023 16:19
src/php/inc/custom-post-types/recipe.php Outdated Show resolved Hide resolved
src/php/inc/setup-queries.php Outdated Show resolved Hide resolved
// Defines an `example` JavaScript variable, within the sparkpress-theme-script, equal to $example_data.
wp_localize_script( 'sparkpress-theme-script', 'example', $example_data );

// You can also define global variables that get appended to an enqueued script.
Copy link

Choose a reason for hiding this comment

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

🏆

@dustin-jw dustin-jw requested a review from robtarr November 7, 2023 17:09
Copy link

@robtarr robtarr left a comment

Choose a reason for hiding this comment

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

Thumbs Up

- turn example code into a comment
- remove redundant class in generated page templates
- update instructions for creating post types
- comment out unnecessary add_filter call
@dustin-jw dustin-jw force-pushed the fix--custom-post-type-tags branch from c5077f2 to 481c68a Compare November 7, 2023 18:01
@dustin-jw dustin-jw merged commit 481c68a into main Nov 7, 2023
2 checks passed
@dustin-jw dustin-jw deleted the fix--custom-post-type-tags branch November 7, 2023 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tags and Categories not Displaying Custom Post Type Posts
2 participants