I am moving a site from a Genesis theme to Colorlib theme. The genesis theme includes add_action( 'genesis_before_while', 'custom function' );
in a custom archive page, which loads restricted content from a template part. Is there a standard WP hook equivalent? or a work-around?
2 Answers
After thinking through Tom Nowell's advice it occurred to me I could create a custom hook and place it after if( have_posts()
. This worked like a charm. Thanks again. https://developer.wordpress.org/plugins/hooks/custom-hooks/
-
note that this will be lost when you apply updates to the Colorlib theme– Tom J Nowell ♦Jan 3, 2022 at 0:06
-
Yes. I turned off auto updates on the theme. It is buying me much-needed time to develop a new query, so this works.– MARWEL58Jan 3, 2022 at 4:01
It's possible there's an equivalent filter in the new theme but there is no standard general hook you can use that acts as a direct replacement like for like.
You should check the Colorlib themes documentation and support, but keep in mind Genesis relies heavily on custom hooks by design, much more so than other themes. You might be able to manually add a hook in a child theme if Colorlib is built properly.
-
Thanks. I sent this question to the Colorlib folks.. I may need to recreate the whole query to fit the new theme.– MARWEL58Jan 2, 2022 at 21:45
genesis_before_while
run?Before the Loop Hook - genesis_before_while
it goes abovewhile_posts
The genesis_before_while runs after the if( have_posts() ) * and before while( have_posts() ) : the_post();