sidebar.php
-
Hi,
Im trying to create a theme from scratch, but have one small problem. in index.php file I have
<?php get_header();?> <?php get_sidebar();?> <?php get_footer();?>but I dont have any sidebar.php file in my theme yet, anyhow it renders with ARCHIVES, CATEGORIES and META sections in my theme, but I dont need it yet. When I remove
<?php get_sidebar();?>it is all fine. Can anyone tell me from where it gets the file to display in y theme? Im creating it on my localhostMany thanks
-
Can anyone tell me from where it gets the file to display in y theme?
<?php get_sidebar();?> gets sidebar.php
Thanks,
Its’s interesting, because I don’t have sidebar.php in my theme file structure. I tried deleting the default themes too, and see what happens, still the same. I really don’t know from where it pulls it.
What theme are you using?
help me too icant open login to my site like this ‘Parse error: syntax error,
unexpected ‘<‘ in /home/
u143892164/public_html/
wp-content/themes/
home_dealing6/library/
sidebars.php on line 204′detaatsilado I would change theme to Twenty Twelve theme. If that doesn’t work, please start a new topic.
Thanks @mercime,
Im using blank theme from scratch, it’s completely stripped, and im just adding my styles and markup.
Cheers
There is no sidebar.php file I can edit, but it displays with the GET request anyway.
WordPress loads a default template from from /wp-inludes/theme-compat/sidebar.php
this is the core code, from /wp-includes/general-template.php, behind
get_sidebar():function get_sidebar( $name = null ) { 83 do_action( 'get_sidebar', $name ); 84 85 $templates = array(); 86 if ( isset($name) ) 87 $templates[] = "sidebar-{$name}.php"; 88 89 $templates[] = 'sidebar.php'; 90 91 // Backward compat code will be removed in a future release 92 if ('' == locate_template($templates, true)) 93 load_template( ABSPATH . WPINC . '/theme-compat/sidebar.php'); 94 }Thank you alchymyth,
Will try your way straight away after work. So could I just change the last
ifstatement tofalse? Sorry about the dumb question.Many Thanks
@linards you should not be changing core files which alchyyth referred to above.
Going back to your original post:
but I dont have any sidebar.php file in my theme yet, anyhow it renders with ARCHIVES, CATEGORIES and META sections in my theme, but I dont need it yet.
What exactly do you want to do?
Thank you @mercime,
Im new to PHP, I want to edit(if necessary) the
sidebar.phpfile in my blank theme file directory, but how thesidebar.phpis loaded in my theme from default theme path /wp-inludes/theme-compat/sidebar.php which alchymyth so kindly explained to me.Thanks for taking time to investigate
Will try your way straight away after work. So could I just change the last if statement to false? Sorry about the dumb question.
that was no suggestion to change anything; it was just an explanation why a sidebar shows even if you don’t have the template in your theme.
general caveat: do not edit core files
unless you have sidebar.php in your theme, do not use the
<?php get_sidebar(); ?>in your theme’s templates.I want to edit(if necessary) the sidebar.php file in my blank theme file directory
create a sidebar.php template file in your theme; and add the necessary code;
if you don’t want any output just yet, add only<?php return; ?>into sidebar.phpDear alchymyth,
thank you for your thorough explanation, caveat taken on-board.
This is more than I expected.Cheers
I’m totally new to WP and any website building. Just teaching myself from forums and YouTube videos and going very slow.
I’m using Imbalance 2 theme, and have a few questions:
1) How do I delete the Search field in the upper right corner. One forum said to find the “sidebar.php” and delete from there, but I don’t have one.
2) Also, I don’t seem to have a widgets section. What’s up with that and how do I fix that?
3) I’m using the 4 column layout and would like to have the big left-hand header be 2 columns wide, so it doesn’t wrap my main web title onto two lines. How?
Thank you in advance for your help!
The topic ‘sidebar.php’ is closed to new replies.