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 case for the generic post_type in archive.php #1232

Merged
merged 3 commits into from
Jun 11, 2016

Conversation

benlk
Copy link
Collaborator

@benlk benlk commented Jun 9, 2016

Changes

  • adds a conditional elseif ( is_post_type_archive() ) { to the section at the start of the file:
    • sets the title to post_type_archive_title()
    • sets the feed url to '/feed/?post_type=' . urlencode($wp_query->query_vars['post_type']), which will look like http://example.com/feed/?post_type=roundup
  • wraps the feed url for both the rounduplink and generic cases with site_url(), to make them point to the correct URL if the site is not hosted at the root of its domain.

Why

For #1231, makes sure there's a title for all post_type archives.

Adds site_url because it's a better practice than to rely on / being the root of the site.

@benlk
Copy link
Collaborator Author

benlk commented Jun 9, 2016

In the case of Roundups given by the Link Roundups plugin, this does respect the lroundups_custom_name_plural option that Link Roundups uses to rename the roundups post type..

@@ -53,7 +53,10 @@
* @since 0.5.4
*/
$title = apply_filters( 'largo_archive_rounduplink_title', __( 'Saved Links' , 'largo' ) );
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Collapse these two is_post_type_archive sections into one that runs the filter 'largo_archive_' . $post_type . '_title', and add a similar filter for the default feed url.

The largo_archive_rounduplink_title filter is replaced with a generic
largo_archive_{$post_type}_title filter, maintaining compatibility with
existing filters.

The largo_archive_{$post_type}_feed filter is new, and allows filtering the feed
URL. The feed URL here is no longer specific to the rounduplink post type, instead takes
the form /feed/?post_type=post_type

Also updates the hooks-and-filters docs
@benlk
Copy link
Collaborator Author

benlk commented Jun 10, 2016

Updated:

Changes

  • removes the specific is_post_type_archive( 'rounduplink' ) check for a generic is_post_type_archive()
  • post type title
    • sets the title to post_type_archive_title()
    • applies the filter largo_archive_{$post_type}_title to that title - this preserves compatibility with existing largo_archive_rounduplink_title filters while allowing other post type titles to be filtered.
  • post type feed url
    • sets the feed url to '/feed/?post_type=' . urlencode($post_type), which will look like http://example.com/feed/?post_type=roundup
    • wraps the feed url with site_url(), to make it point to the correct URL if the site is not hosted at the root of its domain.
    • and then applies the filter largo_archive_{$post_type}_feed
  • updates docs

Why

For #1231, makes sure there's a title for all post_type archives.

Switches to generics to make sure that everything can be filtered.

Adds site_url because it's a better practice than to rely on / being the root of the site.

@aschweigert aschweigert merged commit 1f4ef71 into master Jun 11, 2016
@aschweigert aschweigert deleted the 1231-generic-post-type branch June 11, 2016 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants