Saturday, 30 November 2013

Set WordPress Permalinks Settings From functions.php

Permalinks are the permanent URLs to your individual WordPress or blog posts, as well as pages and other lists of blog postings. It's very important to have an easy and beautiful permalinks structure for your site, as it's a part of optimizing your site for SEO.

The default WordPress permalinks structure looks something like this:

http://www.whatever.com/?p=316

And I hate this as much as you all do. However, you can change the default structure of your blog permalinks in the settings of your WordPress blog. But we can also change the default permalinks structure from our functions.php file.

It's pretty easy, just add following snippet to your functions.php file:

<?php
// set permalink
function set_permalink(){
    global $wp_rewrite;
    $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%postname%/');
}
add_action('init', 'set_permalink');
?>

Use this snippet to change the permalink settings from your functions.php file instead of in the admin area. You can replace the red area in above code with following structure codes:

%year%
    The year of the post, four digits, for example 2004

 %monthnum%
    Month of the year, for example 05

 %day%
    Day of the month, for example 28

 %hour%
    Hour of the day, for example 15

 %minute%
    Minute of the hour, for example 43

 %second%
    Second of the minute, for example 33

 %post_id%
    The unique ID # of the post, for example 423

 %postname%
    A sanitized version of the title of the post (post slug field on Edit Post/Page panel). So “This Is A Great Post!” becomes this-is-a-great-post in the URI.

 %category%
    A sanitized version of the category name (category slug field on New/Edit Category panel). Nested sub-categories appear as nested directories in the URI.

 %author%
    A sanitized version of the author name.

Thursday, 28 November 2013

Disable Auto Updates In WordPress

WordPress 3.7 came out with a new automatic background update feature in an effort to promote better security. By the default, only minor releases and translation file updates are enable. But we could manually disable or enable anything we want.

Just put following codes to your wp-config.php file to disable/enable the updates:

To specifically enable development (nightly) updates, use the following:

add_filter( 'allow_dev_auto_core_updates', '__return_true' );

To specifically disable minor updates, use the following:

add_filter( 'allow_minor_auto_core_updates', '__return_false' );

To specifically enable major updates, use the following:

add_filter( 'allow_major_auto_core_updates', '__return_true' );

Plugins, themes and translation file:

Automatic plugin and theme updates are disabled by default.

To enable automatic updates for plugins, use the following:

add_filter( 'auto_update_plugin', '__return_true' );

To enable automatic updates for themes, use the following:

add_filter( 'auto_update_theme', '__return_true' );

Automatic translation file updates are already enabled by default, the same as minor core updates.  To disable translation file updates, use the following:

add_filter( 'auto_update_translation', '__return_false' );

Core Updates:

To disable all core-type updates only, use the following:

add_filter( 'auto_update_core', '__return_false' );

All Updates

To completely disable all types of automatic updates, core or otherwise, add the following to your wp-config.php file:

define( 'AUTOMATIC_UPDATER_DISABLED', true );

You can also disable all automatic updates using the following filter:

add_filter( 'automatic_updater_disabled', '__return_true' );

Hope this would help you. Source: WordPress Codex

Wednesday, 27 November 2013

Most Expensive Pay Per Click Campaigns


Every year businesses and marketing companies around the globe search for new ways to increase revenue and traffic to their website. Publicity is generally always a good thing and increased number of unique visitors to a website usually results in a larger number of sales. Businesses are constantly competing for the top spots on search engine result pages but reaching the top 3 natural links is often a long tedious and challenging task.

Pay per click or adword marketing campaigns have become ever more prevalent in recent years as companies have began to realise its potential to increase profits exponentially. A PPC campaign is the process of bidding on a phrase that you have deemed relevant to your industry. When your paid link is followed through by a potential customer you will be charged according to the amount bid for.

Paid links are so popular because they eliminate the need to earn a top spot in natural search listings. Paid links are always placed in prime locations of the website and taking google as an example we would mostly likely see these phrases as the top 2-3 search results (usually highlighted in yellow) and on the right hand side of a page. By having links in such opportune positions you will significantly increase the chances of consumers visiting your website.

The price of each click is determined by many factors and can start from pennies per click, however this is not always the case any many businesses find themselves paying upwards of $140.

