This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if( has_term( 'jazz', 'genre' ) ) { | |
// do something | |
} | |
// ou | |
has_term( $term, $taxonomy, $post ); | |
//https://codex.wordpress.org/Function_Reference/has_term |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ---------------- | |
Altera o HTML de saída das galerias | |
Alan | |
----------------- */ | |
add_filter('post_gallery', 'my_post_gallery', 10, 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* -------------------------------- | |
Insere estilos no painel de administração | |
Alan | |
------------------------------------ */ | |
add_action('admin_head', 'custom_admin_styles'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function feed_cidades($categoria) { | |
if ($categoria == '') { | |
$args = array ( | |
'post_type' => 'cidades', //it can be other | |
'posts_per_page' => '-1' | |
//'post__not_in' => array($exclude) | |
); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ancestor = get_post_ancestors($post)[0]; | |
if ($ancestor == 16349) { // se for filha de "os distritos" | |
echo '<h2>Localização</h2>'; | |
include 'includes/mapa-local-atrativo.php'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* echo, inline */ | |
echo 'Based on your score, you are a ',($score > 10 ? 'genius' : 'nobody'); //harsh! | |
/* shorthand usage */ | |
$message = 'Hello '.($user->get('first_name') ?: 'Guest'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<pre> | |
<?php | |
$terms = get_terms([ | |
'taxonomy' => 'tipo', | |
'hide_empty' => false, | |
]); | |
print_r($terms); | |
?> | |
</pre> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$id = get_the_ID(); | |
$tipos = wp_get_post_terms( $id, 'tipo', '' ); | |
//print_r($tipos); | |
$tipoSlug = ''; | |
foreach ($tipos as $tipo) { | |
$tipoSlug .= $tipo->slug . ' '; //concatenate the terms with space between | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
------------------------------- | |
Imprime uma mensagem de cumprimento ao usuário baseado na hora local | |
Alan | |
*/ | |
date_default_timezone_set("America/Sao_Paulo"); // Seta o timezone para o nosso fuso-horário | |
$time = date("H"); // pega a hora atual no formato 24h | |
if ($time < "8") { |