Salient theme header custom post type FIX. Salient is well known WP theme and preferred by many. It gives the editors a beautiful way how to manage their page headers.
But those configs are not available for custom post types. Here is a few step guide how to enable the page header options for custom post types.
EDIT: Before you continue reading I want to mention the the commented “bluesix” has mentioned that ThemeNectar have added a filter for this now, and documented how to implement it https://themenectar.com/docs/salient/metabox-cpt/
Salient theme header custom post type fix
In Salient parent theme there are two files that enable the header options. one for pages and one for posts. The files are:
salient/nectar/meta/page-meta.php salient/nectar/meta/post-meta.php
Pages have a bit more options but weather you want the post type header options or page type header options the process is the same. Here is what you need to do:
Please note: A friendly commenter Mayank, noted that this piece of code got moved to the core plugin in Salient 2019. “They have changed the location of the page-meta.php to the salient-core plugin.” so please check it there as well. Thanks Mayank!
1. Duplicate one or both files in your child theme and place it in the same folder structure
YOUR_CHILD_THEME/nectar/meta/page-meta.php YOUR_CHILD_THEME/nectar/meta/post-meta.php
2. In your child themes functions.php place the following line or lines
include("nectar/meta/page-meta.php"); include("nectar/meta/post-meta.php");
3. Modify the content of the files: change the name of the function line 2 and 3
add_action('add_meta_boxes', 'YOURTHEME_metabox_page'); function YOURTHEME_metabox_page()
4. For every occurrence in the duplicated file change the $meta_box
array’s post_type
keys value with an array of your own custom post types
#-----------------------------------------------------------------#
# Fullscreen rows
#-----------------------------------------------------------------#
$meta_box = array(
'id' => 'nectar-metabox-fullscreen-rows',
'title' => __('Page Full Screen Rows', NECTAR_THEME_NAME),
'description' => __('Here you can configure your page fullscreen rows', NECTAR_THEME_NAME),
// 'post_type' => 'pods_cpt_event', < -- REMOVE THIS LINE and
// ADD the following line with an array of your custom post types
'post_type' => array('POST_TYPE1','POST_TYPE2','POST_TYPE3'), // <- like so
.....
next occurrence >>
.....
#-----------------------------------------------------------------#
# Header Settings
#-----------------------------------------------------------------#
$meta_box = array(
'id' => 'nectar-metabox-page-header',
'title' => __('Page Header Settings', NECTAR_THEME_NAME),
'description' => __('Here you can configure how your page header will appear. <br/> For a full width background image behind your header text, simply upload the image below. To have a standard header just fill out the fields below and don't upload an image.', NECTAR_THEME_NAME),
// 'post_type' => 'pods_cpt_event', < -- REMOVE THIS LINE and
// ADD the following line with an array of your custom post types
'post_type' => array('POST_TYPE1','POST_TYPE2','POST_TYPE3'), // <- like so
.....
next occurrence >>
.....
#-----------------------------------------------------------------#
# Portfolio Display Settings
#-----------------------------------------------------------------#
$meta_box = array(
'id' => 'nectar-metabox-portfolio-display',
'title' => __('Portfolio Display Settings', NECTAR_THEME_NAME),
'description' => __('Here you can configure which categories will display in your portfolio.', NECTAR_THEME_NAME),
// 'post_type' => 'pods_cpt_event', < -- REMOVE THIS LINE and
// ADD the following line with an array of your custom post types
'post_type' => array('POST_TYPE1','POST_TYPE2','POST_TYPE3'), // <- like so
That’s it, the header options should show up when editing your custom post type
If you are having difficulties with the options showing up copy of page-meta.php from https://gist.github.com/lehelmatyus/8bf774828430b53c455d91b957ff4e95
PLEASE NOTE: The file above hosted has been generously provided by a commenter Diongo. Thank you Diongo!
Just be sure to replace the following: YOURTHEME_metabox_page and POST_TYPE1 …
add_action('add_meta_boxes', 'YOURTHEME_metabox_page'); function YOURTHEME_metabox_page(){ ... 'post_type' => array('POST_TYPE1','POST_TYPE2','POST_TYPE3'),
Please ♥ Like the page if you found this useful! Cheers!
Hello,
thanks for your solution but I’m using the parent theme, after having edited post-meta.php or page-meta.php, nothing happens…
Could you guide me please ? I’m still looking for solution after 2 months but doesn’t work…
Thanks.
Hi John,
Issue 1. I had some trouble making it work by copying the file and then overwriting it at first, then I copied the post-meta and page-meta files from a previous version of the theme and that worked for me. That is in the GIST
https://gist.github.com/lehelmatyus/640fd63ba94e605daf03487202e2c7d9. from an earlier version of Salient.
Issue 2. Php OpChache, Memcache and other caching mechanism. I found that I could not reproduce the result consistently. So here is what you can try, 2.1 Clear all cache, 2.2 Restart Apache 2.3 hacky way: put some ‘exit;’ in there and reload the page, and have it fail a couple of times then, mistype a php command or function, let it give you some errors, then remove errors and exit.
I hope this helps, I would like to hear back from you if it worked.
I have a site currently running and it works perfectly for me so you should be able to make it work too.
Cheers,
Lehel
Thanks ! I’ll try each solution.
But, do you think that ACF may cause incompatibilities ?
Thanks a lot for your help btw, I thought it was impossible for me to make it work.
I’ll tell you when it’ll appear on front-end/back-end
This fix worked great for the backend, any tips on getting the salient header to work on the front end? No matter what I try the post header will not show up like it does on the regular posts page. I’ve tried copying the single.php to single-custom-name.php and haven’t had any change.
Hi Noah,
Thanks for your comment,
1. Yes copy the original Single.php into your child theme and modify it there. copy the contents of it into and single-POST_TYPE.php and start from there. Make sure you have these lines in there:
2. From the parent theme SALIENT functions.php copy the huge function
and paste it in your child theme’s function.php. Here you can add modifications IF necessary you can make your changes here.
Let me know if this worked.
Thanks,
Lehel
Thanks so much! I’ve been fighting with this for hours!!!
Brad,
Thanks for your comment, I’m really happy I was able to help.
Cheers!
Lehel
Just following up to say that I finally got a chance to sit down and implement this and it works great!!
One thing I’d point out to other users is that YOURTHEME refers to the theme name of the parent theme and not the child theme. For example, I first tried using YOURTHEME = salient-child but got the white screen of death until I changed it to YOURTHEME = salient
Thanks again for writing this post. As I’m sure anyone reading this knows, it’s super annoying to not have custom post types officially supported.
Hi Brad,
Only use underscored “_” in your function names. Like so: name_like_this and NOT dashes “-” not-like_this.
Maybe that was causing it.
Cheers,
Lehel
Hi,
Could You help with that error:
“Fatal error: Cannot redeclare nectar_metabox_posts() (previously declared in /”MY-PATH”/public_html/wp-content/themes/salient-child/nectar/meta/post-meta.php:8) in /”MY-PATH”/public_html/wp-content/themes/salient/nectar/meta/post-meta.php on line 8”
What should i put instead of YOURTHEME?
Thank You!
Strange, because now I realized that even if I do not change anything in the newly created php files, it is still a error:
Fatal error: Cannot redeclare nectar_metabox_page() (previously declared in /MY-PATH/public_html/wp-content/themes/salient-child/nectar/meta/page-meta.php:5) in /MY-PATH/public_html/wp-content/themes/salient/nectar/meta/page-meta.php on line 5
Any idea?
Did you have any success?
I oroginally pu my child theme name instead of YOURTHEME but see what Brad suggested.
Partial Success ! The custom post type is working with Nectar Header Options but you cannot edit the regular pages.
Got “Cannot redeclare nectar_metabox_page()” and white page of death. Do you have a fix ?
Hi Mayank,
Thanks for your comment,
I updated the gist here https://gist.github.com/lehelmatyus/8bf774828430b53c455d91b957ff4e95
Please copy and take a look now,
Cheers!,
Lehel
Doing my best to get this working, but just can’t seem to get the header options available at all in my CPT’s.
I’m using Toolset Types to create my CPT’s , and I’m wondering if this has been a problem for anyone else.
Hi Shan,
Try the files form my gist
https://gist.github.com/lehelmatyus/640fd63ba94e605daf03487202e2c7d9.
go through the steps again, and See what BRAD suggested.
Lehel
You saved my life!! Thank you so much
I tried your method but it’s not working on the new Salient 2019. They have changed the location of the page-meta.php to the salient-core plugin.
Can you please update this post for a newer version. Thanks a ton.
Hi Mayank,
Thank you very much for notifying us on this, I will make a note in the blog post about this and will add more details if I can get my hands on the new salient theme.
Cheers!
Lehel
Hey, i can get you a copy so you can update your guide. Now it works in the custom post type but returns a error when editing normal pages!
Hi Diogo,
Yes, please share it.
Post it to GitHub as a snippet or create a text bin https://textbin.net/, I will review and share it here giving credit to you.
Thank you very much.
Cheers! Lehel
Hi, was anyone able to figure this out with the newest version of Salient (v11.0)?
Árpád, thanks for your help. There you have the page-meta from the latest update. If any other file is needed please let me know. Kind regards!
https://pt.textbin.net/TWf0cspMrE
Hi Diogo!
Thank you for providing the file, very generous of you.
I have gone ahead and updated the content of this post with your file, and mentioned that you provided the file.
Thanks again,
Árpád Lehel Mátyus
Hi – I am running version 10.0.1 – can you advise what edits to make to add support for custom post types please.
Jon, did you find any solution?
Hey everyone – latest Salient I found this solution.
In the theme directory, take single.php – duplicate it and save it as single-POST_TYPE.php (replace with your post type, for example: single-product.php would place it on Product pages) and then place this in your theme directory alongside single.php – do NOT add anything else to it.
// Add to custom post type.
function salient_child_page_header_post_types($post_types) {
$new_post_types = array(
‘POST_TYPE’
);
$post_types = array_merge($new_post_types, $post_types);
return $post_types;
}
add_filter(‘nectar_metabox_post_types_page_header’, ‘salient_child_page_header_post_types’);
add_filter(‘nectar_metabox_post_types_navigation_transparency’, ‘nectar_metabox_post_types_fullscreen_rows’);
_
This sill add all meta boxes, page header settings etc to your custom post type.
ThemeNectar have added a filter for this now, and documented how to implement it https://themenectar.com/docs/salient/metabox-cpt/
Thank you for this. I will add the link to the post and credit you.
Almost 6 years later and this till works. Thank you very much.
🙂 My pleasure. So glad to hear it.