Guys and girls, what month have I been trying to revive my wordpress site. Clearly I see that I still the same bydlokoder. Help me to implement such a thing that I did, just more normal code (: D):
So there is: There is a "system" of regions on the site, the selected region is a category. That is, the user is invited to select 6 categories, and a redirect is made to the selected one. There is a menu consisting of 4 categories: Rent, Sale, Exchange, Purchase. When you click on one of the categories, subcategories appear, but those that belong to the category that you clicked on in the menu, as well as those belonging to the already selected region. That is, in general, to present a picture of nesting categories:
Moscow
-Rent
- For a long time
-Exchange
--Apartments
Peter
-Rent
- For a short time
-Purchase
--Rooms
I hope it is clear. How did I:
<div id="menu1"> //Π±Π»ΠΎΠΊ ΠΌΠ΅Π½Ρ <div id="order-cat" class="order"> //Π±Π»ΠΎΠΊ ΠΏΠ΅ΡΠ²ΠΎΠΉ ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΈ <?php /* ΠΡΠ»ΠΈ ΠΌΡ Π² ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΈ ΠΈ ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΡ - ΡΠ΅Π³ΠΈΠΎΠ½, ΡΠΎ ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠΏΠΈΡΠΎΠΊ Π΄ΠΎΡΠ΅ΡΠ½ΠΈΡ
ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΉ Π°ΡΠ΅Π½Π΄Ρ */ if(is_category() and get_query_var('cat') == '10') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 30,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '11') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 31,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '34') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 37,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '33') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 38,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '15') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 32,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '35') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 36,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } ?> </div> <div id="order-cat" class="sell"> //Π±Π»ΠΎΠΊ Π²ΡΠΎΡΠΎΠΉ ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΈ <?php /* ΠΡΠ»ΠΈ ΠΌΡ Π² ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΈ ΠΈ ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΡ - ΡΠ΅Π³ΠΈΠΎΠ½, ΡΠΎ ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠΏΠΈΡΠΎΠΊ Π΄ΠΎΡΠ΅ΡΠ½ΠΈΡ
ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΉ ΠΏΡΠΎΠ΄Π°ΠΆΠΈ */ if(is_category() and get_query_var('cat') == '10') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 40,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '11') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 43,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '34') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 41,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '33') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 42,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '15') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 44,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '35') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 39,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } ?> </div> <div id="order-cat" class="buyme"> //Π±Π»ΠΎΠΊ 3ΠΉ ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΈ <?php /* ΠΡΠ»ΠΈ ΠΌΡ Π² ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΈ ΠΈ ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΡ - ΡΠ΅Π³ΠΈΠΎΠ½, ΡΠΎ ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠΏΠΈΡΠΎΠΊ Π΄ΠΎΡΠ΅ΡΠ½ΠΈΡ
ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΉ ΠΏΠΎΠΊΡΠΏΠΊΠ° */ if(is_category() and get_query_var('cat') == '10') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 46,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '11') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 49,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '34') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 47,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '33') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 48,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '15') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 50,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '35') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 45,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } ?> </div> <div id="order-cat" class="changeme"> //Π±Π»ΠΎΠΊ 4 ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΈ <?php /* ΠΡΠ»ΠΈ ΠΌΡ Π² ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΈ ΠΈ ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΡ - ΡΠ΅Π³ΠΈΠΎΠ½, ΡΠΎ ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΠΏΠΈΡΠΎΠΊ Π΄ΠΎΡΠ΅ΡΠ½ΠΈΡ
ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΉ ΠΎΠ±ΠΌΠ΅Π½Π° */ if(is_category() and get_query_var('cat') == '10') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 52,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '11') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 55,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '34') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 53,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '33') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 54,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '15') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 56,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } else if(is_category() and get_query_var('cat') == '35') { $args = array('style'=>'none','show_count'=> 1,'hide_empty'=> 0,'use_desc_for_title' => 0,'child_of'=> 51,'hierarchical'=> true,'title_li'=>'','number'=>7); wp_list_categories($args); } ?> </div> </div>
get_query_var ('cat') == '10', get_query_var ('cat') == '11', etc. are identifiers of the category-region. And in each variable $ args: 'child_of' => 45, 'child_of' => 44, etc. - this is the ID of the child headings, namely rent, sale, purchase, exchange, which in turn are subcategories from categories- regions.
Oh, I hope that at least someone understood what I mean :) In the end, someone will help to somehow reduce the code, and stop being a coder :)