Archived topic
Bulk change Disable Elements
15 replies · Started by Paul on May 24, 2017
Hi
I realise that I have been inconsistent in Disable Elements settings across my site. There are now hundreds of posts. Is there a way to bulk change so that all posts (they are custom posts) can be given the same Disable Elements settings?
I know I can achieve some of what I want with CSS but I would really prefer the simpler solution.
thanks
Hi Paul,
This post should help: https://generatepress.com/forums/topic/sections-set-to-disabled-by-default/#post-314143
With some conditional tags: https://codex.wordpress.org/Conditional_Tags#A_Single_Page.2C_a_Single_Post.2C_an_Attachment_or_Any_Other_Custom_Post_Type
Let me know if you need more info.
Hi Leo
Many thanks for the really quick response.
I am pretty sure that what you shared would do the trick - but I am not sure how to use the conditional. If I want to hide the site name and logo on every page, would this be correct:
add_action( 'after_setup_theme','tu_remove_header' );
function tu_remove_header() {
remove_action( 'generate_header','generate_construct_header' );
}
But I only want to hide it on specific custom post types - sfwd-topic, sfwd-lessons, sfwd-courses (from LearnDash LMS).
Could you help with the code please.
best wishes
Paul
Try this:
add_action( 'after_setup_theme','tu_remove_header' );
function tu_remove_header() {
$post_types = array(
'sfwd-topic',
'sfwd-lessons',
'sfwd-courses'
);
if ( in_array( get_post_type(), $post_types ) ) {
remove_action( 'generate_header','generate_construct_header' );
}
}
Fantastic - works perfectly!
Thank you so much.
May I ask one more question. As well as removing the site header, I would like to ensure that the Content Title is always visible - even though I may have Disabled it on a specific post. Is that possible?
best wishes
Paul
You could try this:
add_action( 'wp','tu_always_show_title', 55 );
function tu_always_show_title() {
add_filter( 'generate_show_title', '__return_true', 20 );
}
Thanks Tom
Unfortunately that didn't work.
I just edited the code above - can you try again?
Thanks again Tom - unfortunately the title still doesn't show.
I don't know if this helps - I deactivated GP Premium and the Disable Elements block is still on the Edit Post page but with only one option, Content Title. If this is unchecked, the Title does show. Checked and the title doesn't show.
Hmm, how are you adding that code?
I am placing it into functions.php in gpchild theme (that's where I put the code to remove the site header too).
Hmm.. Any chance you can send me temporary admin login details with a link to a page where the title should be showing up?: https://generatepress.com/contact/
Ahh the title is there but still has CSS applied to it.
Try this:
.single-sfwd-topic .entry-header {
display: block;
}
Great - works!
Thank you very much for investing so much time in helping me Tom.
Really appreciated.
best wishes
Paul