How to display custom post type on wordpress page

From wordpress 3.0 version we got the custom_post_type method introduced in wordpress api.  Here we shown, How to display custom post type on wordpress page If you want to know how use this method or create the custom post type then use following URL:

How to display custom post type on wordpress page

https://purabtech.in/how-to-use-the-custom-post-type-in-wordpress-3-0/

In this tutorial I will show how to show the custom post type in wordpress theme page. First create custom-post.php page in your wordpress theme folder and use following code.

[/php]

php

/*Template Name: custom post*/

?>

php get_header(); ?>

<div id=”container”>

<div id=”content” role=”main”>

php the_ID(); ?>”

php $recent = new WP_Query(‘post_type=custom_post′); while($recent->have_posts()) : $recent->the_post();?>

php the_title( ‘

‘, ‘

‘ ); ?>

<div>

php the_content(); ?>

php

the_content();
global $post;
$custom = get_post_custom($post->ID);
echo $custom_meta = $custom[“custom_meta”][0];

?>

php wp_link_pages( array( ‘before’ => ‘

‘ . __( ‘Pages:’, ‘wordpressapi’ ), ‘after’ => ‘

‘ ) ); ?>

php edit_post_link( __( ‘Edit’, ‘wordpressapi’ ), ”, ” ); ?>

</div><!– .entry-content –>

php comments_template( “, true ); ?>

php endwhile; ?>

</div><!– #content –>

</div><!– #container –>

php get_sidebar(); ?>

php get_footer(); ?>

[/php]

Then go to your wordpress admin panel and create page called custom page and from right side panel you will find the page attribute section use the template drop down and choose the custom post option.

How to display custom post type on wordpress page
How to display custom post type on wordpress page

Now you are set for showing your custom post type in custom page. Open your custom page on that page you will see all the entries of custom post type.

For more detail information about custom post type and using this check above URL.

custom post type permalink not working wordpress

From WordPress 3.0 version we are able to use the custom_post_type. In installation time of theme or plugin new permalink structure will be created and you can easily able to use the custom post type permalink.

custom post type permalink not working wordpress
custom post type permalink not working wordpress

If your custom_post_type function is having some issues then wordpress permalink for your custom post type will not work. If your custom post type permalink is not working properly then normally you will get the 404 page and message saying page not found.
Your wordpress does not create the permalink structure aumatically so you need to recreate the Rewrite rules again with wordpress.

If you not added following code in you custom_post_type function then please add the following code:

'rewrite' => array(
 'slug' => 'issue',
 'with_front' => FALSE,
 ),

The right way to use rewrite rule in function is as follows;

register_post_type( 'movies',
 array( 'label' => __('Movies')
, 'public' => true,
'show_ui' => true ,
'rewrite' => array( 'slug' => 'movies', 'with_front' => false )
 ) );

If you are still facing issue and 404 page is coming then go the your wordpress panel -> setting- > permalink page and hit save changes button.
That will flushes the rewrite rules and build rewirte rules again in wordpress.

Add google maps in wordpress post

You can add the google maps in wordpress post or pages very easily. You need to just use following code in your functions.php file. Open your functions.php file from your wordpress theme folder and copy paste the following code in that file.

Add google maps in wordpress post

You can Add google maps in wordpress post or pages very easily. Open your functions.php file from your wordpress theme folder and copy our code in file. If you don’t have functions.php file in your wordpress theme folder then create functions.php file and put following code in that file.


//Google Maps adding through Shortcode
function add_googlemap_in_wordpresss_in_wordpress($atts, $content = null) {
 extract(shortcode_atts(array(
 "width" => '620',
 "height" => '430',
 "src" => ''
 ), $atts));
 return '<iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'&output=embed" >';
}
add_shortcode("googlemap_in_wordpress", "add_googlemap_in_wordpresss_in_wordpress");

How to use google maps in your wordpress posts and pages.

use the following code in your posts or pages.

[googlemap_in_wordpress width="280" height="280" src="[you_url]"]
Add google maps in wordpress post
Add google maps in wordpress post

You can change the height and width as per your requirement and for url you need to use following url
http://maps.google.com/
go to above url and choose your location and right side top you will find the link option. click on that link url and you will get the link of your location. Just copy paste that url. example as follows

[googlemap_in_wordpress width="280" height="280" src="[http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=New+York,+NY,+United+States&sll=37.0625,-95.677068&sspn=47.215051,79.013672&ie=UTF8&hq=&hnear=New+York&ll=40.555548,-73.730621&spn=0.356317,0.617294&z=11&iwloc=A]"]

Above code put in your post or page. you can see the google maps in your page.

Here is list of some wordpress plugins which will help you to integrate the google map in wordpress.

how to display or embed the google map in wordpress

how to modify autosave Interval in wordpress

When you start writing post in wordpress panel. WordPress has facility to autosave the post with in every one minute. modify autosave Interval in wordpress.

how to modify autosave Interval in wordpress

how to modify autosave Interval in wordpress
how to modify autosave Interval in wordpress

When editing a post, WordPress uses Ajax to auto-save revisions to the post as you edit. You may want to increase this setting for longer delays in between auto-saves, or decrease the setting to make sure you never lose changes. The default is 60 seconds.

