Posts Tagged ‘wordpress hooks’

Add menu into wordpress page

May 11, 2011 Leave a comment

Hello Folks,

Since many days i was wondering to add a dynamic menus that i could insert via plugin. I wanted to insert login and logout buttons into menu bar without editing the template. Then i found out one hook for the wordpress that i could inject my content into menu.


The above hook will call add_menu which contain 2 parameters.

      function add_menu($items,$args)
            items .= "<li>Another Menu</li>";
            return items;

it will look as following

As you can see another menu is created beside. As css is not applied it looks like that apply css would
look alike.

If there is any problem give a reply.

Shortcode with wordpress

February 16, 2011 Leave a comment

Hello readers here is one more article for creating a shortcode into the wordpress . Like if you want to have custom tags to be written into a post and should replace it with another function then could be achieved it in minutes ..
Say for example you want to add a tag [google] which will replace with,so here we could do.
First decide what shortcode you want to name as for now we have named it [google].
Step 1:
Not time for calling the wordpress function. Yes wordpress has provided inbuilt function creating shortcode.


This above function would call the specified function whenever wp will find the shortcode. In our case [google].


So now the get_google_url would echo the url.


function get_google_url()
      return "";

Oh thats done !! basic of the shortcode is done .. Thats easy now will go ahead to get parameters from the shortcode. Like if we want to add search url like So with shortcode [google supercar] will give output like . Could achieve by the following way


function get_google_url($atts)
      return "".$atts[0];

So now where ever you will put [google value] then it will output google search url.

but remember if there are two parameters like [google value1 value2] they would be treated as seperate parameters not one .

Hope its easy to learn wordpress .

Thanx Readers.
Ketan Mujumdar

%d bloggers like this: