Forums

Quoting Feed not using RSS (7 posts)

  1. Havockcouk
    Member
    Posted 4 years ago #

    I'm using a wordpress blog as one half of my website, where it sits on the 'second page'. In order to draw attention to it I quote part of the most recent post on the frontpage, at the moment using a javascript that uses my blog's RSS feed. This is proving rather slow - is there a way I can access my WP database directly ?

    Thanks,

    Marc

  2. whooami
    Member
    Posted 4 years ago #

    is there a way I can access my WP database directly ?

    of course you can!

    is that front page a php page or just an html page?

    depending on that you can do a few things.

    --

    you could, for instance, use the except on your blog, grab your feed which you set up to just show excerpts, and redisplay it

    you could also code another little page that grabs th excerpt, or even more specifically so many characters of your latest post and redisplay it on your front page.

    ..

    thats just the beginning of whats possible -- and there are hundreds of similar threads on here, that talk about doing that. God knows I cant find them though.

    and since it appears you dont want to use RSS (ive no idea why) yes you can still do it.

  3. whooami
    Member
    Posted 4 years ago #

    here' some code that will get you started.

    <?php require('./wp-blog-header.php');
    query_posts('showposts=1');
    while (have_posts()) : the_post(); ?>
    <?php the_excerpt(); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark">Read More</a>
    <?php endwhile; ?>

    you ned to make sure that 1. you use the right path to your wordpress install's wp-header.php, and 2. that your most recent post has an excerpt.

    If you include that via a standard php include it ought to work just fine.

  4. Havockcouk
    Member
    Posted 4 years ago #

    It's HTML at the moment, using a bit of Javascript to access my RSS via a PHP file on my server; I presume the lot running at the same time is the reason why nine out of ten times I get a time-out error message from the PHP script (it does occasionally feed back the blog excerpt). Anything that will shorten the process should be good, I'd thought. Is the above PHP something I could include in the body of what I have at the moment ?

    Thanks for the prompt reply.

  5. Havockcouk
    Member
    Posted 4 years ago #

    I've done a dry run with the PHP and that works fantastically - thanks. Is there anyething I can include in the script to add the title and date ?

  6. whooami
    Member
    Posted 4 years ago #

    <?php the_title ?>

    <?php the_time('F jS, Y') ?>

  7. Havockcouk
    Member
    Posted 4 years ago #

    That's done it - thanks for that. There is still some variation in how quickly the information is retrieved - I'll contact my host and see whether there's anything they can do about that, but at least now this part of the operation runs smoothly.

    Many thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic