Skip to content

Instantly share code, notes, and snippets.

View layoutph's full-sized avatar

Glenn Dasmarinas layoutph

View GitHub Profile
@layoutph
layoutph / gist:804a395112b20a96df6c986660502246
Created April 5, 2018 00:56
Fetch BTC balance from BTC address using PHP
<?php
function getBalance($address) {
return file_get_contents('https://blockchain.info/de/q/addressbalance/'. $address);
}
$theb = getBalance('1EzwoHtiXB4iFwedPr49iywjZn2nnekhoj');
$theb = $theb / 100000000;
echo 'Address Balance: ' . $theb;
?>
<!-- This will loop and will show all products with a product category of freeshipping -->
<?php
$args = array( 'product_cat' => 'freeshipping', 'post_type' => 'product', 'posts_per_page' => 500, 'orderby' => 'rand' );
$loop = new WP_Query( $args );
while($loop->have_posts()) : $loop->the_post(); ?>
<div class='col-md-3 col-sm-4 col-xs-12' style="padding-bottom: 30px;">
<a href="<?php echo esc_url( get_permalink() ); ?>"><img src='<?php echo get_the_post_thumbnail_url(); ?>' style="border-radius: 15px" class="img-responsive theimage" /> </a>
<center>
@layoutph
layoutph / woocommerce-greet-user.php
Created March 29, 2017 01:45
Woocommerce Greet Visitors
<?php
// Setting up variable names
$current_user = wp_get_current_user();
// Get current username
if ( !$current_user->user_firstname ) { $customername = $current_user->display_name; }
// No username, then use the default username. If you are the admin , then the display name is "admin"
if ( $current_user->user_firstname ) { $customername = $current_user->user_firstname; }
@layoutph
layoutph / get-wordpress-thumbnail
Created April 1, 2015 03:12
Get Wordpress Thumbnail created using Set Featured Image
<?php
$yeah = get_the_post_thumbnail( $post_id, 'thumbnail' );
echo $yeah;
?>
@layoutph
layoutph / Pure CSS Dropdown
Last active August 29, 2015 14:17
Pure CSS Dropdown
<div id="container">
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">WordPress</a>
<!-- First Tier Drop Down -->
<ul>
<li><a href="#">Themes</a></li>
<li><a href="#">Plugins</a></li>
@layoutph
layoutph / CssReset
Created March 14, 2015 09:20
CSS Reset
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@layoutph
layoutph / mediaqueries_for_bootstrap
Last active August 29, 2015 14:17
Media Queries for Bootstrap
@media(max-width:767px){}
@media(min-width:768px){}
@media(min-width:992px){}
@media(min-width:1200px){}
@layoutph
layoutph / Bootstrap Template CDN
Created March 14, 2015 06:19
Bootstrap Template with Bootstrap CDN
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
@layoutph
layoutph / WPThumbnail
Created March 14, 2015 02:49
Get thumbnail image as declared in Set as featured image
$yeah = get_the_post_thumbnail( $post_id, 'thumbnail' );
echo $yeah;
@layoutph
layoutph / Echo Post Slug
Created March 14, 2015 02:48
Echo Post Slug
function the_slug() {
$post_data = get_post($post->ID, ARRAY_A);
$slug = $post_data['post_name'];
return $slug;
}
Once done, simply call the function within the loop to get the post or page slug.
<?php echo the_slug(); ?>