Skip to content

Instantly share code, notes, and snippets.

View theodorocaliari's full-sized avatar
💻

Theodoro Caliari theodorocaliari

💻
View GitHub Profile
<?php
function foo(){
//cpt $labels, $rewrite, $args
.
.
.
register_post_type('cpt',$args);
<?php
define('WP_DEBUG', false);
@ini_set('log_errors', 1);
@ini_set('display_errors', 0); /* enable or disable public display of errors (use 'On' or 'Off') */
@ini_set('error_log', dirname(__FILE__) . '/wp-content/logs/php-errors.log'); /* path to server-writable log file */
@ini_set( 'error_reporting', E_ALL ^ E_NOTICE ); /* the php parser to all errors, excreportept notices. */
?>
@theodorocaliari
theodorocaliari / gist:8671541
Last active January 4, 2016 20:00
Set password in phpmyadmin
http://askubuntu.com/questions/118772/how-to-change-root-password-for-mysql-and-phpmyadmin
bonus: https://www.digitalocean.com/community/articles/how-to-install-and-secure-phpmyadmin-on-debian-7
<?php
/* limit number of post revisions */
//http://perishablepress.com/stupid-wordpress-tricks/
define('WP_POST_REVISIONS', 3);
?>
<?php
$menu_name = 'main_nav';
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menuitems = wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) );
?>
<nav>
<ul class="main-nav">
<?php
<?php
$the_tax = get_taxonomy( get_query_var( 'taxonomy' ) );
echo $the_tax->labels->name;
?>
@theodorocaliari
theodorocaliari / list-pages-wp.php
Created October 29, 2013 13:49
listing pages WP
<?php
function list_pages(){
//http://codex.wordpress.org/Function_Reference/wp_list_pages
//lista as paginas criadas no wordpress
$args = array(
'title_li' => __( '' ),
'sort_column' => 'menu_order, post_title',
'exclude' => '2,5,6,7,8,9',
'post_type' => 'page',
);
@theodorocaliari
theodorocaliari / wp-slimjetpack-comments-carrousel-remover.php
Created October 29, 2013 13:18
Remove comments in WP slimjetpack carrousel
<?php
//remove comments from jetpack carrousel
function filter_media_comment_status( $open, $post_id ) {
// http://aahank.com/2013/disable-comments-jetpack-carousel/
$post = get_post( $post_id );
if( $post->post_type == 'attachment' ) {
return false;
}
return $open;
}
# CACHE
# 1 YEAR
<FilesMatch "\.(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 2 DAYS
<?php
/* Register custom post types on the 'init' hook. */
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 0.1.0
* @access public