Skip to content

Instantly share code, notes, and snippets.

View davidperezgar's full-sized avatar

David Perez davidperezgar

View GitHub Profile
@davidperezgar
davidperezgar / content-latestposts.php
Created December 24, 2014 15:34
Latests posts with bootstrap
<div class="row latestposts">
<?php
$args = array(
'posts_per_page' => 2
);
$postlist =get_posts($args);
foreach($postlist as $post){
setup_postdata( $post );
?>
@davidperezgar
davidperezgar / cpt-mobiliario.php
Created December 24, 2014 15:40
CPT Con Jerarquía
<?php
/**
* Custom Post Types Mobiliario
*
*/
add_action('init', 'my_custom_init_mob');
function my_custom_init_mob()
{
@davidperezgar
davidperezgar / mark-feature-post.php
Last active August 29, 2015 14:12
Post featured in home with Wordpress
//Código en el post type:
//Variable Meta para Mobiliario
add_action('admin_init', 'admin_init_ptype');
add_action('save_post', 'save_ptype');
function admin_init_mobiliario(){
add_meta_box("fichadele", "Variables Mobiliario", "meta_options_mobopt", "mobiliario-opticas", 'side', 'high');
}
function meta_options_mobopt(){
@davidperezgar
davidperezgar / favicon-wordpress.php
Created December 28, 2014 15:56
Favicon Code in Header.php for Wordpress Site
<link type="image/x-icon" href="<?php bloginfo('stylesheet_directory'); ?>/images/favicon.png" rel="icon" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
@davidperezgar
davidperezgar / wp-config-es.php
Created December 29, 2014 20:29
WP-Login ES for Local and Remote
<?php
if ($_SERVER['HTTP_HOST'] === "localhost") {
define('DB_NAME', '');
define('DB_USER', 'root');
define('DB_PASSWORD', 'root');
define('WP_HOME', 'http://localhost/');
define('WP_SITEURL', 'http://localhost/');
define('WP_DEBUG', false);
} else {
define('DB_NAME', '');
add_filter('woocommerce_attribute_show_in_nav_menus', 'wc_reg_for_menus', 1, 2);
function wc_reg_for_menus( $register, $name = '' ) {
if ( $name == 'pa_size' ) $register = true;
return $register;
}
@davidperezgar
davidperezgar / htaccess-wordpress
Last active June 16, 2016 16:22
Htaccess with Deflate and Expires for Wordpress
<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"
<?php
/*
Template Name: My Custom Page
*/
@davidperezgar
davidperezgar / htaccess
Last active August 29, 2015 14:13
Not allow execute PHP in WP-uploads
<FilesMatch "\.(php|php\.)(.+)(\w|\d)$">
Order Allow,Deny
Deny from all
</FilesMatch>