Skip to content

Instantly share code, notes, and snippets.

Francisco arenas dospuntocero

Block or report user

Report or block dospuntocero

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dospuntocero / search.php
Created May 20, 2019
order wordpress posts using url variables
View search.php
//passing variables like ?orderby=title
$my_query = new WP_Query( array(
'post_type' => 'project',
'post_status' => 'publish',
'orderby' => get_query_var('orderby'), // will return orderby query string variable
'order' => 'DESC',
'paged' => get_query_var('paged'),
dospuntocero / changing the language of windows 10
Last active May 31, 2019
changing the keyboard configuration on windows 10 - for good. using powershell
View changing the language of windows 10
if you want to know which keyboards do you have available, use this command
if you want to add a new one and you know the languagetag and the keyboard layout you want you can use something like this
Set-WinUserLanguageList -LanguageList en-US, en-001 -Force
if you want to remove from the list of posibilities the ones you dont want to use, just do the following (pressing enter after each line):
dospuntocero / add sort order on wordpress
Last active May 31, 2019
combination of parts needed to add a new parameter on the wordpress url for sorting.
View add sort order on wordpress
//adds the orderby parameter to the url for the sorting
function add_orderby() {
if ( isset( $_GET['orderby'] ) ) {
if ( in_array( $_GET['orderby'],[]) ) {
set_query_var( 'orderby', 'meta_value_num' );
set_query_var( 'meta_key', $_GET['orderby'] );
dospuntocero / singlefield.php
Last active May 31, 2019
solution found on advanced custom fields support forum. kudos to EbbandFlow
View singlefield.php
//For use with a single field.
$video = get_field('video'); //Embed Code
$video_url = get_field('video', FALSE, FALSE); //URL
$video_thumb_url = get_video_thumbnail_uri($video_url); //get THumbnail via our functions in functions.php ?>
<?php //Lightbox Link via Thumbnail ?>
<a href="#lightbox"><img src="<?php echo $video_thumb_url; ?>"/></a>
dospuntocero / youtube-id.php
Created Mar 3, 2019 — forked from leogopal/youtube-id.php
PHP function to get youtube ID from URL
View youtube-id.php
function get_youtube_video_ID($youtube_video_url) {
* Pattern matches
dospuntocero / multiposttype
Created Feb 27, 2019
Query multiple custom post types in single loop
View multiposttype
$args = array(
'post_type' => array('testimonial', 'other_post_type', 'another-post-type'),
'posts_per_page' => 1,
'tax_query' => array(
array (
'taxonomy' => 'testimonial_category',
'field' => 'slug',
'terms' => 'home'
dospuntocero / generic post type loop
Last active May 31, 2019
generic post type loop
View generic post type loop
$loop = new WP_Query( array(
'post_type' => 'the post type',
'posts_per_page' => -1
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
dospuntocero / extend image
Created Feb 24, 2019
used this technique to expand an image to fill the whole div and maintain aspect ratio
View extend image
object-fit: cover;
overflow: hidden;
dospuntocero / videolink id
Created Feb 24, 2019
i need to get just the id from a youtube link using an oembed field from advanced custom fields
View videolink id
dospuntocero / excerpt_limit.php
Created Nov 19, 2018
Limit the excerpt by number of characters but do NOT truncate the last word. This will allow you to return a maximum number of characters but preserve full words, so only the words that can fit within the specified number limit are returned and allow you to specify the source of where the excerpt will come from.
View excerpt_limit.php
function get_excerpt($limit, $source = null){
$excerpt = $source == "content" ? get_the_content() : get_the_excerpt();
$excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
$excerpt = strip_shortcodes($excerpt);
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, $limit);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
$excerpt = $excerpt.'... <a href="'.get_permalink($post->ID).'">more</a>';
You can’t perform that action at this time.