get_template_part in admin

Yes, get_template_part() does work on Admin pages. Here is how I tested: Add this to functions.php theme (or child theme) file: add_action( ‘admin_menu’, ‘wpse_99662_register_admin_test_page’ ); function wpse_99662_register_admin_test_page() { add_menu_page( ‘Admin Test Page’, ‘Admin Test Page’, ‘manage_options’, ‘admin_test_page’, ‘wpse_99662_admin_test_page’ ); } function wpse_99662_admin_test_page() { echo ‘<h2>Admin Test Page</h2>’; get_template_part( ‘admin’, ‘test’ ); } The admin-test.php file … Read more

How to pass variables with get_template_part?

This is essentially scope visibility issue. include brings code into a current scope, function call creates new closed off scope. In get_template_part() only certain WordPress globals are being made available by load_template() call inside. While the basic answer is to declare your variables as globals, you might want to ponder your overall architecture a bit … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)