• I am currently looking to implement WP blog functionality within an HTML theme (client desired to do this, not me). I am doing this using an iframe call. I am curious if there is a theme that just displays the blog posts and nothing more. Along with this, is it possible to implement a search function and most recent posts elsewhere on the page, or must it also be contained within the iframe reference? Many thanks for the help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi setshot50,

    Using iframes to display content from a WordPress blog could get messy pretty quickly, depending upon what you’re trying to accomplish.

    You might consider integrating WordPress into the website using PHP. This page in the codex gives some quick examples and the basic code needed to make calls to WordPress so that it outputs the content into whatever page(s) you’d like to have it appear.

    If you take this route, the WordPress posts will be “themed” by the CSS on the site you’re integrating them into. The actual WordPress theme won’t really matter so much.

    This is just enough to provoke some thought. If you’d like more help, perhaps you could provide some additional details on exactly what you’re trying to accomplish. A link to what you’re working on might be helpful also.

    Cheers!

    Thread Starter setshot50

    (@setshot50)

    Many thanks for your reply. If you would kindly take a look at this page you’ll see the blog I am trying to implement (A blog relating to…). I’m relatively new to this world (old school HTML guy). I’ve modified the CSS file a bit to provide a more integrated look. It would be nice if I could just pull the posts from WP and not necessarily the styling. Also, in the right hand column, I would like to have the widgets (e.g., search, recent posts). Is this possible?

    Hi setshot50,

    Yes. What you’re trying to accomplish is doable. In fact, integrating WordPress instead of using an iFrame is the best way to get the content (posts) from WordPress without any styling.

    The link I mentioned previously provides great info, but perhaps some additional amplification will help you get going.

    First things first: you’re going to want to change that .html file into a .php file.

    Then, at the top of the file, you’ll want to include this bit of code before your HTML output starts (even before the <!DOCTYPE> declaration:

    <?php
    require('/the/path/to/your/wp-blog-header.php');
    ?>

    Obviously you need to change the path there. From what I can see for the page you linked to, it might look like this:

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

    This code essentially “calls” WordPress and says “I’m planning to query you on this page.”

    Then, once you get to the portion of your page where you’d like the posts to appear, you could use code like this;

    // Get the last 3 posts.
    
    <?php
    global $post;
    $args = array( 'posts_per_page' => 3 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a><br />
    <?php endforeach; ?>

    This code (above) is a very, very basic version of what is known in WordPress parlance as “The Loop.” It is highly, highly customizable.

    The super-simple version above would pull up the last 3 posts and output them into your page’s html code.

    For starters, you could try putting that code into your page after this line: <div class="innercontent">

    Everything coming out of WordPress at that point would obey the CSS rules for your “innercontent” ID.

    If you wanted the WordPress post titles to have an <h2> tag, then you would modify the above code as follows:

    // Get the last 3 posts.
    
    <?php
    global $post;
    $args = array( 'posts_per_page' => 3 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><h2><?php the_title(); ?></h2></a><br />
    <?php endforeach; ?>

    The options you have are (nearly) endless. You can display an excerpt of your post(s), the entire post content, permalinks to the posts with the titles, only the titles (with or without links), and additional stuff like your category(-ies), tags, author(s), etc.

    If you’d like to give this a shot and let me know if you have specific questions about modifications you’d like to make, I’d be glad to provide some additional help.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Implementing WP in HTML’ is closed to new replies.