- This topic is empty.
-
AuthorPosts
-
November 11, 2012 at 11:44 pm #628990CasinoSasaMember
Is anyone familiar with PHP And wordpress enough to help a man out.. Im trying to use wordpress for a news section only.. Having my site on .php pages.. I wish to use the wordpress news items on my homepage of my .php site.. I have googled and searched wordpress and they do have a page dedicated to this. But it only shows how to display the titles and none of the text..
Does anyone know how to change the php code in order to render out a line or 2 of text as well as the title.
This is the code from wordpress in order to integrate the posts in to a standard php website..
[PHP]
< ?php query_posts('showposts=3'); ?>
< ?php while (have_posts()) : the_post(); ?>
< a href="” rel=”bookmark” title=”Permanent Link to “>< ?php endwhile;?>
[/PHP]Does anybody know how to modify this so it shows a line or 2 of the content as well rather than just the title to the post.. ?
regards
gazNovember 12, 2012 at 4:59 am #829661AnonymousInactiveHey so let me get this correct.
You have wordpress installed, and you have news items on it.
But you also have a .php pages outside of the wordpress install, and you would like to pull those wordpress news items out and display them on your .php pages?
Rak
November 12, 2012 at 5:02 am #829662AnonymousInactive[PHP]include(‘path-to-wp/wp-load.php’);
$recent_posts = wp_get_recent_posts(array(‘numberposts’ => 10));
echo ‘- ‘;
- ‘, $post, ‘
foreach($recent_posts as $post) {
echo ‘‘;
}
echo ‘‘;[/PHP]
once wp-load.php is loaded you have access to all of WPs functions.
November 12, 2012 at 8:15 am #829665CasinoSasaMember@Rak 246758 wrote:
once wp-load.php is loaded you have access to all of WPs functions.
Hi rak, that maybe true but I have no idea what WP functions are or what you can do with them
But you are correct in I want to basically pull wordpress posts into my .php pages.. That code above just renders out the same as I already have. It just shows the titles of the posts.. I want to show some of the text too.. Like as teaser text. How do i show some text aswell as the title link?
November 12, 2012 at 9:13 am #829668Poker ZealotMember@societyofslots 246750 wrote:
Is anyone familiar with PHP And wordpress enough to help a man out.. Im trying to use wordpress for a news section only.. Having my site on .php pages.. I wish to use the wordpress news items on my homepage of my .php site.. I have googled and searched wordpress and they do have a page dedicated to this. But it only shows how to display the titles and none of the text..
Does anyone know how to change the php code in order to render out a line or 2 of text as well as the title.
This is the code from wordpress in order to integrate the posts in to a standard php website..
[PHP]
< ?php query_posts('showposts=3'); ?>
< ?php while (have_posts()) : the_post(); ?>
< a href="” rel=”bookmark” title=”Permanent Link to “>< ?php endwhile;?>
[/PHP]Does anybody know how to modify this so it shows a line or 2 of the content as well rather than just the title to the post.. ?
regards
gazIn my eyes you should avoid the overload and getting the posts directly out of the database.
There is absolutely no point in loading the complete wordpress core plus a small theme to display three news posts within another site.November 12, 2012 at 2:51 pm #829671CasinoSasaMemberSounds good smartface.. But how do I do that ?
November 12, 2012 at 3:59 pm #829672AnonymousInactiveI dont use wordpress but you have the post, you just need the value
Code:< ?php query_posts('showposts=3'); ?>
< ?php while (have_posts()) : the_post(); ?>
< a href="” rel=”bookmark” title=”Permanent Link to “>
// Not sure what they call the article con but this will 200 characters you can make it a full word with a little more code
< ?php endwhile;?>November 12, 2012 at 11:48 pm #829680CasinoSasaMemberWell were getting closer.. It does render out the wordpress content.. But it renders it all out.. There is no character limit – it just chucks out the whole post for each one..
November 13, 2012 at 1:31 pm #829686AnonymousInactive@societyofslots 246782 wrote:
Well were getting closer.. It does render out the wordpress content.. But it renders it all out.. There is no character limit – it just chucks out the whole post for each one..
hmm
try this
where 20 should be the # of characters
November 13, 2012 at 2:11 pm #829688Poker ZealotMemberyou’d rather use the function the_excerpt() instead of the_content()
November 13, 2012 at 6:13 pm #829694CasinoSasaMemberHouston we have landed!
Id like to thank you both for your help.. All Free chips for the code and smartface for his “mod” as it worked with the_excerpt() rather than the_content()..
So thanks peeps.. much appreciated
-
AuthorPosts