rosswintle / sync-pinboard

WordPress plugin for syncing Pinboard pins into a WordPress post type
1 stars 1 forks source link

Taxonomy Term Archive Pages are Broken #6

Open kangabell opened 3 years ago

kangabell commented 3 years ago

The archive pages for the pinboard-tag taxonomy don't seem to work. The link provided through the admin gives "/pinboard-tag/[tag-name]", which leads to a 404.

I am using the TwentyTwentyone theme with WordPress v5.6.1 (current).

archive

rosswintle commented 3 years ago

Thanks for this report. This isn't actually a 404. It's a valid term archive, but just an empty one that found nothing to display.

In terms of the cause...well, it seems like you learn something every day. WordPress technical language ahead - let me know if you need a plainer explanation!

It turns out that this is caused by me setting exclude_from_search to true when registering the post type for bookmarks. This also removes the post type from "main queries" and so this page is not showing items from the pinboard-bookmark post type. Which is why nothing is showing. It's trying to list "posts" (and other post types) that are related to the term, but not bookmark items.

I can see why you would want to do this. But I'm now torn because I don't really want my pins in search results. I might have to find a workaround.

One option is to at least put a filter on the options when registering a post type, then you can at least turn this on yourself.

Again, leave it with me and I'll try to add to a release sometime soon.

Thanks so much!

rosswintle commented 3 years ago

If you want to quick-fix this yourself, and are happy to have pins in (WordPress) search results, you can edit post-types/pinboard-bookmark.php and change:

'exclude_from_search'   => true,

to

'exclude_from_search'   => false,
rosswintle commented 3 years ago

Reference: https://wordpress.stackexchange.com/a/223557

rosswintle commented 3 years ago

Documented in the WordPress reference: https://developer.wordpress.org/reference/functions/register_post_type/#exclude_from_search

I honestly never knew this despite working with WordPress for more than ten years!

kangabell commented 3 years ago

@rosswintle Awesome, thank you for so much info. On the site I'm working on, I'm using the Relevanssi search plugin, which allows me to greatly control what turns up in search, so that portion is a non-issue for me. But I would like to be able to display all bookmarks in a given tag.

Maybe I'm missing something though... What is the purpose of having this taxonomy, if you can't view it on the frontend? Is it just for internal use?

kangabell commented 3 years ago

Also: the code change worked like a charm – thanks!!!

rosswintle commented 3 years ago

Ah, good stuff.

What is the purpose of having this taxonomy, if you can't view it on the frontend? Is it just for internal use?

Well, it syncs from tags in Pinboard. So there's that.

My original use case was for showing a selection of pins/bookmarks in a block. I used these for my "weeknotes" back in 2019 (was it really that long ago?). See, for example: https://rosswintle.uk/2019/11/the-weeks-28th-october-and-4th-november/ - scroll down to the "Pins" section.

I didn't want the pins cluttering up the site apart from on those posts. And the idea was partly that I get to keep a copy of everything that's in pinboard that I own.

I totally get that you would want to show your pins to the world though so will try to make it happen some time.

Thanks for your interest and helpful contributions!

kangabell commented 3 years ago

Ah yes. Here is my use case! A section on the website that displays the pins. In this case, I am mainly using the plugin to import pins (over 11,000 of them), not sync. From here, the client is adding new pins/bookmarks directly into wordpress, and attaching featured images to some of the old ones. (Pinboard itself will no longer be used.) And we are using those tags to filter the display (each tag pictured here links to the corresponding archive page).

Screen Shot 2021-02-12 at 9 47 47 AM

At some point, if time/budget allows, I'd like to move the custom post type into my custom theme, and remove the plugin (since we don't need the sync/import functionality anymore).