Friday 25 July 2014

show featured image to the beginning of each post if added any or show default post image

<?php



function easy_the_content_filter( $content ) {


        // Add image to the beginning of each post. if any featured image is added by  author than show the  featured  image otherwise  show  the  common image for all post  if no featured image is set by author.
       if ( is_singular('post') && has_post_thumbnail()) {
        $thumbnail = get_the_post_thumbnail();

        $content = $thumbnail . $content;
       
        }
        else
        {
            $content = sprintf('<img class="post-icon" src="%s/images/php.jpg" alt="Post icon" title="" width="100"/>%s',get_bloginfo( 'stylesheet_directory' ),$content );
        }

    // Returns the content.
    return $content;
}


?>

Add image to the beginning of each post in wordpress

<?php



function easy_the_content_filter( $content ) {


        // Add image to the beginning of each page

            $content = sprintf('<img class="post-icon" src="%s/images/php.jpg" alt="Post image" title="" width="100"/>%s',get_bloginfo( 'stylesheet_directory' ),$content );
     

    // Returns the content.
    return $content;
}


?>

Add Word Limit to Wordpress Posts

<?php


//Add Word Limit to Posts

add_filter("the_content", "easy_custom_filter");

  function easy_custom_filter($content)
  {

    return substr($content, 0, 100);
   // return a subset of it
  }


?>

Show category images on single product page

<?php
//Show category images on single product page

$terms = get_the_terms( $post->ID, 'product_cat' );// get the post categories ids

  foreach ( $terms as $term ) // traverse all post category deails
{
        $category_name = $term->name;
        $category_thumbnail = get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true);
        $image = wp_get_attachment_url($category_thumbnail);
        echo '<img src="'.$image.'">';
    }
   

?>

How to enable menu support in wordpress

<?php
//How to enable menu support in WordPress theme

function easy_enable_menu()
{
    add_theme_support( 'menus' );   
}

add_action( 'init', 'easy_enable_menu', 10 );

?>

How to remove bulk edit options

<?php


    //How to remove bulk edit options

    add_filter( 'bulk_actions-' . 'edit-post', '__return_empty_array' );
?>

Thursday 17 July 2014

how to create a custom post type in wordpress

<?php

/// put this code into your theme functions.php file 
add_action('init', 'easy_register_post_type');  //  hook  our function with Wordpress  process/stage

function easy_register_post_type() {

register_post_type(
    'products', array(
        'labels' => array(
            'name' => 'Products',
            'singular_name' => 'Product',
            'add_new' => 'Add new product',
            'edit_item' => 'Edit product',
            'new_item' => 'New product',
            'view_item' => 'View product',
            'search_items' => 'Search product',
            'not_found' => 'No products found',
            'not_found_in_trash' => 'No products found in Trash'
        ),
        'public' => true,
        'supports' => array('title',
           'title',
            'editor',
            'excerpt',
            'custom-fields',
            'revisions',
            'thumbnail'
        ),
        'has_archive' => true,
        'taxonomies' => array()
    )
);
}

?>

how to set new post thumbnail size in wordpress

<?php
//how to  set new post thumbnail size in wordpress

// set any size with your requirement  for the  thumbnail image

// add this code into your functions.php file

set_post_thumbnail_size( 210, 210, true );

?>

How to display custom post meta in wordpress

<?php
// To get the price of a random product we will need to know the ID
   $product_id=101;
    $price = get_post_meta( $product_id, 'product_price', true );

echo $price

?>   

Friday 11 July 2014

Top 20 Websites Making The Most Money

Top 20 Websites Making The Most Money



20. LinkedIn - $215,200,000 $7 per second
19. ClickBank - $350,000,000 $11 per second
18. Yandex - $439,700,000 $14 per second
17. Orbitz - $757,500,000 $24 per second
16. Groupon - $760,000,000 $24 per second
15. Taobao - $774,210,000 $25 per second
14. Zynga - $850,000,000 $27 per second
13. Skype - $860,000,000 $27 per second
12. Overstock - $1,100,000,000 $35 per second
11. Baidu - $1,199,000,000 $38 per second
10. Facebook - $2,000,000,000 $63 per second
9. NetFlix - $2,160,000,000 $68 per second
8. AOL - $2,417,000,000 $77 per second
7. Priceline – $3,072,240,000 $97 per second
6. Expedia, Inc. - $3,348,000,000 $106 per second
5. Alibaba - $5,557,600,000 $176 per second
4. Yahoo! - $6,324,000,000 $200 per second
3. eBay - $9,156,000,000 $290 per second
2. Google - $29,321,000,000 $929 per second
1. Amazon – $34,204,000,000 $1,084 per second



Freelance Jobs