• envision

    (@envision)


    On my portfolio-site I wanted to have word-press maintain the short “news and updates” posts on my front page. The goal is to have WordPress do the heavy-lifting and THEN transparently pull the posts into the external web-site with a little php-magic!

    The starting point to accomplish this is here:
    https://www.transycan.net/blogtest/2005/07/05/integrate/2/

    This may only take you half-way though. I dynamically build my entire page FIRST storing all output into a php-variable as a string. Only when the page is complete do I print the whole thing in one shot.

    The Major Problem:
    ——————-
    Most of WordPress’s ‘Template-Tag’ functions “echo” their output rather than sensibly returning a value. I suppose somebody skipped the class on ‘Get_member() and Set_member() functions…

    Regardless, for some ‘Template-Tag’ functions the final parameter is a boolean value to toggle ‘display’. Use FALSE to GET the value and store it.

    Other functions employ other tricks. For ‘the_tag()’ you may be simply be able to use ‘get_tag()’ or ‘get_the_tag()’ in some cases. In others more work is needed.

    Searching the WordPress web-site docs, and forums reviles the solution to all of these but you will have to work for it.

    The End
    ———
    This took much longer than I wanted to spend on it, so not- much explanation but here’s some PHP to help the next guy in-line.

    This will be in action on https://www.stevengpeterson.com probably later this week. Right now all updates are on the private-dev-site.

    /* WordPress Integration
    ********************************************/
       $display .= "<div>";
    
    if (have_posts()) : while (have_posts()) : the_post();
    
    $wp_date = the_date('','<h3>','</h3>', false);
    $wp_postID = get_the_ID();
    $wp_permalink = get_permalink();
    $wp_title = the_title('','',false);
    
    $wp_author = get_the_author();
    $wp_time = get_the_time();
    $wp_content = apply_filters('the_content', get_the_content());
    
    $wp_category = "";
    foreach((get_the_category()) as $category) {
        $wp_category .= $category->cat_name . ', ';
        }
    
       $display .= "$wp_date
          <div class=\"post\" id=\"post- $wp_postID\">
             <h3 class=\"storytitle\"><a href=\"$wp_permalink\"
                rel=\"bookmark\">$wp_title</a></h3>
    
             <div class=\"meta\">$_eFiled $wp_category —
                $wp_author @ $wp_time
                </div>
    
             <div class=\"storycontent\">
                $wp_content
                </div>
    
             <div class=\"feedback\">
                </div>
          </div>
    
    endwhile; else:
    $wp_apology = _e('Sorry, no posts matched your criteria.');
    
       $display .= "<p>$wp_apology</p>";
    endif;
    
       $display .= "
          </div>";
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter envision

    (@envision)

    wierd – some of my code is being truncated above if the line is too long. I clicked ‘edit’ and it’s all there, come back and it’s missing.

    Now the ‘edit’ is missing too…

    the content line for those who want it:

    $wp_content = apply_filters('the_content',
                                   get_the_content());

    Adam Brown

    (@adamrbrown)

    It’s not truncated. Use the scroll bar at the bottom of your post. And the ‘edit’ link is temporary; you only get to edit your post for the first several minutes after posting it.

    Thread Starter envision

    (@envision)

    ahh i see says the blind man.. ??

    I’m under some pressure this week, so bare with me. I solved it and posted the solution – so we’ll call it a successful day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Import WordPress Posts into a Pre-Existing PHP Site Layout!’ is closed to new replies.