1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Adding CSS to RSS Feed Generated in PHP???

Discussion in 'White Hat SEO' started by ramtripper, Sep 28, 2011.

  1. ramtripper

    ramtripper BANNED BANNED

    Joined:
    Jul 31, 2010
    Messages:
    427
    Likes Received:
    273
    HELPP PLZZZ

    Okay, so i've been cracking away at a problem forever now...


    All i want is to have my blog feed on my static homepage so that it becomes dynamic and big G see's that it constantly gets fresh content.

    I got the feed to work using the following code:

    Code:
    <?php query_posts('showposts=5'); ?>
    <?php while (have_posts()): the_post(); ?>
    
    <?php the_excerpt_rss(); ?> 
    
    <?php endwhile; ?>

    My goal is to make it look pretty, not just a jumble of words stuck together. How do i do this?

    You can see it at the bottom of this page:

    Code:
    http://debtfreecounselor.com/index1.php
    The feed is coming from:

    Code:
    http://debtfreecounselor.com/blog/

    How can i add CSS to it? or maybe there is a better function to call out the feed, instead of the_excerpt_rss(); ??

    Plleeeeasseee helpp, im dying over here. been losing so much sleep over this crap
     
  2. PhillyLuke

    PhillyLuke Junior Member

    Joined:
    May 18, 2011
    Messages:
    101
    Likes Received:
    37
    Occupation:
    Fulltime SEO/IM
    Location:
    Philadelphia, PA
    I would need to mess a bit with your code to make sure everything works as needed, but at a first glance I think you can do the following:

    Wrap that PHP code you are using in it's own <div id="blogfeed"> tag you can use to style the various elements the PHP code pulls in. (I just used "blogfeed" as an example ID - put whatever you want here.

    Right now your PHP is pulling in the post title as a title only (with only "strong" tags around it) which would make it hard to style within your CSS.

    It would probably be better to pull in the title as a link to the actual post.

    This would allow you to style the <a href> tags these titles will now be surrounded with within your "blogfeed" css class. You can then probably style those away to fit your needs.

    Also try surrounding your "excerpt" php code with <p> tags - you can then probably style the <p> tags within your blogfeed class as you see fit.

    Again I would need to mess a bit with the code to see whether this works completely, but I think it's the direction you need to head towards.
     
  3. PhillyLuke

    PhillyLuke Junior Member

    Joined:
    May 18, 2011
    Messages:
    101
    Likes Received:
    37
    Occupation:
    Fulltime SEO/IM
    Location:
    Philadelphia, PA
    To give you an example of how I'm styling some Wordpress PHP excerpts:

    Code:
     <div id="covertext">
    		<?php rewind_posts(); ?>
    			<?php $recent = new WP_Query("cat=68&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>	
    			<div id="categorylinks">
    				<h4><?php hidden_category(', ') ?></h4>
    			</div>		
    			<div id="titlelinks">
    				<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    			</div>
    			<div id="author">
    				<p>by <?php the_author(); ?></p>
    			</div>
    			<div id="covercontent">		
    				<?php the_excerpt(); ?>
    			</div>
    			<?php endwhile; ?>
    		</div>
    I use some strange PHP calls there when I should be working within the loop - but you get the idea!
     
    • Thanks Thanks x 1
    Last edited: Sep 28, 2011
  4. PhillyLuke

    PhillyLuke Junior Member

    Joined:
    May 18, 2011
    Messages:
    101
    Likes Received:
    37
    Occupation:
    Fulltime SEO/IM
    Location:
    Philadelphia, PA
    I can PM you the URL of that PHP code I cited above if you're interested in how I set up the CSS to style it. Let me know!
     
    • Thanks Thanks x 1
  5. ramtripper

    ramtripper BANNED BANNED

    Joined:
    Jul 31, 2010
    Messages:
    427
    Likes Received:
    273
    yea i realized last night that i can add any code before or after the pulls and it will affect each post it pulls since it's a loop -.-

    i made use of ur title permalink though, thanks again. here's what the code looks like now. its coming out pretty decent i must say :)

    Code:
    <font face="Arial" style="font-size: 10pt" color="#000000"><p align="left">
    <?php query_posts('showposts=4'); ?>
    <?php while (have_posts()): the_post(); ?>
    <strong><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong><br />
    <font size="1"><?php the_excerpt_rss(); ?></font> <br /><br />
    
    <?php endwhile; ?></font>