SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: Limiting The Wordpress Posts
-
Jun 27, 2011, 03:29 #1
- Join Date
- Oct 2006
- Posts
- 160
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Limiting The Wordpress Posts
Hi there,
Okay, after a bit of redesign of my portfolio site, I've decided to include the latest blog posts. I found a thread via Google which provided the following link which pulls out the latest posts from the RSS Feed of my blog.
Currently, the RSS Feed itself is pulling 10 out of the 15 posts currently in the blog database. However, I want to limit this to 3-5 so that it can be easily displayed on my site.
Below is the link in question which is an exact copy of the code I currently have running.
Parse an RSS Feed with ASP - Sample Source Code
I expect there is some way to customise the RSS Feed itself or simply editing the existing ASP code provided on the page above....but I'm not sure how or where to edit it.
If someone could help me out I'd be very grateful!
-
Jun 27, 2011, 06:39 #2
- Join Date
- Oct 2002
- Location
- Scotland
- Posts
- 3,631
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Code:For x = 0 to objItems.length - 1
Code:Dim iNum iNum = objItems.length - 1 If iNum > 2 Then iNum = 2 '2 means 3 items, 0-based For x = 0 to iNum
-
Jun 29, 2011, 11:01 #3
- Join Date
- Oct 2006
- Posts
- 160
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi there,
Thanks very much for your advice. However, one niggling problem I currently have is that the unmodified code appears to be causing some errors when placed within my ASP page.
However, when the line "<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>" is removed, the code works and the feeds are loaded as expected. Obviously this isn't ideal by any means.
Unfortunately as I need to work on the remainder of the website, I am unable to provide a link. However, the error code I am receiving is:
Code:Microsoft JScript compilation error '800a03f7' Unterminated string constant /fonttest/index.asp, line 127 ' change the RSSURL variable to the exact URL of the RSS Feed you want to pull ------------------------------------------------------------------------------^
-
Jun 29, 2011, 12:58 #4
- Join Date
- Oct 2002
- Location
- Scotland
- Posts
- 3,631
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Erm. The code VBScript ASP but you've set the page to use JScript ASP. Make your mind up.
-
Jul 5, 2011, 16:39 #5
- Join Date
- Oct 2006
- Posts
- 160
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi there,
Sorry for such a late reply. Thank you so much for the code, it's now working perfectly - and also for your advice about doctypes (haha oops!).
One last thing I want to do is format them so that the posts are in separate divs next to each other. Please could you tell me how I could separate the blog posts into different sections? (e.g. at the moment they are simply a list).
If possible, I would also like to grab the date from the posts and display this alongside the other data already gathered.
Thanks again for your help.
-
Jul 6, 2011, 11:14 #6
- Join Date
- Oct 2002
- Location
- Scotland
- Posts
- 3,631
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Putting them in DIVs is simply a matter of structuring the HTML code around the <%=OutputHTML_1%> etc. parts (and adjusting HTML content of OutputHTML_1 etc.)
As regards getting the dates, just add an extra Case statement for the "date" element, something like:
Code:Case "date" 'Assuming the node element is actually called date thedate = objChild.text
It's not difficult - you just need to get clear in your mind what the code is doing, and how you integrate that with HTML in a web page.
-
Jul 8, 2011, 04:20 #7
- Join Date
- Oct 2006
- Posts
- 160
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Great! Thanks very much for your help
.
By the way, if anyone's curious and checking out this post for their own blog, below is the code for pulling out the "pubDate" and also formatting it.
Code:Case "pubdate" pubDate = objChild.text ...... ArrayTemp = split(pubDate, " ") pubDateFormat = ArrayTemp(0) & ArrayTemp(2) & " " & Cint(ArrayTemp(1)) OutputHTML_3 = OutputHTML_3 & "<a href=""" & link & """>" & title & "</a>, Published:" & pubDateFormat & "<br />" & description & "<br />" Next
Bookmarks