CORS policy: No ‘Access-Control-Allow-Origin’

Font from origin domain.dev has been blocked… (CORS and browsersync)

If you are getting issue fonts are blocked in web client CORS then below code will help you. Use the code in .htaccess file and problem will be resolved 🙂
# Allow access from all domains for webfonts.
<IfModule mod_headers.c>
<FilesMatch “\.(ttf|ttc|otf|eot|woff|woff2|font.css|css)$”>
Header set Access-Control-Allow-Origin “*”
</FilesMatch>
</IfModule>

Know android codes for mobile device

Know android codes for mobile device :

1- For IMEI NUMBER :

*#06#

2- for Ram

*#*#3264#*#*

3- Phone service menu

*#0*#

4- Battery Status

*#0228#

5- phone service mode

*#9090#

6- Battery use or device related information

*#*#4636#*#*

7- Camera related inforamtion

*#*#34971539#*#*

8 – Software/Hardware information

*#12580*369#

Redirect all url to https

If you have a secure certificate (SSL) on your website, you can automatically redirect visitors to the secured (HTTPS) version of your website to make sure their information is protected.

Using the following code in your .htaccess file automatically redirects visitors to the HTTPS version of your site:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If you have an existing .htaccess file:

  • Do not duplicate RewriteEngine On.
  • Make sure the lines beginning RewriteCond and RewriteRule immediately follow the already-existing RewriteEngine On.

How To Create WordPress Shortcodes

WordPress introduced the shortcode API in version 2.5. Shortcodes are now used by a large number of WordPress plugins to allow users to add content to their posts and pages. All of us have probably used them at one time or another. They usually come bundled with plugins, or even themes, and what they do is watch for when you insert something inside square brackets then replace that with some other content; it could be a simple sentence or it could be a massive PHP function, it all depends on what you instructed WordPress to do.

The shortcode API allows you to create your own shortcodes by adding functions to your theme functions.php template (this is located at www.yourwebsite.com/wp-content/themes/yourtheme/).

In addition to creating your own shortcodes, WordPress also includes five default shortcodes with the WordPress core:
audio – Allows you to embed audio files.
caption – Allows you to wrap captions around content. It is commonly used with images.
embed – Allows you to embed a wide range of content such as video, audio and tweets.
gallery – Allows you to insert image galleries.
video – Allows you to embed video files.

In this article we will create some simple WordPress shortcodes to help you create any functionality you like.

A Basic Example

In our first example we want to create a shortcode that will create some “custom text” every time we type [spin2win] into the editor. First we need to create the callback function that will return the “custom text”

function spin2win_func() {
return “I am new shortcode text”;
}

Next we need to add this shortcode to WordPress using the add_shortcode function in either our functions.php file

add_shortcode( ‘spin2win’, ‘spin2win_func’ );

So the full code would be like this :

function spin2win_func() {
return “I am new shortcode text”;
}
add_shortcode( ‘spin2win’, ‘spin2win_func’ );

Note : spin2win_func and spin2win can be any name.

Creating a Shortcode With Attributes

Attributes can expand the functionality of shortcodes by allowing you to pass data through your shortcodes.

When WordPress encounters this we want a function that will insert an image. It needs to read the width and height attributes

function get_images($atts) {
extract(shortcode_atts(array(
‘width’ => 250,
‘height’ => 180,
), $atts));
return ‘‘;
}

add_shortcode(‘getpics’, ‘get_images’);

That’s all 🙂

Media query for large screen

Here is media query for large screen. You can apply the breakpoints and enjoy the work.

@media screen and (min-width: 1400px) {

}
@media screen and (min-width: 1600px) {

}
@media screen and (min-width: 1900px) {

}

How to change continue reading link text in wordpress

How to change continue reading link text in wordpress. In this tutorial I will show you how you can change the “continue reading” text in wordpress. If you want to modify continue reading link with Read more , you can use this function in your functions.php file.

function my_code_excerpt_more( $more ) {
return ‘ ‘ . __(‘Read More’, ‘your-text-domain’) . ‘‘;
}
add_filter( ‘excerpt_more’, ‘my_code_excerpt_more’ );

May be your theme does have another text except “continue reading”, so this trick also will work for those.

How to change length of post excerpt in wordpress theme

In this case here is little code and that will help!! You will have to use the code in functions.php file

/* Changed excerpt length to 200 words*/
function your_code_excerpt_length( $length ) {
return 20;
}
add_filter( ‘excerpt_length’, ‘your_code_excerpt_length’, 200 );

If you are not ok with the limit of 200, you can change to to any integer number you like.

How to use post excerpt in WordPress Twenty Fifteen theme

In this tutoarial, I will show you, how you can fix the post excerpts issue in the WordPress Twenty Fifteen theme.
Twenty Fifteen theme has greatl layout, Neat & clean content area, great readability settings and other features Twenty Fifteen is going to be favorite of many bloggers. Most of the blog users expect post excerpts on front page. The Twenty Fifteen shows full article on front page, category page, search page etc . There are number of articles on front page, category page, archive pages, search page etc so the length of webpage becomes huge and webpage size also increases. This can be avoided by showing post excerpt in Twenty Fifteen.

For fixing excerpts issue, Look in the content.php which need to be modified for post excerpt.

/* translators: %s: Name of current post */
the_content( sprintf(
__( ‘Continue reading %s’, ‘twentyfifteen’ ),
the_title( ‘‘, ‘‘, false )
) );wp_link_pages( array(
‘before’ => ‘

‘,
‘link_before’ => ”,
‘link_after’ => ”,
‘pagelink’ => ‘‘ . __( ‘Page’, ‘twentyfifteen’ ) . ‘ %’,
‘separator’ => ‘, ‘,
) );
?>

You can see from the block of code shown above that full content of each post is displayed through the the_content() function. If we change this block of code to show full content for single post and post excerpt for all other cases, then purpose will be solved.

if ( is_single() ) :
Full post content

else :
Post excerpt

endif;

So for now we will have to modify our code. Look below I have modified the code

‘, ‘‘, false )
) );

wp_link_pages( array(
‘before’ => ‘

‘,
‘link_before’ => ‘‘,
‘link_after’ => ‘
‘,
‘pagelink’ => ‘‘ . __( ‘Page’, ‘twentyfifteen’ ) . ‘ %’,
‘separator’ => ‘, ‘,
) );
else :

/* translators: %s: Name of current post */
the_excerpt( sprintf(
__( ‘Continue reading %s’, ‘twentyfifteen’ ),
the_title( ‘‘, ‘‘, false )
) );

wp_link_pages( array(
‘before’ => ‘

‘,
‘link_before’ => ‘‘,
‘link_after’ => ‘
‘,
‘pagelink’ => ‘‘ . __( ‘Page’, ‘twentyfifteen’ ) . ‘ %’,
‘separator’ => ‘, ‘,
) );
endif;

?>

Now we have done!! This piece of code will work perfectly on the wordpress site.

How to enable error reporting in Magento2

Here is the tip, how you can enable magento error reporting in magento 2

Connect FTP OR login into cpanel account and go to the following directory

pub/errors

find the local.xml.sample and rename to local.xml

and also on magento root folder find index.php and put the display error code at the bottom

error_reporting(E_ALL);
ini_set(‘display_errors’, 1);

Change woocommerce price position

If want to change the position of the price in wocommerce then this is possible. You can it easy in adding little code in the functions.php file.

If you want to put price near add to cart button then please add following code to Functions.php file of your child theme (or parent theme, if not using a child theme)- you can use Dashboard -> Appearance > Editor or direct FTP

remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );
add_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 29 );