day 26

404 page

If we try to access something that is unavialalbe we are greeted with a 404 page on any site.
But in wordpress, if we have not created a 404 page explicitly, according to template hierarchy it just shows the index page. It is necessary to have a 404 page for good user experience

get_search_form() function :

This function can be used to spawn a search form for wordpress anywhere in our site.
We can use this in our 404 page, instead of having to create the search form manually.

<div>
	<h1><?php esc_html_e("Page Not Found! Maybe try searching?"); ?></h1>


<?php
get_search_form();

?>

</div>

wp_dropdown_languages() function :

We can use this function to spawn a select input with all the available languages. It doesn’t look that great but maybe useful to look at its code and see how wordpress processes the language selection This is how it looks in my site.

The Slider

The slider component in the theme was complex for me to write code for.
We can use a mix of CSS and js to show the posters dynamically.
This is the ugly version of the script I am using to display one slide.

jQuery(document).ready(function (){
	const slides = document.getElementsByClassName('the-slide');
	slides[0].classList.add('active');
});


Grids, grids everywhere:-

Grids in css are a great way to create layout for your site. I have used grid to spawn the movie cards in home page.
Here is how to create a grid of 3 columns


<style>
.grid{
display: grid;
grid-template-columns: : 1fr 1fr 1fr;
}

Creating layouts, flexboxes are also used. We can combine both grids and flexboxes, nest them and create some good layouts.

git : Working on multiple branches at the same time?, don’t forget to check you are on correct branch before commiting.

How to temporarily save changes and then checkout to other branch (stash)
$ git stash

then

$ git switch the-other-branch

Once done there you can come back to your earlier branch and get the change by using

$ git stash apply

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *