-
-
Save deardorffdev/887b731a6b384706d882c64763f2d0c1 to your computer and use it in GitHub Desktop.
Useful Wordpress Snippets
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 | |
// Get the_content by post id | |
echo apply_filters('the_content', get_post_field('post_content', $post_id)); | |
// Featured Image display | |
$attr = array( | |
'src' => $src, | |
'class' => "attachment-$size", | |
'alt' => trim(strip_tags( $wp_postmeta->_wp_attachment_image_alt )), | |
); | |
if ( has_post_thumbnail() ) { | |
the_post_thumbnail( $size, $attr ); | |
} | |
// wp_get_attachment_image with class | |
echo wp_get_attachment_image( get_sub_field( 'slider_image' ), 'medium', false, array( 'class' => 'attachment-medium featured' ) ); | |
// conditional call sidebar | |
<?php if ( is_active_sidebar( 'primary' ) ) : ?> | |
<div id="sidebar-primary" class="sidebar"> | |
<?php dynamic_sidebar( 'primary' ); ?> | |
</div> | |
<?php endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment