• https://webhostmaven.com

    If you look at my homepage, I was able to widgetize the home page and I placed a “news” banner below the first post.

    I am unable to figure out how to get that widget, in this case the banner, above the first post but below the comparison table…

    any html help?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter gregdoggle

    (@gregdoggle)

    Here is my function.php

    <?php
    register_sidebar( array(
    ‘name’ => ‘index-insert’,
    ‘id’ => ‘index-insert’,
    ‘before_widget’ => ‘<div id=”%1$s” class=”%2$s widget”>’,
    ‘after_widget’ => ‘</div>’,
    ‘before_title’ => ‘<h3 class=”widget-title”>’,
    ‘after_title’ => ‘</h3>’
    ) );
    ?>

    And here is my index.php

    <?php if ($count==0) { ?>
    <?php dynamic_sidebar(‘index-insert’) ?>
    <?php } ?>
    <?php $count = $count + 1; ?>

    But, I want it above the first post not after it.

    You don’t show enough of your index.php. Post about 15 lines up to and including the $count = $count + 1; line

    Thread Starter gregdoggle

    (@gregdoggle)

    here is more:

    <h2>” rel=”bookmark”><?php the_title(); ?></h2>
    <?php the_excerpt(); ?>
    <div class=”post-bottom”>
    ” class=”readmore”>Continue Reading
    ” class=”viewwebsite”>View The Website
    </div>
    <br clear=”all” />
    </div>
    <?php if ($count==0) { ?>
    <?php dynamic_sidebar(‘index-insert’) ?>
    <?php } ?>
    <?php $count = $count + 1; ?>
    <?php endwhile; ?>

    Almost enough! You need to put the call to dynamic_sidebar somewhere before the code you have posted so far – probably just before a line that contains if (have_posts()). Why don’t you put your whole index.php in a pastebin and post the link here.

    Thread Starter gregdoggle

    (@gregdoggle)

    OK – it still isn’t quite clear where the table is coming from, but I think this should work.

    First delete these lines:

    <?php if ($count==0) { ?>
    <?php dynamic_sidebar('index-insert') ?>
    <?php } ?>
    <?php $count = $count + 1; ?>

    Then put the dynamic_sidebar line ahead of the if (have_posts()) line, like this:

    <?php dynamic_sidebar('index-insert') ?>
    		   <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    Thread Starter gregdoggle

    (@gregdoggle)

    almost man, but now it appeared above the table.

    The table is a plugin so that might be why it is not in the index.php

    I moved it back for now, but man you got the right idea.

    I have to do something with that plugin, just not sure where and what.

    The question is “How does the plugin determine where to insert the table?”

    Does the plugin documentation say anything about that? What is the plugin?

    One more try before we have to mess with the plugin. Put the dynamic_sidebar call just after the if (have_posts()):

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php if (++$count == 1) dynamic_sidebar('index-insert'); ?>
    Thread Starter gregdoggle

    (@gregdoggle)

    ok, that definitely did it, thanks bro…

    Only minor thing now is, it is too “tight” to the comparison table.
    I need a bit of space between the banner and the table…

    Could I just add <p> in the widget? or is their a better way than my half assed way?

    Several ways to do it. You can add a break in the code:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php if (++$count == 1) {
       echo '<br />';
       dynamic_sidebar('index-insert');
    } ?>

    The ‘correct’ (but more complicated) way to do it is to enclose the sidebar in a div and use CSS to style it:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php if (++$count == 1) {
       echo '<div class="index-insert">';
       dynamic_sidebar('index-insert');
       echo '</div>';
    } ?>

    Then, in style.css, add:

    .index-insert {
       margin-top: 10px;
    }

    hey it’s not working

    i add text widget to test in ‘index-insert’ widget area but not working it not working, but Showing “sorry, no posts matched your criteria”

    i tried with all above code

    this what i put the code

    <div class="entry">
    
                            <?php the_excerpt(); ?><span class="read-more"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" class="btns"><?php _e('Read More', 'Behance'); ?></a></span>
    
                        </div>
                            <div class="fix"></div>
                        </div><!-- /.post -->
    
                        <div class="post-bottom">
                            <div class="fl"><span class="cat"><?php the_category(', ') ?></span></div>
                            <div class="fr"><?php the_tags('<span class="tags">', ', ', '</span>'); ?></div>
                            <div class="fix"></div>
                        </div>
                    </div><!-- /.box -->
    
              <?php if ($count==0) { ?>
    <?php dynamic_sidebar('index-insert') ?>
    <?php } ?>
    <?php $count = $count + 1; ?>
    <?php endwhile; ?>
            <div class="box">
                        <div class="post">
                            <p><?php _e('Sorry, no posts matched your criteria.', 'Behance') ?></p>
                        </div><!-- /.post -->
                    </div><!-- /.box -->
                <?php endif; ?>

    and in function.php
    register_sidebar(array('name' => 'index insert','id' => 'index-insert','before_widget' => '<div id="%1$s" class="widget %2$s">','after_widget' => '</div>','before_title' => '<h3>','after_title' => '</h3>'));

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Suggestion or help please…almost there..’ is closed to new replies.