This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$deal_price = get_post_meta($post->ID, 'deal_price', true); | |
$old_price = get_post_meta($post->ID, 'old_price', true); | |
$discount = round(((1-($deal_price / $old_price))*100),0); | |
echo $discount.'%'; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//let's get my klout score!! | |
//first, let's see if I've got the data already cached locally | |
$klout = get_transient("klout"); | |
//dang it! it looks like I might not. let's check with the Klout API | |
if( !$klout ) { | |
$json = file_get_contents("http://api.klout.com/1/klout.json?key=[API key]&users=clarklab"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['insert_post'] )) { //check that our form was submitted | |
$title = $_POST['thread_title']; //set our title | |
if ($_POST['thread_description']=="") { // check if a description was entered | |
$description = "See thread title..."; // if not, use placeholder | |
} else { | |
$description = $_POST['thread_description']; //if so, use it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function update_user_points($id, $value){ | |
$points = get_user_meta($id, 'points', true); | |
$points = $points + $value; | |
update_user_meta($id, 'points', $points); | |
return $points; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Redirect | |
*/ | |
$redirect_url = get_post_meta($post->ID, 'redirect_url', true); | |
// get the destination URL | |
$count = get_post_meta($post->ID, 'count', true); | |
// get the number of times it's been clicked |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//start a new WP_Query with whatever parameters you want | |
$firstquery = new WP_Query(array( | |
'posts_per_page' => 2 | |
'tag' => 'summer' | |
)); | |
//start some looping action on $firstquery | |
while ($firstquery->have_posts()) : $firstquery->the_post(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
\$${1:query} = new WP_Query('posts_per_page=5'); | |
while (\$${1:query}->have_posts()) : \$${1:query}->the_post(); | |
${0:// do something} | |
endwhile; | |
]]></content> | |
<tabTrigger>wpq</tabTrigger> | |
<scope>source.php</scope> | |
<description>WP_Query basic loop</description> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- in footer.php --> | |
<div class="footer-text"><?php echo get_theme_mod('footer_text') ?></div> | |
<!-- rendered HTML content --> | |
<div class="footer-text">©2012 Site Name</div> | |
<!--in functions.php (to enable the field in the Theme Customizer) --> | |
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function post_format_picker () { | |
$screen = get_current_screen(); | |
if ( $screen->id == 'post' ) { | |
echo '<script>jQuery(document).ready(function(){ | |
var hash = window.location.hash; | |
if (hash){ | |
jQuery("a[href$="+hash+"]").click(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
\$${1:query} = new WP_Query('${2:posts_per_page=5}'); | |
while (\$${1:query}->have_posts()) : \$${1:query}->the_post(); | |
${3:// do something} | |
endwhile; | |
]]></content> | |
<tabTrigger>wpq</tabTrigger> | |
<scope>source.php</scope> | |
<description>WP_Query basic loop</description> |
OlderNewer