My site is set to show a static page as the front page.
I have then created a blank page called "Latest News" and have set this to display one post on the default template which I believe is index.php. I have modified index.php to show the_excerpt.
From the_excerpt on index.php there are the read more links that take the user to the_content on single.php
My question is this:
How can I link from my homepage to the excerpt of the post that is displayed on index.php, considering that the page id of the excerpt of the post is updated each time I add a new post.
At the moment when I click the link on the homepage it takes me to the full post display on single.php.
Here is the code for the link:
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('300-thumb', array('class' => 'thumbnail')); ?></a>
Francisco Javier Carazo Gil answers:
If I have understood well, you can use this function: http://codex.wordpress.org/Function_Reference/the_excerpt
Francisco Javier Carazo Gil comments:
Or something like this: http://wordpress.org/support/topic/custom-the_excerpt-with-read-more-link
John Cotton answers:
Your question isn't clear to me...
Where do you want to link to if not the permalink for the page?
Just a pop-up of the excerpt?
Luis Abarca answers:
For home page you should use home.php in your templates.
The info could be stored in post meta, you can store the post ID and then use get_post($post_id) to show the excerpt
Luis Abarca comments:
index.php is a fallback for your templates, if category.php, archive.php, single.php, etc, are missing, then WP will use index.php to show the info.
So, you dont need to use a static page, you can create a custom home.php and show the last post or a selected post.
But if you need the static page, you can store the last post ID in page custom meta to show the excerpt of the last post.
Luis Abarca comments:
<blockquote>But if you need the static page, you can store the last post ID in page custom meta to show the excerpt of the last post.</blockquote>
And you can use front-page.php to create the custom template.
Check this plugin:
Arnav Joy answers:
can you explain some more points about your question , it is not clear..