WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Displaying the latest post title on a regular home page (4 posts)

  1. amyrogers
    Member
    Posted 7 years ago #

    I wanted to display the title of the latest post on my blog on my regular home page, which is file "home.php." This home page is at mywebsite.com/home.php. The blog is at mywebsite.com/blog/. I used the following code, but got an error.

    <?php
    require('blog/wp-content/themes/amy/header.php');
    ?>
    
    <?php query_posts('showposts=1'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a><br />
    <?php endwhile;?>

    Error message:

    Fatal error: Call to undefined function: language_attributes() in /home/server/amy/mywebsite.com/blog/wp-content/themes/amy/header.php on line 2

    How do I fix this?

  2. Kafkaesqui

    Posted 7 years ago #

    <?php
    require('blog/wp-blog-header.php');
    ?>

    Try that.

    Reference:
    http://codex.wordpress.org/Creating_a_Static_Front_Page#Integrating_WordPress

  3. amyrogers
    Member
    Posted 7 years ago #

    Thanks very much, Kafkaesqui. I thought "wp-blog-header.php" was just a placeholder for the real thing. I got it working now. PHP is amazing.

  4. DevonTT
    Member
    Posted 6 years ago #

    What would it look like if I wanted to include the date and time of the post?

    Also, what if you wanted to display more than one headline (with time and date)?

    Thx

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.