How to change length of post excerpt in wordpress theme

How to change length of post excerpt in wordpress theme

To change the length of the post excerpt in a WordPress theme, you can modify the theme’s functions.php file. First, access the functions.php file by navigating to Appearance > Theme Editor in your WordPress dashboard. Then, add the following code to the file:

function custom_excerpt_length($length) {
return 30; // Change 30 to the desired number of words
}
add_filter('excerpt_length', 'custom_excerpt_length');

This code will adjust the default excerpt length. The 30 can be changed to any number, depending on how many words you want your excerpt to display. Once you save the changes, the new excerpt length will be applied across your site. Make sure to back up your functions.php file before editing to prevent any issues. Alternatively, some themes allow you to modify excerpt length directly through the theme customizer or settings panel.

How to use post excerpt in WordPress Twenty Fifteen theme

How to use post excerpt in WordPress Twenty Fifteen theme

To use post excerpts in the WordPress Twenty Fifteen theme, you first need to enable them in your posts.

By default, the theme shows full content on the homepage and archives, but you can change that by manually setting an excerpt.

When editing a post, scroll down to the “Excerpt” field in the post editor and add a custom summary or short version of your content.

If this field is not visible, enable it by clicking on “Screen Options” at the top of the editor page and checking the box for “Excerpt.

” Once you’ve added your excerpt, the Twenty Fifteen theme will automatically display it in the post list on your homepage or archive pages, instead of the full content.

This is especially useful for creating clean, easy-to-navigate layouts with summaries of your posts.

Additionally, you can customize the appearance of excerpts via the theme’s settings or by editing the theme’s files, such as index.php or archive.php, to control how excerpts are shown.

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

Enable AJAX Submit in GravityForms in wordpress

To enable AJAX form submission in Gravity Forms on your WordPress site, simply navigate to the form settings and enable the AJAX option.

This allows users to submit forms without a page reload, enhancing user experience and improving performance. To activate AJAX, use the shortcode [gravityform id="1" ajax="true"], replacing "1" with your actual form ID.

Alternatively, if adding the form via PHP, use gravity_form(1, false, false, false, '', true);.

Enabling AJAX ensures smoother interactions, reduces page load times, and provides instant feedback, making it ideal for modern, dynamic websites.

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

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.