Skip to content

Instantly share code, notes, and snippets.

View guilhermealveslopes's full-sized avatar

Guilherme Lopes guilhermealveslopes

View GitHub Profile
<script>
jQuery(document).ready(function($){
$(function() {
$('.menu-interno li a').click(function() { /* Define o elemento do clique */
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top
@guilhermealveslopes
guilhermealveslopes / remove-older-post.php
Created April 19, 2017 21:38
Filtra post, removendo anteriores a data atual.
/* On loop */
$today = date( 'Y-m-d' );
$date = get_field('data', false, false); /* Get the ACF date field */
$date = new DateTime($date);
if(strtotime($today) <= strtotime($date->format('Y-m-d') ) ): /* Verifica se a data do post é menor que a data atual */
@guilhermealveslopes
guilhermealveslopes / checkfile.txt
Created April 19, 2017 18:17
Checa valor da url
<?php
$meta = get_post_meta( $post->ID, 'meta', true);
if (!empty($meta)) { ?>
Se for nula exibe.
<?php }
else { ?>
Se não for nula exibe.
<?php
$wp_rewrite->flush_rules();
@guilhermealveslopes
guilhermealveslopes / If variable not null
Created April 7, 2017 00:43
If variable is null display X, else. display X
<?php $meta = get_post_meta( $post->ID, 'meta', true); <--! define o valor da variável -->
if (!empty($telefone)) { ?> <--! Confere se está vazia ou não -->
Resultado caso não seja nula.
<?php } else { ?>
Resultado caso seja nula.
<?php } ?>
<?php $user_id = get_current_user_id();
$args=array(
'post_type' => 'post',
'posts_per_page' => -1,
'author' => $user_id
);
$wp_query = new WP_Query($args); while ( have_posts() ) : the_post(); ?>
<!-- Conteudo -->
<?php endwhile; ?>
//* Redirect WordPress Logout to Home Page
add_action('wp_logout',create_function('','wp_redirect(home_url());exit();'));
@guilhermealveslopes
guilhermealveslopes / Search & Filter Avada fix
Created March 15, 2017 17:22
Fix S&F result for Avada theme.
/* Duplicate and edit*/
/avada/search.php +/ /avada/search-filter-results.php
remove line 71-74 {
$post_timestamp = strtotime($post->post_date);
$post_month = date('n', $post_timestamp);
$post_year = get_the_date('o');
$current_date = get_the_date('o-n');
}
@guilhermealveslopes
guilhermealveslopes / JS Field repeat
Created February 14, 2017 11:56
JS Field repeat
$(document).ready(function(){
$('#primeiro').change(function() {
$('#segundo').val($('#primeiro').val());
});
});
/** Change text from $primeiro to $segundo after type **/
$(document).ready(function(){
$('#primeiro').keyup(function() {
$('#segundo').val($('#primeiro').val());
@guilhermealveslopes
guilhermealveslopes / Metawp
Created February 14, 2017 01:00
Get Meta Wordpress
<?php echo get_post_meta( $post->ID, 'META', true); ?>