How to Embed a YouTube Video in WordPress

If you want to add the youtube or google and any third-party video in wordpress. It is really easily achievable. How to Embed a YouTube Video in WordPress.

How to Embed a YouTube Video in WordPress

WordPress itself provides to upload and submit youtube video in wordpress post. Just open wordpress admin panel and click on Add new post button.

Select the From URL tab. Paste the YouTube video’s URL into the URL field. Then click the Insert into Post button.

You can change the height and width of video using following code

[ youtube=http://www.youtube.com/watch?v=H2Ncxw1xfck&w=320&h=240]

I suggest to use Viper’s Video Quicktags wordpress plugin. I really like this wordpress plugin for embedding the third party video in wordpress blog or post.

You can download this plugin from following URL:

http://wordpress.org/extend/plugins/vipers-video-quicktags/

This plugin give you really great control with video player and size of video player. After installing the plugin you will find the “video quicktag” option in setting tab. Screenshot as follows:

Open the add new post tab, you will find very cool options for adding the video in post.

You just need to add the video URL in the dialog box.

create 404 page in wordpress theme with classic design

Many wordpress theme developer when create new wordpress theme, they need to think about 404 page must. In this article I going to give you information about how to create 404 page in wordpress theme with classic design.

create 404 page in wordpress theme

What is 404 page?

The 404 or Not Found error message is an HTTP standard response code indicating that the client was able to communicate with the server but the server could not find what was requested. 404 errors should not be confused with “server not found” or similar errors, in which a connection to the destination server could not be made at all. Another similar error is “410: Gone”, which indicates that the requested resource has been intentionally removed and will not be available again. A 404 error indicates that the requested resource may be available in the future.

I recommend to wordpress theme developer create customize 404 page in wordpress theme. Go to google custom search engine page and get google search engine code for your website from following URL:

http://www.google.com/cse/

Use following code creating the 404 page in wordpress theme.


<?php get_header(); ?>

<?php get_sidebar(); ?>

<div class="text" style="padding:50px 0 0 150px; ">

<img src="<?php bloginfo('template_url'); ?>/images/octocat_happy.gif">
<h1 class="title">Page Not Found</h1>
<p>We are sorry about!</p>
<p>Please try search again from here:</p><br>

<form action="http://images.purabtech.in/search-result/" id="cse-search-box">
<div>
<input type="hidden" name="cx" value="partner-pub-4949877136251097:p4u7h8-3y7v" />
<input type="hidden" name="cof" value="FORID:10" />
<input type="hidden" name="ie" value="ISO-8859-1" />
<input type="text" name="q" size="25" />
<input type="submit" name="sa" value="Search" />
</div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script>

</div>

<?php get_footer(); ?>

I used here my websites search engine code. Dont forget to change the google search engine code as your web site.

404-error-pages-for-your-website-7 create 404 page in wordpress theme
create 404 page in wordpress theme
The 404 or Not Found error message is an HTTP standard response code indicating that the client was able to communicate with the server but the server could not find what was requested. 404 errors should not be confused with “server not found” or similar errors, in which a connection to the destination server could not be made at all. Another similar error is “410: Gone”, which indicates that the requested resource has been intentionally removed and will not be available again. A 404 error indicates that the requested resource may be available in the future.

How to create user registration in wordpress

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

create user registration in wordpress
create user registration in wordpress

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:

  1. Profile Pic
create user registration in wordpress
create user registration in wordpress

This plugin allows authors to add a picture to their profile and helps automate the process of displaying author profiles

Using both plugin you can easily achieve the User and Registration, login, forgot password, profile edit, user photo upload etc… functionality.

get recent comments without wordpress plugin

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.


<?php
$total_comments = $wpdb->get_results("SELECT comment_date_gmt, comment_author, comment_ID, comment_post_ID, comment_author_email FROM $wpdb->comments WHERE comment_approved = '1' and comment_type != 'trackback' ORDER BY comment_date_gmt DESC LIMIT 10");
$comment_total = count($total_comments);
echo '<ul>';
for ($comments = 0; $comments < $comment_total; $comments++) {
echo "<div style='clear:both;width:355px;padding-top:3px;'><div style='float:left;width:35px;'>";
echo get_avatar($total_comments[$comments]->comment_author_email,$size='32',$default='<path_to_url>' );
echo "</div> <div style='width:320px;'>";
echo '<li>';
echo $total_comments[$comments]->comment_author . ' says ';
echo '<a href="'. get_permalink($total_comments[$comments]->comment_post_ID) . '#comment-' . $total_comments[$comments]->comment_ID . '">';
echo get_the_title($total_comments[$comments]->comment_post_ID);
echo '</a></li></div></div>';
}
echo '</ul>'
?>

My footer is looking like as follows:

get recent comments without wordpress plugin
get recent comments without wordpress plugin

how to create wordpress pages by script

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');
how to create wordpress pages by script
how to create wordpress pages by script

How to use pagination in wordpress post without plugin

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

How to use pagination in wordpress post without plugin
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.

<?php $args = array(
    'before'           => '<p>' . __('Pages:'),
    'after'            => '</p>',
    'link_before'      => ,
    'link_after'       => ,
    'next_or_number'   => 'number',
    'nextpagelink'     => __('Next page'),
    'previouspagelink' => __('Previous page'),
    'pagelink'         => '%',
    'more_file'        => ,
    'echo'             => 1 ); ?>
<?php wp_link_pages( $args ); ?>

This is the one of the sample code.

<?php wp_link_pages('before=</pre>
&after=
<pre>&next_or_number=number&pagelink=page %'); ?>

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.

$content = get_the_content();
$pages = explode('<!--<span class="hiddenSpellError" pre="" data-mce-bogus="1">nextpage</span>-->', $content);

you can also use the above code in your loop.

wordpress migration to new hosting service or domain

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

6. wp_usermeta
meta_key column – change(source_domain)

Most important part of migration. Fixing the image path of wordpress website

7. Just run following query using phpmyadmin or command prompt and any sql editor.

UPDATE wp_posts SET post_content = REPLACE(post_content, ’NEW_DOMAIN.com’, ‘OLD_DOMAIN.com’);

For changing the mysql queries you can use the following URL:

https://purabtech.in/mysql-queries-wordpress-website-migration/

Follow above steps and your are done with migration.

wordpress migration to new hosting service or domain
wordpress migration to new hosting, question always came to web developers. Using our steps wordpress migration to new hosting service or domain made easy

That sit!

How to find wordpress posts by category 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.

How to find wordpress posts by category name

Use following code :

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php  query_posts('paged='.$paged.'&category_name=Your Category&posts_per_page=10'); ?>
<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php while ($my_query->have_posts()) : $my_query->the_post(); ?>

php the_permalink() ?>" title="<!--?php the_title(); ?-->">
<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php the_title(); ?>

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

find wordpress posts by category name
find wordpress posts by category name

how can we execute custom queries on wordpress

We can use the custom queries in wordpress. Using the custom queries we can fetch the wordpress table data as per our custom requirement.

how can we execute custom queries on wordpress

We you create your table then you can fetch values from that table using following command.

$ourdata = $wpdb->( "SELECT id, name FROM yourtable" );

If you want to create the table in wordpress then use following article.

https://purabtech.in/create-add-tables-wordpress-theme/

More example about executing the own custom quries.

$wpdb->query("
	DELETE FROM $wpdb->postmeta WHERE post_id = '123'
	AND meta_key = 'google'");

another example about adding the data into table which is from wordpress:

$table_name = "your_table";
 $welcome_name = "Mr. WordPressapi";
  $welcome_text = "Congratulations, you just completed the installation!";

  $insert = "INSERT INTO " . $table_name .
            " (time, name, text) " .
            "VALUES ('" . time() . "','" . $wpdb->escape($welcome_name) . "','" . $wpdb->escape($welcome_text) . "')";

  $results = $wpdb->query( $insert );

Getting the single value from any table

$user_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->users;"));

Get the single row value from wordpress table

$mylink = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = 10", ARRAY_A);
how can we execute custom queries on wordpress
how can we execute custom queries on wordpress

you can use inner join, outer join and multiple join in wordpress custom queries.