Getting current post ID in functions.php

I believe this should work in all cases – whether you are in the loop or not. (In a widget, chances are you are not in the loop) Mind you, outside the loop, this will work very well on single pages or posts, but might not display the post you want on other types of … Read more

$content variable – Is this a reserved variable for a WordPress function? – php / wordpress

$content – is not reserved in WordPress, it can be used. In the function the_content () – a variable is used, but it is only available in this function. The code of the function itself: https://core.trac.wordpress.org/browser/tags/4.7/src/wp-includes/post-template.php#L230 Scope of variables in php: http://php.net/manual/en/language.variables.scope.php

how to add an image to the footer?

Sounds like several different pointers may be useful: Are you working on a theme that was custom developed for your website? If not, you should create a child theme so that anytime the parent theme receives an update, your changes won’t be overwritten. The image you’re trying to add should either be uploaded through WordPress’s … Read more

How do I pass arguments for multiple functions hooked to a single action?

The value for the default output should be passed to do_action() as the second parameter. E.g.: do_action( ‘my_action’, ‘<p>Default output</p>’ ); Note that the above code will not actually output anything. It’s just going to fire the callbacks attached to the my_action hook and it will pass ‘<p>Default output</p>’ to those functions. You can modify … Read more

Shortcode return function with link href inside PHP

You can use ob_start and ob_get_clean to print out your shortcode. function shortcode_html() ob_start(); ?> <div class=”boxed max-width”> <div class=”indice-title”> <span><?php echo $content; ?></span> <i class=”fa fa-twitter” aria-hidden=”true”></i> </div> </div> <?php return ob_get_clean(); } add_shortcode( ‘print_shortcode’, ‘shortcode_html’ );

wp_validate_logged_in_cookie

wp_validate_logged_in_cookie() comment from source: /** * Validates the logged-in cookie. * * Checks the logged-in cookie if the previous auth cookie could not be * validated and parsed. * * This is a callback for the {@see ‘determine_current_user’} filter, rather than API. * * @since 3.9.0 * * @param int|bool $user_id The user ID (or … Read more