Skip to content

Instantly share code, notes, and snippets.

@dededey
dededey / prev_next_posts.php
Created February 2, 2016 14:38
prev next arrows
<?php
$right_arrow = "<img src=\"".$dir."/images/news/next_news.svg\" />";
next_post_link('%link',$right_arrow);
?>
@dededey
dededey / rewrite_url_video.php
Created January 26, 2016 14:03
rewrite the youtube vimeo url
// function to rewrite the VIMEO YOUTUBE URL
function mod_url($url){
$yt = strpos($url, 'youtube');
$vim = strpos($url, 'vimeo');
if($yt):
$url = str_replace("watch?v=","v/",$url);
endif;
if($vim):
$url = str_replace("vimeo.com","player.vimeo.com/video",$url);
@dededey
dededey / svg.php
Created November 25, 2015 14:45
add svg support to wordpress uploader
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
function fix_svg_thumb_display() {
echo '
td.media-icon img[src$=".svg"], img[src$=".svg"].attachment-post-thumbnail {
@dededey
dededey / drag_update.php
Created November 23, 2015 14:40
flexslider update DRAG
// DRAG:
if (slider.vars.drag) {
slider.bind('udragstart.udrag', function(event) {
event.preventDefault();
var target = (event.px_delta_x < 0) ? slider.getTarget('next') : slider.getTarget('prev');
slider.flexAnimate(target, slider.vars.pauseOnAction);
});
}
@dededey
dededey / last_post.php
Created November 16, 2015 11:12
This function returns the total amount of posts available after the current post.
// This function returns the total amount of posts available after the current post.
function more_posts() {
global $wp_query;
return $wp_query->current_post + 1 < $wp_query->post_count;
}
@dededey
dededey / array_unique_mod.php
Created November 10, 2015 10:18
select distinct values in array by key
<?php
foreach ($network as $net) :
$hash = $net['current_tax'];
$continent_unique[$hash] = $net;
endforeach;
?>
function add_custom_types_to_tax( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
// Get all your post types
$post_types = get_post_types();
// $post_types = array( 'post', 'your_custom_type' );
$query->set( 'post_type', $post_types );
return $query;
}
@dededey
dededey / nth-child.less
Created September 15, 2015 12:41
looping for iteration creat nth child x for background color
.loopingClass (@index) when (@index > 0) {
.single-day:nth-child(@{index}){ background-color: darken(#96bbdd,@index*4) ;}
.loopingClass(@index - 1);
}
// end the loop when index is 0
.loopingClass (0) {}
// "call" the loopingClass the first time with highest value
.loopingClass (@iterations);
CSS
.box{
position: relative;
width: 50%; /* desired width */
}
.box:before{
content: "";
display: block;
padding-top: 100%; /* initial ratio of 1:1*/
}
@dededey
dededey / thumbnail_url.php
Created August 28, 2015 10:59
thumbnail url
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );