WordPress.org

Forums

[resolved] Tying wordpress blog into another page (10 posts)

  1. chewbears
    Member
    Posted 4 years ago #

    Gotta say loving wordpress (as it is my first post).

    Here is what I would like to figure out if I can do. I have my site. Which is at mysite.com and I have my wordpress blog at mysite.com/news

    What I would like to know if it is possible is to tie "new posts" or posts of a specific caterogry on my mysite.com. I only have wordpress installed in the news folder, but was wondering if I could copy over some of the php to make this work.

    I think the easiest way to do this would be to move my wordpress blog over to mysite.com and just redo the permalinks to be names like I want, but! before I give up and do that wanna know if the tie in is possible.

    thanks!

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

  3. chewbears
    Member
    Posted 4 years ago #

    Rev. I consider myself a searcher, before poster, but you sir have made me feel like I just didn't know how to search : (

    Thanks, great links! Will implement and comment back if I have issues!

    Quick aside since you may be looking here : P

    <?php query_posts('showposts=3'); ?>
    <?php while (have_posts()) : the_post(); ?>
    " rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?>
    <?php endwhile;?>

    Where do you set the category? So if I want my news to show last 3 posts? Where do I place the category so that I can only show the last 3 posts from select categories.

    Thanks

  4. chewbears
    Member
    Posted 4 years ago #

    Rev., or anyone else that might be able to help!

    I have failed : (

    I have followed the directions in the links you provided and I can not get it to read the php.

    My site is advanceperformance.com and my wordpress is located at advanceperformance.com/news/

    I have :

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

    At the top of the page and my custom post display in a section called "blog"

    Anyone? I have also checked permissions and any other failing point. Don't know if it is something little I am just overlooking as I have been looking at this for some time now.

    Firebug isn't being very helpful either. I just notice none of the php is returning anything : ( so clearly something is wrong!

  5. chewbears
    Member
    Posted 4 years ago #

    any thoughts today? I went through it again last night and am baffled. Check spellings etc and nothing works ; (

  6. chewbears
    Member
    Posted 4 years ago #

    checked all the permissions and am at my last stand : P

    If I can not get this to work I guess I am trying something else.

  7. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    Just remembered to check this thread. Sorry for the delay, Here's how I do it...

    <?php
    // Include WordPress
    define('WP_USE_THEMES', false);
    require('../empire/wp-blog-header.php');
    query_posts('showposts=10');
    ?>
    </head>

    that bit of code goes just above the closing </head> as I've shown, some folks say it goes at the VERY top of your page.... but, that didn't work for me, it works perfectly where I have it. Notice I have ../empire two dots, you probably don't need that. My WP is in a subdirectory, so I had to back out of that, that's why I have the extra dot. Also, the file you are trying to attach to WP is a .php file correct? It can't be .html, but it's as simple as renaming it to .php and possibly adding this to a .htaccess file to tell browsers to use index.php rather than index.html
    DirectoryIndex index.php index.html

    Now, if you only want to use a certain category, you just include that in the above code here:

    query_posts('showposts=10');

    http://codex.wordpress.org/Function_Reference/query_posts

    so, an example: query_posts('showposts=10&cat=4');
    returns 10 posts in category 4

    so that sets up calling the posts...but nothing is displayed yet, so you just need to build a loop. That goes in the <body> section of your webpage somewhere, here's my loop:

    <div id="voodoorss">
          <?php while (have_posts()): the_post(); ?>
            <div class="dateIcon">
            <h5><?php the_time('M'); ?></h5>
            <p><?php the_time('j'); ?></p>
            </div>
            <div class="text">
            <h4><?php the_title(); ?></h4>
            <div class="thumb"><?php the_post_thumbnail(); ?></div>
            <?php the_excerpt(); ?>
    
            <a href="<?php the_permalink(); ?>">Read More...</a>
            </div>
            <br />
            <?php endwhile; ?>
        </div>

    That just displays the date in an icon, the title, the excerpt, a thumbnail, and the Read More as a link back to my blog

  8. chewbears
    Member
    Posted 4 years ago #

    Rev,

    I can not test it now but I can not believe I over looked the file extention : (

    I have index.html, I just completely over looked it. All these years of coding and I constantly make the smallest mistakes. Thanks for posting your example snippets, I should be fine with the code. In the mean time I did start to rough in buzzfeeder, which I think is amazing, lol, and I would vote as one of the greatest free to use RSS reader out there.

    So I am kinda glad I got stumped by such a simple thing like the .php and found another source.

    Again thanks for the post Rev. I will let you know how it goes, but I am certain the page will read the php now lol.

  9. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    It should definitely work, glad to get it sorted out!

  10. chewbears
    Member
    Posted 4 years ago #

    worked like a charm!

Topic Closed

This topic has been closed to new replies.

About this Topic