HOME       >>       Programming

Embedding Wordpress Posts In Other Pages Not all content required


mrdee

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.


mrdee

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:Hope that makes things a bit easier to understand.


sonesay

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:


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.

Baniboy

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.


mrdee

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.


Baniboy

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.


mrdee

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.


Baniboy

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.


mrdee

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://forums.xisto.com/no_longer_exists/" 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

"; ?>

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:

<?phprequire('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(); ?> <?phpendforeach;?>

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.

Baniboy

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.


anwiii

if not all content is required, then why not extract the information from your rss feed rather than individual posts and pages? i saw your post when you first posted and still not really sure what you want to accomplish except you want a news page. i am assuming you what to extract your posts and put them on your news page?take a look at my website "onlinecheapo.com" in my sidebars i have extracted information from my posts through my newsfeed on wordpress. once i make a post in wordpress which will affect my main wordpress page and the specific page the post is on, it will, my main page will automatically update to include the new posts. i think i have it set to show about 100 characters since it's in the sidebars. this can be changed ofcourse. if this is something you were looking for, let me know.


mrdee

OK, I'll make it perfectly clear:Go have a look at http://forums.xisto.com/no_longer_exists/ the left yuu will see a menu, this I want to leave as it is (keep it), and at the right, you will see some news articles, sorted by date, but all written by hand in HTML and no comments possible unless (like on the top one) I add a form myself that users can fill in to submit a comment.It is that right hand side content I want to be replaced by Wordpress content instead of using static HTML, that is all.(Having said that, "that is all", means, "that is all I want to achieve", achieving it is quite a different matter).


anwiii

that didn't answer my question. a lot of wordpress themes include a newsfeed. if yours doesn't, then it's not hard to do. after you create an rss feed, you take a script that can not only grab the content off that feed but is also able to post it on a seperate page or even website. you have php scripts that you can use to do this that are already coded. you don't have to code anything. i showed you an example of pulling a newsfeed and posting it. the difference between my example and what i think you are asking for is mine is embedded in the sidebars where you want yours embedded in the content area with more content from the newsfeed and for your news page. when you make a script to do this, there is no limitation where you put the script.i'll make a sample page and see if it's what you are looking for...ok. done creating a sample page. it's "onlinecheapo***DOT***com/news***DOT***html" as you can see, i can keep my sidebars the same and implement the script in the body of the page. the script is the exact same script running on the right side of the page with the only difference being that i changed the settings to add more news per my rss feed. you can see where it is is taken from if you go to my blog and click the rss feed button at the bottom of the page.now if this is not what you are looking for, please let me know. i am done trying to figure it out if this isn't what you are looking for. the only difference that i can tell is that the content is being grabbed from an rss feed rather than the database where word press posts are stored.


mrdee

Thanks again for your reply, anwii.Looking at your sample page (thank you for making that example), I would say that is what I want.I notice that the left and right sidebars have remained intact and that your content in the body is as I would like it.So, just to recap, I want everything on my page left as it is (header, sidebar menu), except for the body where I want the content to appear as it does on your page, namely as blog entries, rather than articles which I have written in HTML.You also talk about creating an RSS feed here, don't forget you are dealing with an ignorant bum here (although one willing and eager to learn), I roughly know what RSS feeds are, but don't ask me to create one as I haven't got the faintest idea how to do that.My knowledge, unfortunately, goes as far as ceating pages using just HTML, the rest I am trying to learn.Also, when you tell me to look where you get the code from by clicking on the RSS feed button, when I do that, what I see is a page full of plain text, is that right?Sorry if the things I am saying and asking here sound dumb, but, as I mentioned, my knowledge needs to be extended a great deal, which is why I come here often to get advice from experienced people.Thank you for all the help you have given so far.



REGISTER GET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.