Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Embedding Wordpress Posts In Other Pages


13 replies to this topic

#1 mrdee

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 810 posts
  • Gender:Male
  • Location:Slough (UK)
  • myCENT:90.63

Posted 19 February 2011 - 08:27 PM

I have set up my wordpress and want to get it into my existing webpages instead of the manually edited articles I currently use.

However, as I already have my site laid out, I don't want to embed the entire wordpress page. I only want to include the articles, but keep the formatting which I had set up in wordpress.

I tried to follow this guide but it just resulted in plain text appearing in the page, which isn't what I want.

If anyone could help me out here, that would be brilliant.

#2 mrdee

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 810 posts
  • Gender:Male
  • Location:Slough (UK)
  • myCENT:90.63

Posted 25 February 2011 - 11:23 AM

Maybe to clarify a bit further:

My website looks similar on all pages, I have just made 2 tables, one on the left, where the menu appears, and one on the right, where the main page (as chosen in the menu) appears.in the main table,
I want to keep it like that, only, for my news pages (Dutch and English), I just want the layout left intact, except that, in the main table, I want the

articles to appear as Wordpress blog posts, rather than just separate tables with text and pictures in it.

I have made a screenshot to show what it looks like at the moment, sorry there is only one bit of a table visible in the main section (on the right), but it concerns a very long article here, but, anyway, anythig that appears below is just the same, ie. a table, with the date top left, the title of the article under neath, and then the main text of the article.

The main reason why I am posting this here is because the Wordpress support is not always very clear to search, and the explanations are sometimes difficult to understand, and also, because the forums are not always very helpful neither.

Anyway, here is a screenshot of my news page:
Attached File  newspage.png   46.85K   8 downloads

Hope that makes things a bit easier to understand.

#3 sonesay

    |||[ n00b King ]|||

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 958 posts
  • Gender:Male
  • Location:Auckland
  • myCENT:68.27

Posted 25 February 2011 - 10:30 PM

View Postmrdee, on 25 February 2011 - 11:23 AM, said:

Maybe to clarify a bit further:

My website looks similar on all pages, I have just made 2 tables, one on the left, where the menu appears, and one on the right, where the main page (as chosen in the menu) appears.in the main table,
I want to keep it like that, only, for my news pages (Dutch and English), I just want the layout left intact, except that, in the main table, I want the

articles to appear as Wordpress blog posts, rather than just separate tables with text and pictures in it.

I have made a screenshot to show what it looks like at the moment, sorry there is only one bit of a table visible in the main section (on the right), but it concerns a very long article here, but, anyway, anythig that appears below is just the same, ie. a table, with the date top left, the title of the article under neath, and then the main text of the article.

The main reason why I am posting this here is because the Wordpress support is not always very clear to search, and the explanations are sometimes difficult to understand, and also, because the forums are not always very helpful neither.

Anyway, here is a screenshot of my news page:
Attachment newspage.png

Hope that makes things a bit easier to understand.



I had a look at the example link where you are using as a guide. Your main problem is it has no styles correct? I think this is probably due to a setting you've set in the first snipplet of code

<?php
    // turn off WordPress themes and include the WordPress core:
    define('WP_USE_THEMES', false);
    require($_SERVER['DOCUMENT_ROOT'] . '/wordpress/wp-blog-header.php');
?>




I'm guessing the WP_USE_THEMES = false will cause wp to output your content in just plain text. I have no personal experince of word press my self so I am only guessing that is what is happen. If that is the case then maybe you can try turn it on just to see the effect. If that still does not do what you need then it may look like you need to somehow create your own CSS to format it. You can probbaly do this by getting at your table container and selecting what ever child elements underneath it to style it as you please.

Could you possible paste the entire html code generated by your page I would be interested to see what it actually outputs.

#4 Baniboy

    Advocatus Diaboli

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 878 posts
  • Gender:Male
  • Location:/root
  • Interests:Everything...
  • myCENT:37.47

Posted 26 February 2011 - 10:56 AM

