WordPress.org

Support

Support » Localhost Installs » renaming index.php

renaming index.php

  • 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

Viewing 7 replies - 1 through 7 (of 7 total)
  • esmi

    @esmi

    Forum Moderator

    Is this page part of your WP site?

    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

    esmi

    @esmi

    Forum Moderator

    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.

    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!!

    esmi

    @esmi

    Forum Moderator

    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.

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

    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!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘renaming index.php’ is closed to new replies.
Skip to toolbar