Competition is generally regarded as the reason for inflated costs. An example of this would be the search term 'Mesothelioma attorney' which along with many other asbestos compensation phrases holds a spot as one of the most expensive phrases. It was suggested that a legal firm in Florida was paying upwards of $200 for each click owed to competition in that area being so great. Asbestos compensation claims are a rather lucrative industry so attorneys are willing to pay 'over the odds' to not only generate a lead but to prevent a rival company from benefiting from the lead.

The type of industry that the search is related to can also affect the cost of a phrase, industries that sell legal services, web space and insurance dominate the top spots of most expensive PPC phrases. Most legal services are around $100 per click whilst insurance can range anywhere from $30-$80 per click.

Google is by far the most popular place for businesses to bid for keywords using their adwords platform. This is due to the fact that over 60% of people use google with the other sharing the other 40%. This give you more opportunity to bring potential custom to your business. Other search engine such as Yahoo and bing offer a similar service and are usually cheaper per click.

Finally the length of a search term can make or break a PPC campaign, a phrase that is overly broad may acquire many unique visitors however the amount of people who purchased your service would be lower (due to you not being quite what they want) and you would be paying a much higher rate per link. An overly specific search term would be cheaper and would receive far less visitors however the percentage of people who go on to buy something would be no doubt higher.

An example of this would be a company selling custom t-shirt, paying for the search term 'buy a t-shirt' would yield vast amounts of visitors however not many would purchase the item whereas 'buy a black t-shirt with a picture of a dog' would have far less visitors but a greater turn around rate.

Author Author - Adam Howard writes for Atrium on workers health. Asbestos is the biggest killer of industrial workers so litigation in this area is very lucrative. Due to this it is very competitive which is reflected in paid search click prices.

Saturday, 23 November 2013

Add Extra CSS In WordPress Posts With Custom Fields

I posted last couple of WordPress articles on BWidgets about the amazing power of custom fields. This is article is also about another great use of custom fields.

Sometimes, a specific post needs to be more styles with some custom CSS codes. We all know that we can directly write our CSS code in post editor, but that's not very clean way to do this. So, we're going to do this with custom fields.

This is clean, easy, and a bit fun as well. Yea, these things makes me feel like James Bond 007. Here we go:

First, we need to add following code to your WordPress theme's header.php file:

<?php if (is_single()) {
    $css = get_post_meta($post->ID, 'css', true);
    if (!empty($css)) { ?>
        <style type="text/css">
        <?php echo $css; ?>  
        </style>
    <?php }
} ?>

Save the file. Once saved, when you're writing a post which requires some custom extra CSS styling, you'll just have to put your custom CSS styles in a custom field named css.

Friday, 22 November 2013

How To Get Custom Fields Outside The Loop In WordPress

Custom fields are one of the most useful and powerful feature in WordPress and are used on many WordPress-powered blogs. In this post, I'm going to show you how to get custom fields values outside the loop.

Thanks to Paul Whitehead for this trick. I want to share link to his website, but the website is dead right now.

Simply post following snippet anywhere in your WordPress site. Don’t forget to replace customField on line 4 by the name of the custom field you want to display.

<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'customField', true);
?>

Wednesday, 20 November 2013

How To Get Value Of A Specific Custom Field In WordPress

WordPress allows us to add custom fields to a our posts, which adds extra information, which is known as meta-data. But we can do a lot more there custom fields. For example, I embedded a video in this post with the use of custom fields.

More of newbies gets confused when it comes to use custom fields. But they're not that complicated, at least the basic use of these fields.

Here's how you can get value of a specific custom field in your WordPress posts:

<?php echo get_post_meta($post->ID, 'mood', true); ?>

"mood" would be ID value of custom field. That was simple.

And here's how to display custom field only if exists:

<?php
    $url = get_post_meta($post->ID, 'snippet-reference-URL', true);

    if ($url) {
        echo "<p><a href='$url'>Reference URL</a></p>";
    }
?>

Sunday, 17 November 2013

Using A Different Post Template For Posts Within A Specific Category

On Thursday I posted an article about using different post template for posts formats, but now it's time for doing the same thing with categories, instead of formats. You can use this trick in your WordPress to create different type of posts, such as portfolio items.

