Skip to content

Instantly share code, notes, and snippets.

View carlaizumibamford's full-sized avatar
💭
I may be slow to respond.

CARLA I. BAMFORD carlaizumibamford

💭
I may be slow to respond.
View GitHub Profile
Display posts by author, using author id:
$query = new WP_Query( array( 'author' => 123 ) );
Display posts by author, using author ‘user_nicename‘:
$query = new WP_Query( array( 'author_name' => 'rami' ) );
Show Posts From Several Authors
Display posts from several specific authors:
$query = new WP_Query( array( 'author' => '2,6,17,38' ) );
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', '' );
<?php echo the_post_thumbnail('post-thumbnail', array('class' => 'retina additional-class')); ?>
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 . '" />';
}
@carlaizumibamford
carlaizumibamford / Resolving Jquery Conflicts (After)
Created February 2, 2022 23:11
Resolving Jquery Conflicts (After)
&lt;?php jQuery(document).ready(function(){
// insert coding here
}); ?&gt;
@carlaizumibamford
carlaizumibamford / Resolving Jquery Conflicts (Before)
Created February 2, 2022 23:10
Resolving Jquery Conflicts (Before)
&lt;?php $(document).ready(function(){
// insert coding here
}); ?&gt;
<?php if( !post_password_required( $post->ID ) ) : ?>
<?php else: ?>
<?php echo get_the_password_form(); ?>
<?php endif;?>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^sample\.com
RewriteRule ^(.*)$ http://sample.com/$1 [R=301,L]
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.sample\.com
RewriteRule ^(.*)$ http://sample.com/$1 [R=301,L]
@carlaizumibamford
carlaizumibamford / Conditional tag for multiple pages (Wordpress)
Last active February 2, 2022 22:53
Wordpress conditional tag for multiple pages
<?php if( is_page('PAGE ID') || is_page('PAGE ID') || is_page('PAGE ID') ): ?>
<?php endif; ?>