Posts

Showing posts from June, 2012

Get custom field value through shortcode

Creating wordpress short-codes is simple. We can access custom field value through shortcode, just follow the function.

Wordpress hidden options in admin side bar menu

This little piece of code does something pretty cool. This function will add an additional option to your settings menu. It will show you a complete list of all the settings you have within your database related to your wordpress site. The code below will only made this link visible to an admin user and hide it for all other users. // CUSTOM ADMIN MENU LINK FOR ALL SETTINGS function all_settings_link() {     add_options_page(__('All Settings'), __('All Settings'), 'administrator', 'options.php'); } add_action('admin_menu', 'all_settings_link'); Another method you can simply go to the options page with this URL domain.com/wp-admin/options.php to access wordpress hidden options.

Include or exclude custom post types in wordpress search result

Defining post types in search query allows you to include or exclude the custom post types in wordpress search result. Just add this function to functions.php

Loading jQuery from the Google CDN

Customize the order of the admin menu

This code will allow you to reorganize the order of elements in the admin menu. All that you need to do is click on an existing link in the admin menu and copy everything before the /wp-admin/ URL. The order below represents the order the new admin menu will have.

Add custom fields in user profile

Place the code below into your functions.php file to add custom user profile fields. Edit or add lines as you see fit. Remember not to remove the line: return $contactmethods; otherwise this won't work.

Disable wordpress plugin update notification

We can disable wordpress plugin update notification within 2 lines of code. Just add the below code in functions.php .

Set your footer sticky at the bottom of the page

It time to show your footer bar sticky at the bottom of the page, just go though the script [code lang="js"] $(window).bind("load", function() { var footerHeight = 0, footerTop = 0, $footer = $("footer");//Added your footer id over here positionFooter(); function positionFooter() { footerHeight = $footer.height(); footerTop = ($(window).scrollTop()+$(window).height()-footerHeight)+"px"; if ( ($(document.body).height()+footerHeight) < $(window).height()) { $footer.css({ position: "absolute" }).animate({ top: footerTop }) } else { $footer.css({ position: "static" }) } } $(window) .scroll(positionFooter)

Using wordpress admin ajax

Using wordpress admin ajax is very simple. You need to follow this steps accordingly. Create a function to display your form in front end. You can use short code to include your form in post/page. Make sure you must have action filed in form, with the help of action value you can access wp_ajax hook. Declare the ajax hook respective to the action name. In this example, my action name is the_ajax_hook1, so i have created the hook wp_ajax_the_Action_hook1(wp_ajax_{$action}). Include your js file by wp_enque_script(). Localize your included script with the help of wp_localize_script(). That's all.. Here is our example... [code lang="php"] /* Plugin name:KTM Ajax call Description: creating ajax call from front end Author : Karthik */ //It helps to add your script. wp_enqueue_script('ktm_my_script' , plugin_dir_url(__FILE__) . 'script.js' , array('jquery') ); //It helps to access php variable i

Wordpress optimization tips

WordPress Optimisation - A4UExpo [slideshare id=1356656&w=650&h=355&sc=no] View more presentations from Joost de Valk Source:  yoast.com