This really good feature of wordpress but sometimes this became very painful to blogger because of revision posts and size to database. Due to post revision wordpress post table size increases and Due to that database became slower.

So I recommend to change the auto save time of your wordpress.You can change the ‘auto-save’ time of wordpress blogs by your own time limit. This task invloves changin the configuration of AUTOSAVE_INTERVAL constant and replacing the given time interval by your time.

Just follow my steps very carefully. Open the wp-config.php file which you can find in your wordpress root folder.

and find the following sentence.

define('AUTOSAVE_INTERVAL', 60 ); // seconds

and change that to following


define('AUTOSAVE_INTERVAL', 180 ); // seconds

After doing this change upload wp-config.php file to server again. After this change Auto save will start after 3 min instead of 1 minute.

How to use the_excerpt in WordPress

We all know what is excerpt. In wordpress using excerpt is good idea. WordPress provides the inbuild function called the_excerpt. Many people want to to show first few words on the theme front page. For that this function is very useful.

How to use the_excerpt in WordPress

How to use the_excerpt in WordPress
How to use the_excerpt in WordPress

If you do not provide an explicit excerpt to a post (in the post editor’s optional excerpt field), it will display an automatic excerpt which refers to the first 55 words of the post’s content. Also in the latter case, HTML tags and graphics are stripped from the excerpt’s content.

Important Note: the_excerpt function must be written in The Loop.
For using the excerpt tag you need to put following code in the loop.

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1">php</span> the_excerpt(); ?-->

Some times you need to put excerpt tag conditionally. In archive or category and home page you want to show only the excerpt of post then you can use following code:

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1">php</span> if ( is_category() || is_archive() || is_home() ) {-->
	the_excerpt();
} else {
	the_content();
} ?-->

If you want to Control Excerpt Length using Filters use following code. To change excerpt length using excerpt_length filter, add the following code to functions.php file in your theme:

function new_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');

use the_excerpt in WordPress

Tip: You can Remove […] string using Filters.By default, excerpt more string at the end is set to ‘[…]’. To change excerpt more string using excerpt_more filter, add the following code to functions.php file in your theme:

function new_excerpt_more($more) {
	return '[.....]';
}
add_filter('excerpt_more', 'new_excerpt_more');

If you want to make read more link after excerpt then use following code:

function new_excerpt_more($more) {
       global $post;
	return '<a href="'. get_permalink($post->ID) . '">' . 'Read the Rest...' . '</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');

increase memory allocation for wordpress

Many people faced memory issue wordpress and WordPress itself uses the so much memory. By default wordpress uses the 32mb memory. shown you to increase memory allocation for wordpress using config file.

increase memory allocation for wordpress

First you need to know what is the use of increasing the memory limit for wordpress. If I increase the WP_MEMORY_LIMIT from 32M to 64 or 96M will it make my website load fast.

We can adjust the amount of memory using the wp-config.php file.

define('WP_MEMORY_LIMIT', '96M');

Many shared hosting provides the default memory for php. What I see most commonly shared hosting set the memory limit to 8mb or 16mb. They does not allow you to increase the php memory limit and in that case if you changed the wp-config file then also there is no use of that change.

increase memory allocation for wordpress
increase memory allocation for wordpress

What that setting do?
This setting increases PHP Memory only for WordPress, not other applications. By default, WordPress will attempt to increase memory allocated to PHP to 32MB (code is at beginning of wp-settings.php), so the setting in wp-config.php should reflect something higher than 32MB.

set post excerpt length to limited characters in wordpress

In wordpress 3.0 limiting the excerpt is very easy. the_excerpt function is very useful and helpful in wordpress. In wordpress limiting the excerpt is very easy. With our code you can set post excerpt length to limited characters in wordpress. the_excerpt function is very useful and helpful in wordpress.

set post excerpt length to limited characters in wordpress

set post excerpt length to limited characters in wordpress
set post excerpt length to limited characters in wordpress

In many wordpress theme we used the excerpt. Many times we need to control excerpt characters as per our wordpress theme requirement. You can easily change the excerpt length using wordpress hook.

You just need to open your functions.php file from your wordpress theme folder and put following code in that.

function change_excerpt_length($length) {
    return 100;
}
add_filter('excerpt_length', 'change_excerpt_length');

This filter is used by wp_trim_excerpt() function. By default the excerpt length is set to return 55 words.

register activation hook using in wordpress plugin

wordpress hooks are very important for wp developers. We can use the wp hooks in wordpress plugin and themes. Here in this article I will show you how to register the hook in wordpress plugin. I given the simple code sample which will give you the fare idea about using the wordpress hooks.

register activation hook using in wordpress plugin

register activation hook using in wordpress plugin
register activation hook using in wordpress plugin

register_activation_hook is very important function for creating the wordpress plugin. The function register_activation_hook registers a plugin function to be run when the plugin is activated.
You can use the register_activation_hook as follows:

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php register_activation_hook($file, $function); ?>

