How to add Custom Sidebars or Widget Area in WordPress

Sidebars allow you display widgets inside your theme. In this post, we will teach you the way to create sidebar and display that sidebar in your theme.

First thing you need to do is register the sidebar or widget area. So copy the below code and paste in your functions.php file. Once you registered the sidebar, It will be displayed in your Appearance => Widget screen in the backend.(WP admin).

function register_sidebar_widget() {
     register_sidebar( array(
        'name' =>__( 'Sidebar', 'wpb'),
        'id' => 'sidebar',
        'description' => __( 'Appears on the static front page template', 'wpb' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'register_sidebar_widget' );

 

Now You need to copy and paste the below code in your template files to display the sidebar.

<?php if ( is_active_sidebar( 'sidebar' ) ) : ?>
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar' ); ?>
</div>
<?php endif; ?>

 

In this example codes, we have registered and displayed the widget are in template files.

Please let me know, If you have any queries or feedback.

Shutting down Google+ for consumer (personal) accounts on April 2, 2019


In December 2018, Google announced their decision to shut down Google+ for consumers in April 2019 due to low usage and challenges involved in maintaining a successful product that meets consumer’s expectations.

On April 2nd, your Google+ account and any Google+ pages you created will be shut down and we will begin deleting content from consumer Google+ accounts. Photos and videos from Google+ in your Album Archive and your Google+ pages will also be deleted. You can download and save your content, just make sure to do so before April. Note that photos and videos backed up in Google Photos will not be deleted.

The process of deleting content from consumer Google+ accounts, Google+ Pages, and Album Archive will take a few months, and content may remain through this time. For example, users may still see parts of their Google+ account via activity log and some consumer Google+ content may remain visible to G Suite users until consumer Google+ is deleted.

For more details: https://support.google.com/plus/answer/9195133

What is Constructors and Destructors?

CONSTRUCTOR : PHP allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.
DESTRUCTORS : PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence.

Advance Happy New Year

As You Log Out Of Last Year
And Login To This New Year,
I Wish To Send You Happy New Year Wishes
Full Of Success, Prosperity, Happiness And Joy.
May This Be A Year Of Change Unto Your Life
May God Give You Protection And Good Health
So That You Live To See Other Years To Come

How to get ID of the logged-in User in Yii2?

Logged in user information will be stored in Yii::$app->user->identity variable. The authenticated user identity information can be retrieved via Yii::$app->user->identity.
You can get ID by using below code.

<?= \Yii::$app->user->identity->ID ?>

If you have any doubts, Please comment here.