Example #1
0
/**
 * Shortcode for displaying a single tile
 * @param  array $atts      The shortcode's attributes
 * @param  string $content  The shortcode's enclosed content.
 * @return string           HTML Output
 */
function tile($atts, $content = NULL)
{
    // Attributes
    extract(shortcode_atts(array('id' => NULL), $atts));
    if (is_null($id)) {
        return;
    }
    $post = get_post($id);
    if (is_null($post)) {
        return;
    }
    $html = '';
    $html .= '<a class="tile" href="' . get_permalink($id) . '"';
    if ($thumb = post_thumb_url($id)) {
        $html .= ' style="background-image:url(' . $thumb . ')"';
    }
    $html .= '>';
    $html .= '<span>' . $post->post_title . '</span>';
    $html .= '</a>';
    return $html;
}
<a href="<?php 
the_permalink();
?>
" class="tile" style="background-image:url(<?php 
echo post_thumb_url();
?>
)">
  <span class="tile__title"><?php 
the_title();
?>
</span>
</a>
Example #3
0
<?php

use Roots\Sage\Titles;
if (has_post_thumbnail()) {
    $bg = post_thumb_url();
} else {
    $bg = val_get_field('background_image', 'option')['url'];
}
$padding = val_get_field('banner_padding');
?>
<div class="page-banner" style="background-image: url(<?php 
echo $bg;
?>
);<?php 
echo $padding ? 'padding-top: ' . $padding . 'rem; padding-bottom: ' . $padding . 'rem";' : NULL;
?>
">
  <div class="page-banner__container container">
    <?php 
if (!val_get_field('hide_title')) {
    ?>
    <h1><?php 
    echo Titles\title();
    ?>
</h1>
    <?php 
}
?>
    <?php 
if ($header_content_used = val_get_field('use_content_as_header')) {
    ?>