Nā ʻAno Hoʻouna Kūlohelohe me nā ʻĀina Dute

wordpress

WordPress is becoming such an indispensable platform to so many companies, but the average company doesn't even take advantage of a fraction of the capabilities. One of our clients wanted to add a resource section to their site but didn't want to do it using pages nor in blog posts. This is exactly what WordPress supports Nā Kūlana Kū Kūhelu no ka mea!

In this case, we wanted to add a Resource Section to one of our clients' sites. It's fairly simple to add a Hōʻailona Koho Kūlana i kāu kumuhana WordPress. Hoʻohui ʻoe i kēia code aʻe me ka hoʻohana ʻana i ka hana register_post_type i kāu ʻaoʻao functions.php:

// Hoʻohui i nā kumuwaiwai Custom Post Type add_action ('init', 'create_post_type'); hana hana_post_type () {register_post_type ('kumuwaiwai', hoʻonohonoho ('lepili' => hoʻonohonoho ('inoa' ​​=> __ ('Kumuwaiwai'), 'singular_name' => __ ('Resource'), 'add_new' => __ ('Add New'), 'add_new_item' => __ ('Add New Resource'), 'edit_item' => __ ('Edit Resource'), 'new_item' => __ ('New Resource'), 'all_items' => __ ('All Resources'), 'view_item' => __ ('Nānā Kumuwaiwai'), 'search_items' => __ ('Nā Kumuwaiwai Huli'), 'not_found' => __ ('ʻAʻole ʻIke ʻia nā Kumuwaiwai'), 'not_found_in_trash' => __ ('ʻAʻohe Puna i ʻōpala'), 'parent_item_colon' => '', 'menu_name' => __ ('Resources')), 'public' => ʻoiaʻiʻo, 'has_archive' => ʻoiaʻiʻo, 'rewrite' => hoʻonohonoho ('slug' => 'kumuwaiwai'), 'kākoʻo' => hoʻonohonoho ('inoa', 'hoʻoponopono', 'mea kākau', 'thumbnail', 'excerpt', 'comments')) ; }

ʻO kahi paʻakikī hou aʻe e ʻike pehea e hana ai mahele kuʻuna no kāu Hōʻailona Koho Kūlana. One reason why it's difficult to figure out how to do this is because it's called a custom taxonomy and utilizes the kāinoa_taxonomy function to customize it. In this case, we're wanting to add resource types like Webinars, Whitepapers, etc. to the theme… so here's some additional code for the functions.php file:

add_action ('init', 'resource_category_init', 100); // 100 no laila ua hoʻopaʻa inoa ʻia ka post post resource_category_init () {register_taxonomy ('type', 'resources', array ('labels' => array ('name' => 'Resource Type', 'singular_name' => ' ʻAno Kumuwaiwai ',' search_items '=>' Nā ʻimi kumu waiwai ',' popular_items '=>' Nā ʻano kumuwauwai kaulana ',' all_items '=>' Nā ʻano kumuwaiwai āpau ',' edit_item '=> __ (' Edit Type Resource ') , 'update_item' => __ ('Update Type Resource'), 'add_new_item' => __ ('Add New Resource Type'), 'new_item_name' => __ ('Type Resource New')), 'hierarchical' => 'false', 'label' => 'ʻAno Kumuwaiwai')); }

ʻAe nā ʻano Custom Post e ʻae iā ʻoe e hoʻolālā i ka waihona a me nā ʻaoʻao hoʻokahi no kāu ʻano Post Kina. E kope wale i nā waihona archive.php a me single.php. Kapa hou i nā kope me ka Hōʻailona Koho Kūlana i ka inoa. I kēia hihia, lilo ia i waihona-kumu waiwai.php a me nā kumuwaiwai hoʻokahi.php. I kēia manawa hiki iā ʻoe ke hoʻopilikino i kēlā mau ʻaoʻao akā makemake ʻoe i ka ʻaoʻao waiwai e nānā.

2 Comments

  1. 1

    ʻO kahi ala ʻē aʻe e hoʻohana ai i kahi plugin e like me nā ʻaoʻao ʻike maʻalahi maʻalahi a i ʻole ʻāpana.

    Hāʻawi kēia mau plugina iā ʻoe e hoʻohui maʻalahi i nā pahu meta maʻamau a hana i kahi ʻaoʻao a me nā template template.

    • 2

      ʻOiaʻiʻo @ google-d5279c8b66d25549a0ec3c8dd46a3d1a: disqus! E haʻi pono wau i koʻu manaʻo e like me kahi mau plugins e hoʻohui i kahi ton o overhead i ka blog ... a ʻaʻole hiki iā ʻoe ke neʻe wale i kahi kumuhana mai kahi pūnaewele a i kahi aʻe, pono ʻoe e hōʻoia e neʻe i nā plugina. . ʻO ia wale nō ke kumu o kaʻu hana e hoʻokomo i nā hana kūpono i nā faila kumuhana.

Pehea kou manaʻo?

Ke hoʻohana nei kēia pūnaewele i ka Akismet e ho'ēmi i ka spam. E aʻo pehea e hanaʻia ai kāuʻikeʻikepili.