Show specific pages list as drop down box in WordPress
Updated On May 23, 2015 April 29, 2013 -Written ByListings displayed in the form of drop down box look neat and do not take much space on your website. Unlike posts, we generally publish limited number of pages on a WordPress website. Hence, one better way to show pages listing is in the form of drop down box.
Display Pages list as drop down box (php code)
1. Just add following code to required place where you want to show the drop down box. If you want to add this to a widget area, then enable PHP code execution in widget through a plugin. Then drag the PHP code widget and paste this code in it.
2. In this code, (532,389,417,450,472,510,502,520) are IDs of pages that we want to list. You should replace them with page IDs as on your website. Procedure to find page IDs is similar to finding categeory and tag IDs in WordPress.
3. In the code, (selected=532) means which page listing should be displayed by default (like Contact Us in the screenshot) in the drop down box. You can replace it with any page listing as on your website. You can also style this code output by wrapping in specific class and then defining css style for that class as per requirement.