Is there a tirck in the get_xxxx function in the general_template.php file?

The do_action: do_action( ‘get_header’, $name ); its triggering the action get_header, so all actions attached using add_action to the action ‘get_header’ will be executed, its also passing the $name as parameter to the functions by example: function my_function($name){ echo “The Action sent me the name:”.$name.”!!”; } add_action(‘get_header’, ‘my_function’); when the do_action( ‘get_header’, $name ); is … Read more

How to move style from template file to section?

What about putting styles before the function get_header(); <style type=”text/css”>#header { display: none; }</style> <?php get_header();?> <div class=”main-container-of-my-template”></div> <?php get_footer(); ?> However this is not recommended as it loads the styles even before the <html> not within the <head> section of your website, but as per your requirement this could be the only way to … Read more

Template part vs Sidebar (differences)

The get_sidebar($name); function loads sidebar template file sidebar-{$name}.php if no name in the prentacies is specified it loads the sidebar.php file. get_sidebar() and get_template_part() are almost identical, at the end they call locate_template() function that take care of loading from files. The only difference is the hook fired. If you use get_sidebar() for all your … Read more

Correct way to use get_template_part() and get_post_format() with custom post types?

What you’ve done will include content-competitions-<post-format>.php. I don’t know if that is what you want, but that is correct as far as structure goes. I also don’t know what you mean by “to change that one line”, but get_template_part will use the two parameters to construct a file name/path so, yes, you do need to … Read more

get_template_part not working with ajax

get_template_part() includes the PHP file, which will break $resp. You need to use output buffering to capture the output into a variable: ob_start(); get_template_part( ‘templates/update’, ‘profile’ ); $data = ob_get_clean(); $resp = array( ‘success’ => true, ‘data’ => $data );