1

Slightly Advanced Noob Alert: {Sorry}.

I'm designing a WordPress Site {No Active Yet}. I have a plugin [feelbox], but currently it displays only on the single post page. There is no option in the plugin settings to display it on the frontpage [index.php]. Here is the main plugin file - feelbox.php is too long to post here. Here is the first part of it:

> if (!$options) {
        feelbox_add_default_options();
    } else {
        if ($options['showinpostsondefault'] == 'on') {
            add_filter('the_content', 'add_feelbox_widget_to_posts');
        }
        if (empty($options['showtweetfollowup'])) {
            $temp = array(
                'showtweetfollowup' => 'on'
            );          
            update_option('feelbox_wp_options', $temp);         
        }   
    }
}

function feelbox_add_default_options() {    
    $temp = array(
        'showsparkbar' => 'on',
        'showinpostsondefault' => 'on',
        'showtweetfollowup' => 'on',
        'validkey' => '0',
        'sortmoods' => 'off'
    );

    update_option('feelbox_wp_options', $temp);
}

function feelbox_website_and_apikey_match() {
    $options = get_option('feelbox_wp_options');
    return $options['validkey'] == '1';
}

function feelbox_get_widget_html() {
    global $wpdb;
    global $post;
    global $moods;

    if ( ( $use_centralized_site == FALSE ) || ($use_centralized_site == TRUE && feelbox_website_and_apikey_match()) ) {
        $post_id = (int)$post->ID;
        $obj = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}lydl_posts WHERE ID=" . $post_id, ARRAY_A);
        $sum = $obj["emotion_1"]+$obj["emotion_2"]+$obj["emotion_3"]+$obj["emotion_4"]+$obj["emotion_5"]+$obj["emotion_6"];

But here is my index.php:

 <?php $mts_options = get_option('dualshock'); ?>
<?php get_header(); ?>
<div id="page">
    <div class="content">
        <article class="article">
            <div id="content_box">
                <?php $j = 0; if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <div class="post excerpt <?php echo (++$j % 2 == 0) ? 'last' : ''; ?>">
                        <header>                        
                            <h2 class="title">
                                <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a>
                            </h2>
                        </header><!--.header-->
                        <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="nofollow" id="featured-thumbnail">
                            <?php if ( has_post_thumbnail() ) { ?> 
                                <?php echo '<div class="featured-thumbnail">'; the_post_thumbnail('featured',array('title' => '')); echo '</div>'; ?>
                            <?php } else { ?>
                                <div class="featured-thumbnail">
                                    <img width="450" height="200" src="<?php echo get_template_directory_uri(); ?>/images/nothumb.png" class="attachment-featured wp-post-image" alt="<?php the_title(); ?>">
                                </div>
                            <?php } ?>
                        </a>
                        <div class="post-content image-caption-format-1">
                            <?php echo excerpt(38);?>
                        </div>

                    </div><!--.post excerpt-->

                    <div class="post-info">

                        <span class="thecomment"><?php echo comments_number(__('No Comment','mythemeshop'), __('One Comment','mythemeshop'), '<span class="comments">'.__('Comments','mythemeshop').'</span> <span class="comm">%</span>');?></span>
                        <span class="readMore"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php _e('Read More','mythemeshop'); ?></a></span>

                    </div>
                <?php endwhile; endif; ?>   
                <span><?php if ( function_exists('print_feelbox_widget') ) { print_feelbox_widget(); } ?></span>
                <!--Start Pagination-->
                <?php if ( isset($mts_options['mts_pagenavigation']) == '1' ) { ?>
                    <?php  $additional_loop = 0; pagination($additional_loop['max_num_pages']); ?>           
                <?php } else { ?>
                    <div class="pagination">
                        <ul>
                            <li class="nav-previous"><?php next_posts_link( __( '&larr; '.'Older posts', 'mythemeshop' ) ); ?></li>
                            <li class="nav-next"><?php previous_posts_link( __( 'Newer posts'.' &rarr;', 'mythemeshop' ) ); ?></li>
                        </ul>
                    </div>
                <?php } ?>
                <!--End Pagination-->
            </div>
        </article>
        <?php get_sidebar(); ?>
<?php get_footer(); ?>

I tried to call up the function by inserting this under the post-info DIV, no luck.

<?php if ( function_exists('print_feelbox_widget') ) { print_feelbox_widget(); } ?>

Any help would be greatly appreciated. Thanks.

1 Answer 1

1

Your plugin inserts its feelbox widget by filtering the_content:

if ($options['showinpostsondefault'] == 'on') {
    add_filter('the_content', 'add_feelbox_widget_to_posts');
}

But your index page doesn't display the_content, just Title, featured thumbnail, an excerpt and, number of comments.

The plugin code you've shown us doesn't include a print_feelbox_widget() function. Does such a function actually exist in your plugin? (Also, you've included it after the closing tag of your post-info div, and outside the close of "the loop" (<?php endwhile; endif; ?>) so if it's meant to be used in "the loop" you need to move it up a couple lines.)

Otherwise, you might be able to hack your plugin to filter an additional template tag (the_excerpt?) and then add that tag to your index.php template.

So, in your plugin:

if ($options['showinpostsondefault'] == 'on') {
    add_filter('the_content', 'add_feelbox_widget_to_posts');
    add_filter('the_excerpt', 'add_feelbox_widget_to_posts');
}

Then, in index.php something like:

<div class="post-content image-caption-format-1">
    <?php the_excerpt();?>
</div>

You'll have to play around with exact placement, of course.

Good luck.

1
  • Hmmm, tried that. This is what I got back at the bottom of the featured image in the front page.'code' Warning: Missing argument 1 for excerpt(), called in /home/content/p3pnexwpnas07_data03/24/2493124/html/wp-content/themes/dualshock/index.php on line 24 and defined in /home/content/p3pnexwpnas07_data03/24/2493124/html/wp-content/themes/dualshock/functions.php on line 230 Mar 8, 2015 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.