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

Friday, August 26, 2022

[FIXED] How to Register Multiple Sidebars at once in functions.php

 August 26, 2022     css, html, jquery, php, wordpress     No comments   

Issue

I am trying to register multiple sidebars at once and access theme by different id's just like we are registering multiple menus at once i.e. Main-Menu and Footer-menu.

<?php register_nav_menus(array('primary-menu' => 'Main-Menu','secondary-menu' => 'Footer-menu')); ?>

  • How we will do this with sidebars as well.We just write one line code and register multiple sidebars at once.

Solution

You need to use the WordPress native function register_sidebars().

You will be able to register multiple sidebars at once as your menus.

register_sidebars( 2, array(
    'before_widget' => '<div class="widget %d">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="widgettitle">',
    'after_title' => '</h2>',        
    'name'=>__( 'My sidebar %d', 'textdomain' )   
);

The register_sidebar() function is a better way to achieve this but it takes more than 1 line.



Answered By - Benoti
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

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