Posts

The Famous loop in Wordpress for Generating posts

 Go to index.php file and write below code to display post <?php while ( have_posts ()) {     the_post (); ? > < h2 >< a href = " <?php the_permalink () ? > " > <?php the_title ();   ? > </ a ></ h2 > <?php the_content ();   ? > < hr > <?php } ? > and save and check blog to display posts. to display single post add new file single.php in theme folder. Add below loop code in single.php for display single post. <?php while ( have_posts ()) {     the_post (); ? > < h2 > <?php the_title ();   ? > </ h2 > <?php the_content ();   ? > < hr > <?php } ? > For Page First create new test page with dummy content and publish And add page.php file in theme folder. and add below code in page.php  <?php while ( have_posts ()) {     the_post (); ? > < h2 > <?php the_title ();   ? > </ h2 > <?php the_con...

Creating new theme in Wordpress

First go to wp-content/theme and create new folder of your theme ->fictional-university-theme Add file -> index.php and write some text, and add style.css and add below description in comment /*  Theme Name: Fictional University  Author: Anil Kumar Author URI: https://www.example.com Version: 1.0 Description: A fictional university theme for WordPress. License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Text Domain: fictional-university Tags: university, education, responsive, custom-header, custom-menu, featured-images */ and save and go to Appearence-> theme and check theme  and also add png file of theme in this folder for theme thumbnail. after that Activate the theme. and also in style.css add body { color: orange;} After activation delete other theme folder from wordpress.

Wordpress setup in Xamp Localhost

 - Create Project folder in htdocs - Download and extract wordpress files in Project folder. - Go to phpmyadmin and create new Database for this project. -Rename wp-config-sample.php to wp-config.php - Edit it and change the database settings Set Up a Custom Domain (e.g., mytheme.local)  Edit hosts File -> C:\Windows\System32\drivers\etc\hosts Add this line at the end -> 127.0.0.1   mytheme.local Edit Apache Config -> C:\xampp\apache\conf\extra\httpd-vhosts.conf Add this configuration at the bottom -> <VirtualHost *:80>     DocumentRoot "C:/xampp/htdocs/mythemeproject"     ServerName mytheme.local     <Directory "C:/xampp/htdocs/mythemeproject">         AllowOverride All         Require all granted     </Directory> </VirtualHost> After Go to XAMPP Control Panel and restart Apache.

Basics Of PHP

 Introduction to PHP PHP (Hypertext Preprocessor) is a server-side scripting language designed for web development. PHP code is executed on the server, and the result is sent to the browser as plain HTML. PHP statements end with a semicolon ; . PHP is case-sensitive for variable names but not for keywords. Variables Variables declared with $ symbol -> $name =  "Anil"; Types are determined automatically (loosely typed). Variable names must start with a letter or an underscore _. Data Types String → "Hello, World!" Integer → 25 Float → 10.5 Boolean → true or false Array → ["PHP", "MySQL", "JavaScript"] Object → Instance of a class NULL → Represents a variable with no value Strings Functions strlen($str) → Returns the length of a string. str_replace("find", "replace", $str) → Replaces text within a string. strtolower($str) → Converts to lowercase. strtoupper($str) → Converts to uppercase. substr($str, start,...