Forums

splash pg ---w/ recent post? (9 posts)

  1. chaz19
    Member
    Posted 7 years ago #

    hey guys-

    quick ?....im cr3eaing a splash pg and would like to query an exerpyt from my most recent post on WP. any ideas?

  2. moshu
    Member
    Posted 7 years ago #

    1. Use a recent posts plugin
    2. Use feeds (and a feedreader)
    3. See this: http://www.transycan.net/blogtest/2005/07/05/integrate/ - scenario #1.

  3. Jonathan Landrum
    Member
    Posted 7 years ago #

    Yup. I'm doing the same thing, only I'm showing the whole post. WP is set up to look for files in a hierarchy (read this codex article: http://codex.wordpress.org/Template_Hierarchy). The first file it looks for on the home page is home.php. Some themes come with this file, others do not. Creating one is simple: you just save index.php as home.php. Then, to get only one post to show, change this line:

    <?php get_header(); ?>

    to this:

    <?php get_header(); query_posts('posts_per_page=1'); ?>

    and to get it to show only the excerpt, change this:

    <div class="entry">
    <?php the_content(); ?>
    </div>

    to this:

    <div class="entry">
    <?php the_excerpt(); ?>
    </div>

    and that will show the most recent article's excerpt on your front page.

    ~Jonathan

  4. chaz19
    Member
    Posted 7 years ago #

    thanks guys -- that's just what I needed.
    Very helpful!

  5. chaz19
    Member
    Posted 7 years ago #

    well...I think I complicated my task and now I'm begging for more support. I decided that I want a different theme look for my splash page -- so I utilize different css styles and have the page under my root directory:

    http://www.chazsouthard.org/splash_test7.html

    my current weblog is under a different directory, which is:

    http://www.chazsouthard.org/wordpress/index.php

    now, I'm still in the testing and development phase of this new splash page -- and I know that I have it labeled as a .html. so I think my first step would be to relabel it as a.php. but from there, somehow, I need to query code from a different directory.

    I'd like the php code to appear under the heading journey/journal....right now I just have some dummy text just for design sake.

    So I guess my questions are --
    do I have to move the splash page into my Word press directory?
    Is it possible to pull PHP code from that directory?

    I've tried a bunch of different ways already and I keep on getting roadblocks with the PHP code. As you can tell on the PHP fool -- and I'm struggling in trying to figure out how to fit the code into this page.

    I've read over all the suggestions -- but I'm still at a loss.....is there a simple solution or is is very in depth?

    Any and all help would be greatly appreciated -- I am a quadriplegic so hand coding takes in quite awhile and any help is welcomed with great gratitude. Thank you in advance--

    chaz

  6. moshu
    Member
    Posted 7 years ago #

    1. No, you don't have to move the splash page into the WP directory.
    2. Yes, it is possible to use any and all WP template tags in that splash page - provided you make it a .php file AND add this to the very top of it (before everything)
    <?php
    require('./wordpress/wp-blog-header.php');
    ?>

    3. Then you can use either The_Loop - as described in my tutorial linked above or some other solution, e.g. a recent_post plugin to show the last post.

  7. chaz19
    Member
    Posted 7 years ago #

    Moshu-you've been so incredibly helpful and I kind of now understand "the loop"

    for the most part, now I have the splash page working. I'm just trying to fine tune it and I have two other questions.(my apologies for being such a bother and nag on this issue, I don't know where I'd be without all the help of moderators.....you guys deserve a big paycheck at the end of the day)

    here's the code that I used to query from my weblog to my splash page:
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <?php if ( !(in_category('3')) ) { ?>

    <div class="post">

    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>

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

    <div class="entry">
    <?php the_excerpt(); ?>
    </div>

    </div> <!-- closes the first div box -->

    <?php } ?> <!-- Close the if statement. -->

    <?php endwhile; else: ?>
    <p>Sorry, no posts matched your criteria.</p>
    <?php endif; ?>

    and so far it does query all of the excerpts of my last five weblog entries. So my final questions are:

    1. How do I limit the query to just one single Post, without changing my options in my Word press dashboard?

    2. with the given excerpt that displays in a splash page. How do I edit the PHP code so that it brings me directly to my web-log index page, instead of bringing me to the actual single Post page?

    my current testing splash page is located on:
    http://www.chazsouthard.org/splash_3.php

    is that enough questions?... many thanks for also writing the well-written codex--it is very user-friendly and understandable even to a person like me who has little understanding of php...I don't know if you receive enough appreciation for all of your support -- but I know many people/Web loggers are grateful and lucky to have it.

  8. chaz19
    Member
    Posted 7 years ago #

    finally figured it out --

    I think I over complicated the code, and instead am using:

    <?php
    $posts = get_posts('numberposts=1');
    foreach($posts as $post) :
    ?>
    <h2> <?php the_title(); ?></h2>
    <small><?php the_time('F jS, Y'); ?></small>
    <?php the_excerpt(); ?>
    <?php endforeach; ?>

    thanks for all the help again

  9. moshu
    Member
    Posted 7 years ago #

    You are very welcome. Glad you figured it out - today I was less around the computer... because the "big paycheck at the end of the day" comes from 'normal, real' jobs. This is just a volunteer "hobby" ;)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.