WTH Programmer for Wordpress Customization

Discussion in 'Programming' started by thecubehost, Jul 18, 2009.

  1. #1
    Hey,

    I have a Wordpress template that I've been working on. I've been getting frustrated because I've been getting errors everytime I try using the query function in Wordpress. Like I've been trying to show post from a certain category in one section and show a certain post in one section.

    Let me know if you will be able to do this. Please PM me your quotes.

    Thanks.
     
    thecubehost, Jul 18, 2009 IP
  2. AfterHim.com

    AfterHim.com Peon

    Messages:
    1,922
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    What errors are you getting?
     
    AfterHim.com, Jul 18, 2009 IP
  3. thecubehost

    thecubehost Active Member

    Messages:
    221
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    70
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    I'm getting various syntax errors. When I go to the line it tells me the last line in the document which sometimes has nothing on it. Also, the lines I enter to get specific posts or categories give errors in my template but not in others. I believe it may be a deeper problem since I don't have a function.php file. However, I need this problem solved soon.
     
    thecubehost, Jul 18, 2009 IP
  4. Jalpari

    Jalpari Notable Member

    Messages:
    5,640
    Likes Received:
    137
    Best Answers:
    0
    Trophy Points:
    260
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    what is ur theme name and plz share ur link so we can diagnose more easily.
     
    Jalpari, Jul 18, 2009 IP
  5. Yeah

    Yeah Well-Known Member

    Messages:
    865
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    135
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    does your theme widget ready ?
     
    Yeah, Jul 19, 2009 IP
  6. thecubehost

    thecubehost Active Member

    Messages:
    221
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    70
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    It is a custom theme. Here is the index.php code.

    <?php get_header(); ?>
    <div id="content">
    	<div id="homepage">
                   <div id="homepagetop">		
                		<div class="featuredtop">        
               		 	<?php include (ABSPATH . '/wp-content/plugins/plugin-name/plugin.php'); ?>
    			</div>  	
                   </div>		
    		<div id="homepagebottom">	
    			<div class="featuredbottom">
    			<h2>Header2</h2>
    		**THE SINGLE POST IS TO BE HERE**
    			</div>
                        </div>	
    		</div>
    	<?php include(TEMPLATEPATH."/sidebar.php");?>
    </div>
    <!-- The main column ends  -->
    <?php get_footer(); ?>
    Code (markup):
    I tried using

    <?php while (have_posts()) : the_post(); ?>
    <?php query_posts('cat=3&showposts=2'); ?>
    Code (markup):
    and

    <?php while (have_posts()) : the_post(); ?>
    <?php query_posts('p=1'); ?>
    Code (markup):
    And I get errors like the following everytime. However, those lines work in other templates just not mine. Also, I've remove widgets.
    Parse error: syntax error, unexpected $end in /home/username/public_html/wp-content/themes/theme_name/index.php on line 64 
    Code (markup):
     
    thecubehost, Jul 19, 2009 IP
  7. srobona

    srobona Active Member

    Messages:
    577
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    88
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7
    put endwhile at the end, hope it solve the problem :)
     
    srobona, Jul 19, 2009 IP
  8. bunq.co.uk

    bunq.co.uk Peon

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #8
    look like you need to read up on the loop, no need to hire anyone, keep your money in your pocket for your next project.

    Here is a simple wordpress loop taken from the standard theme

    apply your css and div's where needed to separate the info, you can add in various tags like author, time etc, read the link below

    you need to read up on the loop how it opens and closes, it really is simple.

    have a look here
    hxxp://codex.wordpress.org/The_Loop

    hope that helps, if you need any more help drop me a pm or lets discuss it here

    Regards Roy
    Bunq
     
    bunq.co.uk, Jul 19, 2009 IP
  9. thecubehost

    thecubehost Active Member

    Messages:
    221
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    70
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #9
    You guys are the hero for the day. I forgot about adding that line <?php endwhile; ?>

    Now, the only issue I have is with the following code.
    <?php query_posts('cat=1&showposts=2'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <?php endwhile; ?>
    Code (markup):
    How can I add and limit the amount of words shown and have an option to "Continue Reading?"
    Help is greatly appreciated.
     
    thecubehost, Jul 19, 2009 IP
  10. izwanmad

    izwanmad Banned

    Messages:
    1,064
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #10
    for that, you just need the Custom Excerpts plugin: http://wordpress.org/extend/plugins/custom-excerpts/

    or just use the instructions below:

    1. In your functions.php , add the following function:

    function custom_excerpt($text, $chars) 
    {
    	$text = strip_shortcodes($text); 
    	
    	$text = str_replace(']]>', ']]&gt;', $text);
    	$text = strip_tags($text); 
    	
    	$pattern = "/\[(.*?)\b[^>]*\]/ims"; 
    	$text = preg_replace($pattern, "", $text);
    	
    	$text = substr($text,0,$chars); 
    	$text = substr($text,0,strrpos($text,' '));
    	$text = $text . "..."; 
    	echo $text; 
    }
    PHP:
    2. To display the text (with character amount limiting), put this in the loop:

    <?php custom_excerpt($post->post_content, 300); ?>
    PHP:
    that will limit the text to 300 character

    3. to display the read more link (continue reading), put this (also in the loop):

    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">Read More...</a></div>
    PHP:
     
    izwanmad, Jul 19, 2009 IP
  11. thecubehost

    thecubehost Active Member

    Messages:
    221
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    70
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #11
    When I use the following I get the error below.
    <?php query_posts('cat=1&showposts=2'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <?php custom_excerpt($post->post_content, 300); ?>
    <?php endwhile; ?>
    
    Code (markup):
    This is the sidebar.php code.

    <div>  
    	<div class="news_updates">	
    	<h2>News Updates</h2>
    <?php query_posts('cat=1&showposts=2'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <?php custom_excerpt($post->post_content, 300); ?>
    <?php endwhile; ?>
    	</div>
    </div>
    
    Code (markup):
     
    thecubehost, Jul 19, 2009 IP
  12. izwanmad

    izwanmad Banned

    Messages:
    1,064
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #12
    you get the error because you didn't put the code I provide in functions.php (see point #1).
     
    izwanmad, Jul 19, 2009 IP
  13. thecubehost

    thecubehost Active Member

    Messages:
    221
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    70
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #13
    Now, the following shows at the top of the page.
    function custom_excerpt($text, $chars) { $text = strip_shortcodes($text); $text = str_replace(']]>', ']]>', $text); $text = strip_tags($text); $pattern = "/\[(.*?)\b[^>]*\]/ims"; $text = preg_replace($pattern, "", $text); $text = substr($text,0,$chars); $text = substr($text,0,strrpos($text,' ')); $text = $text . "..."; echo $text; } /
    Code (markup):
    And this appears at the /wp-admin/ login page.

    function custom_excerpt($text, $chars) { $text = strip_shortcodes($text); $text = str_replace(']]>', ']]>', $text); $text = strip_tags($text); $pattern = "/\[(.*?)\b[^>]*\]/ims"; $text = preg_replace($pattern, "", $text); $text = substr($text,0,$chars); $text = substr($text,0,strrpos($text,' ')); $text = $text . "..."; echo $text; }
    Warning: Cannot modify header information - headers already sent by (output started at /home/username/public_html/wp-content/themes/themename/functions.php:15) in /home/thecubeh/public_html/pmb/wp-includes/pluggable.php on line 865
    Code (markup):
    I never had a functions.php file before. I just added it and copied your code straight to create it.
     
    thecubehost, Jul 19, 2009 IP
  14. izwanmad

    izwanmad Banned

    Messages:
    1,064
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #14
    Now, just put this code in that functions.php

    <?php
    function custom_excerpt($text, $chars) 
    {
        $text = strip_shortcodes($text); 
        
        $text = str_replace(']]>', ']]&gt;', $text);
        $text = strip_tags($text); 
        
        $pattern = "/\[(.*?)\b[^>]*\]/ims"; 
        $text = preg_replace($pattern, "", $text);
        
        $text = substr($text,0,$chars); 
        $text = substr($text,0,strrpos($text,' '));
        $text = $text . "..."; 
        echo $text; 
    }
    ?>
    PHP:
    That will work.

    I've used this code for a number of my theme... for example: http://forums.digitalpoint.com/showthread.php?t=1398365
     
    izwanmad, Jul 19, 2009 IP
  15. hockeychick

    hockeychick Peon

    Messages:
    115
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #15
    i still can't figure out the solution and cauz i have come acoss the same problem but different errors
     
    hockeychick, Jul 19, 2009 IP
  16. AdnanAhsan

    AdnanAhsan Well-Known Member

    Messages:
    601
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    110
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #16
    friends here is my msn: , add me, at the moment i am so tired and sleepy, i worked whole night and its 8:21AM here, so i will come online in the evening, will try my best to help each one thanks :)
     
    AdnanAhsan, Jul 19, 2009 IP
  17. thecubehost

    thecubehost Active Member

    Messages:
    221
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    70
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #17
    Now I changed the functions.php to
    <?php
    function custom_excerpt($text, $chars)
    {
        $text = strip_shortcodes($text);
       
        $text = str_replace(']]>', ']]&gt;', $text);
        $text = strip_tags($text);
       
        $pattern = "/\[(.*?)\b[^>]*\]/ims";
        $text = preg_replace($pattern, "", $text);
       
        $text = substr($text,0,$chars);
        $text = substr($text,0,strrpos($text,' '));
        $text = $text . "[B]Continue Reading...[/B]";
        echo $text;
    }
    ?>
    Code (markup):
    How can I turn that into a link to view the rest of the post?
     
    thecubehost, Jul 19, 2009 IP
  18. izwanmad

    izwanmad Banned

    Messages:
    1,064
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #18
    3. to display the read more link (continue reading), put this (also in the loop):

    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">Read More...</a>
    PHP:
    Please read the post above carefully before asking. If you still have problem with that one, you clearly need someone to look at your code.
     
    izwanmad, Jul 19, 2009 IP
  19. bunq.co.uk

    bunq.co.uk Peon

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #19
    or alternatively just write the exact number of words you want to display in the excerpt and add the read more link below that izwanmad has added, then you write the full post in the normal WYSIWYG panel, that will display on the page when a user clicks through.

    a simple solution if your not up on code, but probably not the best way to do it !


    All the best

    Roy
     
    bunq.co.uk, Jul 20, 2009 IP
  20. Yuuko008

    Yuuko008 Member

    Messages:
    682
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    33
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #20
    If you still need someone to do it, please pm me with your budget and your MSN or YM. I'm more than willing to help you.
     
    Yuuko008, Jul 20, 2009 IP