Set dynamic attributes to entire site
Today while integrating theme in WordPress i have asked to my TL that is it possible to set title attribute for a tag of the HTML without actually placing it to entire site.
She has given me solution which i am sharing here,
jQuery(function () { //set dynamic title attribute to <a> tag jQuery('a').each(function() { //check broken links for the SEO if(jQuery(this).attr("href")=="#" || jQuery(this).attr("href")=="") jQuery(this).attr("href","javascript:void(0);"); if(jQuery(this).text()!='') jQuery(this).attr("title",jQuery(this).text()); }); //set dynamic title attribute for the <input type=' submit'> tag jQuery('input:submit').each(function() { if(jQuery(this).val()!='') jQuery(this).attr("title",jQuery(this).val()); }); //set dynamic title attribute for the <input type=' button'> tag jQuery('input:button').each(function() { if(jQuery(this).val()!='') jQuery(this).attr("title",jQuery(this).val()); }); }); |
Above code will set title attribute for the <a> and <input> tags.
And this way developer can place such dynamic attributes which saves lots of development and designing time.
Stop Plugin from showing updates
While developing WordPress site most of the time we use different plugin for the better support of the site.And some times we as a developer make some customization in the default plugin files for our required functionality.
The plugin files are always get updated from its developer and the updates for newer version are notified to us by the wordpress. Suppose we have make some customization in code in the original plugin’s file then that changes will be removed if we update the plugin file to newer version.So to solve this problem we have to stop the automatic update option of the plugin or update notification of the plugin.
To do this we can have two Methods.
That are,
Method 1:
just add below code to the function.php file of your current theme ,
# 3.0: remove_action( 'load-update-core.php', 'wp_update_plugins' ); add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) ); |
if you are using wordpress 3.0 or higher version.
read more
How to resolve jquery conflict?
Many a times in the project we have to use jQuery code.And some times this jQuery code gets conflict with some other jQuery code.So to solve that issue i have some solution which will help you to getout from the jQuery conflict issue so that you can get back to your work.
When you are using multiple jQuery files you may lead to the conflict amoung them.Because most of the time jQuery file use “$” in the file as the jQuery reference variable throw out the code.And because of this “$” variable jQuery files get conflict with each other.
To resolve the jQuery conflict issue you can use any of the below option,
Option 1:
When you put jQuery into no-conflict mode, you have the option of assigning a variable name to replace $. ( only once )
<script src="prototype.js"></script> <script src="jquery.js"></script> <script>var $j = jQuery.noConflict();</script> |
Insert your own Search option in your wordpress theme
While developing you own theme many times you don’t want to use the default search of the wordpress and you want your own search option which looks better and suits your site design.So if you want to insert your own search option in the theme instead of the default search its very easy to implement it.
Now lets do that in the wordpress theme,
First of all add one function in the functions.php file in your theme folder.
This function creates your search view.And add it to the wordpress site where ever you want.
So lets define that function in functions.php file,
function custom_search_form() { ?> <form method="get" class="" action="<?php bloginfo('home'); ?>/"> <p> <input type="text" value="" name="s" id="s" /> <input type="submit" value="Go" /> </p> </form> <?php } add_action('thesis_hook_header' , 'custom_search_form'); ?> |
Create a plugin in wordpress
Creating a plugin in wordpress is just like doing your favorite work with lot of fun.
so lets start to create very simple plugin in wordpress.
steps to create the plugin,
1> create a plugin folder.
for ex, my_first_plugin
2> now create a php file in that folder.
for ex, my_first_plugin\first_plugin.php
Insert update and delete in WordPress.
In the core php, we need to write at-least 10 to 15 lines, sometimes more than that for the database connection and insert update or delete operations on the database..
But in the wordpress we just need a single line for the opration and no need to connect to database. Because this steps are done at the installation only.
INSERT QUERY :
$wpdb->insert( $table, $data, $format );
table (string):
The name of the table.
data (array):
Data to insert in column => value pairs.
format (array|string) : (optional)
An array of formats to be mapped to each of the value in $data. If string, that format will be used for all of the values in $data. If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types.
How to convert SQL to Excel in Php?
Many a times while developing a project we want to send the query data to the user or we want to have the query data for any other reason like analysis or report etc.
So to convert the SQL query data into the excel sheet form is many a times useful for developers.
You can do it using following code,
<? $sql = "select * from wp_db"; $result = mysql_query($sql); $arr_data = array(); while($data = mysql_fetch_assoc($result)){ $arr_data[] = $data;
}
Install WordPress in few minutes.
Steps to install wordpress are very easy…
its actually just take 10 to 15 minutes to install WordPress.
so lets do it quickly
STEPS :
1. Download wordpress zip file.That is available here.
How to configure mail from localhost ( wamp ) using PHP?
I have searched a lot when I was required to configure mail using my localhost for my project. At many sites I have read that it’s just not possible to send mail using localhost. You have to upload your project on the net.
But after searching a lot I get to know that it’s possible to send mail using localhost without uploading the project. And today I post this blog so that the PHP programmer can get to know that it’s not that we just cannot send mail from localhost .We can do.
Steps to send mail from localhost:
Search in this website
our sponsors
latest comments
- sagar on List of all standard version of c language
- Mohit Dhukia on How to access/unblock songs.pk in india?
- shinto peter on How to configure mail from localhost ( wamp ) using PHP?
- tammylleanne on Implementation limitation of c programming language
- Deepak on How to access/unblock songs.pk in india?
Find us on Facebook
Top Authors
Find us on stackoverflow
Polls
My Bookmarks
- Audio/video Recorder & player application based on MATLAB
- check dependency of your binary
- defination of all standard c programming language function
- Great Question-Answer on c programming
- know what your c code means
- Limition of c programming language
- List of all version of c programming language
- Online c compiler
- php freelancing work
- some more stuff on C programming language
- Volatile Keyword in Embedded System
- Write Android application in c language