[Plugin: Multiple content blocks] Support for page-{slug}.php files (includes hack solution)
-
I needed the ability to use Multiple Content Blocks on different page template files. I use the page-{slug}.php approach and MCB did not look in there, so I put a bit of a hack in place to get it working:
Line 61: Right after the close of the “if(substr(strrchr($fileToRead,’/’),1) == ‘default’…”
} else if ($post->post_type == 'page') { // try to load template file based upon template hierarchy for pages // see: https://codex.www.ads-software.com/Template_Hierarchy#Page_display // try page-{slug}.php first $fileToRead = get_template_directory().'/page-'.$post->post_name.'.php'; // if not, try page-{id}.php next if (!file_exists($fileToRead)) $fileToRead = get_template_directory().'/page-'.$get_queried_object_id().'.php'; // if not, try page.php next if (!file_exists($fileToRead)) $fileToRead = get_template_directory().'/page.php'; // if not, try index.php last if (!file_exists($fileToRead)) $fileToRead = get_template_directory().'/index.php'; // set filepath to start at /themes $fileToRead = strstr($fileToRead,'/themes/'); }
Any chance actual support could be added so that I don’t have to maintain a separate copy?
Thanks!
Brianhttps://www.ads-software.com/extend/plugins/multiple-content-blocks/
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘[Plugin: Multiple content blocks] Support for page-{slug}.php files (includes hack solution)’ is closed to new replies.