1

I'm using a WordPress plugin that allows integration actions to integrate it within a theme. Using GeneratePress' Elements feature, I'm adding the action as a hook. Currently the code I'm using is:

<?php do_action(webcomic_integrate_landing_page);
?>

The action itself has some boolean parameters listed at this website. The one I'm most interested in is webcomic_meta.

How can I incorporate the webcomic_meta parameter (set to false) within the PHP tags for running this action?

1

First of all, let's take a look at do_action docs. As we can read there, this is the function that:

Execute functions hooked on a specific action hook.

And that's the way to use it:

do_action( string $tag,  $arg = '' )

So the first param is the tag (or the hook name). And then you can pass $arg (or rather $args).

And how to pass that args?

Well... It depends on action. Some of them take no args. Some of them take only one, and some of them take many args. Here's examples:

// this action takes no args
do_action( 'foo' );

// this action takes one arg
do_action( 'bar', $param );

// and this takes few args:
do_action( 'foobar', $param1, $param2, $param3 );

In your case, webcomic_integrate_landing_page takes only one param, which should be an array (as we can read here):

do_action( 'webcomic_integrate_landing_page', array $args );

So if you want to pass any args in there, here's how:

do_action( 'webcomic_integrate_landing_page', array( 'webcomic_comments' => true, 'webcomic_meta' => false ) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.