How to Enqueue Google Fonts on WordPress Theme

Register custom fonts

/**
 * Register custom fonts.
 */
function themeslug_fonts_url() {
	$fonts_url = '';
	$fonts     = array();
	$subsets   = 'latin,latin-ext';

	/*
	 * Translators: If there are characters in your language that are not supported
	 * by Oswald, translate this to 'off'. Do not translate into your own language.
	 */
	if ( 'off' !== _x( 'on', 'Oswald font: on or off', 'themeslug' ) ) {
		$fonts[] = 'Oswald:400,700';
	}

	/*
	 * Translators: If there are characters in your language that are not supported
	 * by Montserrat, translate this to 'off'. Do not translate into your own language.
	 */
	if ( 'off' !== _x( 'on', 'Montserrat font: on or off', 'themeslug' ) ) {
		$fonts[] = 'Montserrat:400,700';
	}


	if ( $fonts ) {
		$fonts_url = add_query_arg( array(
			'family' => urlencode( implode( '|', $fonts ) ),
			'subset' => urlencode( $subsets ),
		), 'https://fonts.googleapis.com/css' );
	}


	return esc_url_raw( $fonts_url );
}

Continue Reading

How to display WordPress post view count without a plugin

Tutorial 1

Use this code in functions.php

function rm_post_view_count(){
	if ( is_single() ){
		global $post;
		$count_post = esc_attr( get_post_meta( $post->ID, '_post_views_count', true) );
		if( $count_post == ''){
			$count_post = 1;
			add_post_meta( $post->ID, '_post_views_count', $count_post);
		}else{
			$count_post = (int)$count_post + 1;
			update_post_meta( $post->ID, '_post_views_count', $count_post);
		}
	}
}
add_action('wp_head', 'rm_post_view_count');

Continue Reading

How to Remove .DS_Store on Mac

  1. Open your Terminal
  2. In the command line, type: cd
  3. Drag and drop the folder you wish to delete .DS_Store files from in this case our theme folder. Press enter.
  4. Finally, in the command line, type:
    find . -name '.DS_Store' -type f -delete

    Press enter.

Visual Composer Get images from “attach_images”

In VC_MAP definition you have:

array(
	"type"        => "attach_images",
	"heading"     => esc_html__( "Screenshots", "text-domain" ),
	"description" => esc_html__( "Add screenshots.", "text-domain" ),
	"param_name"  => "screenshots",
	"value"       => "",
),

In shortcode function you should have: Continue Reading