Need WP Coding Help

Discussion in 'HTML & Website Design' started by Alanaj, Sep 18, 2010.

  1. #1
    Hi DP,

    I apologize if this is in the wrong place. If it is, please let me know and I'll move my post. I have a customized WP theme but there are two issues that I really need help with.

    1. My search box doesn't work.

    Style.CSS code:

    searchr{width:126px;height:28px;background:url(images/searchbg.png);right:0;}

    .searchr input[type="text"]{border:0;margin:6px 0;margin-left:3px;padding:1px;width:95px;background: none !important; height:18px;float:left;color:#666666;font-family:Arial;font-size:13px; font-weight:bold;}

    .searchr input[type="image"]{width:20px;height:27px;float:right;margin:0px;margin-left:0;}

    #sform{width:300px;height:20px; font-size:12px; padding:2px; }

    #s{width:180px;height:15px;border:#333333;background:url(images/search.png) no-repeat;padding:5px;}

    #s input{height:25px;width:50px;}

    #searchsubmit{font-weight:bold;color:#CCCCCC;width:65px; padding:4px;height:19px;background:#364040; }

    .searchform input{vertical-align:middle;}


    The code on the page templates is:

    <div class="searchr">

    <form id="searchform" action="<?php bloginfo('url'); ?>/">

    <input name="s" value="Search Site..." onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" type="text">

    <input src="<?php bloginfo('template_directory'); ?>/images/space.gif" value=" " type="image">

    </form>

    </div>

    2. Nothing I type shows up on the index page. Here is the template code:

    <?php query_posts('posts_per_page=4&cat=4');

    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <div class="grey"><!--grey start-->

    <div class="grey_heading"><?php echo the_title() ?></div>

    <div class="grey_text">

    <?php $content=get_the_content(); echo substr(strip_tags($content),0,260);?> <a href="#">Read more...</a>

    </div>

    </div><!--grey end-->

    <?php endwhile; endif; ?>

    <div style="clear:both;"></div>

    <?php query_posts('posts_per_page=1&cat=7');

    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <div class="heading"><?php echo the_title() ?></div>

    <div class="text">

    <?php $content=get_the_content(); echo $content;?>

    </div>

    <?php endwhile; endif; ?>

    <br />

    </div><!--content end-->

    Any and all help is greatly appreciated. Thank you in advance!
     
    Alanaj, Sep 18, 2010 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <form id="searchform" action="<?php bloginfo('url'); ?>/">
    That forward slash may be the problem.

    As for the second question, all I can think of is that the posts are not in category 4 or 7.
     
    Cash Nebula, Sep 20, 2010 IP
  3. ChPeter

    ChPeter Peon

    Messages:
    974
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Alanaj

    Your problem needs a more detailed discussion,
    feel free to contact our website company,
    our experts will definitely help you
     
    ChPeter, Sep 20, 2010 IP
  4. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Forget what I said about the forward slash, your search box works fine in TwentyTen. The bloginfo function doesn't put a forward slash on the end of directories.

    I found out that your code has a problem because it overrides the search query. You need to add the extra parameters to the end of the query string:
    
    <?php query_posts($query_string.'&posts_per_page=4&cat=4'); ?>
    ...
    <?php query_posts($query_string.'&posts_per_page=1&cat=7'); ?>
    ...
    
    Code (markup):
     
    Cash Nebula, Sep 21, 2010 IP
  5. Alanaj

    Alanaj Active Member

    Messages:
    108
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #5
    Cash,

    Thanks for taking the time to help me out with this. It turns out the problem is larger than just adjusting the coding.

    Cheers
     
    Alanaj, Sep 22, 2010 IP
  6. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You're welcome :) If it's not too much trouble, I really like to know how you fixed it.
     
    Cash Nebula, Sep 23, 2010 IP