Revision: 50419
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 20, 2011 13:41 by FatFolderDesigner
Initial Code
// in the functions.php file function the_loop(){ $GLOBALS['h']=array(); foreach(func_get_args()as$k=>$v){$i++;$GLOBALS['h'][$v]=false;} require 'loop.php'; } function display($v){ global $h; if(array_key_exists($v,$h)){ return $h[$v]; }else{ return true; } } // how you call the new loop on your theme page the_loop('comments','meta'); // how you'd go about filtering items out of the loop, in this case comments and meta would be filtered if(display('title')){ // Your title display code } if(display('meta')){ // Your meta display code } if(display('content')){ // Your content display code } if(display('comments')){ // Your comments display code }
Initial URL
http://fatfolderdesign.com/308/unimportant/simpler-single-loop-wordpress-theme-creation
Initial Description
Instead of requiring the loop.php file in your custom themes you can use there two functions, placed in your functions.php file to not only automatically include it, but make a dead simple to filter sections out on a page by page basis negating the need for special loops for specific page types (like a search loop or a main index loop) The first section is the code you put into your functions file. The second is how you would call the new "the_loop()" function, simple but all the individual sections you want filtered out as variables, one after another. The third sections is how you would go about filtering items out. More information at the link, questions or comments can be posted here or there and I'll get back to you whenever I can.
Initial Title
Simple single "loop.php" Word Press theme function
Initial Tags
php, wordpress
Initial Language
PHP