Skip to content

Instantly share code, notes, and snippets.

@caralgar
caralgar / page-{slug}.php
Created March 22, 2016 16:09
Include one page inside another on WordPress
<?php
$include = get_pages('include=ID'); // Insert the page ID
$content = apply_filters('the_content',$include[0]->post_content);
echo $content;
?>
@caralgar
caralgar / style.css
Created March 9, 2016 07:55
Disable Mouse wheel on embedded Google Maps
.map{width:100%;height:400px;}
.map-wrapper{position:relative;}
.map-overlay{width:100%;min-height:400px;position:absolute;top:0;z-index:200;}
@caralgar
caralgar / functions.php
Last active January 16, 2017 13:22
Change WordPress default login logo & url
<?php
/*-----------------------------------------------------------------------------------*/
/* Cambiamos el logo y URL del formlulario de login (80x80px)
/*-----------------------------------------------------------------------------------*/
function my_custom_login_logo() { ?>
<style type="text/css">
.login h1 a {
background-image: url(<?php echo site_url(); ?>/wp-content/uploads/2017/01/images/login-logo.png) !important;
padding-bottom: 0px;
width:180px !important;
@caralgar
caralgar / functions.php
Last active February 15, 2016 12:59
Exclude items from minimum cost when calculating the free shipment (Woocommerce)
<?php
// Exclude items from minimum cost when calculating the free shipment
global $woocommerce;
$eligible = array( '1936' ); // Array of IDs exluded
$cart_items = $woocommerce->cart->get_cart();
@caralgar
caralgar / functions.php
Created February 5, 2016 11:22
Add category slug as a class to body tag & posts
<?php
function category_id_class( $classes ) {
global $post;
foreach ( get_the_category() as $category ) {
$classes[] = $category->category_nicename;
}
return $classes;
}
add_filter( 'post_class', 'category_id_class' ); // Add to article
add_filter( 'body_class', 'category_id_class' ); // Add to body
@caralgar
caralgar / functions.php
Created February 2, 2016 10:49
How to disable responsive images in WordPress 4.4.x
<?php
add_filter( 'max_srcset_image_width', create_function( '', 'return 1;' ) );
@caralgar
caralgar / style.css
Created February 1, 2016 09:11
How to use a Custom Font @WordPress
/*
- First of all upload your font via ftp
- Then paste this code into style.css
- Repeat for each font-weight
*/
@font-face {
font-family: FontName;
src: url(fonts/FontName.ttf);
font-weight: normal;
}
@caralgar
caralgar / functions.php
Created January 19, 2016 14:30
Format excerpt for wordpress
<?php
function wpse_allowedtags() {
// Add custom tags to this string
return '<br>,<i>,<a>,<p>,<strong>';
}
if ( ! function_exists( 'wpse_custom_wp_trim_excerpt' ) ) :
function wpse_custom_wp_trim_excerpt($wpse_excerpt) {
$raw_excerpt = $wpse_excerpt;
if ( '' == $wpse_excerpt ) {
@caralgar
caralgar / functions.php
Last active May 3, 2018 09:03
(Remove) Hide menu from WordPress Dashboard
<?php
// Hide Menu from WordPress Dashboard
function custom_menu_page_removing() {
$userid = get_current_user_id();
if ($userid != 1 && $userid != 2){
remove_menu_page( 'edit.php?post_type=clients' );
remove_menu_page( $slug );
remove_menu_page( 'duplicator' ); // for admin.php?page=duplicator
}
}
@caralgar
caralgar / functions.php
Created December 22, 2015 08:39
WPML shortcode language select for a text block
<?php
function wpml_find_language( $attr, $content = null ){
extract(shortcode_atts(array(
'lang' => '',
), $attr));
$current_language = ICL_LANGUAGE_CODE;
if($current_language == $lang){
$output = do_shortcode($content);
}else{