WordPress.org

Ready to get started?Download WordPress

Forums

Use text from my word press page elsewhere on my website (12 posts)

  1. paulcronin
    Member
    Posted 3 years ago #

    Hi,

    I'm new to Word Press, have read the FAQs, trouble shooting pages and have googled but couldn't find the answer to what I thought was a simple question:

    I want to include text from my word press 'page' elsewhere on my website.

    Here's a worked example of what I want to do:
    I have created the page 'about' in the Word Press dashboard.
    I have webpage about_us.php, and want to include the text from my new Word Press 'about' page in about_us.php.
    In this way I'd be using Word Press as a simple CMS where text from my 'about' page ends up on about_us.php.

    I just need a point in the right direction.

    Example code for this would be even better!

    I know Word Press has so much more to offer than this simple functionality, but this would be so very useful.

    Thank you for any pointers,
    Paul

  2. paulcronin
    Member
    Posted 3 years ago #

    P.S. I have installed Word Press 3.0.1 to mydomain.com/cms/

  3. Mike Schinkel
    Member
    Posted 3 years ago #

    Are you wanting to have your webserver serve the about_us.php page directly from a URL? If so, that's not normally how WordPress works; instead you'd add the text from that page into your "About" page using the WordPress admin.

    If instead you are saying you have two WordPress "Pages" at the URLs "/about/" and "/about-us/", for example, and you want the content entering into the "About" page somewhere on the "About Us" page then what you want is to create a "WordPress Page Template" (google it to learn how) by copying page.php from your theme to another file name (the name about_us.php would be okay) and then insert this code into your theme where you want the text to display:

    <?php
    $page = get_page_by_path('about');
    echo apply_filters('the_content', $page->content);
    ?>

    Hope this helps.

    -Mike

  4. paulcronin
    Member
    Posted 3 years ago #

    Hi Mike,

    I'm afraid I'm still a little confused. I have my own, existing web pages, and I want Word Press to supply content for those pages.

    I just want to the text input into word press on these pages. I don't want an entire 'word press site'.

    Thanks for any pointers,
    Paul

  5. Mike Schinkel
    Member
    Posted 3 years ago #

    That approach is foreign to me so not sure how you'd go about it. I'd try migrating to WordPress if I were you. Sorry, otherwise I can't really help. :-(

  6. DaisyMariposa
    Member
    Posted 3 years ago #

    Paul,

    Can you please clarify what you're trying to do?

    And why you're trying to do it?

    • Do you want an RSS feed from your blog inserted into a page on your Web site?
    • Do you want to copy-and-paste text from your blog posts into a page on your Web site?
    • Do you want to have text automatically transferred from your blog to your Web site?
  7. paulcronin
    Member
    Posted 3 years ago #

    Mike

    That approach is foreign to me so not sure how you'd go about it. I'd try migrating to WordPress if I were you. Sorry, otherwise I can't really help. :-(

    I do have WordPress?

    Daisy
    I'm simply trying to pull out the text from my word press pages and insert into my already existing website pages automatically. I just want to pull out the text from my WordPress 'about' page to my website 'about us' page.

    I thought this would be pretty straight forward for something as powerful as WordPress.

    Thank you for any insight out there,
    Paul

  8. DaisyMariposa
    Member
    Posted 3 years ago #

    Paul,

    I'm not aware of a way to do what you want automatically.

    I wanted the text from the About page for the blog I created for a friend to appear in a blog post, so I copied the text on the About page and pasted it into the post.

    It didn't even take a minute for me to accomplish this.

  9. paulcronin
    Member
    Posted 3 years ago #

    I'm not looking for a copy and paste solution!

    I would have thought WordPress could do this.

    I guess I try a more traditional CMS.

    Thanks

  10. Mike Schinkel
    Member
    Posted 3 years ago #

    Paul,

    Of course you can do it in WordPress. WP is probably the most flexible CMS available. I just did not want to encourage you to use an approach that is anti-thetical to WordPress best practice.

    This following works as a standalone file from the root of your WordPress directory:

    <?php
    include "wp-load.php";
    $page = get_page_by_path('about');
    echo apply_filters('the_content', $page->post_content);

    If your WordPress root is not in the same directory as your about_us.php file then you'll have to do something like this:

    <?php
    include "/path/to/your/wordpress/root/wp-load.php";
    $page = get_page_by_path('about');
    echo apply_filters('the_content', $page->post_content);

    Hope this helps.

    -Mike
    P.S. And please consider moving your site to WordPress instead of using this approach. You'll get so many benefits if you do...

  11. paulcronin
    Member
    Posted 3 years ago #

    Hi Mike,

    Thank you, that did the trick.

    I'll certainly be trying out more of word WordPress' features in future, but this is great addition for a pre-existing site.

    Thanks,
    Paul

  12. Mike Schinkel
    Member
    Posted 3 years ago #

    Be sure to check out http://wordpress.stackexchange.com if your future questions go unanswered here.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags