I'm getting confused trying to implement these custom theme hooks. Trying to wrap my head around that.
I thought i understood this. but now after reading code for several hours; it's made it worst.
How do i modify the argument being passed in the following?
functions.php
function theme_content() {
do_action('theme_content'); // Initialize my custom hook
}
function theme_content_alter($arg) {
// Do processing
if (!$arg) {
echo '<h2>default</h2>';
}
if ($arg == 'foo') {
echo '<div class="content">bar</div>';
}
echo apply_filters('theme_content','theme_content_alter', $arg);
} add_action('theme_content', 'theme_content_alter');
index.php
theme_content($arg = 'foo');
What i'm trying to achieve
Being able to override hooks and handle contextual processing inside a functions or a separate file from a require.
An example: on a front page i want theme_content() to have no sidebar but on a subpage it'll contain a sidebar, etc. This could be expressed like so:
Is this the proper way to do this? I've tried to write it in my theme and haven't been able to figure out why it's not working. My arguments are not being passed in the parameters.
What i have done
Reviewed several threads on this SE and found them not very helpful for my context: