Layisha okuthunyelwe kwakamuva ngesigaba ngemenyu ye-WordPress usebenzisa umthwalo we-jQuery

jquery

Uma uvakashele amanye amabhulogi amakhulu ngaphandle lapho athanda Mashable, ungaqaphela ukuthi banesistimu yemenyu enhle kakhulu eyehlayo futhi ikunikeze ukubonakala kokuthunyelwe kwakamuva kwebhulogi kusuka esigabeni ngasinye. Ukuqinisekisa ukuthi ikhasi alithathi unomphela ukulayisha, balayisha lokho okuqukethwe besebenzisa i-Ajax… bese beyilayisha kuqala kuphela ngemuva kokuthi ikhasi selilayishwe ngokugcwele.

I-WordPress Ajax Submenu

Besifuna ukwenza okufanayo lapha ku Martech Zone. Ukunikeza ukuqonda ngezigaba esinazo, bengifuna ukukhombisa okunye okuthunyelwe ngaphakathi kwesigaba ngasinye. Sazi kahle i-WordPress, i-WordPress API kanye ne-jQuery kepha ngaze ngathola i-athikili ku- Ilanda Okuthunyelwe ngesigaba kusetshenziswa i-jQuery ukuthi sibe nesisombululo esihle.

QAPHELA: Isici esisodwa sendlela yabo engikholwa ukuthi siyisixazululo esihle ukudlulisa yonke intambo query_post ngeJavaScript… kubonakala kimi ukuthi uzivulela wena ngokugenca! Ngiguqule iskripthi salesi siza ukuze ngidlulise kuphela amapharamitha adingekayo ngaphakathi komyalo we-query_posts.

Okokufundisa kunyathela umsebenzisi ngokwakha isifanekiso sokudonsa ngamandla okuthunyelwe, nokuthi ungazakha kanjani izixhumanisi ezingaqala isicelo. Bekungaba lula ukube besifuna nje ukwenza ezinye izixhumanisi, kepha empeleni besifuna ukusebenzisa i-WordPress 'eyakhelwe kwimenyu yokuzulazula. Ngeshwa kithi, izixhumanisi zemenyu zeWordPress zikhiqize izinombolo njengoba ungeza futhi ususa izinto zemenyu… kepha empeleni azinalo ulwazi ngesigaba ofisa ukusidonsa futhi usidlulise ocingweni lwakho lwe-Ajax.

Ukulebula izinto zohlu lwemenyu kahle, sifake ikhodi kusuka ku-WPreso, Ngeza ikhasi / iposi leslug ekilasini lezinto zemenyu.

Inkinga eyodwa kuphela… isebenza ekhasini noma kokuthunyelwe, kepha empeleni ayisebenzelanga Isigaba! Ngakho-ke sivuselele isicelo se-slug nge:

$ slug = thola_cat_slug ($ id);

Futhi ungeze umsebenzi kusuka kuma-WPRecipes, I-WordPress iqhinga: Thola isigaba slug usebenzisa isigaba ID, ukubuyisela emuva i-slug yesigaba kumfanelo yedatha kumenyu yokuzula.

Ngakho… sibonga imizamo yokubambisana yamasayithi ama-3 WordPress nokuhlenga okuhle okwenziwe yi-jQuery guru lethu ku- DK New Media, UStephen Coley (yokwenza bushelelezi imenyu), sinohlelo oluhle kakhulu lwe-submenu!

Wonke umsebenzi wenziwe ngaphakathi kwamafayela wethu wetimu. Silayishe izihlungi zemenyu yokuzulazula ku-works.php, sengeze i-submenu div kufayela lethu le-header.php, sengeza ithempulethi le-submenu kithina, futhi salayisha ifayili le-submenu JavaScript kusihloko sethu - siqinisekisa ukuthi i-jQuery isivele ilayishiwe kutimu yethu kanjalo. Ngiyethemba uyawazisa umsebenzi, bekuyisibuyekezo esimnandi esizeni!

8 Amazwana

  1. 1
  2. 6
  3. 8

UCABANGANI?

Le sayithi isebenzisa i-Akismet ukunciphisa ugaxekile. Funda ukuthi idatha yakho yokuphawula isetshenziswa kanjani.