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 jQuery(document).ready(function(){ | |
// insert coding here | |
}); ?> |
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 modify_post_thumbnail_html($html, $post_id, $post_thumbnail_id, $size, $attr) { | |
$id = get_post_thumbnail_id(); | |
$src = wp_get_attachment_image_src($id, $size); | |
$alt = get_the_title($id); | |
$class = $attr['class']; | |
if (strpos($class, 'retina') !== false) { | |
$html = '<img src="' . $src[0] . '" alt="' . $alt . '" class="' . $class . '" />'; | |
} else { | |
$html = '<img src="' . $src[0] . '" alt="' . $alt . '" class="' . $class . '" />'; | |
} |
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 echo the_post_thumbnail('post-thumbnail', array('class' => 'retina additional-class')); ?> |
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
define( 'DB_NAME', 'database_name_here' ); | |
define( 'DB_USER', 'username_here' ); | |
define( 'DB_PASSWORD', 'password_here' ); | |
define( 'DB_HOST', 'localhost' ); | |
define( 'DB_CHARSET', 'utf8' ); | |
define( 'DB_COLLATE', '' ); |
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
Display posts that have one category (and any children of that category), using category id: | |
$query = new WP_Query( array( 'cat' => 4 ) ); | |
Display posts that have this category (and any children of that category), using category slug: | |
$query = new WP_Query( array( 'category_name' => 'staff' ) ); | |
Display posts that have this category (not children of that category), using category id: | |
$query = new WP_Query( array( 'category__in' => 4 ) ); | |
Display posts that have several categories, using category id: |
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
Display posts that have one tag, using tag slug: | |
$query = new WP_Query( array( 'tag' => 'cooking' ) ); | |
Display posts that have this tag, using tag id: | |
$query = new WP_Query( array( 'tag_id' => 13 ) ); | |
Display posts that have “either” of these tags: | |
$query = new WP_Query( array( 'tag' => 'bread,baking' ) ); | |
Display posts that have “all” of these tags: |
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
Display post by ID: | |
$query = new WP_Query( array( 'p' => 7 ) ); | |
Display page by ID: | |
$query = new WP_Query( array( 'page_id' => 7 ) ); | |
Show post/page by slug | |
$query = new WP_Query( array( 'name' => 'about-my-life' ) ); | |
Display page by slug: |
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
// This will NOT work | |
$exclude_ids = '1,2,3'; | |
$query = new WP_Query( array( 'post__not_in' => array( $exclude_ids ) ) ); | |
// This WILL work | |
$exclude_ids = array( 1, 2, 3 ); | |
$query = new WP_Query( array( 'post__not_in' => $exclude_ids ) ); |
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
Display only password protected posts: | |
$query = new WP_Query( array( 'has_password' => true ) ); | |
Display only posts without passwords: | |
$query = new WP_Query( array( 'has_password' => false ) ); | |
Display only posts with and without passwords: | |
$query = new WP_Query( array( 'has_password' => null ) ); | |
Display posts with a particular password: |