We discussed everything previously, so let's get into this trick:

Using A Different Post Template:

In this tutorial, we'll create a different post template for the cat-1 category. We'll use multiple single.php files to make it more easy and customizable.

Create a single.php file for your category. We're going to name it single-cat-1.php. You can also copy your single.php file to this template and make some changes that you want in the video template.

Upload single-cat-1.php to the root of your current theme. Same place where single.php file is located.

Okay, so now we'll tell WordPress to use single-cat-1.php template for the posts within video category. Add following to your theme's functions.php file:

add_action('template_include', 'load_single_template');
  function load_single_template($template) {
    $new_template = '';

    // single post template
    if( is_single() ) {
      global $post;

      // 'cat-1' is category slugs
      if( has_term('cat-1', 'category', $post) ) {
        // use template file single-template-cat-1.php
        $new_template = locate_template(array('single-cat-1.php' ));
      }

    }
    return ('' != $new_template) ? $new_template : $template;
  }

In above code, replace cat-1 is the slug of your category, and single-cat-1.php is your custom post template file. Save the file. That's it.

How To Log Out From New Facebook Messenger Android App


Facebook has released the latest update of its Messenger app for Android. This release covers some major changes in the app interface and features. You can also text your contracts from this app, which makes it replacement of texting.

But Facebook forgot to add something in this new upload. There's no option to Log Out of your account in this new update. Don't worry there's a solution of every problem.

Most of us used to log out of our Facebook accounts from Account settings menu, which will not work in this case. Here's how to log out from this app:

In Gingerbread: Click on Settings > Applications > Manage applications > Find and click on "Messenger" > Click on Clear Data > That's IT!

In ICS & JellyBean: Click on Settings > Apps > Find and click on "Messenger" > Click on Clear Data > That's IT!

Friday, 15 November 2013

Is Your Website Down For Everyone Or It's Just You?

A couple of days ago my website WWEFansNation.com's server went down, and the following message appeared:

503 Service Unavailable: The server is currently unavailable (because it is overloaded or down for maintenance)

But my website was not down at all. It was just my WiFi operator's fault. It was just down on my WiFi connection, but was up to entire universe.

My fellow blogger, Rajat Garg of TrueBloggerTips, passed me link to isup.me to check whether my website is down for everyone or it's just me.

You can also check if your website is down for everyone or it's you by visiting isup.me.

Thursday, 14 November 2013

Using A Different Post Template For Posts Formats In WordPress

Post Formats is a theme feature which was introduced with the WordPress 3.1 release. It gave us a new feature to style posts based on its format. If you ever used WordPress' default themes, then you might know about their different post templates based on the post format. So it's time for you to style your posts based on its format. Here's a demo of this trick from my own WordPress site:

This is a simple post.

This is a video post with a different template.

Add Post Format Support To Your WordPress Theme:

Before starting this tutorial, it's important for you to add support for post formats in your current WordPress theme. If this section is available in your post editor then you can skip this step:


If not, then follow this tutorial.

Using A Different Post Template:

In this tutorial, we'll create a different post template for the Video format. Most of developers uses a single post template file for all different format. But we'll use multiple single.php files to make it more easy and customizable.

Create a single.php file for your post format (we're using Video). We're going to name it single-video.php. You can also copy your single.php file to this template and make some changes that you want in the video template.

Upload single-video.php to the root of your current theme. Same place where single.php file is located.

Okay, so now we'll tell WordPress to use single-video.php template for the posts with video format. Add following to your theme's functions.php file:

add_action('template_include', 'load_single_template');
  function load_single_template($template) {
    $new_template = '';

    // single post template
    if( is_single() ) {
      global $post;

      // template for post with video format
      if ( has_post_format( 'video' )) {
        // use template file single-video.php for video format
        $new_template = locate_template(array('single-video.php' ));
      }

    }
    return ('' != $new_template) ? $new_template : $template;
  }

Save the file. That's it.

Now just publish a post with video format & see the magic. You can do the same with every post format. On a related note, I'll also share the same trick with categories, instead of formats.

Popular Posts

 
Powered by Blogger.