#wordpress 2022-04-19

2022-04-19 UTC
Kongpc joined the channel
#
Kongpc
KAMPANAT THUMWONG
jsbach, [jamesg483] and [Will_Monroe] joined the channel
#
[Will_Monroe]
Hello, I'm trying add a custom post kind using a helpful post from [chrisaldrich] and I have a question about how WordPress child themes work. I have looked around but I can't seem to find an answer. Here goes:
#
[Will_Monroe]
I created and have activated a child theme for the WordPress Twenty Twenty theme using the Child Theme Configurator plugin. I understand that making changes to the template/view support for a particular post kind can be made and added to the `kind_views` folder that will persist even if the Post Kinds plugin updates. But if I make changes to a file in the Post Kinds plugin directories (e.g.,
#
[Will_Monroe]
`wp-content/plugins/indieweb-post-kinds/includes/register-kinds.php`) will that be overwritten when Post Kinds updates? If so, is there a way to make changes that define a new post kind that _won't_ be updated when the plugin updates? I'm very much a novice so if it's too complex, I should probably just plan to make notes to restore my custom code when the plugin updates in the future. Thank you for your consideration!
#
GWG
[Will_Monroe]: There's a way to register a custom post kind, yes... I wouldn't recommend editing the plugin
JohnBeales joined the channel
#
GWG
Out of curiosity, what was in the custom code? Maybe it belongs in the plugin?
#
[Will_Monroe]
[dshanske] thank you! I'd like to register a custom post kind in a way that you recommend and that is durable.
#
[Will_Monroe]
Chris outlines the creation of an example custom post kind, `chickens` , that I am using to create an `annotation` post kind that is more or less what Chris already uses on his site. I plan to just copy his steps in that post making amendments along the way, as needed.
#
GWG
So, you just need to create a separate plugin that you activate that adds the new kind, and activate that
#
GWG
I wrote this for [chrisaldrich] a few years back as an example. It should still be accurate. https://gist.github.com/dshanske/c8eb82d6419bbcc25d81f1469e3eba7d
#
[Will_Monroe]
Very nice. In this instance, does creating a separate plugin simply mean added a folder to `wp-content/plugins` and then adding the `kind-register.php` code with custom edits made by me to define the new post kind?
#
GWG
Correct
#
GWG
I'd call it something custom though
#
[Will_Monroe]
How about `annotation-kind-register.php`?
#
GWG
That's fine, also change the name in the file
#
GWG
Where it says plugin name
[Sam_Butler] joined the channel
#
[Will_Monroe]
Got it. Thank you.
#
[Will_Monroe]
Do I need to change the name of the function in the gist? I'm getting a fatal error related to `register_post_kind` when I try to activate the plugin.
#
[Will_Monroe]
Changing the name of the function from `example-register-kind` to `annotation-register-kind` seems to have worked.
#
GWG
Great
#
[Will_Monroe]
This is neat. There are some customizations that I think I'll want to investigate related to `kind-views` but it's working! Thank you.
#
GWG
Anything you want to propose upstream...tell me
#
[Will_Monroe]
Will do. Thank you!
JohnBeales, [jamesg483], neceve, angelo and russ_bain joined the channel