Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jonschr
Created May 5, 2020 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonschr/8e01dccd6c88fc4656e57a8fda258bc9 to your computer and use it in GitHub Desktop.
Save jonschr/8e01dccd6c88fc4656e57a8fda258bc9 to your computer and use it in GitHub Desktop.
<?php
//* Output services before
// add_action( 'before_loop_layout_services_photo', 'rb_services_photo_before' );
function rb_services_photo_before( $args ) {
// wp_enqueue_script( 'SCRIPTHANDLE' );
}
//* Output each services
add_action( 'add_loop_layout_services_photo', 'rb_services_photo_each' );
function rb_services_photo_each() {
//* Global vars
global $post;
$id = get_the_ID();
//* Vars
$title = get_the_title();
$permalink = get_the_permalink();
$content = get_the_content();
//* Markup
if ( $content )
printf( '<a href="%s" class="featured-image" style="background-image:url( %s )"></a>', $permalink, get_the_post_thumbnail_url( $id, 'large' ) );
if ( !$content )
printf( '<div class="featured-image" style="background-image:url( %s )"></div>', get_the_post_thumbnail_url( $id, 'large' ) );
if ( $title ) {
if ( $content )
printf( '<h3><a href="%s">%s</a></h3>', $permalink, $title );
if ( !$content )
printf( '<h3>%s</h3>', $title );
}
edit_post_link();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment