Hi,
Been fighting with a plugin for two weeks now. Thought I had it today, but I then just got a T_String error. What Id like to do is output a custom field "Small" under some generated thumbnail photos. When I change the code at a spot to text, I see the text under every thumbnail. I've yet to figure out the correct way to generate $small under each.
Below is the code where the pagination starts:
$types = array('post', 'page');
$post_types = get_post_types(array('public' => true, '_builtin' => false), 'object', 'and');
if ($post_types) {
foreach ($post_types as $post_type ) {
$types[] = $post_type->query_var;
}
} else {
$post_types = array();
}
if ($options['source'] == '_featured') {
$filter = array('numberposts' => $options['limit'],
'meta_key' => '_fps_featured',
'meta_value' => 1,
'order' => 'DESC',
'post_type' => $types);
} elseif (substr($options['source'], 0, 1) != '|') {
$filter = array('numberposts' => $options['limit'],
'post_type' => $options['source'],
'order' => 'DESC',);
} else {
$source = explode('|', $options['source']);
if ($source[1] == 'category') {
$category = 'category';
} else {
$category = $source[1] . '_category';
}
$filter = array('numberposts' => $options['limit'],
'post_type' => $types,
$category => $source[2],
'order' => 'DESC',);
}
if ($options['randomize']) {
$filter['orderby'] = 'rand';
} else {
$filter['orderby'] = 'post_date';
}
$featured_posts = get_posts($filter);
require('slider-layout-templates.php');
$out .= '<div id="fps-container" style="width: ' . $options['width'] . '">';
$out .= '<div class="fps-slides-container">';
$slide_nb = 1;
$pagination = '';
foreach($featured_posts as $featured) {
$pagination .= '<li><a href="">' . get_the_post_thumbnail($featured->ID, 'FPS pagination thumbnail', array('class' => 'fps-thumbnail-mini')) . '</a><p><?php $small = get_post_meta($post->ID, 'small', true);echo $small;?></p></li>';
// $featured "is" $post
// get per-post or global layout
if (get_post_meta($featured->ID, '_fps_layout', true)) {
$layout = get_post_meta($featured->ID, '_fps_layout', true);
} else {
$layout = $options['layout'];
}
if ($layout == 'custom') {
$template = $options['custom-layout'];
} else {
$template = $layouts[$layout];
}
// get per-post or global thumbnail size
if (get_post_meta($featured->ID, '_fps_thumbnail', true)) {
$thumbnail_size = get_post_meta($featured->ID, '_fps_thumbnail', true);
} else {
$thumbnail_size = $options['thumbnail'];
}
$tags = get_the_tags($featured->ID);
$tags2 = '';
if ($tags)
foreach($tags as $tag) {
$tags2 .= '<a href="/tag/' . $tag->slug . '">' . $tag->name . '</a>, ';
}
$tags2 = trim($tags2, ', ');
$content = $featured->post_content;
if (strpos($content, '<!--more-->')) {
$content = substr($content, 0, strpos($content, '<!--more-->')) . ' <a href="' . get_permalink($featured->ID) . '">(more...)</a>';
}
$content = apply_filters('the_content', $content);
$thumbnail = get_post_thumbnail_id($featured->ID);
$thumbnail = wp_get_attachment_image_src($thumbnail, $thumbnail_size);
global $post;
$post = $featured;
$tmp = str_replace(array('{id}',
'{permalink}',
'{title}',
'{excerpt}',
'{content-full}',
'{content}',
'{author}',
'{author-link}',
'{date}',
'{time}',
'{comments-count}',
'{categories}',
'{tags}',
'{thumbnail}',
'{thumbnail-src}',
'{thumbnail-width}',
'{thumbnail-height}',
'{slider-width}'),
array($featured->ID,
get_permalink($featured->ID),
$featured->post_title,
apply_filters('the_excerpt', $featured->post_excerpt),
apply_filters('the_content', $featured->post_content),
$content,
get_the_author_meta('display_name', $featured->post_author),
get_author_posts_url($featured->post_author),
get_the_date(''),
get_the_time(''),
(int) $featured->comments_count,
get_the_category_list(', ', '', $featured->ID),
$tags2,
get_the_post_thumbnail($featured->ID, $thumbnail_size, array('class' => 'fps-thumbnail')),
$thumbnail[0],
$thumbnail[1],
$thumbnail[2],
$options['width']), $template);
if ($slide_nb != 1) {
$tmp_display = 'display: none; ';
} else {
$tmp_display = '';
}
$out .= '<div class="post fps-slide" style="' . $tmp_display . 'width: ' . $options['width'] . ';">' . $tmp . '</div>';
$slide_nb++;
} // foreach post
$out .= '</div>';
if ($options['pagination'] == 2) {
$out .= '<ul class="fps-pagination thumb-pagination">' . $pagination . '</ul>';
}
$out .= "</div>\n";
$out .= get_post_meta($post->ID, 'small', true);
// include JS/CSS only if needed
if ($featured_posts) {
self::$do_footer = true;
}
return $out;
} // generate_html
// shortcode for FPS, just a wrapper
function shortcode($options, $content) {
return self::generate_html();
} // shortcode
// slides JS code for footer
function wp_footer() {
if (!self::$do_footer) {
return;
}
$options = get_option('wf_fps');
$preload_img = plugins_url('/images/preload.gif', __FILE__);
if($options['include-css']) {
$slides_css = plugins_url('/css/featured-posts-slider.css?v4', __FILE__);
echo '<style type="text/css">@import url(' . $slides_css . ");</style>\n";
}
if($options['include-jquery']) {
$jquery_js = plugins_url('/js/jquery-1.6.2.min.js', __FILE__);
echo '<script type="text/javascript" src="' . $jquery_js . '"></script>' . "\n";
}
if($options['include-slides']) {
$slides_js = plugins_url('/js/slides.min.jquery.js', __FILE__);
echo '<script type="text/javascript" src="' . $slides_js . '"></script>' . "\n";
}
echo '<script type="text/javascript">' . "\n";
echo 'jQuery(document).ready(function() {';
echo "jQuery('#fps-container').slides({
preload: true,
preloadImage: '{$preload_img}',
container: 'fps-slides-container',
generateNextPrev: {$options['prev-next']},
next: 'fps-next',
prev: 'fps-prev',
pagination: true,
generatePagination: " . ($options['pagination'] == '1'? '1': '0') . ",
paginationClass: 'fps-pagination',
currentClass: 'current',
fadeSpeed: {$options['effect-speed']},
slideSpeed: {$options['effect-speed']},
start: 1,
effect: '{$options['effect']}',
randomize: 0,
play: {$options['autoplay']},
pause: {$options['autoplay']},
hoverPause: {$options['hover-pause']},
autoHeight: 1});";
echo "\n});";
echo "\n</script>\n";
} // wp_footer
// warning if [fps] shortcode is already taken
public function warning() {
$shortcode = get_option('wf_fps');
$shortcode = $shortcode['shortcode'];
echo '<div id="message-shortcode" class="error"><p><strong>Featured Posts Slider shortcode is not active!</strong> The shortcode [' . $shortcode . '] is already in use by another plugin. Please <a href="themes.php?page=wf-fps#shortcode">update the settings</a> and select a different shortcode.</p></div>';
} // warning
} // class wf_fps
// template function, echoes slider code
function the_featured_posts_slider() {
echo wf_fps::generate_html();
} // the_featured_posts_slider
// template function, returns slider code
function get_the_featured_posts_slider() {
return wf_fps::generate_html();
} // get_the_featured_posts_slider
// hook Featured Posts Plugin
add_action('init', array('wf_fps', 'init'));
add_action('after_setup_theme', array('wf_fps', 'add_thumb_support'));
?>
The part I have edited include:
Line 727 which I changed to: $pagination .= '<li><a href="">' . get_the_post_thumbnail($featured->ID, 'FPS pagination thumbnail', array('class' => 'fps-thumbnail-mini')) . '</a><p><?php $small = get_post_meta($post->ID, 'small', true);echo $small;?></p></li>';
Line 820 when I added: $out .= get_post_meta($post->ID, 'small', true);
Any help you can give me would be much appreciated as I've got to go live with this soon and I'm stumped.