Get the Category thumbnail and list with custom code

<code> </code>
<div id=”columnpostsec”><!–?php $taxonomies = array( ‘post_tag’, ‘apprentice-learning-zone’, ); $categories = get_terms( $taxonomies, ‘orderby=name&amp;hide_empty=0&amp;order=desc’ ); //Get all the terms foreach ($categories as $cat) { $parent = $cat-&gt;parent;&lt;br ?–> $namee = $cat-&gt;name;</div>
?&gt;
<div id=”main_box_div”>
<div id=”resource_box_img”>
<div id=”resource_box_img_lower”><img src=”&lt;?php echo z_taxonomy_image_url($cat-&gt;term_id,’thumbnail’); ?&gt;” alt=”” /></div>
<div id=”resource_box_img_text”></div>
</div>
</div>
<!– end .columnpostsec –>

Add Inline style using WordPress inbuilt functionality

add_action( 'init', 'prefix_register_styles' );

/**
* Register Theme styles.
*
* @since 0.0
* @access public
* @return void
*/
function prefix_register_styles(){

$themeversion = wp_get_theme()->display('Version'));

//Register main style.css for theme
wp_register_style( 'prefix-screen', get_bloginfo('stylesheet_url'), array(), floatval($themeversion) , false );

}

add_action( 'wp_enqueue_scripts', 'prefix_theme_stlyles' );

/**
* Load Theme Styles
*
* @since 0.0
* @access public
* @return void
*/
function prefix_theme_stlyles() {

if (is_admin()) {

return;

}

if (!is_admin()) {

//Load the main style.css
wp_enqueue_style( 'prefix-screen' );

if( get_option('prefix-css-color', false) != false){

$color = get_option('prefix-css-color', false);

$prefix_themecss = ".blah{ background-color:$color;}";

wp_add_inline_style('prefix-screen', $prefix_themecss);

}

}

}

Get an attachments caption,title, alt and description


function wp_get_attachment( $attachment_id ) {
$attachment = get_post( $attachment_id );
return array(
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'href' => get_permalink( $attachment->ID ),
'src' => $attachment->guid,
'title' => $attachment->post_title
);
}

$attachment_meta = wp_get_attachment(your_attachment_id);

And then either loop through the array values or simply reference by the key name of what you want (ie: caption, description, etc.):

echo $attachment_meta['caption'];

The above would echo the image's caption.

Ajax Pagination example for woocommerce

Jquery code


[script]
jQuery(function($) {
$(document).on('click', '.pagi a', function(e){
e.preventDefault();
var link = $(this).attr('href');
$('#content-all').fadeOut(500, function(){
$('#content-all').empty();
$(this).load(link + ' #content-all', function() {
$(this).fadeIn(500);
});
});
});
});
[/script]

Content code

 

