WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] sidebar.php (16 posts)

  1. Linards
    Member
    Posted 1 year ago #

    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 localhost

    Many thanks

  2. @mercime
    Volunteer Moderator
    Posted 1 year ago #

    Can anyone tell me from where it gets the file to display in y theme?

    <?php get_sidebar();?> gets sidebar.php

  3. Linards
    Member
    Posted 1 year ago #

    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.

  4. @mercime
    Volunteer Moderator
    Posted 1 year ago #

    What theme are you using?

  5. detaatsilado
    Member
    Posted 1 year ago #

    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'

  6. @mercime
    Volunteer Moderator
    Posted 1 year ago #

    detaatsilado I would change theme to Twenty Twelve theme. If that doesn't work, please start a new topic.

  7. Linards
    Member
    Posted 1 year ago #

    Thanks @mercime,

    Im using blank theme from scratch, it's completely stripped, and im just adding my styles and markup.

    Cheers

  8. Linards
    Member
    Posted 1 year ago #

    There is no sidebar.php file I can edit, but it displays with the GET request anyway.

  9. alchymyth
    Forum Moderator
    Posted 1 year ago #

    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  }
  10. Linards
    Member
    Posted 1 year ago #

    Thank you alchymyth,

    Will try your way straight away after work. So could I just change the last if statement to false? Sorry about the dumb question.

    Many Thanks

  11. @mercime
    Volunteer Moderator
    Posted 1 year ago #

    @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?

  12. Linards
    Member
    Posted 1 year ago #

    Thank you @mercime,

    Im new to PHP, I want to edit(if necessary) the sidebar.php file in my blank theme file directory, but how the sidebar.php is 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

  13. alchymyth
    Forum Moderator
    Posted 1 year ago #

    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.php

    http://codex.wordpress.org/Function_Reference/dynamic_sidebar

    http://codex.wordpress.org/Widgetizing_Themes

  14. Linards
    Member
    Posted 1 year ago #

    Dear alchymyth,

    thank you for your thorough explanation, caveat taken on-board.
    This is more than I expected.

    Cheers

  15. wandakatja
    Member
    Posted 1 year ago #

    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!

  16. alchymyth
    Forum Moderator
    Posted 1 year ago #

    @wandakatja

    please start your own topic.

    http://codex.wordpress.org/Forum_Welcome#Where_To_Post

Topic Closed

This topic has been closed to new replies.

About this Topic