how to display recent 5 posts from wordpress site to magento - wordpress

I'm having magento ecommerce website & wordpress blog site. I want to display recent 5 blog posts in my magento homepage. I tried with below codes
// Get the last 3 posts.
<?php
require('/the/path/to/your/wp-blog-header.php');
?>
<?php query_posts('showposts=3'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?><br />
<?php endwhile;?>
I copied this file in new .phtml file and i called that file to homepage. But after doing this my homepage is showing only header & breedcrumbs...
Any solution for this problem is appreciated......

Don't integrate on the php side, use the rss feed with a feed reader such as http://www.magentocommerce.com/magento-connect/flagbit-feed-reader.html

Related

simple html site to wordpress and edit visually

I am converting a very simple html site to WordPress. I made a very simple folder like,
custom_theme
header.php
front-page.php
about.php
footer.php
I cut all the code from index.html and spared them into header,footer,front-page,about.
then in the wp dash board i created those page and select the template. The site is working fine.This is the live site
http://www.mannmechanicalhvac.com/
Now i want to edit the content and image from wordpress visually not from code. Is their any possibility to do that?
###thanks in advance.
A very basic example:
<?php while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<div class="page-content"><?php the_content(); ?></div>
<?php endwhile; ?>
the_content() outputs the content which was entered in the editor.
This is a good starter theme: _s from Automattic
or: http://underscores.me/
Recommend to read:
Stepping_into_Templates
Theme_Development
Template_Tags
template-hierarchy
The_Loop

Wordpress showing post info under new pages, but I want it to show only under new posts

I have basic loop to show PHP posts
if (have_posts()) :
while (have_posts()) : the_post(); ?>
<div class="post">
<h2><?php the_title(); ?></h2>
<div class="post-info"><?php echo get_the_date(); ?> - posted by <?php echo get_the_author(); ?> </a></div>
<?php the_content('<button class="show-more">Saznajte više</button>'); ?>
</div>
<?php
endwhile;
else :
echo "<p>No posts</p>";
endif;
It is the line that has <div class="post-info...
Now it is working very well, it shows date and author under post heading, but it also shows that when a new page is created. I understand Wordpress works like blog and it is natural for it to treat new pages as posts, however I want to avoid that behavior. I only want it to be shown under post headings, but not under new page headings. What would you suggest me?
https://developer.wordpress.org/themes/basics/template-hierarchy/
Check this template hierarchy and you'll understand how WordPress call template files.
Basically, WordPress firstly runs index.php and then call different template files. Since you only have index.php, so when rendering pages it all also falls back to index.php.
What you can do is creating a page.php with its own design for WordPress to call properly.

Page layout (page.php) doesn't apply to pages

I made few pages in my admin panel. Then created page.php with this code inside
`<?php get_header(); ?>
<section>
<?php if (have_posts()): while (have_posts()): the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</section>
<?php get_footer(); ?>`
Set one of this pages as "homepage". And when i open site it shows me header, footer... everything it should, but when i try to open any of the other pages, I get 404 page...
Help me please, where i have to search for mistakes?
Thank you
You need to define one of the following: index.php (REQUIRED), home.php, or front-page.php.
Here's the way template inheritance works for the home page:
WordPress looks for front-page.php, regardless of whether or not your site is set up to show a static front page, or your most recent posts
If front-page.php doesn't exist, WordPress looks for home.php
If no home.php is set, WordPress defaults to index.php
You can read more about template inheritance in the codex.

Wordpress Latest Blog Entries Plugin for Website

I would like to display my blog entries on my website in an iframe or whatever suggested method is. Can somebody please advice how to do that?
Thanks in advance.
Hi,
There are multiple options to do this I am mentioning three of them:
Menthod # 1
You can create a page template in wordpress and than using that page template create a page. Now you have the URL you can use that page in iFrame on any website.
Method # 2
Create a file at the root level of the server with this code:
<?php
// Include WordPress
define('WP_USE_THEMES', false);
require('wp-load.php');
query_posts('showposts=1');
while (have_posts()): the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<p>Read more...</p>
<?php endwhile; ?>
Now you can call this file in the iFrame and you have the latest posts.
Method # 3
You can use the rss feed from wordpress and either use PHP or jQuery to style it.
Thanks
Peachlabs

How to get posts' content as HTML from a wordpress blog remotely

I have a self-hosted WordPress blog, and I am making a static home page for my website based on jQuery.
So, I wanted to display some content from my blog, on my home page (in widgets), as a news section.
For example, I may fetch
the latest five posts' titles and content
OR a specific page content (via passing the page id)
OR a specific post (via passing the post id)
So does WordPress include any PHP file that shows the posts contents as plain text, or HTML?
I thought about fetching the blog's RSS, and then show it on the page, but the RSS doesn't provide the full content of the post.
If it's hosted on the same server, you could integrate WordPress into your app by including wp-blog-header.php, and then call get_posts(), using setup_postdata().
For example:
<ul>
<?php
global $post;
$tmp_post = $post;
$myposts = get_posts('numberposts=5&offset=1&category=1');
foreach($myposts as $post) :
setup_postdata($post);
?>
<li><?php the_title(); ?></li>
<?php endforeach; ?>
<?php $post = $tmp_post; ?>
</ul>
Take a look at Yahoo! Pipes.

Resources