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.

WordPress blog excerpt not working in Themes

Some of the themes in wordpress does not display excerpt on blog page, category pages or archive pages. This is because theme does not include the experts code in the theme file.

This is a very simple tutorial that anyone can implement and take advantage of this built-in feature. The benefit of implementing this tutorial is that it decreases page load time and it increases the pageview count.

So we will have to update theme as per our need. For this process we will have to edit index.php file, archive.php file, and category.php file and find the code

<?php the_content(); ?>

If this is there then replace it with

<?php the_excerpt(); ?>

 

Enable AJAX Submit in GravityForms in wordpress

If you want to use Ajax submit on GravityForms in wordpress then you must use the ajax=”true” in the shortcode otherwise the form will be not submitted as ajax and your page will be reloaded.

Below is the sample code for ajax submit
[gravityform id=”1″ title=”false” description=”false” ajax=”true”]

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 );

Show only single category posts on WordPress archive page

Here is the code you can use to show only single category posts on wordpress archive page.

function my_custom_get_posts( $query ) {

if ( $query->is_archive() ) {
$blog_term = get_term_by(‘slug’, ‘your-blogcategry-slug-name’, ‘category’);
$blog_term_id = $blog_term->term_id;
$query->set(‘cat’, $blog_term_id);
}
}
add_action( ‘pre_get_posts’, ‘my_custom_get_posts’, 1 );

CSS Media Queries for iPads & iPhones

Sometimes we got very confusion while developing responsive work. When we apply the breakpoints for iPad and iPhone that does not works properly. As per my experience while searching on the Internet I found some useful information regarding the media queries. I applied those and that works fine for me. So today I am going to add the media queries here for the same.

iPad Media Queries

iPad Media Queries (All generations – including iPad mini)

 

iPad in portrait & landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) { /* STYLES GO HERE */}

iPad in landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) { /* STYLES GO HERE */}

iPad in portrait


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) { /* STYLES GO HERE */ }

Retina iPad in landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 2) { /* STYLES GO HERE */}

Retina iPad in portrait


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait)
and (-webkit-min-device-pixel-ratio: 2) { /* STYLES GO HERE */ }

iPad mini Media Queries

iPad mini in portrait & landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (-webkit-min-device-pixel-ratio: 1) { /* STYLES GO HERE */}

iPad mini in landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 1) { /* STYLES GO HERE */}

iPad mini in portrait


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait)
and (-webkit-min-device-pixel-ratio: 1) { /* STYLES GO HERE */ }

iPad mini Resolution


Screen Width = 768px (CSS Pixels)
Screen Height = 1024px (CSS Pixels)

Screen Width = 768px (Actual Pixels)
Screen Height = 1024px (Actual Pixels)

Device-pixel-ratio: 1

iPhone Media Queries

iPhone 6 Media Queries

iPhone 6 in portrait & landscape


@media only screen
and (min-device-width : 375px)
and (max-device-width : 667px) { /* STYLES GO HERE */}

iPhone 6 in landscape


@media only screen
and (min-device-width : 375px)
and (max-device-width : 667px)
and (orientation : landscape) { /* STYLES GO HERE */}

iPhone 6 in portrait


@media only screen
and (min-device-width : 375px)
and (max-device-width : 667px)
and (orientation : portrait) { /* STYLES GO HERE */ }

How to Add Google Translate in WordPress

Today I will show you how you can add google translator plugin on the wordpress site in easy steps. First of all you have install this plugin Google Language Translator

After activating the plugin go to Settings » Google Language Translator to configure the plugin.

Make sure that the plugin is activated. After that you need to select your website’s default language, and the languages you want to be available for translation. Once you are done simply save your plugin settings.

Now after then you have to use the widget code on the widget section to display the translator on the site (simply drag and drop).

If you want to do that custom then you need to copy the code as per below screenshot and paste in your template file.

Now you have done you website in multi language option….. Thanks!!

Get page id in wordpress

Here is the tips for getting page id in wordpress. First of all I will show page id in admin area.

Go to the pages and clcik on that, then you can see all pages list. Look the below screenhsot.

After then click on the desired page and you can see the page id on the address bar as I have marked. attached screenshot.

If you want to check page id on the front side then you should use the code. Use the blow wordpress function . It will give you the page id on the pages
get_the_ID();

More detail you can get here

If you want to show page id only for specific page then you can use the below code
<?php if(get_the_ID() == ‘475’) {?>
I am your page
<?php } ?>

Burger menu not working on ipad/tablet in wordpress

If you are working with wordpress enfold theme then may be you get the issue of menu on the tablet/ipad in landscape mode. Them menu does not appears as a burger so try this media query, may be it will help :


@media only screen and (max-width: 1024px) { /*** put your css code here ****/}