People want to use wordpress for simple website registration module and user management module. We have solution to create user registration in wordpress. There is User and registration module present in wordpress but only through wordpress admin panel.
create user registration in wordpress
But Client dont want to show the worpress admin module to normal user. They want to create user profile page which is matching with there wordpress theme or website.
In this article I will give the tip about how to create user and registration module in wordpress.
First download Theme my profile wordpress plugin from following URL:
Theme My Profile
This plugin allows you to theme a user’s profile based upon their role. It even includes custom roles if you have any.
Install this plugin to your wordpress and use only subscriber for using the theme profile. This plugin will create the user profile page page to your wordpress website.
Next step is download Theme my login wordpress plugin from following URL:
This plugin themes the WordPress login, registration and forgot password pages according to your current theme. It replaces the wp-login.php file by using a page template from your theme. Also includes a widget for sidebar login.
Activate this plugin and choose options as per your choice. Above plugins are very easy to use and you can customize plugins as per your choice also.
Next step is download Profile pic wordpress plugin from following URL:
Showing the most recent comments is great for SEO purpose. Our code snippet will able to get recent comments without wordpress plugin in your wordpress site.
get recent comments without wordpress plugin
You can display the most recent comments of your entire blog without any wordpress plugin. Showing the most recent comments is great for SEO purpose. Your site will increase the visibility and people interaction. Socially you and your blog will became more famous. Using following code snippet you will be able to add the recent comments in your wordpress site.
I want to display the comments in footer area. I created following code. You can copy paste the code in your sidebar.php or footer.php file.
Using following code you are able to display recent comments with author’s gr-avatar also.
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.
// Create post object
$my_post = array();
$my_post['post_title'] = 'My post';
$my_post['post_content'] = 'This is my post.';
$my_post['post_status'] = 'publish';
$my_post['post_author'] = 1;
$my_post['post_type'] = 'page',
$my_post['post_category'] = array(8,39);
// Insert the post into the database
wp_insert_post( $my_post );
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.
/*
Plugin Name: Create WordPress Pages
Plugin URI: http://images.purabtech.in/
Description: Create wordpress pages by script
Version: 1.0
Author: wordpressapi
Author URI: http://images.purabtech.in/
*/
function create_wordpress_pages(){
// Create post object
$my_post = array();
$my_post['post_title'] = 'My post';
$my_post['post_content'] = 'This is my post.';
$my_post['post_status'] = 'publish';
$my_post['post_author'] = 1;
$my_post['post_type'] = 'page',
$my_post['post_category'] = array(8,39);
// Insert the post into the database
wp_insert_post( $my_post );
}
register_activation_hook(__FILE__, 'create_wordpress_pages');
There is difference between post pagination and in post pagination.If you want to keep pagination in wordpress post without plugin, Than use our code
When we are developing the new wordpress theme then we need to always need to think about post pagination and in post pagination. Yes, there is difference between post pagination and in post pagination.
How to use pagination in wordpress post without plugin
If you want to keep single post and pagination between in single post that is also possible through wordpress api. In this article I will show you hwo to use the in page or post pagination.
Open your single.php file from wordpress theme folder and put following code in that.
<?php wp_link_pages( ); ?>
We can pass the following parameter the this function.
Now I will explain What wordpress doing for using this function. WordPress is using simple explode php function for using the next page tag. Like following way.
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
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.
Another good example for fetching the 30 days latest post from wordpress
<!--?php
//based on Austin Matzko's code from wp-hackers email list
function filter_where($where = '') {
//posts in the last 30 days
$where .= " AND post_date --> '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts($query_string);
?>
Using above code you can display all months wordpress posts.
In single.php file we have function to add comments functionality. Here in this article I will give the code for customize the comments template.
From wordpress 2.7 version we got the functionality of changing or customizing the comments template as per your theme. As we all know in single.php file we called following function to add comments functionality. wordpress comments is very important functionality. Here in this article I will give the code for customize the comment template.
customize the comments template
<?php comments_template(); ?>
This function basically calls the comments.php file and add the data from wordpress database.
If we check the comments.php file. Usually we are having following content in comments.php file
[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]
<?php
// Do not delete these lines
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('Please do not load this page directly. Thanks!');
if ( post_password_required() ) { ?>
<p>This post is password protected. Enter the password to view comments.</p>
<?php
return;
}
?>
<!-- You can start editing here. -->
<div id="comment">
<?php if ( have_comments() ) : ?>
<h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3>
<div>
<div><?php paginate_comments_links(); ?></div>
</div>
<ol>
<?php wp_list_comments('callback=wordpressapi_comments'); ?>
</ol>
<div>
<div><?php paginate_comments_links(); ?></div>
</div>
<?php else : // this is displayed if there are no comments so far ?>
<?php if ('open' == $post->comment_status) : ?>
<!-- If comments are open, but there are no comments. -->
<?php else : // comments are closed ?>
<!-- If comments are closed. -->
<p>Comments are closed.</p>
<?php endif; ?>
<?php endif; ?>
<?php if ('open' == $post->comment_status) : ?>
<div id="respond">
<h3><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3>
<div>
<small><?php cancel_comment_reply_link(); ?></small>
</div>
<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
<p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a comment.</p>
<?php else : ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if ( $user_ID ) : ?>
<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out »</a></p>
<?php else : ?>
<p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
<label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>
<p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
<label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p>
<p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
<label for="url"><small>Website</small></label></p>
<?php endif; ?>
<!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>-->
<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
<?php comment_id_fields(); ?>
</p>
<?php do_action('comment_form', $post->ID); ?>
</form>
<?php endif; // If registration required and not logged in ?>
</div>
<?php endif; // if you delete this the sky will fall on your head ?>
</div>
In the comments loop for showing the comments we used the wp_list_comments() function. Use this for customize the comments template.
We can customize this function as per our requirement. We can pass the following parameters to this function. use following for customize the comments template.
[/viral-lock]
For customize the comments template following parameter is important.
callback (string) The name of a custom function to use to display each comment. Defaults to null. Using this will make your custom function get called to display each comment, bypassing all internal WordPress functionality in this respect. Use to customize comments display for extreme changes to the HTML layout. Not recommended.
In my theme I used that in following way. I changed and passed parameter in comments.php file.
Many times some people add the full URL of website in the name parameter. That time showing author name of comment writer is looks so ugly. So I used following trick in this function. Using this line of code we can show only 20 characters of author.
how to do wordpress migration to new hosting service – This question always came to web developers. After searching on Internet I really did not found satisfied answer for this question. Using our steps wordpress migration to new hosting service or domain made easy
wordpress migration to new hosting service or domain
Earlier I did wordpress migration to new hosting service or new domain so many times. It was like 5 minutes job for any web developer. Don’t be afraid about wordpress migration at all.
Many people suggest to use wordpress utility which import and export xml. This is given by wordpress itself. But I strongly say don’t use that tool. that is not really full proof.
Just follow my steps to do wordpress migration to new hosting or domain.
1. First take backup of file system of your wordpress website using FTP credential.
2. Open wp-config.php file and change database name(what you want)
3. wp_options -Table name
option_name column – change(siteurl and home)
4. wp_blogs- Table name
domain column – change to your domain name
5. wp_site- Table name
domain column – change to your domain name
You can fetch the wordpress posts by category name. We have given simple code snippet for find wordpress posts by category name. Many developer want to do this. I will show how easily achieve this.
You can control the per page post showing and pagination also. You can use following code in any of your page.