I developed a child theme for Genesis that adds Bootstrap on top of it.
In the core of this child theme I edited the way the category is displayed in the post, putting it above the title.
Now, I'd like to remove the action again but it seems not working.
This is theory, below I write something more, with code.
PRACTICALLY
I have the file src/lib/post.php
that adds the action shq_genestrap_post_meta_categories
:
function shq_genestrap_post_meta_categories() {
$filtered = apply_filters( 'shq_genestrap_post_meta_categories', '[post_categories]' );
if ( false == trim( $filtered ) ) {
return;
}
// Remove the label and commas
$filtered = str_replace([__( 'Filed Under: ', 'genesis' ), ', '], '', $filtered);
genesis_markup( [
'open' => '<p %s>',
'close' => '</p>',
'content' => genesis_strip_p_tags( $filtered ),
'context' => 'entry-meta-categories',
] );
}
add_filter( 'shq_genestrap_post_meta_categories', 'do_shortcode', 20 );
add_action( 'genesis_entry_header', 'shq_genestrap_post_meta_categories', 9 );
remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
As you can see, I add my custom function genesis_post_meta
and then I remove the Genesis action genesis_post_meta
.
Now, from the file src/functions.php
I'd like to remove the action shq_genestrap_post_meta_categories
I added before:
remove_action( 'genesis_entry_header', 'shq_genestrap_post_meta_categories', 9 );
But this doesn't work.
WHY AM I DOING THIS
The final goal is to provide a Bootstrap on top Genesis, so, the files in src/lib
should not be modified: this way, when I update the main repository, it is possible to update the child theme.
To further customize the child theme, instead, I want to use the file src/functions.php
that is never updated on the repository.
Doing this, if someday I update the file src/lib/post.php
it is sufficient to copy the files from the main repository into the customized version of the theme and all the other customizations done through the src/functions.php
file will continue to work.
But, as told, I'm not able to remove actions set by the files in src/lib
.
CONCLUSIONS AND QUESTION (AGAIN)
I add the action shq_genestrap_post_meta_categories
in src/lib/post.php
.
Then I'd like to remove the action shq_genestrap_post_meta_categories
from the file src/functions.php
but this doesn't work:
// src/function.php
remove_action( 'genesis_entry_header', 'shq_genestrap_post_meta_categories', 9 );
How can I remove the action added in src/lib/post.php
from the file src/functions.php
?