Wordpress into an existing PHP site

Hi

I’ve managed to integrate my blog into my website but I’m not sure if I’m doing it the cleanest way (I’ve picked it up from various blogs/ forums etc)

I’d also like to use tags or categories to select which posts to show (like a WHERE clause in SQL would)

IE: Only show posts with a tag (or category) of “YAL”

My code below:


<?php
global $post;
$args = array( 'posts_per_page' => 20 );
$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(); ?>"><?php the_content(); ?>

<?php wp_get_attachment_image(); ?><?php get_tag(); ?><?php get_category(); ?> (these don&#8217;t actually work)

</a><br />
<?php endforeach; ?>

Thanks Force Flow :slight_smile:

I’m completely lost here, I’ve tried various methods (found online) but cant help but feel I’m missing the basics!

Hi there,

So let’s briefly take a step back.
Could you tell us a little bit about what you have done.
Your title alludes to the fact that you have integrated WP into an existing site.
Is this correct?
Is the WP install confirmed as working?
It would help if you could share the url of your site.

Hi Pullo

My site is not actually live yet but woill be www.togganet.co.uk.

I’ve uploaded the page with the wordpress features here: http://www.togganet.co.uk/YAL.php

When I say I’ve integrated it, I mean I have managed to pull from my worpress blog into my homepage. IE Take the article/ title etc

The blog is live on www.togganet.co.uk/blog - I want to use this as a background tool to populate my main site. I wnat to use categories to seperate different articles

Ok, so “Latest News/ Articles” is pulled in from your WP blog, which is on the same domain.
How are you doing that?

I’m using the code below:

<?php
/* Don't remove this line. */
require('./blog/wp-blog-header.php');
?>

In addition to the code in the OP

Oh ok.
I’m not sure that this is the best thing to do here, as by simply requiring the file “wp-blog-header.php” you don’t have any control over how the output is formatted.
What is a more common way of doing this, is to embed a feed from your blog (which can then be ordered chronologically or whatever) in your main site.
The feed would be generated automatically and would contain the title of each article, a short blurb/description and a link to the full article.

Thanks Pullo

I’ll look into this now

Really appreciete your help