Skip to content

Instantly share code, notes, and snippets.

View davidperezgar's full-sized avatar

David Perez davidperezgar

View GitHub Profile
@davidperezgar
davidperezgar / limit_posts_per_archive_page.php
Created March 21, 2016 13:11
Limit Posts per archive Page WordPress
function limit_posts_per_archive_page() {
if ( is_category() )
$limit = 2;
elseif ( is_search() )
$limit = 1;
else
$limit = get_option('posts_per_page');
set_query_var('posts_per_archive_page', $limit);
}
@davidperezgar
davidperezgar / wp-admin-columns.php
Last active March 28, 2016 11:29
Manage Admin columns WordPress
/** Add columns **/
// Add to admin_init function
add_filter('manage_edit-productos_columns', 'add_new_productos_columns');
function add_new_productos_columns($columns) {
$columns['cb'] = '<input type="checkbox" />';
$columns['title'] = 'Producto';
$columns['prod_ref'] = 'Referencia';
$columns['prod_precio'] = 'Precio';
$columns['image'] = 'Miniatura';
@davidperezgar
davidperezgar / custom-flags.php
Created March 28, 2016 11:50
Custom flags in WPML (functions.php)
function language_selector_flags(){
$languages = icl_get_languages('skip_missing=0&orderby=code');
if(!empty($languages)){
foreach($languages as $l){
if(!$l['active']) echo '<a href="'.$l['url'].'">';
echo '<img src="'.get_bloginfo('stylesheet_directory').'/img/'.$l['code'].'.jpg" height="28" alt="'.$l['language_code'].'" width="28" />';
if(!$l['active']) echo '</a>';
}
}
@davidperezgar
davidperezgar / htaccess-ssl.txt
Last active March 7, 2017 20:40
htaccess WordPress SSL
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
@davidperezgar
davidperezgar / fullwidth-container.css
Created April 6, 2016 08:47
Full Width in container bootstrap
section.post_content section {
width: 500%;
margin-left: -200%;
}
@davidperezgar
davidperezgar / inputtinymce.php
Created April 28, 2016 08:09
Input with Tinymce editor in metabox WordPress
<?php wp_editor($proycom_deco,"proycom_deco",array('textarea_name' => 'proycom_deco','tinymce'=>true)); ?>
@davidperezgar
davidperezgar / centernav.css
Created April 28, 2016 08:30
CSS center navbar Bootstrap
.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}
.navbar .navbar-collapse {
text-align: center;
}
@davidperezgar
davidperezgar / quantity-input.php
Last active May 3, 2016 10:45 — forked from chrisvanpatten/functions.php
Quantity Select in Woocommerce in theme/woocommerce/global
<?php
/**
* Product quantity inputs
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@davidperezgar
davidperezgar / class-before-widget.php
Created May 5, 2016 11:20
Add fullwidth class to before_widget var
$before_widget = str_replace('" id=', ' widget_fullwidth" id=', $before_widget);
@davidperezgar
davidperezgar / widget-title.php
Last active June 24, 2016 15:02
WordPress Widget with field title
<?php
/*
Widget Name:
Description:
Author: davidperez
Author URI: https://www.closemarketing.es
*/
function widget_name() {
register_widget( 'widget_name' );
}