Skip to content

Instantly share code, notes, and snippets.

View taciara's full-sized avatar
🏠
Working from home

Taciara Furtado taciara

🏠
Working from home
View GitHub Profile
@taciara
taciara / taxonomia-single.php
Created March 6, 2019 15:17
Dar echo em uma taxonomia dentro de uma página/single....
<?php // colocar isso após o if(have_posts()):the_post();
$termsAutor = get_the_terms( get_the_ID(), 'NOMEDATAXONOMIA' );
$autor = '';
if ( $termsAutor && ! is_wp_error( $termsAutor ) ) {
foreach ( $termsAutor as $term ) {
if ( 0 == $term->parent ) {
$autor = $term->name;
} else {}
}
@taciara
taciara / shortcode.php
Created April 29, 2019 14:44
Shortcode: Como Criar e como inserir no site
<?php //CRIANDO SHORTCODE ?>
<?php
add_shortcode('NOMEDOSEUSHORTCODE', 'NOMEDAFUNCAO');
function NOMEDAFUNCAO() { ?>
<?php ob_start(); ?>
SEU CODIGO AQUI
<?php return ob_get_clean(); ?>
<?php } ?>
<?php //INSERINDO SHORTCODE ?>
@taciara
taciara / querypost.php
Last active May 3, 2019 14:24
Como fazer um query post
<?php
global $post;
$MeuQueryPostNovo = array(
'post_type' => 'NOMEDOPOSTTYPE',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => -1,
);
$the_query = new WP_Query( $MeuQueryPostNovo );
?>
@taciara
taciara / filterizr.js
Last active May 6, 2019 14:37
Usar o filterizr com taxonomia. Este código você pode usar como uma galeria de fotos com filtragem / categoria.
/*
javascript
tem que incluir esse arquivo js: https://cdn.rawgit.com/giotiskl/Filterizr/1.3.4/dist/jquery.filterizr.min.js
*/
window.jQuery(function ($) {
var $filterizd = $('.projects-gallery .items').filterizr({
filter: 'all',
layout: 'sameSize',
@taciara
taciara / archive.php
Created May 13, 2019 12:21
Como inserir o titulo do seu archive
<?php query_posts(array('post_type' => 'NOMEDOSEUCUSTOMPOSTTYPE')); ?>
<h1><?php post_type_archive_title(); ?></h1>
<?php wp_reset_query(); ?>
@taciara
taciara / instagram.php
Created May 27, 2019 15:12
Como inserir Instagram no site
<?php
/**
* [IMPORTANTE] COMO USAR
*
* Adicione o shortcode [instagram_photos] dentro do conteúdo de uma página
* ou use o código php do_shortcode('[instagram_photos]')
*
*
* Você pode usar o atributo "limit" para limitar o máximo de fotos que serão mostrados.
@taciara
taciara / taxonomia-archive.php
Created June 18, 2019 18:11
Loop da taxonomia dentro de um post type
<?php //COLE ISSO EM LOOP DO POST TYPE ?>
<?php $getCats = get_terms("NOMEDATAXONOMIA", array("hide_empty" => false)); ?>
<?php foreach($getCats as $getCat): ?>
<?php // USE ESSE TRECHO APENAS SE A SUA TAXONOMIA CONTER CAMPO PARSONALIZADO
$id_Imagem = get_term_meta($getCat->term_id, 'NOMEDOCAMPOPERSONALIZADO', true);
$minhaImagem = wp_get_attachment_image_src($id_Imagem,'full');
?>
<div class="item">
<a href="<?php echo get_term_link($getCat->term_id); ?>">
<figure>
@taciara
taciara / woocommerce.php
Created June 28, 2019 00:24
Prevenir aviso “Não há metodos disponíveis” no WooCommerce para produtos sem peso.
<?php
//Para resolver isso, estou disponibilizando um pequeno snippet que, se nenhum informação de peso for passada ao plugin WooCommerce Correios, então o peso será 300 gramas. Se algum peso for informado, então este será utilizado normalmente.
add_filter( 'woocommerce_correios_shipping_args', 'fa_min_correios_weight' );
function fa_min_correios_weight( $args ) {
$args['nVlPeso'] = ! $args['nVlPeso'] ? 0.3 : $args['nVlPeso'];
return $args;
}
?>
@taciara
taciara / remove-custom-post-type-slug-from-permalinks.php
Last active July 4, 2019 11:42
Remover o Slug do CPT na ulr e no Permalinks
<?php
1. Create your custom post type (unless already created). This can be done very easily by using the great, free Custom Post Type UI plugin.
2. Create a plugin for our new code to live in (yes, it could go in your theme’s functions.php file, but then it’d be lost if the theme were changed!).
?>
<?php
// PARTE 1 DO FUNCTIONS:
// 3. Filter the permalink for our custom post type so that all published posts don’t have the slug in their URLs:
//Remova o slug dos permalinks de postagem publicados. Apenas afeta nosso tipo de postagem personalizada.
function gp_remove_cpt_slug( $post_link, $post ) {
@taciara
taciara / menu-scrol.html
Created July 7, 2019 19:19
Menu Scroll para página one page com menu ativo
<link href='https://fonts.googleapis.com/css?family=Lato:100,400,700' rel='stylesheet' type='text/css'>
<style>
* {
font-family: 'Lato', sans-serif;
font-weight: 300;
transition: all .1s ease;
}
html, body {
height: 100%;