PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 2, 2022

[FIXED] get sidebar in a specific page like shop page or about me page or 404 error page or else

 February 02, 2022     hook-woocommerce, php, sidebar, woocommerce, wordpress     No comments   

Issue

  • how to write code and where (like in page.php or function.php or else )for calling sidebar in a specific page like shop page or about me page or 404 error page or else.
  • if you want to check theme file whats missing code causing not appearing sidebar in any pages ,specially in shop page. ,here is the type of file available in my theme file (image).
  • I am asking this question because in post type page and in single product pages only the sidebar is showing in but not showing in any of the page type pages like in shop page or about me page or 404 error page or home page like that.(shop page image ,image , blog post page image , single product page image).
  • I tried many possible efforts but didn't figure out how to get a sidebar on a specific page.
  • i also tried this code in page.php but didnt shown sidebar in any page.

<?php if($enable_sidebar) get_sidebar(); ?>

  • so, i need help . it will be appreciate

Solution

Answer : To make sidebar appear in specific page like shop page or about me page or 404 error page or else.

step 1: check what type of page is actually shop page is , is it page type or post type (image1).

step 2: once you found type of page like shop page is page type then go to page.php from appearance/theme editor/ page.php . and write this code between '< / div > < ! - - / # content - - >' code'< / div > ' .

</div> <!--/#content-->
        <?php if ( is_shop() ) :
get_sidebar( 'shop' );
         endif;
        ?>
    </div> <!-- .row -->

this will appear sidebar in shop page only here simply change name of page in code to show sidebar in that named page . (image)

extra 1 : if you want to show in some multiple other pages you can use this code .(

</div> <!--/#content-->
    <?php if ( is_page (array(42,'about-me','Contact') ) );
         endif;
        ?>  
</div> <!-- .row -->

)

extra 2 : : if sidebar appearing below content not in side then you should use 'class row ' and put code at before end of row div. it auto make two colum one for content left and one for sidebar right so that it will auto align sidebar in side of content.(image2).



Answered By - ank
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing