Function File in WordPress -6

Function File in WordPress -6

In WordPress, functions.php file act as a plugin for WordPress site that’s automatically activated current theme. This file uses PHP code to add or change default features on a WordPress site. The Following hooks are given with their purpose.

  • add_action()  
    • Actions are the hooks that the WordPress launches at specific points during execution, or when specific events occur.
  • wp_enqueue_style(‘name’,’location’)
    • Registers the style and enqueue it
  • wp_enqueue_script(‘name’, url, dependency, version, load before closing)
    • This function fires when scripts are enqueued.
  • get_stylesheet_uri()   
    • The stylesheet file name is ‘style.css’ which is appended to the stylesheet directory URI path

<?php

//Function to add script and style

function files()

{

    wp_enqueue_style(‘stylesheet’, get_stylesheet_uri());

    wp_enqueue_style(‘bootstrap-css’, ‘//cdn.jsdelivr./bootstrap/dist/css/bootstrap.min.css’);

    wp_enqueue_script(‘slick’, ‘//cdnjs./slickcarousel/slick.min.js’, array(‘jquery’), 1.1, true);

    wp_enqueue_script(‘js’, get_template_directory_uri() . ‘/js/mn.js’, array(‘jquery’), 1.1, true);

}

add action (‘wp_enqueue_scripts’, ‘files’);

?>

Post Your Comments & Reviews

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

*

*