Easy Guide to Add the New Facebook Page Plugin in WordPress

In this tutorial, we will show you how to add the Facebook page plugin in WordPress.

What is Facebook Page Plugin?

 

Facebook page plugin is the replacement of what was previously known as the Facebook Like box. It allowed you to promote your Facebook page on your website. The new Facebook Page plugin does the exact same thing.

It has a new and improved look which now displays your Facebook cover photo as well. It comes with two buttons. Users can Like your page, and they can also share it. You have the option to show users which of their friends have already liked your page. You can also display recent posts from your Facebook page.

How to Add The New Facebook Page Plugin in WordPress

First you need to visit Facebook’s Page Plugin website. You will find the options to configure the appearance of your Facebook page embed.

Simply provide the URL of your Facebook page. Next you will need to enter the width and height for the box. Alternatively, you can leave it blank, and Facebook will try to automatically adjust it.

You can show your cover photo, posts, and friend’s faces in the page plugin. Once you are satisfied with the appearance, click on the Get Code button to continue.

Facebook will now show you two code snippets. Copy the first code snippet and paste it in your theme or child theme‘s header.php file right after the <body> tag.

Next, copy the second code snippet and paste it anywhere you want to display the page like box. You can also paste this code snippet into a text widget by going to Appearance » Widgets.

We hope this tutorial helped you add Facebook Page plugin to your WordPress site.

Easy Guide to Add an iframe Border Around a Video Embed

Adding Border Around iframe Videos in WordPress

First thing you need to do is to open a post or page containing your iframe video embed code. A typical iframe embed code should looks something like this:

