How to edit contents of sidebar WordPress

Change header.php

Step 1. Go to the directory /wp-content/themes/twentyfifteen/
Step 2. Open files header.php
Step 3. Insert your code as below:

<div id="sidebar" class="sidebar">
<header id="masthead" class="site-header" role="banner">
<div class="site-branding">
<?php

?>
<button class="secondary-toggle">
<?php _e( 'Menu and widgets', 'twentyfifteen' ); ?>
</button>
</div><!– .site-branding –>
</header><!– .site-header –>
<?php include 'your_code.php';?>
<?php get_sidebar(); ?>
</div><!– .sidebar –>

Change sidebar.php

Step 1. Go to the directory /wp-content/themes/twentyfifteen/
Step 2. Open files sidebar.php

Step 3. Replace command:
<?php dynamic_sidebar( 'sidebar-1' ); ?>

by:
<?php
ob_start();
dynamic_sidebar( 'sidebar-1' );
$sidebar_1 = ob_get_contents();

ob_end_clean();
// Change $sidebar_1 here
echo $sidebar_1;
?>

Create a custom error 404 page for WordPress

Step 1. Go to the directory /wp-content/themes/twentyfifteen/
Step 2. Create new file 404new.php
Step 3. Delete or rename the file 404.php
Step 4. Open files index.php, search.php, archive.php, image.php, replace command get_template_part( 'content', 'none' ); by command include ('404new.php');, as below:
Line 51.     // If no content, include the "No posts found" template.
Line 52.     else :     
Line 53.     include ('404new.php'); // get_template_part( 'content', 'none' );

Htaccess redirect www working wrong

Incorrect code:

# Use www
RewriteCond %{HTTP_HOST} ^sidenotes\.xyz$
RewriteRule ^(.*)$ http://www.sidenotes.xyz$1 [R=301,L]

http://sidenotes.xyz/example.html redirect to http://www.sidenotes.xyzexample.html (missing /)

Correct code:

# Use www
RewriteCond %{HTTP_HOST} ^sidenotes\.xyz$
RewriteRule ^(.*)$ "http\:\/\/www\.sidenotes\.xyz\/$1" [R=301,L]