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
var link = document.createElement('a'); | |
link.href = 'images.jpg'; | |
link.download = 'Download.jpg'; | |
document.body.appendChild(link); | |
link.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
// Put this PHP code into your functions.php le. | |
// This will load the jQuery library onto your page by inserting a link in the <head> section where you call wp_head. | |
if(!is_admin()) { | |
wp_deregister_script('jquery'); | |
wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/ | |
jquery/1.3.2/jquery.min.js"), false, '1.3.2'); | |
wp_enqueue_script('jquery'); | |
} |
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 // display random posts | |
$home_brew = new WP_Query('showposts=3&orderby=rand'); | |
while($home_brew->have_posts()) : $home_brew->the_post(); | |
// output custom stuff here! Post title, content, custom elds.. | |
endwhile; | |
wp_reset_postdata(); | |
?> |
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
// element margins | |
body * + * { | |
margin-top: 1.5rem; | |
} | |
// grid | |
.grid { | |
display: flex; | |
flex-flow: row wrap; | |
} |
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 // additional loop via get_posts | |
global $post; | |
$args = array('category' => -9); // exclude Asides category | |
$custom_posts = get_posts($args); | |
foreach($custom_posts as $post) : setup_postdata($post); | |
... | |
endforeach; | |
?> | |
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 // Loop 1 | |
$ rst_query = new WP_Query('cat=-1'); // exclude category | |
while($ rst_query->have_posts()) : $ rst_query->the_post(); | |
... | |
endwhile; | |
wp_reset_postdata(); // reset the query | |
// Loop 2 | |
$second_query = new WP_Query('cat=-2'); // exclude category | |
while($second_query->have_posts()) : $second_query->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
<?php // The WordPress Loop - customized with WP_Query | |
$custom_query = new WP_Query('cat=-9'); // exclude Asides category | |
while($custom_query->have_posts()) : $custom_query->the_post(); | |
... | |
endwhile; | |
wp_reset_postdata(); // reset the query | |
?> | |
// more examples | |
<?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
<?php // The WordPress Loop - customized with query_posts | |
global $query_string; // grab the global query information | |
$posts = query_posts($query_string.'&cat=-9'); // exclude Asides category | |
if (have_posts()) : while (have_posts()) : the_post(); | |
... | |
endwhile; else: | |
... | |
endif; | |
wp_reset_query(); // reset the query | |
?> |
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
// when adding a custom field to a page, you can check its value like this: | |
<?php // e.g conditional sidebar display | |
if (!get_post_meta($post->ID, "noSidebar", true)) { | |
get_sidebar(); | |
} ?> |
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
// To check what query string is being used by the Loop | |
// insert before the loop. | |
<?php echo "<pre>"; print_r($wp_query->query_vars); echo "</pre>"; ?> |
NewerOlder