Chitika ad

Sunday, 17 November 2019

What is functions.php in wordpress

functions.php

In wordpress php functions are defined in seperated in special file called functions.php.
Wordpress dont allow to call php functions in post and pages directly
You can post data and use ajax functions in same manner as well in php scrips
Tag name is used to differentiate each functions

You can also receive post data in functions and you can use return values in your pages also

functions.php


<?php
function test(){
    if($_POST['name']){
    echo $_POST['name'];
    echo "<h2>OOOOOOOPSssssssssssssssss</h2>";
    }
}
//add_action("test",test);

add_action( 'wp_ajax_test','test');
add_action( 'wp_ajax_nopriv_test','test');

function tp(){
echo "hai";
}
add_shortcode( "tp", tp);



function my_wpdiscuz_shortcode() {
  if (file_exists(ABSPATH . 'wp-content/plugins/wpdiscuz/templates/comment/comment-form.php')) {
      ob_start();
      include_once ABSPATH . 'wp-content/plugins/wpdiscuz/templates/comment/comment-form.php';
      return ob_get_clean();
  }
}
add_shortcode('wpdiscuz_comments', 'my_wpdiscuz_shortcode');


?>


No comments:

Post a Comment