How do I run a PHP script on my WordPress website?

by 5 replies
6
I was looking for a plugin but then figured a php script on codecanyon can do what i want on my WordPress website but then i don't know a thing about php script and how to make it work on my WordPress website. Do i install it or something to have it function like wen i install a plugin in WordPress. Need help thanks
#programming #php #run #script #website #wordpress
  • PHP is not a plugin it is a language and looks like this. sololearn are good to start
    • [1] reply
    • <?php

      $keyword_one = $result['keyword_one'];
      $keyword_two = $result['keyword_two'];
      $keyword_three = $result['keyword_three'];
      $keyword_four = $result['keyword_four'];
      $keyword_five = $result['keyword_five'];
      $keyword_multi = $result['keyword_multi'];



      $input = array($keyword_multi);
      $keyword = array_rand($input);

      // echo $input[$keyword]; $keyword_one, $keyword_two, $keyword_three, $keyword_four, $keyword_five
      ?>
  • If you havent worked with programming language like php or havent coded in wordpress, you should probably just get a plugin.

    Otherwise you can add the php script with add_action hooks or add_shortcode inside functions.php. Or you may want to put the code inside a theme template file
  • The php script needs to be executed on the wordpress to work. So either you can add the script to the page where you need it to work but adding any code which you don't have idea about can be harmful. So, you better take a hard look on that code and if that isn't malicious then you can add it to the page where it needs to be executed
  • Simplest solution:
    Install plugin "insert php" by Will Bontrager software.
    https://wordpress.org/plugins/insert-php/

Next Topics on Trending Feed

  • 6

    I was looking for a plugin but then figured a php script on codecanyon can do what i want on my WordPress website but then i don't know a thing about php script and how to make it work on my WordPress website. Do i install it or something to have it function like wen i install a plugin in WordPress. Need help thanks