Cov Ntawv Kev Cai Ncaj Ncees nrog Kev Cai Pawg

wordpress

WordPress tau dhau los ua qhov kev pab cuam tsis txaus rau cov tuam txhab ntau, tab sis lub tuam txhab nruab nrab tsis tseem coj qhov zoo ntawm ib feem ntawm lub peev xwm. Ib qho ntawm peb cov neeg xav tau ntxiv cov khoom seem rau lawv lub xaib tab sis tsis xav ua nws siv cov nplooj ntawv lossis hauv cov ntawv blog. Nov yog qhov uas WordPress txhawb nqa Hom Ncej Kev Cai rau!

Hauv qhov xwm txheej no, peb xav tau ntxiv Qhov Kev Pab Cuam los ua ib qho ntawm peb cov neeg siv cov xaib. Nws yog yooj yim haum ntxiv ib Hom Post Custom rau koj cov ntsiab lus WordPress. Koj ntxiv cov lej hauv qab no uas siv txoj haujlwm register_post_type rau koj functions.php nplooj:

// Ntxiv Cov Khoom Siv Custom Custom Type Hom add_action ('init', 'create_post_type'); muaj nuj nqi create_post_type () {register_post_type ('resources', array ('lab' '=> array (' npe '=> __ (' Resources ')),' singular_name '=> __ (' Resource '),' add_new '=> __ ('Ntxiv Tshiab'), 'add_new_item' => __ ('Ntxiv Cov Khoom Tshiab'), 'edit_item' => __ ('Hloov Cov Khoom Siv'), 'new_item' => __ ('Cov Khoom Tshiab'), 'all_items' => __ ('Txhua yam Khoom Siv'), 'view_item' => __ ('Saib Cov Ntaub Ntawv'), 'search_items' => __ ('Nrhiav Cov Ntaub Ntawv'), 'not_found' => __ ('Cov Khoom Siv Tsis Pom'), 'tsis_found_in_trash' => __ ('Tsis muaj chaw muab khoom pov tseg rau hauv thoob khib nyiab'), 'parent_item_colon' => '', 'menu_name' => __ ('Cov Khoom Siv')), 'pej xeem' => tseeb, 'has_archive' => muaj tseeb, 'rov sau dua' => array ('slug' => 'resources'), 'txhawb' => array ('npe', 'editor', 'sau', 'thuv', 'excerpt', 'tawm lus'))) ; }

Ib me ntsis nyuaj nrhiav yog yuav ua li cas pawg pawg rau koj Hom Post CustomCov. Ib qho laj thawj vim li cas nws yooj yim los xam seb yuav ua li cas ua qhov no vim tias nws tau hu ua ib qho kev cai sean thiab siv cov sau npe_taxonomy muaj nuj nqi rau customize nws. Hauv qhov no, peb xav ntxiv cov peev txheej zoo li Webinars, Whitepapers, thiab lwm yam rau lub ntsiab lus… yog li ntawm no yog qee qhov kev cai ntxiv rau cov ntaub ntawv functions.php:

add_action ('init', 'resource_category_init', 100); // 100 yog li hom xa ntawv tau tso npe muaj nuj nqi resource_category_init () {register_taxonomy ('hom', 'peev txheej', array ('cov ntawv' => array ('npe' => 'Chaw yam', 'singular_name' => ') Resource Type ',' search_items '=>' Nrhiav Cov Cuab Yeej Siv Ntaus ',' popular_items '=>' Cov Chaw Nrov Cov Hom ',' all_items '=>' Txhua Hom Khoom Siv ',' edit_item '=> __ (' Kho Cov Khoom Siv Hom ') , 'update_item' => __ ('Hloov tshiab Cov Hom Khoom Pab'), 'add_new_item' => __ ('Ntxiv Cov Khoom Siv Tshiab'), 'new_item_name' => __ ('Hom Khoom Siv Tshiab')), 'hierarchical' => 'cuav', 'daim ntawv lo' => 'Hom Khoom Siv')); }

Cov Kev Cai Post Type tseem tso cai rau koj los tsim cov ntaub ntawv archive thiab nplooj ntawv ib zaug rau koj Kev Cai Ntaus Kev Post. Tsuas yog luam cov ntawv archive.php thiab single.php. Hloov cov ntawv luam nrog daim the Hom Post Custom nyob rau hauv lub npe. Hauv qhov no, qhov ntawd yuav yog archive-resources.php thiab single-resources.php. Tam sim no koj tuaj yeem hloov cov nplooj ntawv no txawm li cas los koj xav tau nplooj ntawv cov khoom siv los saib.