How to Access Functions.php | Video

What is Functions.php

WordPress offers extensive customization to your wordpress website. You can edit functionality, looks any way you want to by inserting your own code in the “functions.php” of your wordpress website.

Functions.php comes with the theme and as it is suggested by name, it stores theme’s functions. You can customize your website by manipulating functions.php’s code.. There are two ways you can access the functions.php. It can be either access by a FTP client or it can be accessed in wordpress’s administrator dashboard through browser.

Access functions.php By Using a FTP Client

  1. Open FTP client, Connect to your website by providing FTP Login credentials.
  2. Locate Functions.php by going to the directory below:
    [WordPress Website’s Root]> wp-content > Themes > [current_theme_name] > functions.php.
  3. Download the functions file and update the file with required code.
  4. Upload the file to replace the theme’s function.php with changes made to the file.

Access functions.php Through WordPress Dashboard

  1. Sign-in to your WordPress administrator account.
  2. From sidebar, Select “Appearance > Editor”
  3. Select the theme from “Select theme to edit” drop-down menu.
  4. Under “Theme Files”, “Templates” section, Find and click “Themes Functions (functions.php)”.
  5. Click “Update File” After Making the required updates to the file and to save the changes made to the functions file.

Video Tutorial

You can reach Waqas Yousaf through twitter @wiqi.

Read More
Waqas Yousaf January 10, 2018 0 Comments

Create banned words list for WP titles

Why do you need a banned word list for titles?

Running a blog with multiple authors is such a nightmare. You got to deal with many things and on the top of the all you also got to look for the content being posted on the blogs.

You can either reduce the access level of bloggers and read all the content first by yourself and then publish it but it would take like forever and it would only add another task to your responsibilities. Then there is this way, in which you can add words you want to ban on the website and WordPress simply won’t let the bloggers add the titles with the banned words itself. Problem Solved.

How Do I Access Functions.php?

You’ll have to add this tiny function and a hook in your functions.php file which is stored in your theme’s directory.

CAUTION: BACKUP YOUR WEBSITE BEFORE DOING ATTEMPTING CHANGES. I WONT BE RESPONSIBLE FOR ANY MISHAP.

Code

[php] function wpb_title_bws($sTitle)
{
$BannedWords = "abc,xyz,omg"; // Banned words seperated by comma.
$BannedWords = explode(",", $BannedWords);

global $post;
$sTitle = $post->post_title;

foreach($BannedWords as $BannedWord)
{
if (stristr($sTitle, $BannedWord))
wp_die( __(‘Error: Remove the banned word "’. $BannedWord .’" in post title first!’) );
}
}

add_action(‘publish_post’, ‘wpb_title_bws’, 10, 1);
[/php]

 

You can reach Waqas Yousaf through twitter @wiqi.

Read More
Waqas Yousaf October 19, 2016 10 Comments