WordPress.org

Ready to get started?Download WordPress

Forums

renaming index.php (8 posts)

  1. dopple142
    Member
    Posted 7 months ago #

    Hi all,

    I have WordPress installed on my server and it all works fine.
    If I go to my index.php it displays all my blogs as expected.

    I am trying to pull my blogs into a different php page with little luck.

    I have been researching this for some time now. I have read i a lot of placed that is you make it WordPress ready and add the loop it should work.

    i add require('wp-blog-header.php'); - this works.

    however the loop cannot find any of my posts.
    If i past exactly the same code into index.php it works.
    So as soon as the file name is changes it can not find my posts.

    Any help on this would be hugely appreciated!

    Thanks

  2. esmi
    Forum Moderator
    Posted 7 months ago #

    Is this page part of your WP site?

  3. dopple142
    Member
    Posted 7 months ago #

    Hi esmi,

    Thanks for the response...

    No it is a separate php page.
    I have however made some progress....
    The loop I was using which seems to be everywhere I look when researching did not have a $posts = get_posts query.
    I found an alternative loop which does and I am now populating the page (in a fashion!)
    I'm now trying to work out how to format (theme) my content .
    Any ideas if it would be better to customize the theme using css within the separate php page or define a customized theme with in wp?
    Im not sore what the benefits would be either way.

    Thanks

  4. esmi
    Forum Moderator
    Posted 7 months ago #

    I'm not sure if there is a better way here. It's really down to what suits your needs best. If you intend to just have this one page showing posts, then I'd say that using CSS on that page would be the better option. If, however, people will be able to click on a link to see the single Posts, you might want to look at developing a customised theme. It's a bigger job but would be the best approach if you want a seamless visual look to all of your pages.

  5. dopple142
    Member
    Posted 7 months ago #

    Yes that does make sense.

    I have had a loo at defining a theme using
    define('WP_USE_THEMES', true);
    at the start but it displays the theme but states it cannot find any posts

    "Not Found

    It looks like nothing was found at this location. Maybe try a search?"

    however if you then scroll down to underneath the footer it then displays my posts..

    have you seen this happen before?

    Thanks again!!

  6. esmi
    Forum Moderator
    Posted 7 months ago #

    Drop a copy of the file into the pastebin and post the pastebin url here. Perhaps someone will be able to spot the problem and suggest a solution.

  7. pvashist75
    Member
    Posted 7 months ago #

    Yes please share your code that you are using for the page. May be there's something missing which we can correct.

  8. dopple142
    Member
    Posted 7 months ago #

    Thanks guys!

    Here is a link to the output

    http://www.pumphouseapps.co.uk/Pumphouse_new_website/wp.php

    and here is the code

    <?php
    define('WP_USE_THEMES', true);
    require('./blog/wp-blog-header.php');
    ?>
    <?php
    /**
    * @package WordPress
    * @subpackage Default_Theme
    */

    //get_header(); ?>

    <link href="css/wordPressEmb.css" rel="stylesheet" type="text/css">

    <div id="sidebar2">
    <?php get_sidebar('right'); ?>
    </div>

    <?php
    $posts = get_posts('numberposts=10&order=DESC&orderby=post_title');

    foreach ($posts as $post) : setup_postdata( $post ); ?>
    <div id="date">
    <?php the_date(); echo "
    "; ?>
    </div>
    <div id="content">
    <?php the_content(); ?>
    </div>

    <?php
    endforeach;

    ?>

    Thanks again!

Reply

You must log in to post.

About this Topic