Example #1
0
<?php

/*
YARPP Template: List
Description: This template returns the related posts as a comma-separated list.
Author: mitcho (Michael Yoshitaka Erlewine)
*/
?>
<h3>Related Posts</h3>

<?php 
if (have_posts()) {
    $postsArray = array();
    while (have_posts()) {
        the_post();
        $postsArray[] = '<a href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a><!-- (' . get_the_score() . ')-->';
    }
    echo implode(', ' . "\n", $postsArray);
    // print out a list of the related items, separated by commas
} else {
    ?>

<p>No related posts.</p>
<?php 
}
Example #2
0
<?php

global $yarpp;
$yarpp->cache->enforce((int) $reference_ID, false);
// enforce the cache, but don't force it
if ($yarpp->debug) {
    $keywords = $yarpp->cache->get_keywords($reference_ID);
    $output .= "<p>body keywords: {$keywords['body']}</p>";
    $output .= "<p>title keywords: {$keywords['title']}</p>";
}
$output .= '<p>' . __('These are the related entries for this entry. Updating this post may change these related posts.', 'yarpp') . '</p>';
if ($yarpp->debug) {
    $output .= "<p>last updated: " . $wpdb->get_var("select max(date) as updated from {$wpdb->prefix}yarpp_related_cache where reference_ID = '{$reference_ID}'") . "</p>";
}
if (have_posts()) {
    $output .= '<style>#yarpp-related-posts ol li { list-style-type: decimal; }</style>';
    $output .= '<ol>';
    while (have_posts()) {
        the_post();
        $output .= "<li><a href='post.php?action=edit&post=" . get_the_ID() . "'>" . get_the_title() . "</a>";
        $output .= ' (' . round(get_the_score(), 3) . ')';
        $output .= '</li>';
    }
    $output .= '</ol>';
    $output .= '<p>' . __('Whether all of these related entries are actually displayed and how they are displayed depends on your YARPP display options.', 'yarpp') . '</p>';
} else {
    $output .= '<p><em>' . __('No related posts.', 'yarpp') . '</em></p>';
}
Example #3
0
This "template" is used when you choose not to use a template.

If you want to create a new template, look at templates/template-example.php as an example.
*/
$options = array('before_title' => "{$domainprefix}before_title", 'after_title' => "{$domainprefix}after_title", 'show_excerpt' => "{$domainprefix}show_excerpt", 'excerpt_length' => "{$domainprefix}excerpt_length", 'before_post' => "{$domainprefix}before_post", 'after_post' => "{$domainprefix}after_post", 'before_related' => "{$domainprefix}before_related", 'after_related' => "{$domainprefix}after_related", 'no_results' => "{$domainprefix}no_results");
$optvals = array();
foreach (array_keys($options) as $option) {
    if (isset($args[$option])) {
        $optvals[$option] = stripslashes($args[$option]);
    } else {
        $optvals[$option] = stripslashes(stripslashes(yarpp_get_option($options[$option])));
    }
}
extract($optvals);
if ($related_query->have_posts()) {
    while ($related_query->have_posts()) {
        $related_query->the_post();
        $output .= "{$before_title}<a href='" . get_permalink() . "' rel='bookmark' title='Permanent Link: " . preg_replace('/\\s*<br[ \\/]*>\\s*/i', ' ', get_the_title()) . "'>" . get_the_title() . "";
        if ($userdata->user_level >= 8 and $domain != 'rss') {
            $output .= ' <abbr title="' . sprintf(__('%f is the YARPP match score between the current entry and this related entry. You are seeing this value because you are logged in to WordPress as an administrator. It is not shown to regular visitors.', 'yarpp'), round(get_the_score(), 3)) . '">(' . round(get_the_score(), 3) . ')</abbr>';
        }
        $output .= '</a>';
        if ($show_excerpt) {
            $output .= $before_post . yarpp_excerpt(get_the_excerpt(), $excerpt_length) . $after_post;
        }
        $output .= $after_title . "\n";
    }
    $output = stripslashes(stripslashes($before_related)) . $output . stripslashes(stripslashes($after_related));
} else {
    $output = $no_results;
}
Example #4
0
function the_score()
{
    echo get_the_score();
}
Example #5
0
 * YARPP's built-in "template"
 *
 * This "template" is used when you choose not to use a template.
 * If you want to create a new template, look at yarpp-templates/yarpp-template-example.php as an example.
 * More information on the custom templates is available at http://mitcho.com/blog/projects/yarpp-3-templates/
*/
get_currentuserinfo();
$options = array('before_title', 'after_title', 'show_excerpt', 'excerpt_length', 'before_post', 'after_post', 'before_related', 'after_related', 'no_results');
extract($this->parse_args($args, $options));
if (have_posts()) {
    $output .= $before_related . "\n";
    while (have_posts()) {
        the_post();
        $link = get_permalink();
        $tooltip = esc_attr(get_the_title() ? get_the_title() : get_the_ID());
        $title = get_the_title();
        $round = round(get_the_score(), 1);
        $score = current_user_can('manage_options') && $domain !== 'rss' && !is_admin() ? '<abbr title="' . sprintf(__('%f is the YARPP match score between the current entry and this related entry. You are seeing this value because you are logged in to WordPress as an administrator. It is not shown to regular visitors.', 'yarpp'), $round) . '">(' . $round . ')</abbr>' : null;
        $output .= $before_title . '<a href="' . $link . '" rel="bookmark" title="' . $tooltip . '">' . $title . ' ' . $score . '</a>';
        if ($show_excerpt) {
            $excerpt = strip_tags((string) get_the_excerpt());
            preg_replace('/([,;.-]+)\\s*/', '\\1 ', $excerpt);
            $excerpt = implode(' ', array_slice(preg_split('/\\s+/', $excerpt), 0, $excerpt_length)) . '...';
            $output .= $before_post . $excerpt . $after_post;
        }
        $output .= $after_title . "\n";
    }
    $output .= $after_related . "\n";
} else {
    $output .= $no_results;
}