I'm not sure if I understood correctly. But if you want to use the WordPress database with your current layout you can simply turn it into a WordPress half-theme. Just open theme files of another WordPress theme, then you can simply copy-paste some of the WordPress php (ie. the ones of the articles, if that's what you want) code to your layout. The code will be easy to figure out as it'll have functions like e_articles_date(xxxxx) or such (also remember to copy the php code from the header.php to get the meta and title tags from wp). After you've turned your layout into a WordPress theme, make another copy of the earlier theme folder (from which you got the code) and place it renamed in the same wp-content/themes folder. Then copy your own modified layout/theme (index.php and style.css) to the renamed folder, replacing the existing index and css files. Navigate to your WP admin panel and activate the new theme. Then go to the WordPress settings->('General') and set a new path for your news pages (like yourdomain.com/news) in the "Site address (URL)" textbox.
If you want to use some of the WordPress for something else and some of the articles for your news page, I don't know. I guess you could have 2 WordPress installations for each but I wouldn't recommend it's too complicated.
And, for embedding WordPress I guess you'd have to do so many file includes (to load the wp core and connect to database) that by then you could just make a half-theme.

Also, you shouldn't use tables for your layout.

EDIT: I just found something that might help. Just remember that after you load the core through the header you have to write out the php to get the posts as well.

Edited by Baniboy, 26 February 2011 - 11:04 AM.


#5 mrdee

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 810 posts
  • Gender:Male
  • Location:Slough (UK)
  • myCENT:90.63

Posted 26 February 2011 - 01:26 PM

OK, gentlemen,

thank you for the replies.

And, Baniboy, the solution looks difficult (I'll come back to that in a minute), but the first thing I noticed, and something that bugs me is when you say: "Also, you shouldn't use tables for your layout.".

You are probably right, but could you say what the problem with tables is, and also: what else was I supposed to do then?
I wanted the menu to appear on the left hand side of the page, and I also wanted it to stay in its proper place, that is why I used tables.
In the old days, I would have used frames, but apparently, they are practically completely obsolete.

Now, for your other advice:
It does look quite complicated and long-winded, but my site uses predominantly HTML, I only use PHP for special features, such as my greeting cards, or forms that appear on my pages, however, the link you included will be of help to me if i go through it step by step.

I have also installed 2 copies of Wordpress locally to do some practice (it does not matter then if I mess something up).
By the way, the two copies are (as far as I could make out from Wordpress support) becaus my site is bilingual, so I installed a Dutch and an English copy.

By the way, I have a funny experience when trying to add a new post: The title field is fine, a cursor flashes in it and I can just type my title in. However, in the main body of the post, everything I type is invisible, all I can see is some red underlining.
I can only see what I have typed by highlighting, I have looked for a setting to change the text colour, but with no luck.
Is it a bug, or would it have something to do with the fact I am running it locally?
I certainly cannot find anything in Wordpress support.

Anyway, I shall follow your advice, and the advice on the page you referred me to step by step and see where I end up.

Once again, thank you, everyone, for all the good advice.

Edited by mrdee, 26 February 2011 - 03:01 PM.


#6 Baniboy

    Advocatus Diaboli

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 878 posts
  • Gender:Male
  • Location:/root
  • Interests:Everything...
  • myCENT:37.47

Posted 26 February 2011 - 06:03 PM

Yes I know you want to keep it static, so that's why I was only suggesting to do it to your news section. Because if you're going to post frequently, it's better to let WordPress do it instead of creating static pages.

About the tables thing... well, content inside tables doesn't show up until ALL of the content inside it is loaded. Also, I have heard tables slow the page down. Someone viewing your website on a cellphone might not like it that much. There are, of course, other reasons. Mainly I think it's a trend. Users won't probably care or notice, but see how when ks loads the main page? You have to wait for it to load each table's (the forums list) content before it shows it. Well, you can't notice it normally, but I use my phone to browse here and I do notice it. And tables are (for me, atleast) harder to understand and visualize instead of a div structure. But, if you have a lot of nested divs it'll be hard to understand that as well so I guess it doesn't matter if you don't put tables in tables or something like that.

IF you do want to change it, however, I have posted a tutorial on this. Though I'm not sure if it's that good because I didn't explain things separately, but just put the code and explained it in CSS comments. LINK

About your posting problem, I have no idea. Try going to the "HTML" tab in the posting window and see if WordPress has added anything that alters the color.

#7 mrdee

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 810 posts
  • Gender:Male
  • Location:Slough (UK)
  • myCENT:90.63

Posted 26 February 2011 - 06:59 PM

Thank you again for that, Baniboy.

First of all, it is indeed only the news page (or rather, both, the English and Dutch one) that I want to work on Wordpress.
They also get updated regularly (at some times even daily, or more than once a day, depending on the importance of the current news).

I will also have alook at the tutorial you posted and see what i can come up with.

About my editing problem in Wordpress: the funny thing is (forgot to mention that) that the "Visual" and "HTML" tabs do not react to mouse clicks at all.
Also, the "Help" button and the "Screen Settings" button (this name might be wrong here, but it is something similar), at the top right of the page do not yield any reaction whatsoever to mouse clicks, I can't test a "live" Wordpress version at the moment, so I am not sure whether it is a bug, or whether it has something to do with the fact that I am running Wordpress locally (with Apache and WAMP, etc.), maybe time will tell.
I have also tried to copy and paste HTML from my existing page into the edit box, and that gives me a "This post can not be found" error when doing a preview.

Oh, by the way, I am using the latest version (3.1) of Wordpress.

Nevertheless, thank you so much for your continuous input. :)