If you can going to create the wordpress simple plugin then this function is very useful. this function you can use as follows in files.
If you have a function called myplugin_activate() in the main plugin file at either

* wp-content/plugins/myplugin.php or
* wp-content/plugins/myplugin/myplugin.php

you can use code as follows:

global $myvar;
$myvar='whatever';

function myplugin_activate() {
  global $myvar;
  echo $myvar; // this will be 'whatever'
}

register_activation_hook( __FILE__, 'myplugin_activate' );

1. register_activation_hook() must be called from the main plugin file – the one that has “Plugin Name: …” directive.
2. Your hook function must be in the same file as well. From that function it is ok to call other functions defined in other files.
3. Doing echo “My hook called!”; – does not work from it. So this is not a good way to judge whether it working or not.
4. Your global variables must be explicitly declared as global for them to be accessed from inside of my_activation_hook().

Check the sample wordpress plugin code.

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
/*
Plugin Name: A Test
Description: A Test
*/

require_once (dirname(__FILE__) . '/my_other_file.php');

// This code *will not* work. Activation hook function must be defined in the main plugin file.
//    register_activation_hook (dirname(__FILE__) . '/my_other_file.php', 'my_other_function');

// This code will work.
register_activation_hook (__FILE__, 'test_activated');

// This is correct way to declare/access globals.
global $some_var;    // globals must be declared explicitly. Without this you will not be able to access '$some_var' from within 'test_activated()' function.
$some_var = 'hey';

//===========================================================================
function test_activated ()
{
   global $some_var; // Now it will be 'hey'.

   // This function is defined in 'my_other_file.php'
   my_other_function ();

   // This will not work, so don't try. If you need logging write something in temporary log file in here via fopen/fwrite.
	// If you want to quickly test if your activation hook works - put exit() into it. At least you'll see error during activation.
   echo 'test_activated called!';
}
//===========================================================================

?>

The function register_deactivation_hook registers a plugin function to be run when the plugin is deactivated.
following function will deactivate your plugin

register_deactivation_hook( __FILE__, 'myplugin_deactivate' );

How do I get wordpress API Key

Many people are running there site with wordpress. For many reasons We need to WordPress api key. For using the wordpress stat and akismet plugin we need the wordpress api key. In this article we given details for get wordpress API Key

How do I get wordpress API Key

How to get the free wordpress api key?

Go to following URL:

http://akismet.com/personal/

How do I get wordpress API Key
How do I get wordpress API Key

Put your email address and click on register button.

How do I get wordpress API Key
How do I get wordpress API Key

Click on use Akismet for free! Link. Than fill all your information in the form and hit the Next button.

After submission you will see the following message.

You will get the wordpress api through wordpress in following format.

Thanks for choosing Akismet.

Your Akismet API key is: ------------

If you have any questions or concerns about your Akismet subscription, don't hesitate to ask:

http://akismet.com/contact/

Thanks,
The Akismet team.

wordpress comments captcha plugin

we got around 4000 spam comments daily. Spam comments are increasing daily. when we fed-up these comments, we deiced to use the Akismet plugin. That is not enough. So Here is a list of unique and best wordpress comments captcha plugin

wordpress comments captcha plugin

wordpress comments captcha plugin
wordpress comments captcha plugin

I recomend to use the capcha plugin for protecting from spam comments. I like the wp-recaptcha wordpress plugin and I recommend to use that plugin.

Here are some very nice wordpress capcha plugins for wordpress comments.

WP-reCAPTCHA

reCAPTCHA is an anti-spam method originating from Carnegie Mellon University which uses CAPTCHAs in a genius way. Instead of randomly generating useless characters which users grow tired of continuosly typing in, risking the possibility that spammers will eventually write sophisticated spam bots which use OCR libraries to read the characters, reCAPTCHA uses a different approach.

Raz-Captcha

Prevent registration spam and bots login by adding custom captcha tests in the registration page and/or login page

Featuring 5 different and customizable captcha algorithms with possibility to set your own random characters font, styles, colors background and more
For a working demo se login and register pages from the author home page

Simple CAPTCHA

A CAPTCHA for your comment system to prevent unwanted spams. Prevent automated spams by bots and most important naughty peoples. It’s simple and yet secure.

WP Captcha-Free

WP Captcha-Free blocks automated comment spam without resorting to CAPTCHAs. It does so by validating a hash based on time (and some other parameters) using AJAX when the form is posted. Comments posted via automated means will not have a hash or will have an expired hash and will be rejected. Unlike using a captcha, this does not place any burden on the commenter.

CAPTCHA-Godfather

This plug-in protects the form for posting comments from spam by 4 ways; CAPTCHA code, Session ID (which is different from PHPSESSID), Timestamp, IP Address. Also allows the webmaster to choose between fonts.

Security Captcha

Prevent registration spam and bots login by adding custom captcha tests in the registration page and/or login page

SI CAPTCHA Anti-Spam

Adds CAPTCHA anti-spam methods to WordPress on the comment form, registration form, login, or all. In order to post comments or register, users will have to type in the code shown on the image. This prevents spam from automated bots. Adds security. Works great with Akismet. Also is fully WP, WPMU, and BuddyPress compatible.