Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]

There is indeed an unwanted ; (semicolon) in your function (try to look at line 99 in the twentytwentyone-child/functions.php file) which likely is the cause to the syntax error. So just remove that ; and the error would be gone: function my_service_template_footer_data() { echo “<script type=”application/ld+json”> { ‘@context’: ‘https://schema.org/’, ‘@type’: ‘Service’, ‘serviceType’: ‘ ” . … Read more

Pass argument to event hook

I would suggest first read the wordpress documentation about actions to understand how they work. Actions are aplit into two section, add_action and do_action do_action is the “location” where you hook into it. A basic example of do_action do_action(‘my_custom_action’); You can also pass arguments into do_action which can be available in add_action if you choose … Read more

add_action taking an array with the 2nd argument?

Shouldn’t the 2nd argument be a function? The second argument should be a value of type callable. callables are a fundamental type in PHP. E.g. these are some valid callables: Value Equivalent ‘test’ test() [ $obj, ‘test’ ] $obj->test() [ ‘foo’, ‘bar’ ] foo::bar() function() {…} or closure $foo = function(){…}; $foo(); And so on, … Read more

How to debug this search & replace strings snippet?

Notice the if ( is_page() line. It’s to indicate that the snippet only works with pages, not posts. Pull it out of the if condition if you want to apply it site-wide. function wpdocs_replace_content( $text_content ) { $text = array( ‘chamber’ => ‘<strong>chamber</strong>’, ); $text_content = str_ireplace( array_keys( $text ), $text, $text_content ); return $text_content; … Read more