Skip to Content
phpcodeinformation WordPress Standard
wordpress code / April 15, 2022

phpcodeinformation WordPress Standard


Create theme from “” with proper name and comments

Theme Name: SITENAME




Description: SITENAME

Version: 1.0

License: GNU General Public License v2 or later

License URI:

Text Domain: siteslug


Add below code in “wp-config.php” after “define(‘WP_DEBUG’, false);

define( ‘DISALLOW_FILE_EDIT’, true );

define(‘WP_POST_REVISIONS’, false);


Add below filter in general_function.php for hiding login error message

function inn_wrong_login() {

return ‘Wrong username or password.’;


add_filter(‘login_errors’, ‘inn_wrong_login’);


Add below code in “functions.php

remove_action(‘wp_head’, ‘wlwmanifest_link’);

remove_action(‘wp_head’, ‘feed_links_extra’, 3);

remove_action(‘wp_head’, ‘adjacent_posts_rel_link’, 10, 0);

remove_action(‘wp_head’, ‘wp_shortlink_wp_head’, 10, 0 );

remove_action(‘wp_head’, ‘adjacent_posts_rel_link_wp_head’, 10, 0 );

remove_action(‘wp_head’, ‘wp_generator’);

function wpt_remove_version() {  

return ”;  


add_filter(‘the_generator’, ‘wpt_remove_version’);


If your site is not used default posts or pages comments than add below function code in “General_function.php” and add_action, remove_action and add_filter Code in “Function.php”

// Disable support for comments and trackbacks in post types

function df_disable_comments_post_types_support() {

$post_types = get_post_types();

foreach ($post_types as $post_type) {

if(post_type_supports($post_type, ‘comments’)) {

remove_post_type_support($post_type, ‘comments’);

remove_post_type_support($post_type, ‘trackbacks’);




add_action(‘admin_init’, ‘df_disable_comments_post_types_support’);


// Close comments on the front-end

function df_disable_comments_status() {

return false;


add_filter(‘comments_open’, ‘df_disable_comments_status’, 20, 2);

add_filter(‘pings_open’, ‘df_disable_comments_status’, 20, 2);

// Hide existing comments

function df_disable_comments_hide_existing_comments($comments) {

$comments = array();

return $comments;


add_filter(‘comments_array’, ‘df_disable_comments_hide_existing_comments’, 10, 2);
// Remove comments page in menu

function df_disable_comments_admin_menu() {



add_action(‘admin_menu’, ‘df_disable_comments_admin_menu’);


// Redirect any user trying to access comments page

function df_disable_comments_admin_menu_redirect() {

global $pagenow;

if ($pagenow === ‘edit-comments.php’) {

wp_redirect(admin_url()); exit;



add_action(‘admin_init’, ‘df_disable_comments_admin_menu_redirect’);


// Remove comments metabox from dashboard

function df_disable_comments_dashboard() {

remove_meta_box(‘dashboard_recent_comments’, ‘dashboard’, ‘normal’);


add_action(‘admin_init’, ‘df_disable_comments_dashboard’);


// Remove comments links from admin bar

function df_disable_comments_admin_bar() {

if (is_admin_bar_showing()) {

remove_action(‘admin_bar_menu’, ‘wp_admin_bar_comments_menu’, 60);



add_action(‘init’, ‘df_disable_comments_admin_bar’);


If your site is not provide any search related functionality than add below code to your theme.


function fb_filter_query( $query, $error = true ) {

if ( is_search() ) {

$query->is_search = false;

$query->query_vars[s] = false;

$query->query[s] = false;

// to error

if ( $error == true ) {

$query->is_404 = true;





add_action( ‘parse_query’, ‘fb_filter_query’ );

add_filter( ‘get_search_form’, create_function( ‘$a’, “return null;” ) );


Never do any changes in core files.

Always keep wordpress and plugins up to date with new version.

Change wordpress database prefix suitable to your theme name

Create files for functions in include folder :

include/themesetup.php for Theme setup and widgets

include/enqueue_scripts.php for Enqueue Scripts and style (Always include CSS and JS files here), if need some specific js or css file in particular template or post type then use condition here. Not include file in page.  

include/general_function.php for General Hooks , action and function used in theme globally 

include/custom_image_size.php for custom image sizes


If one functionality is used in more pages than create common functions or widget for this. 

When you want to add any inline “JS” for any variable declaration, then you have to add it using below way:


  1. Add below Code in “include/enqueue_scripts.php” for set “AdminURL” variable.

function your_js_vars() { 

$admin_URL = ‘Your Admin URL’; // Your File Path

return array(

‘admin_URL’ =>  $admin_URL



wp_enqueue_script(‘your_script_name’, get_template_directory_uri( ) .’/js/your_js_name.js’, array(‘jquery’), ‘1.0.0’);

wp_localize_script( ‘your_script_name’, ‘your_unique_name’, your_js_vars());


  1. In “your_js_name.js” File you can use this variable as below way:

var my_custom_JS_Code = your_unique_name.admin_URL;


JavaScript & jQuery task is developer responsibility. It’s good our designer is create most of code in jQuery. But it’s developer responsibilities to check file and code.
Below Function only call should once.
JQuery(document).ready(function ()
jQuery(window).resize(function () {
jQuery(window).load(function () {


If you use click event of any button or object then it should not be in ready.

jQuery(document).on(‘click’, ‘.close-menu’, function (e) {


Remove alert and other testing code from js once complete your work.

For Contact form jquery changes use below valid method.
document.addEventListener(‘wpcf7mailsent’, function (event) {
if ( ‘1’ == event.detail.contactFormId ) {
document.addEventListener(‘wpcf7submit’, function (event) {


Never user fixed path for any images, css and js

Always put CSS, JS and Images in proper directory. Only style.css is put on theme directory root. And never write “JS” and “CSS” inline. If you have to need define any “JS” variable dynamically than always use “wp_localize_script” function.

Always use PHP comments. Never use HTML comments. HTML comments display on source.

After integration of static theme by designer you have to first make header, footer and sidebar dynamically.

When you complete with header, footer and sidebar dynamic portion than start work on page development.

Remove extra codes (variable, functions, comments etc…) from all files where you have to change functionality. If you want to backup code then use in your local system.

Never commit backup files.

Take Pull before push in directory. Resolve conflict before before push your code. If you can’t understand how to resolve this take help of your seniors and co-workers.

Use images with proper dimension. Don’t use full size images to everywhere. When you want to show thumbnail than you have to use “thumb image” code. In most of cases all of you have used large images code. Add custom image size in as per required.
add_image_size(‘image_name_slug’, Width, Height, array(position, position));
add_image_size(‘home_banner_image’, 1920, 786, array(canter, canter));

When you create any template than set prefix “tp-“

Ex: If you create template for “contact” page than your file name “tp-contact.php“.

When create custom post type than create file with “type-” prefix in ‘post-types’ folder

Ex: If you create custom post type “property” than your file name “type-property.php” in “post_type” Folder and include in “functions.php
Create particular post type and related function in this file.

If in your project there is no detail page for custom post type than hide it from front-end.

Ex: testimonials 

Always use proper naming for variable declaration.

String Variable : $strVarName

Array Variable : $arrVarName

Always use proper naming for all types of declaration (like variable, functions, templates etc.)

Always check if condition before below cases



Get image url from Image_array


Always remove Archive and Draft link from ACF Page Link, Relational ship Fields. For this use one single function for different fields.
add_filter(‘acf/fields/page_link/query/name=read_more_link’, ‘remove_draft_archive_link’, 10, 3);
add_filter(‘acf/fields/relationship/query/name=read_more_link’, ‘remove_draft_archive_link’, 10, 3);


Always use wordpress function with “get_” prefix not “the_”prefix.


the_title()” replace with “get_the_title()

the_permalink()” replace with “get_permalink()


When you create any template than always set suitable name. 

Common Mistakes: 

– When someone create new template using copy and paste than he/she always forgot to change “Template Name”


Save ACF Field Value in Variable before print direct in code and if ACF field not compulsory then check blank condition before print.
Wrong :
echo get_field(‘subtitle_text’);
Right :
$subtitle_text = get_field(‘subtitle_text’);
echo $subtitle_text;


Add instruction comments for all functions which are created by you.

All external links always open in new window. So, you have to set “ target=’_blank’ ” for all external links. Set using function so external link without http:// or https:// will open in new tab.

When you do any projects than always create dummy records. So, you can do exact functionality for pagination, listing etc. You can use duplicate post plugin for this. If you have not having any content for site then use ‘Lorem ipsum’ text insted of ‘aaaaabb’, ‘asdfghijkl’.

When you have any anchor tag without any links than always add “javascript:void(0);

When you put any email address or phone number than set link for them.

For email use – 

For Call use – callto:1234567

Single line html tag close as below. So, You never get W3Cvalidation error.


echo ‘<img src=”‘.$image[‘url’].'” class=”img-border” alt=”‘.$image[‘title’].'”/>’;

    instead of

echo ‘<img src=”‘.$image[‘url’].'” class=”img-border” alt=”‘.$image[‘title’].'”>’;

Never add any files for ajax call. Always call ajax using default wordpress functions (Use admin-ajax.php)
Send your data to ‘admin_url( ‘admin-ajax.php’ );’ and action parameter will be function name.
function load_portfolio(){


When you have completed any pages than test it from your side completely as per client requirement than do post in group chat.

Always use Fly Dynamic Image Resizer plugin so we can reduce number of image file size


Plugins which we need to add when site live

Admin url change



wp-fastest cache

Contact form DB if contact form 7 used

Yoast SEO

Captcha for Login

Stop user enumeration

Block bad queries


I need to to thank you for this very good read!! I certainly loved every little bit of it. I have you book-marked to check out new things you postÖ


We have hacked your website and extracted y0ur databases.

H0w did this happen?

0ur team has found a vulnerability within your site that we were able to expl0it. After finding the vulnerability we were able to get y0ur database credentials and extract y0ur entire database and move the inf0rmation to an 0ffsh0re server.

What does this mean?

We will systematically go through a series of steps 0f totally damaging y0ur reputation. First your database will be leaked 0r sold to the highest bidder which they will use with whatever their intentions are. Next if there are e-mails f0und they will be e-mailed that their information has been sold 0r leaked and your site was at fault thusly damaging your reputati0n and having angry cust0mers/associates with whatever angry cust0mers/associates do. Lastly any links that y0u have indexed in the search engines will be de-indexed based 0ff 0f blackhat techniques that we used in the past to de-index our targets.

H0w d0 i st0p this?

We are willing t0 refrain fr0m destroying your site’s reputati0n for a small fee. The current fee is $3000 in bitcoins (.16 BTC).

Please send the bitcoin t0 the following Bitcoin address (Make sure t0 copy and paste):


once you have paid we will automatically get informed that it was y0ur payment. Please note that you have to make payment within 5 days after receiving this e-mail or the database leak, e-mails dispatched, and de-index of y0ur site WiLL start!

H0w d0 i get Bitcoins?

Y0u can easily buy bitcoins via several websites 0r even 0ffline from a Bitcoin-ATM.

What if i don’t pay?

if you decide n0t t0 pay, we will start the attack at the indicated date and uph0ld it until y0u do, there’s no counter measure t0 this, y0u will 0nly end up wasting more money trying to find a s0lution. We will c0mpletely destroy y0ur reputation am0ngst go0gle and y0ur customers.

This is n0t a h0ax, do n0t reply to this email, d0n’t try t0 reason 0r negotiate, we will not read any replies. once y0u have paid we will stop what we were d0ing and y0u will never hear fr0m us again!

Please n0te that Bitcoin is anonymous and n0 one will find out that you have c0mplied.

Keep up the fantastic piece of work, I read few articles on this site and I conceive that your web site is rattling interesting and holds sets of good info .

Leave a Reply

Your email address will not be published.

PHPCODE © 2023