Title: [Plugin: Multiple content blocks] Support for page-{slug}.php files (includes hack solution)
Last modified: August 20, 2016

---

# [Plugin: Multiple content blocks] Support for page-{slug}.php files (includes hack solution)

 *  [bkrabach](https://wordpress.org/support/users/bkrabach/)
 * (@bkrabach)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-multiple-content-blocks-support-for-page-slugphp-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: http://codex.wordpress.org/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!
    Brian
 * [http://wordpress.org/extend/plugins/multiple-content-blocks/](http://wordpress.org/extend/plugins/multiple-content-blocks/)

Viewing 1 replies (of 1 total)

 *  [brokentyro](https://wordpress.org/support/users/brokentyro/)
 * (@brokentyro)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-multiple-content-blocks-support-for-page-slugphp-files-includes-hack-solution/#post-2539915)
 * I ran into this problem as well. It would be nice to see this added to the plugin.
 * To the plugin author- thanks for your hard work and an excellent plugin!

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.

 * ![](https://s.w.org/plugins/geopattern-icon/multiple-content-blocks.svg)
 * [Multiple content blocks](https://wordpress.org/plugins/multiple-content-blocks/)
 * [Support Threads](https://wordpress.org/support/plugin/multiple-content-blocks/)
 * [Active Topics](https://wordpress.org/support/plugin/multiple-content-blocks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/multiple-content-blocks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/multiple-content-blocks/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [brokentyro](https://wordpress.org/support/users/brokentyro/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/plugin-multiple-content-blocks-support-for-page-slugphp-files-includes-hack-solution/#post-2539915)
 * Status: not resolved