How to create a post template with two sidebars

If you add sidebar-sidebaraleatorio.php and sidebar-sidebarrecomenda.php sidebar templates to your (child) theme directory, you can then call them with get_sidebar() function. Like so get_sidebar(‘sidebaraleatorio); and get_sidebar(‘sidebarrecomenda);. You can read more about sidebars from the Developer Handbook > Sidebars.

How do I get the page template name chosen?

I picked the following code from an answer here, https://stackoverflow.com/questions/2544870/remove-main-editor-from-wordpress-edit-page-screen/42093956. I tweaked the code to remove the classic editor on pages using default page template. And added the comments. function remove_editor_init() { $post_id = 0; if ( isset( $_GET[‘post’] ) ) { $post_id = $_GET[‘post’]; } $template_file = get_post_meta( $post_id, ‘_wp_page_template’, TRUE ); // var_dump($template_file) … Read more

Is there a more efficient way to loop through pages?

Alternative to if… else… you can use the control structure switch functionality. But if you use if… elseif… or switch is mainly a matter of preference. The performance is the same. if else if ($i == 0) { echo “i equals 0”; } elseif ($i == 1) { echo “i equals 1”; } elseif ($i … Read more

Two exact templates, sidebar showing in one but not the other

Look at the config.php: function roots_display_sidebar() { $sidebar_config = new Roots_Sidebar( /** * Conditional tag checks (http://codex.wordpress.org/Conditional_Tags) * Any of these conditional tags that return true won’t show the sidebar */ array( ‘is_404’, ‘is_front_page’ ), /** * Page template checks (via is_page_template()) * Any of these page templates that return true won’t show the sidebar … Read more