From wordpress 3.0 version release wordpress gives the facility to add a custom post type functionality. With custom post type wordpress is became more powerful and expendable and more advanced We given info about, How to use custom post type in wordpress.
How to use custom post type in wordpress
WordPress recognized the need to people and industry and they introduced the custom post type. In this tutorial I will tell you how to use the custom post type very effectively.
Adding Custom post type is very easy. Using theme or plugin file you can add the custom post types in wordpress admin area.
Here I am going to give you example using wordpress theme files. Open you functions.php file and copy paste the following code in that file.
The function register_post_type() accepts two arguments: the name we want to give our post type, and a list of arguments used to create that post type, which we put in an array called $args.
Using above code that code will add the product post type to wordpress panel.
Now you can add the meta fields to custom post type. Use the following code in file for add the meta fields. Custom meta fields function is available from quite some time. add_meta_box() function is very useful to adding custom fields to wordpress post.
Using following code you can see the product information in edit product page and you can able to see the all information in for edit. Admin will know which fields are available to edit.
Using custom post type and add meta tag you can develop very nice applications. Now I am going to show you how you can extract the custom posts in wordpress frontend.
Using wp_query you can easily extract product posts. In any category page or conditionally you can use following code.
Or you can create the custom theme page using following code. Just create product.php page in your wordpress theme folder.Put following code in that file.
Here in wordpress tutorial, we explained, how to do persistent database connection in wordpress. Persistent connections are links that do not close when the execution of your script ends.
What is persistent database connection?
Persistent connections are links that do not close when the execution of your script ends. When a persistent connection is requested, PHP checks if there’s already an identical persistent connection (that remained open from earlier) – and if it exists, it uses it. If it does not exist, it creates the link. An ‘identical’ connection is a connection that was opened to the same host, with the same username and the same password (where applicable).
how to do persistent database connection in wordpress
If you want to use the persistent database connection then you should follow my steps:
how to do persistent database connection in wordpress
First Open the wp-db.php file from wp-includes folder. In that file find following words:
comment the mysql_connect line. This line you will find two times in that file. You need to change the line both the times. Then upload this file to your wordpress installation.
Persistent database connection will open only one connection and for every query that will check for connection is present or not. If connection is already present then your query will execute using that persistent database connection.
There are couple of issues with persistent database connection, When you are using the persistent connection you should keep following things in mind.
Imp: There are a couple of additional caveats to keep in mind when using persistent connections. One is that when using table locking on a persistent connection, if the script for whatever reason cannot release the lock, then subsequent scripts using the same connection will block indefinitely and may require that you either restart the httpd server or the database server. Another is that when using transactions, a transaction block will also carry over to the next script which uses that connection if script execution ends before the transaction block does. In either case, you can use register_shutdown_function() to register a simple cleanup function to unlock your tables or roll back your transactions. Better yet, avoid the problem entirely by not using persistent connections in scripts which use table locks or transactions (you can still use them elsewhere).
If you want to use smiley images in wordpress posts then you can use our tricks. Here in this article, we given sample and trick for using smiley in posts.
Follow our steps.
Find your smiley image files in the /wp-includes/images/smilies directory and back them up to another directory
Note the names of each smiley file. Your files must match these names and should be in the same ‘gif’ image format.
For predictable behavior, the image sizes should be similar.
Upload your new files to the /wp-includes/images/smilies directory with an FTP program.
How to use smiley images in wordpress posts
How to use smiley images in wordpress posts
If you want to changes the names of smiley and you need to edit wp-includes/functions.php file.
In that file you will find the “smilies_init” function.
WordPress tutorial, We will show how to change background for specific page and category in wordpress theme. achieve using conditional tags.
change background for specific page and category in wordpress
Many times clients demands for different background color or different images as a background. We can very easily achieve this using wordpress conditional tags.
change background for specific page and category in wordpress
You can use following code in your page.php or category.php file which is present in wordpress theme. If you want to change the background for specific page then open page.php file from theme folder.
WordPress admin security is very important. Many people are always take a shared hosting. we given Information about How do we protect wordpress admin panel. Many people are always take a shared hosting for publishing the wordpress website.
With shared hosting or dedicated you should always think about hack proof wordpress admin panel. So no one can misuse your worepress admin panel. Here in this article I will give you some very nice tips about, how to protect our wordpress admin panel.
protect wordpress admin panel
protect wordpress admin panel
1. Create very strong password
Always create a very strong password for your admin user. You should add some special characters and numbers in your password. Your password should be 10 digit minimum and not related to your name or surname.
Main important think is dont disclose your password to anyone.
2. Limit wordpress admin access via IP address
You can use the .htaccess file for limiting the wordpress admin panel for specific ip addresses only. Use following code for that.
<files “wp-login.<span=”” class=”hiddenSpellError” pre=”” data-mce-bogus=”1″>php”>
Order Deny,Allow
Deny from all
Allow from Your.IP.Address
allow from 192.168.2.45
</Files>
[/php]
3. Avoid the “admin” Username
You should always avoid the admin username to login. You can easily achieve this. First create another super admin with another name and open your functions.php file from wordpress theme folder and use following code.
So many times we saw the turbo link in the upper right corner of the admin area. (Remember when computers used to have a Turbo button?) Behind it is a new feature of WordPress.com, support for Gears.
WordPress bloggers must install google gears
In 2007 Google launched its new product called Google Gears. Google Gears makes it easy to browse the Internet, or sites you have already visited so you can visit them again using an amazing cache technology.
Here I will explain you what is google gears is doing. When we open our worpdpress admin, wordpress will download common images, JavaScript libraries and CSS files.
If we use the google gears then WordPress will store all these ’static’ files on your hard drive and will not download them from the web server. Means each time you are opening the WordPress admin panel that time wordpress will not download the common images and css and javascript. Thus, it should speed up things especially if you are on a slow connection.
Following article which is written by Matt (Founder of WordPress) is really helpful about knowing about wordpress and google gears.
For plugin or custom wordpress theme we need create wordpress pages by script. In this article we given code to how to create wordpress pages by script.
how to create wordpress pages by script
You can create the pages by using script. You can execute any script using the “$wpdb->insert” or
“$wpdb->query”.
For creating wordpress post or page you can use the wp_insert_post function. Before calling wp_insert_post() it is necessary to create an object (typically an array) to pass the necessary elements that make up a post. The wp_insert_post() will fill out a default list of these but the user is required to provide the title and content otherwise the database write will fail.
You can use following code for creating the page. This code will execute when only you are logged in to wordpress.
You can create wordpress plugin and use this code. Use following code for wordpress plugin. Copy the code and create the create_wordpress_pages.php file and put in plugin folder.
In this article, we will show you how to retrieve wordpress posts within specific time frame and display all months wordpress post. code snippet with detail.
how to display all months wordpress posts on homepage
how to display all months wordpress posts on homepage
WordPress is providing as full proof wordpress api so we can achieve the this using wordpress api only.
You can use the query_posts() function for fetching the wordpress posts. Open your index.php from your wordpress template folder. Before loop just use the following code for in index.php file.
Many people is having issues with image uploading with WordPressMU. In this article I will tell you the solution. Solved: issue with wordpressMU image or media uploading.
Solved: issue with wordpressMU image or media uploading
Solved: issue with wordpressMU image or media uploading
Single wordpress and wordpressMu has different behaviour.. If you are using apache webserver then there is no issue but if you are using than there is issue with image mapping. specially with nginx web server.
You need to write the rewrite rule for image. Also you need to check about folder permission in your “blogs.dir” directory. change folder permission to 777.
For single wordpress there is uploads folder is present but for wordpressMu there is no uploads folder present in directory. You should look for blogs.dir folder which is present in wordpressMu/wp-content folder.
For solve the issue add the following lines in your apache configuration(httpd.conf) file. If this file is not present then add following lines in your .htaccess file.
Given code for wordpress create archive page for wordpress theme. search engine sites will look for two main file. First sitemap.xml file and archive page. First I would say somthing about archive page in any website. Archive page is very important for SEO purpose.
Create an Archive Page in your WordPress theme
If you do not having archive page in your website so you are lacking somewhere in SEO for your website. What I am going to show in this article, How to create the archive page for worpdress theme or website. In wordpress creating the archive is very easy.
Follow my steps to create the archive page in wordpress site.
Open your wordpress theme folder and copy the single.php as named archive.php
Note: dont copy index.php file as archive.php. It may have different UI and programming attribute in index.php.
Then copy archive.php as archive_template.php new file.
Open the archive_template.php file and copy paste the following code in top of file.