SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2013
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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 Code:
    <?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’t actually work)

    </a><br />
    <?php endforeach; ?>
    Last edited by Force Flow; Jul 29, 2013 at 09:06. Reason: added code tags

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2013
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Force Flow

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2013
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm completely lost here, I've tried various methods (found online) but cant help but feel I'm missing the basics!

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,061
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    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.

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2013
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  6. #6
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,061
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Ok, so "Latest News/ Articles" is pulled in from your WP blog, which is on the same domain.
    How are you doing that?

  7. #7
    SitePoint Enthusiast
    Join Date
    May 2013
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using the code below:

    Code:
    <?php
    /* Don't remove this line. */
    require('./blog/wp-blog-header.php');
    ?>
    In addition to the code in the OP

  8. #8
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,061
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    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.

  9. #9
    SitePoint Enthusiast
    Join Date
    May 2013
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Pullo

    I'll look into this now

    Really appreciete your help


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •