Showing posts with label 404 Redirection. Show all posts
Showing posts with label 404 Redirection. Show all posts

Monday, March 13, 2023

Free Download My Bakkery Single page website Responsive HTML5 Template

webcodeaddict-my-bakery



My Bakery is a Responsive HTML theme for Bakery websites.  which helps you to build your own site. My Bakery perfectly fits the trendy cakery & bakery website with a strong, sweet, and elegant style. It embodies a sensible design with a product-centered layout to captivate every customer’s heart. 


Download free HTML: My Bakery


Created by: Web Code Addict


Sunday, March 12, 2023

How to include files in Wordpress function file?

 To include any file in the function file of WordPress just creates a file with the name

 i.e custom.php
                   
                              custom.php

<?php


====================Your code===============

?>


Go to function.php

Use anyone.

1) include ()

 Include function includes the specified file and it will throw PHP warning if the file isn't found.

include(dirname( ABSPATH ) .'/admin-page.php');

this will return /var/www/vhosts/foo.bar/httpdocs/includes/baz.php

2) include_once()

include_once() works as inlude() and it will not include file

again if already included.

include_once( get_stylesheet_directory() .'/admin-page.php');


3) require()

require() works same as include() but PHP fatal error will be trown

if the file is not exists

require(dirname( ABSPATH ) .'/admin-page.php');
4) require_once()

require_once() performs as require() but fill will be not included
second time.

require_once( get_stylesheet_directory() .'/admin-page.php');

For Parent Theme: get_template_directory()

or get_template_directory_uri()


For Child Theme: get_stylesheet_directory()

or get_stylesheet_directory_uri()

Thursday, April 2, 2020

How to Redirect 404 page to the Home Page using All 404 Redirect to Homepage

//Page 404 to homepage

function test_redirect_404_to_homepage(){

    if( is_404() ){

        wp_redirect( home_url(), 301 );

        exit();

    }

}

add_action('template_redirect', 'test_redirect_404_to_homepage');

*****************************************************


// 404 page redirect to homepage

if( !function_exists('redirect_404_to_homepage') ){

    add_action( 'template_redirect', 'redirect_404_to_homepage' );

    function redirect_404_to_homepage(){

       if(is_404()):

            wp_safe_redirect( home_url('/') );

            exit;

        endif;

    } 

1 hour Free Service for WordPress website :)

      1 hour Free Service for WordPress website :)