Tuesday, January 10, 2017

ACF Repeater Field Pagination

Hello Friends,

Few days ago, I found difficulties in pagination for ACF Repeater Custom Field. I have worked on custom post type before on pagination but this one is newer for me. I have googled lots of article but nothing matches my requirement then after 10 Hrs. of digging I found saver code (which saves my time). Haha.

Below is the code which might help you too. If it isn't solve your problem then send me your code so, I can help out.

In below code replace your parameter with matching ones.

<?php
/*
* Paginate Advanced Custom Field repeater
*/
if( get_query_var('page') ) {
$page = get_query_var( 'page' );
} else {
$page = 1;
}
// Variables
$row = 0;
$images_per_page = 10; // How many images to display on each page
$images = get_field( 'image_gallery' );
$total = count( $images );
$pages = ceil( $total / $images_per_page );
$min = ( ( $page * $images_per_page ) - $images_per_page ) + 1;
$max = ( $min + $images_per_page ) - 1;
// ACF Loop
if( have_rows( 'image_gallery' ) ) : ?>
<?php while( have_rows( 'image_gallery' ) ): the_row();
$row++;
// Ignore this image if $row is lower than $min
if($row < $min) { continue; }
// Stop loop completely if $row is higher than $max
if($row > $max) { break; } ?>
<?php $img_obj = get_sub_field( 'image' ); ?>
<a href="<?php echo $img_obj['sizes']['large']; ?>">
<img src="<?php echo $img_obj['sizes']['thumbnail']; ?>" alt="">
</a>
<?php endwhile;
// Pagination
echo paginate_links( array(
'base' => get_permalink() . '%#%' . '/',
'format' => '?page=%#%',
'current' => $page,
'total' => $pages
) );
?>
<?php else: ?>
No images found
<?php endif; ?>

Monday, July 4, 2016

Window OS - How to delete directories with too long path names

I get it fixed by following quick fix solution.

rimraf <dir>
rimraf is a Node.js package, so you will need to install Node.js which includes npm. Then you can run:
npm install -g rimraf
Then you can run rimraf from the command line.
I found this solution because npm itself was causing this problem due to the way it nests dependencies.
By the way, rimraf gets its name from the UNIX command rm -rf, which recursively deletes files and folders.

Saturday, September 19, 2015

How to remove ?doing_wp_cron from my URLs



I'm finding this string appended to the end of my URLs sometimes: ?doing_wp_cron

It's a sign that you have ALTERNATE_WP_CRON defined in your wp-config.php

In order to do some background processing (like publishing scheduled posts), WordPress redirects you to the URL with ?doing_wp_cron appended.
  
Remove the line from wp-config.php (although that might stop cron from working).

To Solve this manage redirection in the .htaccess file.

Here is an exemple on how to redirect the url by adding these lines in the .htaccess file :

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{QUERY_STRING} (^|&)doing_wp_cron= [NC]
    RewriteRule (.*) /$1? [R=301,L]
</IfModule>

Hope this will help !

Wednesday, September 16, 2015

How to Boost the speed of your Magento Site ?

One of the drawbacks of Magento is currently its speed if default configuration is used. There are certain ways of making it run faster.
Let’s start speeding up Magento!

First step, edit .htaccess file.

Enable Output Compression

This section will turn on the apache mod_deflate module, which compresses text, css, and javascript before it is sent to the browser. This results in a smaller download size. To enable, simply uncomment the appropriate lines so that it looks like the following:


############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
 
    # Insert filter on all content
    SetOutputFilter DEFLATE
    # Insert filter on selected content types only
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
 
    # Netscape 4.x has some problems...
    BrowserMatch ^Mozilla/4 gzip-only-text/html
 
    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
 
    # MSIE masquerades as Netscape, but it is fine
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 
    # Don't compress images
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
 
    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary
 
 
 

Enable Expires Headers

Browsers use Expires headers to determine how long a page component can be cached. Static components, like images, should have far-future expires headers, but truthfully, all page components should have expires headers. To turn this feature on, just uncomment the appropriate line and add “ExpiresActive On” right above it. See below:

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
 
    ExpiresActive On
    ExpiresDefault "access plus 1 year"
 
 
 
Keep in mind, if you use a far future Expires header you have to change the component’s filename whenever the component changes. More info http://developer.yahoo.com/performance/rules.html

Disable ETags

ETags are a way for browsers to validate cached components across subsequent visits. They can slow down a site served from a cluster if the cluster hasn’t implemented them properly. It is best to just turn them off as follows:

############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags
 
    FileETag none
 
 
 
Now, from Magento admin side make sure that you combine JS and CSS files.
  • Magento admin -> System Configuration -> Developer -> Under “Javascript Settings”, change “Merge Javascript Files” to YES.
  • Magento admin -> System Configuration -> Developer -> Under “CSS Settings”, change “Merge CSS Files” to YES
Clear the cache.
Use CDN if it is possible, please note combining CSS/JS when using CDN will cause CSS/JS to “break” until the CDN updates completely.

Enable Flat Catalog

Magento uses the EAV model to store customer and product data. This enables these objects to be incredibly extensible, but results in longer SQL queries and more reads. Enabling the Flat Catalog for Categories and Products merges product data into one table, thereby improving performance. Generally, all stores should enable Flat Catalog for Categories.
More information you can find following yslow user guide http://yslow.org/user-guide/, here you can find more tutorials and resources to follow.
Happy speeding :-)
 

 

 

Wednesday, September 2, 2015

htaccess – 301 Redirect Website From http to https


Now a days more and more websites are making the move from http to https, primarily just because of Google’s announcement back in August 2014, where they said websites with SSL (i.e. secure connection) will benefit from a slight boost in search engine rankings.

Many have made the move, yet failed to notice any difference in rankings. Perhaps the boost is so lightweight that it’s extremely difficult to track. In any case, I don’t see anything wrong with getting an SSL certificate, even if your website isn’t dealing with sensitive data or necessarily going to benefit from a boost, because it ultimately does make a website more secure when transferring data, and that’s always a good thing.

The code


The following code will 301 redirect all http URLs to https. For example http://www.kcontechnosoft.com will redirect to https://www.kcontechnosoft.com

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

 

Copyright @ 2013 PHP WORDPRESS MAGENTO .

Designed by Kcon Technosoft