• I’ve used the following code to embed the blog’s content on an existing website page. (via https://www.shooflydesign.org/buzz/past/embedding_wordpress.html)

    <?php
        // turn off WordPress themes and include the WordPress core:
        define('WP_USE_THEMES', false);
        require($_SERVER['DOCUMENT_ROOT'] . '/blog/wp-blog-header.php');
    ?>
    		<?php
        // get the most recent post(s) in category 1
        // change category=1 as needed for whatever page you're embedding
        // (in this case, just we're getting just one post, but it could be more)
        $lastposts = get_posts('numberposts=5&category=1');
    	$content = get_the_content();
    
    // spit out the content of the post(s)
    foreach($lastposts as $post) {
        setup_postdata($post);
        the_title ();
    	the_date ();
    	the_time ();
    	the_author ();
    	the_content();
    
    }
    
    ?>

    What appears in the test page as a result is the content and postdata described above but with no formatting. Like this:

    almost there. . .April 3, 200910:39 amryan
    test post content here.

    Where, “almost there. . .” is the post title. Followed by the date, time and author. aside from the obvious lack of formatting, it’s also missing the date being formatted as described in the WP blog’s theme. I know the injected Mini-Loop code that is being used says, use_themes; false, but is this formatting applied via CSS or some other method?
    Must be another method, but where? And what can I do to apply this formatting? And which items in the blog theme’s CSS sheet must I copy over to the original website’s CSS sheet (and without altering the look of the website)?

    I want the mini-loop to appear as:
    https://farm4.static.flickr.com/3311/3409011297_5ca6eece55_o.gif
    in the area specified on the existing site.

    Is all this formatting handles by a php file somewhere in the WP install? How can I get this custom page where I want the Loop to appear to call upon that php file? What do I insert and where?
    It’s not in the CSS is it?

    Obviously, I’m not too well versed in web coding… just enough to think I can figure it out and then get too far ahead and need help. So here I am. :]
    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter modularmule

    (@modularmule)

    anyone?

    it’s also missing the date being formatted as described in the WP blog’s theme

    I can’t see where it describes the default formatting for the_date in the Codex, so what you’re getting is, presumably the default.

    but is this formatting applied via CSS or some other method

    if you mean the date format, the_date is basically just an extension of PHP’s date() function, so if you require a different format, just use the format characters from the PHP manual.

    If you’re referring to the formatting/display of each piece of data, it’s going to depend, to some extent upon what tags you’re using and how. the_date, for example, allows for optional ‘before’ and ‘after’ parameters that can be used to insert the markup. But beyond what’s possible within each tag, the rest is normally applied via template files and CSS files within the currently active theme. So, if you disable the theme system, you’re pretty much going to have to add most of the extra markup and formatting yourself once you’ve grabbed the data.

    Thread Starter modularmule

    (@modularmule)

    thanks, esmi.
    got it.

    now, the problem is my loop is only displaying one post. and it’s not even the most recent post. what’s going on?

    <?php
        // turn off WordPress themes and include the WordPress core:
        define('WP_USE_THEMES', false);
        require($_SERVER['DOCUMENT_ROOT'] . '/blog/wp-blog-header.php');
    ?>
    		<?php
        $lastposts = get_posts('numberposts=0&category=1&orderby=date&order=DESC');
    	$content = get_the_content();
    	foreach($lastposts as $post)
        setup_postdata($post); 
    
    ?>

    what follows from there is all the markup for the_date, the title, ID, etc…

    I only need one instance of the div class for the “post” (including content, storytitle, etc), right?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘help with Mini-Loop formatting’ is closed to new replies.