Hello, just need a bit of help.
I have a page that is a .php, and im trying to get my latest word press post to go into a div on that page.
My page is located at /page.php
and my wordpress at /blog
How can i go about this?
Page 1 of 1
Latest wordpress post onto php page?
#2
Posted 30 December 2011 - 04:04 PM
Was just a simple mistake on my behalf on not renaming the wordpress link -.-
Incase anyone wondered same as me,
added this to top of page ( i added just before the <body> tag:
Then this is how to pull the post from the blog:
Still have a lot of styling to do but is a start!
Craig.
Incase anyone wondered same as me,
added this to top of page ( i added just before the <body> tag:
<?php
// Include WordPress
define('WP_USE_THEMES', false);
require('./blog/wp-load.php');
query_posts('showposts=1');
?>Then this is how to pull the post from the blog:
<?php while (have_posts()): the_post(); ?> <h2><?php the_title(); ?></h2> <?php the_excerpt(); ?> <p><a href="<?php the_permalink(); ?>">Read more...</a></p> <?php endwhile; ?>
Still have a lot of styling to do but is a start!
Craig.
#3
Posted 30 December 2011 - 04:30 PM
Actually...
Can anyone help me on reducing the amount of the post that is shown?
I only want to show say 1 / 2 lines.
I tried reducing the height of the div but the post remained 4 / 5 lines.
http://www.vinylpenguin.co.uk/page.php
Incase anyone wondered.
Can anyone help me on reducing the amount of the post that is shown?
I only want to show say 1 / 2 lines.
I tried reducing the height of the div but the post remained 4 / 5 lines.
http://www.vinylpenguin.co.uk/page.php
Incase anyone wondered.
#4
Posted 30 December 2011 - 05:41 PM
Lovelock, on 30 December 2011 - 04:30 PM, said:
Can anyone help me on reducing the amount of the post that is shown?
I only want to show say 1 / 2 lines.
I only want to show say 1 / 2 lines.
There are two things you have got to do to show only a part of an article. The first is to use the_excerpt(), as has been used in the code block you posted to this thread. The second is to add the "more" tag within the posts after the 1-2 lines that you want to display. I know, it is a manual process, but the alternative would be to do a substring or use CSS to hide text that does not fit within a DIV.
#5
Posted 30 December 2011 - 06:06 PM
Just finished making this work. In the theme of wordpress, there is a file called function.php.
Incase anyone was wondering again...
Incase anyone was wondering again...
function custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
- ← can this application be done with .NET and how hard is it?
- Server Side (PHP, Databases, ASP.NET, etc)
- Bulletin Board →
Share this topic:
Page 1 of 1
Help















