• Resolved wallypop

    (@wallypop)


    I’m re-writing a site for a few friends (http://wallypop.110mb.com) who have a small magazine they recently started.

    Their old site was full of frames and honestly bad HTML practice.

    To make things very simple and streamlined, I was hoping to embed a “10 most recent posts” feed into the site. As you can see on the site itself, I already have FeedBurner setup to do that, however the first post is cut off seemingly due to length, and it doesn’t allow me to embed images into it, which would be a main function of the blog (its a magazine site afterall).

    Any idea on how to do this? I can try and pickup PHP and code it myself, however I was hoping some other solution already existed so I wouldn’t have to worry about it breaking or not working properly.

    Any help is extremely appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter wallypop

    (@wallypop)

    OK guys, I figured it out, but I’m putting it here so others can see.

    I simply modified the index.php under themes/default to only show me the posts:

    <div id="content" class="narrowcolumn">
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div class="post" id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    				<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    
    				<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    			</div>
    
    		<?php endwhile; ?>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
    	<?php endif; ?>

    Then, I used Javascript to make an AJAX call to run index.php and then put the results into a td tag I had.

    <script language="javascript" type="text/javascript">
    <!--
    function atload() {ajaxFunction()}
    window.onload=atload;
    //Browser Support Code
    function ajaxFunction(){
    	var ajaxRequest;  // The variable that makes Ajax possible!
    
    	try{
    		// Opera 8.0+, Firefox, Safari
    		ajaxRequest = new XMLHttpRequest();
    	} catch (e){
    		// Internet Explorer Browsers
    		try{
    			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    		} catch (e) {
    			try{
    				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    			} catch (e){
    				// Something went wrong
    				alert("It seems your browser is outdated. Try www.getfirefox.com for a great browser that is compatible!");
    				return false;
    			}
    		}
    	}
    	// Create a function that will receive data sent from the server
    	ajaxRequest.onreadystatechange = function(){
    		if(ajaxRequest.readyState == 4){
    			var returnedPosts = ajaxRequest.responseText;
    			var placetoputit = document.getElementById('pagecontent');
    			placetoputit.innerHTML=returnedPosts;
    		}
    	}
    	ajaxRequest.open("GET", "http://wallypop.110mb.com/jagablog/index.php", true);
    	ajaxRequest.send(null);
    }
    
    //-->
    		</script>

    Its very basic, and my Javascript isn’t great. Once I’m completely satisfied with the styling, I’ll just call the javascript from an external javascript file, to reduce clutter.

    If anyone has any input feel free to share it.

    Thread Starter wallypop

    (@wallypop)

    OK, well that worked really well, however, I can’t find the template file which controls the argument “cat”.

    E.G.

    I want my script to pull back only the posts in a certain category, which normally would be done by using:

    blogpath/index.php?cat=1

    Or in my case I want to use:

    http://wallypop.110mb.com/jagablog/index.php?cat=4

    When I try doing this with the same index.php I had before, it includes everything I tried to remove. Which template .php file controls this? I only want to include the raw post data, the way you can see it on:

    http://wallypop.110mb.com/jagablog

    But I want to be able to call up the appropriate category for the page.

    Any ideas?

    Thread Starter wallypop

    (@wallypop)

    Ok, I figured it out again on my own (why do I bother posting? In case I don’t figure it out, plus then I can put my solution up here).

    I just modified the following files:

    archive.php
    search.php

    To get them to only display what I want. It works pretty well, and I’ll be using this for the rest of my pages as well.

    Thanks again!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Embed a WP “feed” into a site’ is closed to new replies.