• [ Moderator note: moved to Fixing WordPress. ]

    Ok, let me be very clear here, i am not talking about a php page, nor about anything made in wordpress, this is, a normal, regular html file made in dreamweaver, which serves as my sites index, i have no intention of converting the entire site to wordpress, i just want to put my latest post on the site index.html

    Ok, so, ive been looking around and nothing seems to work, many methods seem to require the page already be inside wordpress or made by wordpress, or otherwise be a php file.

    What i have is a website that i added a blog to, a normal, html site, which existed before i even knew wordpress did. I want to display my latest post on the site index, not AS the index, but just one of several items which show what the site is about and so fourth. One other display on the page is a facebook feed, which is just summarizations about certain blog entries or minor project updates not warranting new blog entries.

    Does anyone know how i can display at least 1 latest blog entry on the index.html page for my website? it doesnt have to have photos, or a style or anything, it can just be raw text in a box to get people to click on it so it then links them to the real thing, as i think people are accessing my site then not knowing where the blog is or what its about.

    Thankyou in advance for your assistance here.

Viewing 1 replies (of 1 total)
  • You need to fire an ajax request on php file which serves as an ajax response file and then you can return the blog data from there to your html file. Check below example i have implemented

    
    <!DOCTYPE html>
    <html>
    <head>
    	<meta charset="utf-8">
    	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    	<meta name="viewport" content="width=device-width, initial-scale=1">
    	<title>::TEST::</title>
    </head>
    <body>
    <div id="content">
    </div>
    <script src="https://code.jquery.com/jquery-3.1.1.js" type="text/javascript"></script>
    <script>
    	jQuery(document).ready(function(){
    		 jQuery.get("demo_test.php", function(data, status){
    	        jQuery('#content').html(data);
    	    });
    	});
    </script>
    </body>
    </html>
    

    this is just a normal html file i have placed at wordpress root with the name of “test.html” and created another file called “demo_test.php” with the below code

    
    <?php
    include 'wp-load.php';
    
    $args = array(
    	'post_type'	=> 'post',
    	'posts_per_page'	=> 1
    	);
    
    $query = new WP_Query($args);
    
    if($query->have_posts()):
    	$data = '';
    	while($query->have_posts()):$query->the_post();
    	$data .= '<h1>'.get_the_title().'</h1>';
    	$data .= '<div class="description">'.get_the_content().'</div>';
    
    endwhile;endif;
    echo $data;
    

    What it does basically is calls demo_test.php on page load and returns 1 latest post.

Viewing 1 replies (of 1 total)
  • The topic ‘embed latest posts on normal html page’ is closed to new replies.