#8 Baniboy

    Advocatus Diaboli

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 878 posts
  • Gender:Male
  • Location:/root
  • Interests:Everything...
  • myCENT:37.47

Posted 26 February 2011 - 09:56 PM

Hmmm, then there seems to be something wrong with the Javascript. Make sure you have Javascript enabled in your browser. If that doesn't work then download another copy of WordPress and replace the wp-admin folder in your installation by the wp-admin folder of the new download.

#9 mrdee

    Privileged Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 810 posts
  • Gender:Male
  • Location:Slough (UK)
  • myCENT:90.63

Posted 28 February 2011 - 01:03 AM

Yes, there is probably something that needs re-installing, because my browser is ready to run Javascript, and I did exactly the same on my PC (what I just explained, I did on my laptop) and there it works 100%.

However,it might work fine, and I may be able to write articles and lay out my pages properly, the integration into my existing page seems to be a big no-no.

I tried to follow the instructions on the link I was given, regarding integration of a Wordpress page in my existing page, so I copied the news page of my existing website, left the left table (with the menu) intact, and cleared the right frame, except for the table tags.

Then, according to the instructions, in the table on the right, I copied the following:

<?php  
/* Short and sweet */
define('WP_USE_THEMES', false);
require('http://127.0.0.1:8888/wordpress/ndl/wordpress/wp-blog-header.php');
?>


A little explanation: the "http://127.0.0.1:8888/" bit is because I run Worpdpress locally at the moment (via EasyPHP), and the rest of the line is because, according to the instructions, I made a second folder into the wordpress folder, where the Dutch version of my Worpress resides.
The folder is called "ndl", and inside is the full Wordpress structure again, but then with Wordpress 3.1 in Dutch.

It looks like both languages work.

Anyway, I called this file 'index.htm' and put it in the root directory of the local site first, where I was greeted with either a blank page where the code was to appear, or, in the beginning, I saw

Quote

"; ?>
printed on the screen, the final part of the snippet, but I managed to get rid of that.

I then also moved the page to the root directory of the Dutch Wordpress, also called 'index.htm', but the result was the same, a blank page in the right hand half of the page.

I also tried two more snippets that were recommended by the tutorial site, one that was supposed to show all the posts, and one that was supposed to show a certain number of posts:

<?php
require('http://127.0.0.1:8888/wordpress/ndl/wordpress/wp-blog-header.php');
?>

and
<?php
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : start_wp(); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>    
<?php the_excerpt(); ?> 
<?php
endforeach;
?>

The result?
Well, every one of those, pretty much showed me the same: an empty right half of the page staring me in the face.

The experts among you (or certainly more advanced people) will probably see that I am being very clumsy here, but I have tried all sorts of possibilities, and at least one thing is very consistent: the result is the same every time.

So, with what I have tried to describe here as accurately as i could, has anyone seen yet where I am going wrong?

Thanks for all the help so far (although I seem to end up getting grey hair).

Alos, at the risk of repeating myself: the reason why I am trying out Wordpress locally on my machine at the moment is because I do not want to run the risk of doing some irrepairable/very deifficult to repair damage to my existing website.

Edited by mrdee, 28 February 2011 - 01:08 AM.


#10 Baniboy

    Advocatus Diaboli

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 878 posts
  • Gender:Male
  • Location:/root
  • Interests:Everything...
  • myCENT:37.47

Posted 07 March 2011 - 08:07 PM

Sorry, I have been away for a long time. Found some time to be on now.
So are you using frames or tables now? Anyway, the index.htm is wrong. It's supposed to be a PHP file, so rename the file to index.php.
I don't know how using frames affects the WordPress code, but I do smell some trouble with that.

EDIT: I'm also not sure what happens when you have nested WordPress roots. What I meant by changing the URL was that you did it through the settings menu, not change actual file structure. Not sure if this is what you meant by the "instructions", tho.

Edited by Baniboy, 07 March 2011 - 08:14 PM.





Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users