<div id=”content-all”>
<div class=”content-all”>
<?php do_action( ‘woocommerce_archive_description’ ); ?>
<div class=”nav-previous alignright pagi”><?php next_posts_link( ” ); ?></div>
<div class=”nav-next alignleft pagi”><?php previous_posts_link( ” ); ?></div>
<?php if ( have_posts() ) : ?>
<?php
/**
* woocommerce_before_shop_loop hook
*
* @hooked woocommerce_result_count – 20
* @hooked woocommerce_catalog_ordering – 30
*/
do_action( ‘woocommerce_before_shop_loop’ );
?>
<?php woocommerce_product_loop_start(); ?>
<?php woocommerce_product_subcategories(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php wc_get_template_part( ‘content’, ‘product’ ); ?>
<?php endwhile; // end of the loop. ?>
<?php woocommerce_product_loop_end(); ?>
<?php
/**
* woocommerce_after_shop_loop hook
*
* @hooked woocommerce_pagination – 10
*/
do_action( ‘woocommerce_after_shop_loop’ );
?>

<?php elseif ( ! woocommerce_product_subcategories( array( ‘before’ => woocommerce_product_loop_start( false ), ‘after’ => woocommerce_product_loop_end( false ) ) ) ) : ?>

<?php wc_get_template( ‘loop/no-products-found.php’ ); ?>

<?php endif; ?>

<?php
/**
* woocommerce_after_main_content hook
*
* @hooked woocommerce_output_content_wrapper_end – 10 (outputs closing divs for the content)
*/
do_action( ‘woocommerce_after_main_content’ );
?>
</div>
</div>

Custom taxonomy for products

[code]

/*———————————————————————————–*/
/* product Post Type
/*———————————————————————————–*/

function product_taxonomy() {
register_taxonomy(
‘product_categories’,
‘product’, //post type name
array(
‘hierarchical’ => true,
‘label’ => ‘Product Categories’, //Display name
‘query_var’ => true,
‘rewrite’ => array(
‘slug’ => ‘product’, // This controls the base slug that will display before each term
‘with_front’ => false // Don’t display the category base before
)
)
);
}
add_action( ‘init’, ‘product_taxonomy’);
function filter_post_type_link( $link, $post) {
if ( $post->post_type != ‘product’ )
return $link;

if ( $cats = get_the_terms( $post->ID, ‘product_categories’ ) )
$link = str_replace( ‘%product_categories%’, array_pop($cats)->slug, $link );
return $link;
}
add_filter(‘post_type_link’, ‘filter_post_type_link’, 10, 2);

//Registering Custom Post Type Product
add_action( ‘init’, ‘register_themepost’, 20 );
function register_themepost() {
$labels = array(
‘name’ => _x( ‘Product’, ‘catchproduct_custom_post’,’catchproduct’ ),
‘singular_name’ => _x( ‘Product’, ‘catchproduct_custom_post’, ‘catchproduct’ ),
‘add_new’ => _x( ‘Add New’, ‘catchproduct_custom_post’, ‘catchproduct’ ),
‘add_new_item’ => _x( ‘Add New Product’, ‘catchproduct_custom_post’, ‘catchproduct’ ),
‘edit_item’ => _x( ‘Edit Product’, ‘catchproduct_custom_post’, ‘catchproduct’ ),
‘new_item’ => _x( ‘New Product’, ‘catchproduct_custom_post’, ‘catchproduct’ ),
‘view_item’ => _x( ‘View Product’, ‘catchproduct_custom_post’, ‘catchproduct’ ),
‘search_items’ => _x( ‘Search Products’, ‘catchproduct_custom_post’, ‘catchproduct’ ),
‘not_found’ => _x( ‘No Products found’, ‘catchproduct_custom_post’, ‘catchproduct’ ),
‘not_found_in_trash’ => _x( ‘No Products found in Trash’, ‘catchproduct_custom_post’, ‘catchproduct’ ),
‘parent_item_colon’ => _x( ‘Parent Product:’, ‘catchproduct_custom_post’, ‘catchproduct’ ),
‘menu_name’ => _x( ‘Product’, ‘catchproduct_custom_post’, ‘catchproduct’ ),
);

$args = array(
‘labels’ => $labels,
‘hierarchical’ => false,
‘description’ => ‘Custom Product Posts’,
‘supports’ => array( ‘title’, ‘editor’, ‘excerpt’, ‘author’, ‘thumbnail’, ‘comments’, ‘revisions’, ‘post-formats’, ‘custom-fields’ ),
‘taxonomies’ => array( ‘product_categories’),
‘show_ui’ => true,
‘show_in_menu’ => true,
‘menu_position’ => 5,
‘show_in_nav_menus’ => true,
‘publicly_queryable’ => true,
‘exclude_from_search’ => false,
‘query_var’ => true,
‘can_export’ => true,
‘rewrite’ => array(‘slug’ => ‘product/%product_categories%’,’with_front’ => FALSE),
‘public’ => true,
‘has_archive’ => ‘product’,
‘capability_type’ => ‘post’
);
register_post_type( ‘product’, $args );//max 20 charachter cannot contain capital letters and spaces
}

[/code]

Display dates as “time ago”, the easy way

change-date-formatWant to display human readable dates on your blog, such as “Posted 6 days ago?” There’s a lot of available functions to do so, but only a few people know that WordPress have its own built-in function to do that.
To display human readable dates on your blog, you have to use the

human_time_diff()

function. The following piece of code will show a post date like “Posted 6 days ago”.
Paste it anywhere within the loop, save the file, and you’re done.
Posted

human_time_diff.(get_the_time.(‘U’), current_time.(‘timestamp’)) . ‘ ago’;

Open source twitter streaming code list

Below are the top Open source twitter streaming code list : –

6 steps to make your contest effective on Facebook.

Why should i run a promotion on Facebook?

If your client or yourself ever wondered what the answer is, contests and promotions are an excellent resource to boost your business and are useful for large, medium or small companies but that it will happen only care about your end user.
Contests and promotions serve for various purposes for example to get more audience, increase the level of community interaction, increase your databases or deliver more traffic to your website and therefore, we have to take care of the details to make them truly effective.
The logic of this resource is that you have to give something to get attention so we have to find ways in which people allow us to share your social life to communicate the message of our brand and promotions are highly effective tools to achieve it.
– OK, you convinced me and I decided to organize a contest but … Where do I start?

1) Set goals:
The first step, as in any marketing action, is to set clear objectives you set out with this move. To do that you have to answer the question: What do you want to achieve with this competition?
For example: increase the visibility of your business, generate databases for use in email marketing activities or to learn more about your fans, increase the size or activity in your community or promote a new product.
Determine this with your team is very important and will influence the competition format that will carry forward and should respect the story it tells of your brand.

