Skip to content

Instantly share code, notes, and snippets.

@CEscorcio
CEscorcio / .gitignore
Last active February 20, 2021 20:04
gitignore Wordpress
### WordPress ###
# ignore everything in the root except the "wp-content" directory.
/*
!wp-content/
# ignore everything in the "wp-content" directory, except:
# "mu-plugins", "plugins", "themes" directory
wp-content/*
!wp-content/plugins/
!wp-content/themes/
@CEscorcio
CEscorcio / recent posts.php
Created November 8, 2016 09:33
Wordpress recent posts with thumb check
<ul>
<?php $the_query = new WP_Query( 'posts_per_page=2' ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<li class="col-md-6"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
else {
@CEscorcio
CEscorcio / sharing.php
Created September 8, 2016 18:13
Share post in Wordpress
<div id="share-buttons">
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>&text=<?php the_title(); ?>"><img src="http://alskadehem.se/wp-content/uploads/2014/04/facebook.png" alt="Facebook" /></a>
<a href="http://twitter.com/share?url=<?php the_permalink(); ?>&text=<?php the_title(); ?>" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/twitter.png" alt="Twitter" /></a>
<a href="https://plus.google.com/share?url=<?php the_permalink(); ?>&text=<?php the_title(); ?>" target="_blank"><img src="http://www.simplesharebuttons.com/images/somacro/google.png" alt="Google" /></a>
@CEscorcio
CEscorcio / gist:3895a5845d020b9d68120c36d68de74f
Created July 25, 2016 09:05
WP Custom Type - Related Articles
<?php
// You might need to use wp_reset_query();
// here if you have another query before this one
global $post;
$current_post_type = get_post_type( $post );
// The query arguments
<a href="http://www.linkedin.com/shareArticle?mini=true&amp;title=<?php the_title(); ?>&amp;url=<?php the_permalink(); ?>" title="Share on LinkedIn">Linkedin</a>
<a href="https://plus.google.com/share?url=<?php the_permalink(); ?>" onclick="javascript:window.open(this.href,
'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;">G+</a>
<a href="http://twitter.com/home/?status=<?php the_title(); ?> - <?php the_permalink(); ?>" title="Tweet this!">TWEET</a>
<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&amp;t=<?php the_title(); ?>" title="Share on Facebook.">SHARE FACEBOK</a>
@CEscorcio
CEscorcio / gist:af705bb18128fdfa750b
Created December 15, 2015 12:29
PreHeader Snippet
<td style="display:none !important; visibility:hidden; opacity:0; color:transparent; height:0; width:0; mso-hide:all; line=height:0px; font-size:0px">Your preheader here</td>
<?php
$app_id = "[YOUR APP ID]";
$canvas_page = "[YOUR APP URL]";
$auth_url = "http://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($canvas_page);
$signed_request = $_REQUEST["signed_request"];
@CEscorcio
CEscorcio / hover jquery
Created December 1, 2014 17:56
hover dinamico com jquery
$(".icone").hover(function(){
$(this).attr("src", function(index, attr){
return attr.replace(".png", "_0.png");
});
}, function(){
$(this).attr("src", function(index, attr){
return attr.replace("_1.png", ".png");
});
});
@CEscorcio
CEscorcio / product_category_list.php
Created November 15, 2013 12:34
LIst all categories in wooCommerce
<?php
$args = array( 'taxonomy' => 'product_cat' );
$terms = get_terms('product_cat', $args);
$count = count($terms); $i=0;
if ($count > 0) {
foreach ($terms as $term) {
$i++;
$term_list .= '<li><a href="/categoria/' . $term->slug . '" title="' . sprintf(__('View all post filed under %s', 'my_localization_domain'), $term->name) . '">' . $term->name . '</a></li>';
@CEscorcio
CEscorcio / top categories
Created November 8, 2013 09:10
will restrict category links to top level cats only.
<?<?php wp_list_categories('title_li=&depth=1'); ?>