Update:
As much as I hate to edit a parent theme file, I’ve edited the function: “hu_is_authorized_tmpl” in file: functions/init-front.php to include (authorize) my custom tmpl file. Of course, it works, but this is far from ideal, especially as Hueman is updated very frequently (https://themes.trac.wordpress.org/log/hueman).
I attempted first to override the function with remove_filter (done the proper way to ensure it’ll override the parent?), and this may be the best method to achieve what I need. It didn’t work, however, and I’m hoping it’s a simple mix-up in how I’ve set the overriding function up (likely!).
function my_hu_is_authorized_tmpl( $tmpl ) {
$ct_map = apply_filters(
'hu_content_map',
array( 'tmpl/index-tmpl', 'tmpl/archive-tmpl', 'tmpl/page-tmpl', 'tmpl/single-tmpl', 'tmpl/search-tmpl', 'tmpl/404-tmpl', 'tmpl/MYCUSTOMTEMPLATEFILE-tmpl' )
);
//Are we good after filtering ?
if ( ! is_array( $ct_map ) || ! is_string( $tmpl ) )
return;
return in_array( $tmpl, $ct_map );
}
function my_child_theme_setup() {
remove_filter( 'hu_is_authorized_tmpl', 'hu_content_map' );
add_filter( 'hu_is_authorized_tmpl', 'my_hu_is_authorized_tmpl' );
}
Of note, I agree with the poster of the topic “Custom post type templating issues” on several points. I think we use WP so differently that even themes need to be highly customizable and with few restrictions. I may switch to a CPT for this specific category and will also need to know how best to add a CPT template within Hueman. This is a wonderful theme — one of the best available — but I’m just currently stuck. Input is appreciated.
Hi, I’m having a similar issue, with a custom post type. I created a child theme, and over there proceeded to create custom single and archive templates for my resource type. Unfortunately hueman outsources the functions to the tmpl/ and parts/ folders. After some tracing I managed to find hu_is_authorized_tmpl
function defined in the functions/init-front.php
file. I made a copy of it in my child theme and edited it, to include my custom post type’s templates that I created in the tmpl/
folder of my child theme. As per this documentation it’s supposed to look in the child theme for the replacement. Instead it seems to be ignoring my new init-front.php and using the old one only. I’m now going to try and define this function afresh in the functions.php
of my child theme as advised in the documentation.
GOTCHA! I re-defined the hu_is_authorized_tmpl
function in my child theme’s functions.php
. My site went white-screen, but thanks to the error log created in my site’s root dir, I’ve now confirmed that the hueman theme is loading functions/init-front.php
from the PARENT theme instead of the CHILD theme. They left this function “unplugged”, so I had to edit the parent theme’s functions/init-front.php
to make it “pluggable”, as defined in their documentation. My customizations are now working fine 🙂 Hope this helps others.
Error log:
[30-Dec-2017 16:48:16 UTC] PHP Fatal error: Cannot redeclare hu_is_authorized_tmpl() (previously declared in /..path../wp-content/themes/hueman-tropicsu/functions.php:11) in /..path../wp-content/themes/hueman/functions/init-front.php on line 56
pluggable function in functions/init-front.php
in the parent theme:
if( ! function_exists('hu_is_authorized_tmpl') ) {
function hu_is_authorized_tmpl( $tmpl ) {
$ct_map = apply_filters(
'hu_content_map',
array( 'tmpl/index-tmpl', 'tmpl/archive-tmpl', 'tmpl/page-tmpl', 'tmpl/single-tmpl', 'tmpl/search-tmpl', 'tmpl/404-tmpl' )
);
//Are we good after filtering ?
if ( ! is_array( $ct_map ) || ! is_string( $tmpl ) )
return;
return in_array( $tmpl, $ct_map );
}
}
He hecho lo de conectar en el archivo init-front.php pero no me funciona mi custom post type :/