Nathan Rice wrote about WordPress’s ability to make any page a homepage. One problem I ran into using the technique of pages was the inability to use the <!--more-->
tag to display partial posts. Apparently this is default behavior (for good reason) on pages. However, when using Nathan’s technique, I found myself in a unique situation where I only wanted to show a partial post (on a page) if the post was making use of the <!--more-->
tag (apparently, I’m not alone).
The technique is rather simple. Simply declare a variable named $more as a global and set it to false right before showing your content. If you wish to resume normal behavior after the content is shown, simply set the variable back to true.
<?php global $more; $more = false; ?> <?php the_content('Continue Reading'); ?> <?php $more = true; ?>
Newb here – With WP’s ability to make any page a homepage, can one make more than one page (within a given WP blog) a ‘homepage’ and make use of multiple domain names (not subdomains) for each one of those ‘homepages?’
@marc-
that relies on your hosting configuration, not wordpress. it depends from host to host.
Ron,
I actually had a client ask me for something similar … and I opted to use a page excerpt instead of using the more tag (although either option is fine). I used the page excerpt plugin here:
http://blog.ftwr.co.uk/wordpress/page-excerpt/
It adds an “optional excerpt” field to the page edit screen that you can put anything in. Just call the_excerpt like you would for a post, use query_posts and the loop to specify the page to call, and you’re done.
Oh, and if you were looking for a site to link to for my name, you can just like to rockinthemes.com 🙂
Thanks for the hat tip, by the way 🙂
wait, what? I’m lost.
Jenny,
If you are using a page instead of index.php as your main page on a WordPress install, this technique allows you to use the “more” tag. I would follow Nathan’s example over at Blog Herald and go from there as needed.
@Ronald
Awesome hack. Will put this in the recipe book for future use.
@Nathan
Sheesh, I wish I’d known about that plugin a year ago! I’ve been manually adding my “excerpts” to pages (I use the excerpt as a sub-heading.)
Man. Wish I’d known this three or four months ago.
I had a client who needed “articles” published on one page and “tips” published on another, with editable text before the individual posts, which they wanted shortened with more–so I created a page template, not knowing that the more tag wouldn’t work. Ended up just using categories.php along with category description before the posts instead of the page template and page content itself.
I fail to see why that would work. I mean, what does the more link to, and what happens when you click on it? I would expect that it would link to the page’s permalink, but when you click on it, you’re going to get that same thing (since you’re using a page template) and the more link is just going to display again.
How do you view the content after the more link in this situation?
I agree. Tried the code on page.php and it did not work. As I understand now I would need a custom query to realize this. Not sure yet how, but looking into it. Some details on this in the article would be awesome.
Thanks for passing along and sharing an excellent tip, Mark! I am in the middle of developing several sites, including a large organization site using WordPress as a CMS platform, and this was a challenge recently identified. The tip came made the solution simple.
Cheers!
Dave
Otto,
If you use the technique without doing a “query_posts” first, then you’ll get the result you mentioned in your comment. I referenced Nathan’s article at the beginning of the post, so I’m assuming you’re trying to do something similar.
Otto,
Looks like Ronald beat me to it, but I’ll elaborate a bit more. This tip is talking about homepage design … not page.php design. You’re right, using the more tag on a single page would be silly. But on the homepage, it can be used to handle things like an “about me” box in the sidebar that gives an excerpt of your about page, then links to the rest. The possibilities are endless when it comes to using WP as a functional CMS.
Nathan
hi nathan,
i understand what u trying to said.
but can u pleassssssssssssssseeeeeeeeeeeee gimme the more details explaination.like where should i put the code i stated in ur article, in which php files, what lines and everything in very very details..
cuz my read more link did appear but doesnt function..huk..helpp =(
i am a newbie to the wordpress, and i face the same problem you mentioned then i found your article here so thanks for the tips first, but, i still dont know how to solve that problem in your way,i don’t know where i can put your code in, is it in the page.php or in the template page that i created for my own homepage?
or can you email me the detailed solution? thanks so much
dizzah,
Check out Nathan Rice’s article. You can also check out my article on the loop.
The WordPress codex will be your new best friend. The WordPress codex is a good resource for information on WordPress pages.
What you will have to do is create a new page template, and put the code I mentioned within the loop. You will then have to create a new page within WordPress and use the page template you created as a template. From there, you will have to tell WordPress to use your page as the default home page (Options -> Reading) and go from there.
I hope that helped.
Thank you, this was really useful. I couldn’t get the more tag to work anywhere within the theme I’m using, but this solved that problem.
Thank You! This saved my day 🙂
hey all..
please help me. im doing a weblog for my uni project.
the proble is, after i follow what’s nathan said, the read more now appear in my front page.however, when click the link, it doesnt function at all..pls help me.. im really a newbie in this…
Hi, thanks for this — this is what I was looking for. I copied and pasted your code into the loop, however, and nothing changed. Is there something else that needs to be done?
Thanks.
Great! This works for me! Great and simple solution to use the more tag on wordpress pages.
This saved me a lot of hair pulling, thank you!
My post pages are about 1000 words. A very long page. I would like to split them up into 2 or 3 pages. How can I do that?
So… http://www.example.com/longpost/ would display on 2 or 3 pages, instead of 1, with a More tag.
Is this possible?
you rock. I’ve been searching for this for hours. Thanks. – Nixon
Thank you ! Great and simple solution to use the more tag on wordpress pages.
This was some of the best code I have ever come across. I couldn’t figure out how to use the tag in my custom page templates.
Saved me a lot of work!
Thank you Ronald!
I really appreciate you posting this – I had tried lots of other hacks and just couldn’t get it to work – thank you a ton