• Skip to main content
  • Skip to primary sidebar

WPDigs

February 13, 2017 by Todd Leave a Comment

WordPress Multi-language setup comparing WPML and Polylang on the Enfold theme

If you are looking to add multilingual capabilities to your website. Here is a comparison on how to get started with WPML or Polylang.

Just a very simple comparison of the premium language plugin WPML and the free Polylang. Both are pretty easy to set up and work very well with the Enfold theme from Kriesi on ThemeForest.

Enfold
https://themeforest.net/item/enfold-responsive-multipurpose-theme/4519990?ref=Tandypress

WPML

Home

Polylang

 

Code used in this tutorial for WPML:

Goes in your Enfold child theme functions.php

// Adds Language directory path points to Enfold Child Theme
add_action('after_setup_theme', 'avia_lang_setup');
function avia_lang_setup()
{
$lang = get_stylesheet_directory()  . '/language';
load_child_theme_textdomain('avia_framework', $lang);
}

// Removes Country Flags From Menu
add_action('init','ava_remove_lang_flags', 9999);
function ava_remove_lang_flags() {
	remove_filter( 'wp_nav_menu_items', 'avia_append_lang_flags', 9998, 2 );
	remove_filter( 'avf_fallback_menu_items', 'avia_append_lang_flags', 9998, 2 );
        remove_action( 'avia_meta_header', 'avia_wpml_language_switch', 10);
        add_action('avia_after_footer_columns', 'avia_wpml_language_switch', 10);
}

Goes in your Enfold child theme CSS

/*CSS to hide languages  */

.avia_wpml_language_switch li .language_flag {
display: none !important;
}

.avia_wpml_language_switch li span.language_native{display: block !important;}


.menu-item-language-current {display: none !important;}

 

Filed Under: Coding

December 15, 2015 by Todd Leave a Comment

Better WordPress Minify is still the best

Here is a video showing the steps to use Better WordPress Minify yes its outdated but still works great for version 4.4+ of WordPress. Really it just minifies so what is there to change?

Make sure to use the Advanced settings to get the most out of it. Add this to you functions.php

add_filter('bwp_minify_get_buster', 'bwp_minify_get_buster');
function bwp_minify_get_buster($buster)
{
    return 'my-custom-buster';
}

Then you will get some code for your.htaccess rules. Add it to get the expired headers for the minified js and css.

# BEGIN BWP Minify Rules
# BEGIN BWP Minify Headers
<Files "*.js.gz">
ForceType application/x-javascript
</Files>
<Files "*.css.gz">
ForceType text/css
</Files>
<IfModule mod_mime.c>
AddEncoding gzip .gz
AddCharset utf-8 .js .css
</IfModule>
<IfModule mod_deflate.c>
    <IfModule mod_setenvif.c>
    SetEnvIfNoCase Request_URI "\.gz$" no-gzip
    </IfModule>
</IfModule>
<IfModule mod_headers.c>
Header set Cache-Control "public, max-age=2592000"
Header set Vary "Accept-Encoding"
Header unset ETag
</IfModule>
# END BWP Minify Headers
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=ZIP_EXT:.gz]
RewriteCond %{HTTP:Cache-Control} !no-cache
RewriteCond %{HTTP:If-Modified-Since} !no-cache
RewriteCond %{REQUEST_FILENAME}%{ENV:ZIP_EXT} -f
RewriteRule (.*) $1%{ENV:ZIP_EXT} [L]
RewriteRule ^minify-b(\d+)-([a-zA-Z0-9-_.]+)\.(css|js)$ /index.php?blog=$1&min_group=$2&min_type=$3 [L]
</IfModule>
# END BWP Minify Rules

 

 

Filed Under: Coding

September 11, 2015 by Todd 1 Comment

Clean up the WordPress head with this function

This script removes the WP version from the header and other links that are not always useful.

 

Its placed in your themes functions.php

 

// removes WP version from head and other junk links that slow down site goes in a themes functions.php

function headcleaner_setup () {
    remove_action('wp_head', 'wp_generator');                // #1
    remove_action('wp_head', 'wlwmanifest_link');            // #2
    remove_action('wp_head', 'rsd_link');                    // #3
    remove_action('wp_head', 'wp_shortlink_wp_head');        // #4

    remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10);    // #5

    add_filter('the_generator', '__return_false');            // #6
    add_filter('show_admin_bar','__return_false');            // #7

    remove_action( 'wp_head', 'print_emoji_detection_script', 7 );  // #8
    remove_action( 'wp_print_styles', 'print_emoji_styles' );
}
add_action('after_setup_theme', 'headcleaner_setup');

 

Filed Under: Coding

April 15, 2015 by Todd Leave a Comment

Add Google Analytics to the Registration and Login Page

function add_ga_to_login_page(){
  echo "<script type='text/javascript'>";
  echo "var _gaq = _gaq || [];
_gaq.push(['_setAccount','UA-YOURCODE-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();";
  echo "</script>";
}

add_action('login_head', 'add_ga_to_login_page');

Replace the UA-YOURCODE-1 with your analyics UA code and place this in your themes functions.php file.

Filed Under: Coding

January 21, 2015 by Todd Leave a Comment

Including Custom Post Types in WordPress Search

Add this function to your themes functions.php to add Custom Post Types to your Search. You find the name by hovering over your custom post type dashboard menu or going to and viewing it in the address bar. i.e. custom post type dashboard menu  http://yoursite.com/wp-admin/edit.php?post_type=portfolio

// Include custom types in search results

add_filter( 'pre_get_posts', 'custom_post_type_search' );
/**
 * This function modifies the main WordPress query to include an array of 
 * post types instead of the default 'post' post type.
 */
function custom_post_type_search( $query ) {
  
    if ( $query->is_search ) {
  $query->set( 'post_type', array( 'page', 'post', 'wpfb_filepage', 'greff', 'public-notice', 'news', 'tourism-directory' ) );
    }
    
    return $query;
    
}

 

Filed Under: Coding

December 11, 2014 by Todd Leave a Comment

Improved menu for WPML

Add to a Genesis themes functions.php to add a langauge switcher to the Secondary Menu location.

//* WPML Menu Language Switcher to output to genesis secondary menu for 2 languages without showing current language.
function new_nav_menu_items($items, $args) {
         
    if (function_exists('icl_get_languages') && $args->theme_location == 'secondary' ) {
        $languages = icl_get_languages('skip_missing=0');
        if(1 < count($languages)){
            foreach($languages as $l){
                if(!$l['active']){
                    $items = $items.'<li class="menu-item"><a href="'.$l['url'].'">'.$l['native_name'].'</a></li>';
                }
            }
        }
    }
     
    return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items',10,2 );

 

Filed Under: Coding

  • Go to page 1
  • Go to page 2
  • Go to Next Page »

Primary Sidebar

updraft_plus


Multilingual WordPress

Get Beaver Builder Now!

WordPress form builder - formidable forms

Copyright © 2025 · Executive Pro on Genesis Framework · WordPress · Log in