Skip to content

Instantly share code, notes, and snippets.

View celsofabri's full-sized avatar
👾
The truth is dubious

Celso Fabri Junior celsofabri

👾
The truth is dubious
View GitHub Profile
@celsofabri
celsofabri / exclude-pages-search.php
Last active August 29, 2015 14:06
Exclude "pages" in Search of Wordpress / Excluindo "pages" da busca do WordPress
<?php
function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');
@celsofabri
celsofabri / identify-browser-and-os.php
Last active August 31, 2015 20:56
Identify browser and os / Identifica navegador e sistema operacional
<?php
function mv_browser_body_class($classes) {
global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
if($is_lynx) $classes[] = 'lynx';
elseif($is_gecko) $classes[] = 'gecko';
elseif($is_opera) $classes[] = 'opera';
elseif($is_NS4) $classes[] = 'ns4';
elseif($is_safari) $classes[] = 'safari';
elseif($is_chrome) $classes[] = 'chrome';
@celsofabri
celsofabri / loop-for-taxonomy.php
Last active July 30, 2020 00:27
Looping for Taxonomy / Looping para taxonomia
<?php
$taxonomy = 'rota_categoria'; //Choose the taxonomy
$terms = get_terms( $taxonomy ); //Get all the terms
$queried_object = get_queried_object();
$term_slug = $queried_object->slug;
$term_id = $queried_object->term_id;
$term_tax = $queried_object->term_taxonomy_id;
@celsofabri
celsofabri / limit-sticky-posts.php
Last active August 29, 2015 14:07 — forked from fernandofuly/limit-sticky-posts.php
Limit Number of Sticky Posts to Show / Limitando Número de Posts Fixos Exibidos
<?php
$sticky = get_option( 'sticky_posts' );
/* Sort the newest one at the top */
rsort( $sticky );
/* Get the 2 newest stickies (change 2 for a different number) */
$sticky = array_slice( $sticky, 0, 2 );
/* Query Post */
@celsofabri
celsofabri / gallery-wordpress.css
Created October 24, 2014 19:59
Galeria WordPress
@celsofabri
celsofabri / find-replace-sql-wp.sql
Created November 20, 2014 21:06
SQL Query para fazer um simples localizar e substituir / SQL Query to do a simple find and replace
UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_links SET link_url = replace(link_url, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_links SET link_image = replace(link_image, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');
/*UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl' OR option_name = 'widget_text' OR option_name = 'dashboard_widget_options';*/
UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com');
@celsofabri
celsofabri / ng-tasks.html
Created December 4, 2014 13:06
Add tasks with Angular JS / Adicionando tarefas com Angular JS
<html ng-app="NgApp">
<head>
<title>Add tasks with Angular JS / Adicionando tarefas com Angular JS</title>
</head>
<body>
<div ng-controller="TasksController">
@celsofabri
celsofabri / refresh_url-hash.js
Created December 5, 2014 13:47
Refresh Page without URL Hash / Atualizar Página sem URL Hash
// Refresh Page without URL Hash =======================================
var loc = window.location.href,
index = loc.indexOf('#');
if (index > 5000) {
window.location = loc.substring(0, index);
}
@celsofabri
celsofabri / change_url-hash-scroll.js
Created December 5, 2014 13:48
Change URL Hash on Scroll / Mudar URL Hash ao deslizar
// Change URL Hash on Scroll =======================================
$(document).bind('scroll',function(e){
$('.section-block').each(function(){
if ( $(this).offset().top < window.pageYOffset + 10 && $(this).offset().top + $(this).height() > window.pageYOffset + 10) {
window.location.hash = $(this).attr('id');
}
});
});
@celsofabri
celsofabri / menu_scrolling.js
Last active August 29, 2015 14:11
Menu Scrolling
// Menu Scrolling
$('.menu-list').find('li a').on('click', function () {
var self = $(this),
parent = self.parent(),
index = parent.index();
$('body, html').animate({
scrollTop: $('.section-block').eq(index).offset().top
});