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

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 increase or decrease the maximum execution time of a php script

By default PHP script execution time is set for 30 seconds at php.ini file. This is the time limit set for all the files to finish its execution. If the file takes more than this set time then the execution of the script will be stopped and error message will be displayed like this.

Fatal error: Maximum execution time of 30 seconds exceeded in F:php_filesttest.php on line 14

This maximum execution time limit is set inside the php.ini file like this.

max_execution_time = 30 ; Maximum execution time of each script, in seconds

This value can be increased or decreased as per our requirement at php.ini file but note that in a server environment where many sites are hosted, any change in php.ini will affect all the sites hosted by the server. So this change is not possible unless you own the server and you are the only user. In a shared hosting our host may not like to change any settings of php.ini for our requirement. So there is a option to set the file execution time for the particular file at the individual file end. This adjustment of time limit has no effect if php is running in safe mode. Let us try to learn how this works.

Setting page titles and meta tags in cakephp 2.0

Today I needed to have page titles and meta tags correctly setup for each page in a website i had often used methods like placing variables and setting them to the template in the app controller in a beforeFilter. Then if i needed a different meta tag on another page like contact for example i could go to the contact controller and and overwrite these variables. A great idea but didn’t work too well for the simple pages and the pages controller.

Here is Idea how you can add page titles and meta tags easy in your cake pages

1- First we need to set the page tile,place this code within your method on the controller :
$this->set(“title_for_layout”,”your page title goes here”);

2- Second add below code to your respective view page :

echo $this->Html->meta(‘keywords’, ‘your keywords goes here’, array(‘type’ => ‘keywords’, ‘inline’ => false));
echo $this->Html->meta(‘description’, ‘your description goes here’, array(‘type’ => ‘description’, ‘inline’ => false));

Hope this will help!!!!!!!!!!

Login issue with admin, user and unable to register in oscommerce

Recently we have an issue with oscommerce. We were developing an oscommerce site and everything was working fine in our test server. But when we moved to the production server provided by the client it stops working.

The issue was we couldn’t login as admin. Every time we logged in with correct parameters it was showing an error “Error: Invalid administrator login attempt.” We were searching for a solution in the google but nothing helped us. Later we found that we cannot even login as users and cannot register a new user also. So we have done some debugging and atlast what we got the solution.

The issue with the domain name and the one which we gave in the configure.php. The domain name always show with www. ie, when we type http://mysitename.com it will show as http://www.mysitename.com. What we gave in our configure.php file was http://mysitename.com. So issue with generating cookie and also POST information. When we changed the value of configure.php from http://mysitename.com to http://www.mysitename.com, it began to work. Hope it will be helpful for some others also.

How to Increase PHP’s File Upload Limit Using php.ini

The file upload size limit 2M(Approx) is set by shared hosting providers. They have set it low because it save bandwidth, keep the server moving quickly.
But customers really need a large upload limit? So we must increase the file upload size limit. We can do it by 4 way :

1- By adding below code on the page where you have upload function

ini_set(‘memory_limit’, ‘256M’); //needs to be in {x}M format
ini_set(‘upload_max_filesize’, ’50M’); //needs to be in {x}M format
ini_set(‘post_max_size’, ’50M’); //needs to be in {x}M format

2- Using below code in php.ini file

memory_limit = 256M
upload_max_filesize = 50M
post_max_size = 50M

Make php.ini file and upload it on the root folder

3- Using .htaccess file (Add below code in this file)

php_value memory_limit 256M
php_value upload_max_filesize 50M
php_value post_max_size 50M

4- Finally if above 3 tricks not work, then you need to contact to your hosting provider.