Пример #1
0
<?php

add_shortcode('post', function ($args) {
    $post = get_page_by_path($args['slug'], OBJECT, $args['type']);
    $link = get_permalink($post->ID);
    $excerpt = tt_get_excerpt($post);
    return "<a href=\"{$link}\">" . '<span class="title">' . $post->post_title . '</span><br>' . $excerpt . '</a>';
});
add_shortcode('events', function ($args) {
    $posts = get_posts(['numberposts' => $args['count'], 'post_type' => $args['type']]);
    foreach ($posts as $post) {
        $link = get_permalink($post->ID);
        $retval .= "<a href=\"{$link}\">{$post->post_title}</a><br>";
    }
    return $retval;
});
add_shortcode('tt_sponsor', function ($args) {
    $post = get_posts(['numberposts' => 1, 'post_type' => 'sponsor', 'orderby' => 'rand', 'tax_query' => [['taxonomy' => 'sponsor_level', 'field' => 'slug', 'terms' => $args['level']]]])[0];
    $retval = "Sponsor: {$post->post_title}<br>";
    $retval .= "Description: {$post->post_content}<br>";
    $retval .= "URL: " . get_field('url', $post->ID) . '<br>';
    $retval .= get_the_post_thumbnail($post->ID, 'full', ['class' => 'img-responsive']) . '<br>';
    return $retval;
});
add_shortcode('page_title', function () {
    return the_title(null, null, false);
});
//////////////////////////////////////////////////////// TT rule
add_shortcode('tt_rule', 'tt_rule');
//line
function tt_rule($atts, $content = null)
Пример #2
0
    /**
     * Front-end display of widget.
     *
     * @see WP_Widget::widget()
     *
     * @param array $args     Widget arguments.
     * @param array $instance Saved values from database.
     */
    public function widget($args, $instance)
    {
        $testimonials = get_posts(['numberposts' => 1, 'post_type' => $instance['post-type'], 'orderby' => 'rand']);
        $p = $testimonials[0];
        $excerpt = tt_get_excerpt($p);
        $link = get_permalink($p->ID);
        $fi_url = wp_get_attachment_image_src(get_post_thumbnail_id($p->ID), 'hard512')[0];
        echo $args['before_widget'];
        ?>
        <div class="row tt-headline-widget" style="background-color: <?php 
        echo $instance['background-color'];
        ?>
">
            <div class="col-xs-2 col-xs-offset-1 image">
                <a href="<?php 
        echo $link;
        ?>
">
                    <img class="img-responsive img-circle" src="<?php 
        echo $fi_url;
        ?>
" />
                </a>
            </div>
            <div class="col-xs-8 content">
                <a href="<?php 
        echo $link;
        ?>
">
                    <span class="title"><?php 
        echo $p->post_title;
        ?>
</span>
                    <?php 
        echo $excerpt;
        ?>
                </a>
            </div>
        </div>
        <?php 
        echo $args['after_widget'];
    }
Пример #3
0
<div id="locations-list" class="col-xs-12 col-sm-3">
	<h3>Upcoming Locations</h3>
    <?php 
echo do_shortcode('[tt_posts limit="5" type="tribe_events" cat="-7" layout="list-noimg"]');
?>
</div>

<?php 
$q = ['numberposts' => 1, 'orderby' => 'rand', 'category_name' => 'notable-article'];
$p = get_posts($q)[0];
$excerpt = tt_get_excerpt($p);
$link = get_permalink($p->ID);
$url = wp_get_attachment_url(get_post_thumbnail_id($p->ID));
$url_sq = wp_get_attachment_image_src(get_post_thumbnail_id($p->ID), square);
?>
<div class="col-xs-12 col-sm-3">
    <div class="tt-post">
        <a href="<?php 
echo $link;
?>
"><span class="title"><?php 
echo $p->post_title;
?>
</span><br></a>
        <?php 
echo $excerpt;
?>
    </div>
</div>
<div class="col-xs-12 col-sm-3">
    <img src="<?php