Thauj Cov Lus Tseeb Tshaj Tawm los ntawm qeb ntawm WordPress Cov Ntawv Qhia siv jQuery load

jquery

Yog tias koj tau mus ntsib qee qhov loj ntawm blogs muaj sia li Mashable, koj yuav pom tias lawv muaj cov ntawv qhia zaub mov zoo heev uas poob qis thiab muab koj qhov pom kev rau hauv cov ntawv blog kawg ntawm txhua pawg. Txhawm rau kom paub tseeb cov nplooj ntawv tsis siv mus ib txhis rau thauj khoom, lawv thauj cov ntawd cov ntsiab lus siv Ajax ... thiab preload nws tsuas yog tom qab lub nplooj puv.

WordPress Ajax Submenu

Peb xav ua tib yam li no Martech ZoneCov. Txhawm rau muab qee qhov kev pom rau cov pawg uas peb muaj, Kuv xav qhia qee qhov kev xa tawm hauv txhua. Peb txawj ntau yam ntawm WordPress, WordPress API thiab jQuery tab sis nws tsis yog kom txog thaum kuv pom ib tsab xov xwm nyob rau Fetching Posts los ntawm qeb siv jQuery hais tias peb muaj cov tshuaj zoo.

NCO TSEG: Ib qho kev xav ntawm lawv txoj kev uas kuv tsis ntseeg tias yog ib txoj kev daws teebmeem zoo kis rau tag nrho cov lus nug_post ntawm JavaScript… nws zoo li rau kuv tias koj tuaj qhib koj tus kheej rau kev nyiag! Kuv tau hloov tsab ntawv rau lub xaib no yog li kuv tsuas dhau qhov tsis tsim nyog nyob rau hauv qhov kev nug query_posts.

Cov kev qhia ua ntu zus rau tus neeg siv los ntawm kev tsim ib lub qauv rau dynamically rub hauv cov posts, thiab tom qab ntawd yuav ua li cas los tsim kev sib txuas uas tuaj yeem pib qhov kev thov. Nws yuav tau yooj yim yog tias peb xav kom qee qhov txuas, tab sis peb yeej xav tau siv WordPress 'ua hauv cov ntawv qhia zaub mov. Hmoov tsis zoo rau peb, WordPress 'cov ntawv qhia zaub mov tau tsim cov lej thaum koj ntxiv thiab tshem tawm cov ntawv qhia zaub mov… tab sis lawv tsis tshua muaj cov ntaub ntawv ntawm qeb uas koj xav rub thiab hla hauv koj tus Ajax hu.

Yuav sau npe rau cov ntawv qhia npe ntawm cov khoom lag luam kom raug, peb suav sau cov cai los ntawm WPreso, Ntxiv nplooj ntawv / post slug chav kawm rau zaub mov khoom chav kawm.

Tsuas yog ib qho teeb meem… nws ua haujlwm rau nplooj ntawv lossis post, tab sis tsis tshua ua haujlwm rau qeb! Yog li peb hloov kho qhov kev thov rau lub slug nrog:

$ slug = tau_cat_slug ($ id);

Thiab ntxiv rau qhov haujlwm los ntawm WPRecipes, WordPress ua kom yuam kev: Tau qeb slug siv qeb ID, mus rub rov qab cov qeb kab slug rau hauv cov ntaub ntawv ntaus nqi hauv cov ntawv qhia chaw navigation.

Yog li… ua tsaug rau kev sib koom tes ntawm 3 WordPress cov chaw thiab qee qhov kev kho kom zoo los ntawm peb cov jQuery guru ntawm DK New Media, Stephen Coley (rau ua kom cov ntawv qhia zaub mov kom yooj yim tawm), peb muaj qhov system zoo nkauj heev!

Txhua yam haujlwm tau ua tiav nyob hauv peb cov ntsiab lus. Peb tau thauj cov ntawv qhia cov khoom noj hauv lim dej hauv functions.php, ntxiv cov submenu div rau peb lub ntsiab ntawv header.php, ntxiv cov submenu template rau peb, thiab thauj cov submenu JavaScript ntawv hauv peb cov ntawv sau - xyuas kom jQuery twb tau ntim rau hauv peb lub ntsiab lus. li qub. Vam tias koj txaus siab rau kev ua haujlwm, nws yog qhov hloov tshiab hloov rau lub xaib!

8 Comments

  1. 1

    Koj puas qhia lossis muag tus lej no nyob rau ib qho twg? Kuv twb tau sim ua kom nws ua haujlwm tab sis kuv tsis tuaj yeem paub muab tso rau hauv wp_nav_menu nrog tus yamntxwv…

  2. 6
  3. 8

Yuav ua li cas koj xav hais tias?

Qhov Web site no siv Akismet los txo cov kev pabcuam. Kawm li cas koj cov ntaub ntawv tawm tswv yim tiav.