2) Follow the rules of Facebook:
It is vital for the survival of your promotion that it respects the Facebook imposes rules for this type of action , you have to use an application like The Fan Machine and not use the social network’s wall.

3) Choose a proper participation mechanic:
There are different ways to activate your community, but is essential to personalize the “stories” of your promotion. This means you have to think and customize each of the publications that participants and voters will share automatically  for a greater virality of your action.
You can do this in step 4 when setting up your promo with The Fan Machine

A) The most common method is the image or photograph contest because of their ease of participation, so it is familiar and widespread in this environment and because Facebook is the best performing mechanical gain fans. Also generate databases for future marketing, colors and images of your brand will always be present and the viral power of the spirit of competition.

B) To convert all your fans into clients, the path is to use a coupon promotion.Using this tool is easy to drive your fans to visiting your point of sale. Participants must sign up for a discount coupon that can be used in your business or digitally. This will increase your sales and activity on your site in an unexpected way.

C) For major contests & promotions you can require a little more to your followers and ask upload a video according to a specific set point and follow the same steps as in the image contest. It is very simple for the fans because with one click your video imported from YouTube and begins a real battle of videos, where experiences and entertainment will be the best result will win your community.

D) Under the same mechanics of voting, there is the possibility of promoting a  story contest(text)that is much easier for participants to participate and is really effective to engage with your community.

E) The simplest way to promote a product, service or event isa sweepstakes, as often happens that people do not participate when the mechanics are too complex or has many steps to complete the registration.

4) An attractive prize:
Keep in mind that the award should have some relationship with the customer required to enter or win. Analyzing your audience is central to achieving greater participation of members of your community.

5) Set clear terms and conditions:
This is another time where you can differentiate yourself from the rest of the mechanical or thematic promotions proposing novel but without losing sight of the simplicity. If you want to achieve engagement is vital that you seek to innovate and be creative to avoid falling into
routine.

6) Communication:
When launching a contest or promotion you must not think that automatically you fans know about it.  You must inform to your fans about it with a proper community management work to keep alive the flame of promotions, generating intrigue, causing the competitive spirit among the participants and recalling the reward if they have a target.

How do Facebook Ads work?

Facebook ads work under an auction system, in which each advertiser offers a price (bids) so that their ad is shown instead of one of the others competing for the promotional space.

To get Facebook users to see your ad, you must “bet” how much are you willing to pay to have your add shown, even though you’ll end up paying a lower number. The following chart is very clear:

biddingThere are many formats availabe and here we’ll review which are the most appropriate to archieve each goal. To start with, there are two main categories:avisos

A) Ads – When the business speaks

In this type of ad, the creator can completely modify all the elements of the message. This means, it is possible to configurate the title, the images and even the text included in the ad.

There are 4 Ad formats:

