Skip to content

Instantly share code, notes, and snippets.

View ravismakwana's full-sized avatar
:octocat:

Ravi Makwana ravismakwana

:octocat:
  • India
View GitHub Profile
@ravismakwana
ravismakwana / functions.php
Last active March 5, 2024 10:44
Enqueue Scripts and styles with timestamp versioning in WordPress.
<?php
/* Use this when parent theme used */
wp_register_style('main-css', untrailingslashit( get_template_directory_uri() ).'css/main.css', ['bootstrap'], filemtime(untrailingslashit( get_template_directory() ).'css/main.css'), 'all');
wp_enqueue_style('main-css');
wp_register_script('main', untrailingslashit( get_template_directory_uri() ).'js/main.js', ['jquery', 'slick-slider'], filemtime(untrailingslashit( get_template_directory() ).'js/main.js'), true);
wp_enqueue_script('main');
@ravismakwana
ravismakwana / .htaccess
Created February 16, 2023 12:13
This code is used to redirect 'http' to 'https' in WordPress.
/* Add this code at the top of the .htaccess file */
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
@ravismakwana
ravismakwana / functions.php
Created April 13, 2022 12:58
Post pagination with bootstrap 5
<?php
function bootstrap_pagination(){
$allowed_tags = [
'span' => [
'class' => []
],
'ul' =>[
'class' => [],
],
'li' =>[
@ravismakwana
ravismakwana / functions.php
Created January 19, 2022 13:34 — forked from alexander-young/functions.php
WP Basic Cleanup
<?php
// //remove emoji support
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
// // Remove rss feed links
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
@ravismakwana
ravismakwana / custom-page.php
Last active January 19, 2022 13:28
List Custom Posts with Custom Taxonomy
<?php
$custom_terms = get_terms('career_category');
foreach($custom_terms as $custom_term) {
wp_reset_query();
$args = array('post_type' => 'career',
'tax_query' => array(
array(
'taxonomy' => 'career_category',
'field' => 'slug',
@ravismakwana
ravismakwana / style.css
Created April 1, 2020 10:51
Google Autocomplete Address field does not display autocomplete, Write this CSS in your style.css or wherever your styling there. It will display 😄
div.pac-container {
z-index: 99999999999 !important;
}
@ravismakwana
ravismakwana / Photoshop Plug-ins
Created January 24, 2020 06:35
Convert JPG/PNG files into WebP format in the Photoshop
Follow this link:
https://developers.google.com/speed/webp/docs/webpshop
If you are getting error "webPshop.plugin cannot be opened because the developer cannot be verified"
Open up terminal. Type this command and then the name of the plugin.
sudo xattr -r -d com.apple.quarantine
For example:
@ravismakwana
ravismakwana / functions.php
Last active January 19, 2022 13:32
To add "Defer" into the script
<?php
if(!function_exists('defer_parsing_of_js')) {
function defer_parsing_of_js($url) {
if (is_admin()) return $url; //don't break WP Admin
if (false === strpos($url, '.js')) return $url;
if (strpos($url, 'jquery.js')) return $url;
return str_replace(' src', ' defer src', $url);
}
}
add_filter('script_loader_tag', 'defer_parsing_of_js', 10);