Editing functions.php file
-
Hi, I wrote a code at the beginning of “functions.php” file It is being displayed first thing in the page, and I don’t want that. I want it to be displayed in a specific div. I did that with javascript, but it is not very efficient. What is a better and easy way to do this?. Please see code below and note that I want the “EDiv” to be displayed in “portalsDiv”.
<?php
//Display E-portals only if the current page is the home page and is user is logged in
if (($_SERVER[‘SCRIPT_URI’] == “https://***/**/”) && is_user_logged_in()){echo “<div class=’EDiv’ id=’EDiv’> <h2>HEADING</h2>”;
$user= wp_get_current_user();
$userEmail=$user->user_email;$grade=$wpdb->get_var(“SELECT Grade FROM Students WHERE Email=’$userEmail'”);
echo ‘<script type=”text/JavaScript”>
setTimeout(function(){
document.getElementById(“portalsDiv”).append(EDiv);
},3000);</script>’ ;
echo ‘<img src=”https://www.***.net/**/all/themes/jks/images/**.png”‘;
echo “</div>”;
}
- The topic ‘Editing functions.php file’ is closed to new replies.