[youtube https://www.youtube.com/watch?v=qzOOy1tWBCg&w=560&h=315]

You can add a border around it by adding inline style to the code like this:

[youtube https://www.youtube.com/watch?v=qzOOy1tWBCg&w=560&h=315]

 

Simply change the width of the border as well as the color, and you’re done.

While adding an iframe border works, there is actually a better way to add a border around videos in WordPress. That’s by using oEmbed.

Adding Border Around oEmbed Videos in WordPress

WordPress comes with built-in oEmbed support. Basically WordPress allows you to paste the link of the video, and it will automatically get the embed code for them. Now this only works for oEmbed enabled sites such as YouTube, Vimeo, DailyMotion, Hulu, etc. (See: how to easily add videos in WordPress using oEmbed)

Now that you know how to add a video with oEmbed, here is how you can add a border around oEmbed videos in WordPress.

When adding a video using oEmbed, simply wrap the URL in span tag with inline style parameters, like this:

<span style="border:3px solid #EEE;">http://www.youtube.com/watch?v=qzOOy1tWBCg</span>

If you want to add a same border around all video iframes, then it would be best to add a CSS class to your theme’s stylesheet.

.frame-border { 
border:3px solid #EEE; 
}

Now you can use the CSS class in your iframe embed code like this:

[youtube https://www.youtube.com/watch?v=qzOOy1tWBCg&w=560&h=315]

You can also use the same CSS class in the span tag around your oEmbed video URLs, like this:

<span class="frame-border">http://www.youtube.com/watch?v=qzOOy1tWBCg</span>

The benefit of using a single CSS class is that if you change themes later, then you can easily change the colors with one click vs going back and editing each video individually.

We hope this tutorial helped you add an iframe border around a video embed in WordPress.

Easy Guide to Show Recent Posts by Category in WordPress

In this tutorial, we will cover how to show recent posts by category in your WordPress sidebar.

 

Display Recent Posts by Category (Plugin Method)

First thing you need to do is install and activate the Category Posts Widgetplugin.

Upon activation, you need to visit Appearance » Widgets, there you will notice the new Category Posts widget in the list of available widgets.

Simply drag and drop Category Posts widget to a sidebar where you want to display recent posts by category.

visit Appearance » Widgets

The widget options are quite self explanatory. First you need to provide a title for the category posts section and choose a category. After that you can choose other display options like number of posts, excerpts, featured image, etc.

Once you are done, click the save button to store your widget settings. You can now visit your site to see recent posts by category in action.

Display Recent Posts by Category without a Plugin (Code Snippet)

In this method, we will use a code snippet to display recent posts from a category.

First you need to add this code in your theme’s functions.php file or a site-specific plugin.

function wpb_postsbycategory() {
// the query
$the_query = new WP_Query( array( 'category_name' => 'announcements', 'posts_per_page' => 10 ) ); 
 
// The Loop
if ( $the_query->have_posts() ) {
    $string .= '

 

Make sure that you replace 'announcements' with your own category slug.

This code simply queries WordPress to retrieve 10 posts from a specified category. It then displays the posts in a bulleted list. If a post has a featured image (post thumbnail), then it will show the featured image as well.

In the end, we created a shortcode 'categoryposts' and enabled shortcode in text widgets.

There are three ways of displaying the recent posts by category using this code snippet.

First, you can simply paste the following code anywhere in your desired template file location (such as footer.php, single.php, etc).


Second and third method relies on using the shortcode in the widget area or inside your posts / pages.

Simply visit Appearance » Widgets and add a text widget to your sidebar. Next add [categoryposts] shortcode in the text widget and save it. You can now preview your website to see recent posts by category in the sidebar.

If you want to show recent posts by categories on specific post or pages, then simply paste the shortcode in the post content area.

By default, your list may not look very good. You will need to use CSS to style the category posts list. You can use the code below as an starting point in your theme or child theme’s stylesheet.

ul.postsbycategory {
list-style-type: none;
}
 
.postsbycategory img {
float:left; 
padding:3px;
margin:3px;
border: 3px solid #EEE;
}

use CSS to style the category posts list

That’s all, we hope this tutorial helped you display recent posts by category in WordPress sidebar.

Easy Guide to Import and Export Custom Post Types in WordPress

In this tutorial, we will show you how to import and export custom post types in WordPress. We will also show you how to import any custom taxonomies associated with your post types.

There are two steps involved in exporting and importing a custom post type in WordPress. First step involves migrating the actual custom post type and taxonomies. The second step is to import the post type data.

Often custom post types in WordPress are associated with their own custom taxonomies. We will show you how to export/import your custom taxonomies along with your post type.

 

Exporting Custom Post Types and Taxonomies in WordPress

Some users prefer to create their custom post types and taxonomies by adding code in their theme’s functions.php file or a site-specific plugin. In that case, all you need to do is copy that code and paste it on the site where you want to import them.

However, in some cases you may not be able to locate the code. Don’t worry you can still create the same custom post type on the new site.

All you need to know is the post key value. This is the name used for the post type in your WordPress database. You can find it by simply visiting the post type in your WordPress admin area.

post key value

Once you have the post key, visit the site where you want to import the post type and use Custom Post Types UI plugin to create your custom post type.

import the post type

You can also get custom taxonomy key by simply viewing the custom taxonomy in the admin area.

simply viewing the custom

Use CPT UI plugin to create the same taxonomy on the target site where you want to import the taxonomy.

Use CPT UI plugin

Repeat the process for all custom post types and taxonomies that you want to import.

Bonus Tip: If you used the CPT UI plugin to create your post type, then you can also use it to migrate them. But this only works if the original custom post type was created using this plugin. Visit the Import / Export section in the plugin settings and follow onscreen instructions.

Custom Post Types & Taxonomies Created by Plugins

Many popular WordPress plugins use custom post types and taxonomies to handle custom content types. For example, Soliloquy uses them to create sliders, eCommere plugins use them to create products, etc.

If you want to keep using those plugins, then you don’t need to import CPTs. Simply install the plugin on the target site, and you will have the custom post types and taxonomies ready on your site.

Many such plugins come with their own import/export features but if a plugin does not have that feature you can still export the data.

Exporting / Importing Custom Post Type and Taxonomies Data in WordPress

WordPress comes with a powerful import/export tool which allows you to export and import WordPress data. Simply go to Tools » Export.

Exporting / Importing Custom Post Type

You will see all your post types listed there. Select the post types you want to export and press the Download Export File button.

WordPress will now prepare an XML export file and your browser will start downloading it.

Now switch to your target site where you want to import this data. Go to Tools » Import. You will see a number of options, click on WordPress.

This will bring up a popup asking you to install WordPress importer plugin. Click on the install button and then click on Activate Plugin & Run importerlink.

l WordPress importer plugin

On the importer screen, you need to click on the choose file button and then select the XML file you downloaded earlier. Next, click on the upload file and export button.

Next, click on the upload file

WordPress will now import your custom post type data. All the custom post types you selected earlier will be imported. WordPress will also automatically add terms to the custom taxonomies.

 

8 Proven Methods to Promote Old Posts in WordPress

In this tutorial, we will show you some of the best ways to promote old posts in WordPress.

 

But before we start, let’s take a look at why it’s important to promote old posts.

1. Regularly Share Your Old Posts on Social Media

Regularly Share Your Old Posts on Social Media

Most of your social media updates are seen by a fraction of your followers. Mainly because there is so much noise and not everyone is online at the same time.

That’s why it is recommended to share at various different times of the day. The Revive Old Post plugin automatically shares your old posts on social media networks like Twitter, Facebook, and LinkedIn. It spreads out your updates for different times allowing you to maximize your exposure.

For detailed instructions see our guide on how to automatically share your old WordPress posts.

2. Showcase Related Posts on Your Blog

Showcase Related Posts on Your Blog

When you visit popular blogs like TechCrunch, Mashable, or even WPCademy, you will notice that there is related content next to or below each article.

If a user has scrolled down to read your entire article, then they are engaged. Using a related posts plugin, you can provide them an opportunity to explore more of your website.

3. Display Your Popular Posts

Display Your Popular Posts

It’s true that 20% of your website content gets 80% of your traffic. Some articles are simply more popular than others.

Why not get more traffic to them? You can start showcasing your most popular content with a few simple clicks. People coming to your website are more likely to read what many other users have already found interesting.

Here are some great popular posts plugins for WordPress that you can use.

4. Create Better 404 Pages

Create Better 404 Pages

Most WordPress themes come with a default 404 page template. A 404 page is displayed when a page that the user is looking for cannot be found.

You can use this opportunity to showcase the most important content of your website, and keep that visitor engaged. You can also add a search form on the page, so that users can locate the content they were looking for.

Here are detailed instructions on how to improve your 404 page template in WordPress.

5. Better WordPress Search

Better WordPress Search

The default search feature in WordPress is fairly limiting, but you can improve the search feature. There are two common approaches for that.

The first one is to use Google Custom Search form to replace the WordPress search. The other method is to use a search plugin like SearchWP.

Both of these solutions will help improve your WordPress search.

6. Custom Archive Pages

Custom Archive Pages

Creating a custom archive page is one of the best way to highlight your old but still useful content.

You can show the most popular articles, most commented posts, recent posts, and so on. You can even display all your post categories / tags, add compact archives, and include a search form. This will help people not only in finding content, but will also help them understand what your blog is about. Don’t forget to add an email sign up form on the page.

You may also want to check out WPCademy archives.

7. Interlink Old Articles

Interlink Old Articles

Building internal links is one of the most important SEO strategy. You need to make internal linking a habit.

It’s helpful to the user when you link to your old posts whenever it is relevant. People browse the web by clicking on one link to another. Make sure that there are plenty of your own links for them to click on.

Check out our guide on WordPress SEO tips for beginners for some more SEO advice.

8. Link Old Articles in Comments

Link Old Articles in Comments

When answering user comments on your own blog, you should try to use links to point them to other articles on your own website.

It’s not something you should force, rather it’s important to keep it in the back of your mind, and you will be surprised how many opportunities will come up.

This builds trust and increases your pageviews. This link you add is going to stay there and any future visitors with the same question will continue to click on that link.

We hope this tutorial helped you fine some new ways to promote old posts on your WordPress site.

Easy Guide to Link to External Links from the Post Title in WordPress

In this tutorial, we will learn how to link to external links from the post title in WordPress.

Method 1: Linking Post Title to an External Link in WordPress using Plugin

This method is easier and is recommended for beginners.

First thing you need to do is install and activate the Page Links To plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, simply create a new post or edit an existing one. You will notice the new ‘Page Links To’ meta box below the post editor.

WordPress using Plugin

Click on ‘A custom URL’ to add the link you want to add to post title. Now you can save or publish your post.

That’s all. The post title will now link to the custom URL you provided.

It is not necessary to use it for external links only. You can also use it to send users to different posts and pages on your WordPress site.

Method 2: Add External Link to Post Title Using Code

This method requires you to add code to your WordPress site. You can use this method if you are comfortable with pasting snippets from web into WordPress.

Simply add this code to your theme’s functions.php file or a site-specific plugin.

function print_post_title() {
global $post;
$thePostID = $post->ID;
$post_id = get_post($thePostID);
$title = $post_id->post_title;
$perm = get_permalink($post_id);
$post_keys = array(); $post_val = array();
$post_keys = get_post_custom_keys($thePostID);
 
if (!empty($post_keys)) {
foreach ($post_keys as $pkey) {
if ($pkey=='external_url') {
$post_val = get_post_custom_values($pkey);
}
}
if (empty($post_val)) {
$link = $perm;
} else {
$link = $post_val[0];
}
} else {
$link = $perm;
}
echo '
'.$title.'
'; }

This code looks simply looks for a custom field containing your custom URL. If the post has the custom field, then it outputs the post title linked to your URL.

The next step is to replace your theme’s default display of post title with this function. You will find it in archives.php, content.php, category.php and other templates. It would look something like this:

?php the_title( sprintf( '</p> <h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2> <p>' ); ?

You need to replace it with this code:

 ?php print_post_title() ?

The code part is over, now you need to add the external URL to the post. Simply edit the post or create a new one. On the post editor page, look for the custom fields meta box.

If you cannot see the custom fields meta box, then you need to click Screen Options in the top right corner of the screen. This will bring down a menu where you need to check the box next to ‘Custom Fields’.

 custom fields meta box in  wordpress

You will find the custom fields meta box below the post editor.

Click on ‘Enter New’ and then enter external_url in the ‘Name’ field and the URL you want to add to post title in the ‘Value’ field.

Enter New’ and then enter external_url.  also add to post title in the ‘Value’ field.

You can now save or publish your post. That’s all, your post title will now be linked to the URL you added in the custom field.

Next time you need to add a link, you just need to select the external_urlcustom field from the drop down menu and enter your external link in the value field.

We hope this tutorial helped you learn how to link to external links from the post title in WordPress.

Easy Guide to Stop Storing IP Address in WordPress Comments

In this tutorial, we will learn how to stop storing IP address in WordPress comments.

Pros and Cons of Not Storing IP Address in WordPress Comments

By default, WordPress logs and stores IP addresses of users leaving comments on your website. These IP addresses are permanently stored in your database.

The reason for storing IP addresses with each comment is to help site owners combat with unwanted comments or spam. Plugins like Akismet can block comments from IP addresses known to be exploited by spammers.

Unless your users are using a VPN service, their real IP addresses can still be found in your site logs. Most WordPress hosting providers keep an access log of all visitors to your website for a limited period of time.

On the other hand by not storing IP address in WordPress comments, you can improve privacy of commenters on your website. They may feel more confident about expressing their opinions knowing that your site doesn’t store IP addresses with comments.

Method 1: Stop Storing IP Addresses in Comments with Plugin

This method is easier and recommended for new websites and beginners.

First thing you need to do is install and activate the Remove IP plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Once activated, the plugin will replace user IP with 127.0.0.1, which is an IP address typically used by localhost.

The plugin will not delete IP addresses stored with older comments. If you have older comments with IP addresses stored with them, then you may want to delete those IP addresses as well. We will show you how to do that later in this article.

Method 2: Manually Stop Storing IP Addresses with WordPress Comments

If you are comfortable pasting code snippets in WordPress, then you should use this method instead.

Simply add this code to your theme’s functions.php file or a site-specific plugin.

function wpb_remove_commentsip( $comment_author_ip ) {
return '';
}
add_filter( 'pre_comment_user_ip', 'wpb_remove_commentsip' );

This is basically the same code used by the plugin we mentioned in the first method. However, instead of storing 127.0.0.1, it leaves the IP field blank.

Remove IP Address From Old Comments

Regardless of which method you use to stop storing comments IP, old comments on your WordPress site will always have IP addresses stored with them.

If you have old comments on your site, then you may want to remove IP addresses from those comments.

We will show you how to do that by running a MySQL query on your WordPress database. It is really important to make sure that you have the most recent WordPress database backup.

Next you need to login to your WordPress hosting control panel and look for phpMyAdmin.

Make sure that you have selected your WordPress database by clicking on the database name in the column on your left hand. After that you need to click on the SQL menu.

WordPress database clicking

This will bring you a text area where you need to enter this query:

UPDATE 'wp_comments' SET 'comment_author_IP' = '';

Click on the Go button below the textarea to run your query. That’s all, it will remove all IP addresses stored with comments in WordPress database.

Note: if you have a custom WordPress database prefix, then please adjust the wp_comments to your custom table prefix.

We hope this tutorial helped you learn how to stop storing IP address in WordPress comments.