1)  Classic Ad.

2) Page Post Ad.

3) Mobile App Ad.

4)  Search Results Ad.

1) Classic Ad:

They are the most similar to the newspaper ads, for they don’t exhibit social interactions. They are only situated on the right column, exclusively dedicated for ads.

The exception to this rule is when the ad is linked to a Fan Page, App or Event in Facebook, due to, only in this specific case, the classic ad appears on users Newsfeed between friends activities.

Each advertiser can decide where each ad would point to and direct the traffic. One can select to point the ads to an online store, blog or any other web site or site inside Facebook, like a Fan Page, Event or App could be for instance.

The social context of the ads, such as: “John likes: X”, appears by default when the landing page set is inside Facebook (Fan Page, Event or App).

When we want to promote an external site from Facebook and we wish to include that social information, we must include the URL promoted in the basic information of the Fan Page, by logging into the Administrator Panel.

The requirements for launching a Classic Ad are:
Title: (25 characters maximum)
Text: (90 characters maximum)

Image: (100 pixels width and 72 pixels high as maximum size. You can upload it or select one from an existing album.)

2) Page Post Ad:

This type of ad enables to increase the social reach of a post made on a Facebook Page. For its own features, they can be located on the mobile Newsfeed as well as on desktops Newsfeed and right column.

When promoting a post (post), it doesn’t change its appearance nor its social functionalities (that enables to increase the amount of persons that will see it). Users will be able to interact normally with the post, whether it’s indicating their like, leaving a comment or sharing the post.

For example, if the post that we are promoting is a video, it will be able to be reproduced by the users as usually, or if it’s a poll, they’ll indicate the answer, and so on with the other type of posts.

Keep in mind that, if you want the promoted post to be also shown on the right column, Facebook will only exhibit the first 90 characters of the text.

3) Mobile App Ad.

The aim of this format is to ease the installation of mobile apps. These ads are linked to download sites such as Google Play for Android or App Store for devices with iOS.

Before creating this type of ads, the app must have been set as active on Facebook by following the steps described in this tutorial: Mobile App Install Ads.

It’s worth clarifying that, to promote the installation of an app it’s not necessary for it to be integrated to the social network from the user experience, but Facebook must have knowledge of its existence.

The dimensions of the images to promote the installation of an app are 600 pixels width and 360 pixels high. The title shown will be the name of the app and the description text, that can have up to 100 characters.

4) Search Results Ad.

This type of ads enables to appear in the first place on Facebooks searchs. The image shown will be the one of the Fan Page, App or Event promoted, and it can be configured a description text of 70 characters maximum and also establish to which tab are redirected the users that click on the ad.

These type of ads are only visible from desktops and do not appear on the searchs made through mobile devices nor are they shown when the user extends the listo to “more results”.

B) Sponsored Stories – When the friends speak

The sponsored stories differ from the classic ads since they are not modifiable and  what is directly promotioned is the social behaviour of a friend (logically linked to a Fan Page, Event or App that we have configured). It converts friends into recommenders  of the content published by the pages or about likes and preferences.

A story can mean that a friend has indicated that he liked a page, used an app, attended an event, accessed an offer or commented a post, for instance.

Likewise the promoted posts, when deciding to promote a story, its content doesn’t change but its reach and distribution is increased.

Sponsored stories appear in desktop and mobile Newsfeeds and also on all the other locations that Facebook has available for ads.

In general, this ad format is the one that gains more interactions for, as being related to friends, users pay more attention to these stories, raising the amount of clicks and levels of engagement. People tend to give more credibility to the activity and suggestions of their friends than to the direct communications of brands and organizations.

Besides, the sponsored stories appear with the profile picture and name of the friend  that generated any interaction with the Fan Page, Event or App that is being promoted, giving it a more human, personal and friendly aspect.

In addition to all the actions predetermined by Facebook (indicating a like, making a comment, sharing a post, attending an event, etc) there are other stories that can be promoted thanks to the Open Graph mechanism that Facebook provides so that any company can use it integrated to their social network. For example, you can promote a story about a friend that has checked-in a restaurant or listening to a song or watching a movie.