Custom wordpress page on a new URL

I liked to have the idea of having google search my site and have it displayed within my current site design, and since wordpress allows to have action hooks that allow you to interrupt the present flow of generating the wordpress outputted page.

So to have the google searched and display results within the style that I am using I first needed to create a plugin, if you create a file within your

wordpress base directory/wp-content/plugins/codingfriendsgooglesearch

within the file below within the that directory created above, (I saved this file as googlesearch.php, but it does not matter as long as it is a .php file with the plugin details at the top of the file between the /*… */ parts.

Plugin Name: Google search page
Plugin URI:
Donate link:
Description: Google search page
Version: 0.1
Author: Ian Porter
Author URI:
function get_requested_uri() {
       $requesturi = $_SERVER['REQUEST_URI'];
       if (substr($requesturi, -1)!="/") {
               $requesturi = $requesturi."/";
       preg_match_all('#[^/]+/#', $requesturi, $matches);
       $uri = $matches[0];
       return $uri;
function google_search_display() {
       $uri = get_requested_uri();
       if ($uri[0]=='googlesearch/') {
               include(TEMPLATEPATH . '/googlesearch.php');
add_action( 'template_redirect', 'google_search_display');

What basically happens is when the template_redirect is called, this is when most of the processing of the page has already been done, and we are about to display the requested page from the blog, well in this case I would like to add function call to google_search_display, which is within this same file, and what it does is to search for ‘googlesearch/’ within the first part of the URL requested e.g.

and if so display the googlesearch.php php file from within the templates directory, and here is my googlesearch.php file, and it displays the content within the div tag with cse-search-results, with the present style around the google search results.

<?php get_header(); ?>
<div id="content" class="narrowcolumn" role="main">
<div id="cse-search-results"></div>
<script type="text/javascript">
 var googleSearchIframeName = "cse-search-results";
 var googleSearchFormName = "cse-search-box";
 var googleSearchFrameWidth = 795;
 var googleSearchDomain = "";
 var googleSearchPath = "/cse";
<script type="text/javascript"
<?php get_sidebar(); ?>
<?php get_footer(); ?>

wordpress is really nice where you are able to alter the present execution process.

WordPress – plugin – hello world

WordPress is a blogging software that runs on a webserver, the great thing about wordpress is that you are able to extend the functions to create the pages/comments/archives etc on the blogging site. You are also able to create your own themes that will use the functions that you can create within that theme So lets it straight, a plugin for the wordpress is the way that you can extend the functional aspects of the whole site that is not dependent on the theme that you using (a theme is what you view on the web page the “style” (css) of the site for example).

There is two main directories within the wordpress directory structure to add in new themes (wp-content/themes) and the plugins (wp-content/plugins) this is where you place the code to extend the basic wordpress install.

In this example I going to extend the action get_header, if you save the code below into the directory wp-content/plugins/codingfriends_helloworld as codingfriends_helloworld.php

Plugin Name: Coding friends hello world
Plugin URI:
Description: Outputs hello world
Version: 0.1
Author: Genux
Author URI:
License: GPL2
function codingfriends_helloworld()
  echo "hello world";
add_action('get_header', 'codingfriends_helloworld');

once you have saved that file, then goto your wordpress admin page, on the left is the Plugins link, click on that and within there will be the “new” plugin called coding friends hello world, you just need to activate it and then hey presto it works. There will be “hello world” at the top of the wordpress installed pages within the main site (not the wp-admin part of the site).

What is happening is that you have created a function called codingfriends_hellworld, which outputs “hello world”, but the main part is the


this will add this function to a defined plugin action (to get a list of all of the actions (these happen within the core site), and filters (alter text within the site, e.g. pages that you add to the site, comments etc) you can use look here).

So when the action get_header is called within the main wordpress application, it will call your new function (codingfriends_helloworld).

There is tons of things that you can do with these, alter the comments when posted back to the site, pages etc, just look at the API list.

WordPress admin login

After reading on the SANS website about a dirty process of using distributed wordpress as from here. One of the ways to make sure that the user cannot keep on trying to use brute force to access your site is to set the password randomly, I use this website pctools which comes up with a very nice password for you.

Also within the brute force attach they are using the username of admin to try and login so you could change the admin username.

UPDATE wp_users SET user_login = '<insert name here>' WHERE user_login = 'admin';

Of course if you have setup the pre table name of wp_ instead it would be users table name.