WP plugin: Get-a-Post

posted on January 27, 2005  (Update: January 27, 2008)

Get-a-Post is a WordPress plugin that allows you specify a post or Page (but just one) to be displayed. This can, for example, let you provide an informational note on your sidebar or front page, or a “static” article at the top of a category page or in a custom template, all the while using standard WordPress template tags to decide how it’s displayed.

To install Get-a-Post, download the zip file, extract get-a-post.php, upload this to your wp-content/plugins/ directory, and activate the plugin.

Usage

<?php get_a_post(id); ?>

Place the get_a_post()tag in your template where you want a post/Page to appear, then right after it any template tags you desire to use, as long as they are specific to The Loop (see examples below).

Parameter

id
Either the numeric ID for a post or Page (format: 10 or '10') or it’s postname i.e. Post/Page slug (format: 'post-or-page-title'). Certain defined id options can be used to collect certain types of posts/Pages:

'GETPOST' (or leave parameter empty) - Latest post.
'GETPAGE' - Latest Page.
'GETSTICKY' - (Latest) post or Page with a custom field key of ‘sticky‘ and a value of ‘1‘.
'GETRANDOM' - A random post.

Examples:

<?php get_a_post(123); ?>
    <h3><?php the_title(); ?></h3>
    <?php the_content(); ?>

Displays the title and content of a post or Page (ID #123). Useful as a welcome message in the sidebar. Placed above The Loop, it will appear as the first entry.

<?php if(is_category(1)) : ?>
<?php get_a_post(10); ?>
    <p>A message from <?php the_author(); ?></p>
    <?php the_content(); ?>
<?php endif; ?>

Displays “A message from POST AUTHOR” and content of a post or Page (ID #10) if on the category page for category #1 (tests for this in an if statement using the WordPress 1.5 conditional function is_category()).

<?php get_a_post('about'); ?>
    <h3><?php the_title(); ?></h3>
    <p><?php the_content_rss('', 0, '', 50); ?>
    <a href="<?php the_permalink(); ?>">read more</a></p>

Displays the title and content of a post or Page (Post/Page slug ‘about’); the content is abbreviated to 50 words using the the_content_rss and its ‘cut’ parameter, and then links to the Page itself (using “read more” for link text).

Update [Jan-28-2005]: Because of changes in how the next version of WordPress (1.5) handles processing of The Loop, I’ve made a small mod to Get-a-Post (now version 0.2). This doesn’t change functionality, but does simplify The Loop one now uses for it (see Jan 29 update).
Update [Jan-29-2005]: Sometimes you just need to make things easier. Get-a-Post, now at version 0.3, provides a far simpler method of using it within your template. Example above reflects the update.
Update [Mar-01-2005]: Now finally at R1 (Release 1) since I can’t seem to break it, Get-a-Post has been updated to handle Pages in WordPress 1.5. It also accepts a postname (Post/Page slug) as well as the numeric ID for the post/Page you’re calling. All information above (with additional examples) reflects these changes.
Update [May-04-2005]: R1.1 caches post-meta (custom field) data in a post or Page to use with other plugins or template tags. Slight changes to code, including explicit GPL licensing.
Update [Mar-03-2006]: R1.2 now defaults to the latest (last published) post or Page. Use 'GETPAGE' (all caps) as argument for latest Page, and 'GETPOST' or no argument for latest post. I’ve also slipped in tentative suppport for the next update to WordPress (currently referred to as 2.1). May be the first plugin to do so…
Update [Apr-21-2006]: R1.3 Fixes a bug (see numerous comments below—sorry everyone!). Also slipped in the 'GETSTICKY' id, which displays any post or Page (but again, just one) you add a custom field key of ’sticky’ and value of ‘1′ to.
Update [Jan-27-2008]: R1.4 Adds a 'GETRANDOM' id, which retrieves (surprise!) a random published post (but as always, just one).

Author: Kaf Oseo
Categories: WordPress
Comments: (107) · Leave a comment · Comments RSS2 · Trackback URL

clint
Comment » February 26, 2005 @ 10:31 pm

hey kafkaesqui, came across this plugin tonite and gonna give it a try..I came first for your last edited plug, installed that on a site im workin on and it works great!

Denis de Bernardy
Comment » March 24, 2005 @ 8:31 pm

{{{{{Kafkaesquí}}}}}

Kaf
Comment » March 24, 2005 @ 9:56 pm

“Bracket my name all you want, but you’ll never box me in!”

I wonder if that’s a famous quote…

Paul van Iterson
Comment » April 3, 2005 @ 8:57 am

Wouw, very nice script. Love it :D Use it on my website now.. Keep it up!!

Andreas
Comment » April 20, 2005 @ 9:13 pm

This is useful! I have the same functionality on my site, but it is a very strange solution based on conditional tags. This seems a lot easier to work with. Will try it later, thanks!

Peter
Comment » May 1, 2005 @ 9:51 pm

Hi, is there a way to get a second and third and much more posts on one page .
Becouse i hane a problem i can inser only one…?

Thanks

Kaf
Comment » May 4, 2005 @ 1:23 am

Peter, if your question is specifically about Get-a-Post, then all you need do is use <?php get_a_post(#); ?> (# = post ID) again in your template to display an additional post. Use it three times to get three posts, and so on.

LiZharD
Comment » September 9, 2005 @ 10:42 am

It works with conventional PHP if statement?
I’ve tried with:

LiZharD
Comment » September 9, 2005 @ 10:44 am

php if(is_page(’24′) && $splitpage ==”2″) : ?>
php get_a_post(5); ?>
php the_content(); ?>
php endif; ?>

(sorry for double comment)

Patrice Miller
Comment » October 7, 2005 @ 2:18 pm

Really great plugin! I had a problem maintaining our group blog because if editing the main page but with your plugin, it makes my job easier! Thanks and more power to you!

Chris Bose
Comment » October 11, 2005 @ 5:48 am

Very good plugin; but appears to break in IE6 on the PC when used on the index page. I used a standard WordPress install. Everything looks OK on a Mac Firefox, IE, Safari, but on a PC all the sidebar formatting is lost. Take the code out of the index page and everything looks right again. Have you noticed this?

ldp
Comment » November 3, 2005 @ 11:16 am

hi.
i saw your comment on a topic i made on wordpress.org/support.

its a great plugin, but it’s not what im looking for.
(i’m talking about multiple post in the front page of just one category.)

ravi
Comment » November 8, 2005 @ 4:27 pm

I am having these warnings after activiating it (Ver. 1.5.2):
Warning: Cannot modify header information - headers already sent by (output started at /home/.ankelfraeseren/friendklay/ravichhabra.net/wp-content/plugins/get-a-post.php:58) in /home/.ankelfraeseren/friendklay/ravichhabra.net/wp-admin/admin.php on line 10

Warning: Cannot modify header information - headers already sent by (output started at /home/.ankelfraeseren/friendklay/ravichhabra.net/wp-content/plugins/get-a-post.php:58) in /home/.ankelfraeseren/friendklay/ravichhabra.net/wp-admin/admin.php on line 11

Warning: Cannot modify header information - headers already sent by (output started at /home/.ankelfraeseren/friendklay/ravichhabra.net/wp-content/plugins/get-a-post.php:58) in /home/.ankelfraeseren/friendklay/ravichhabra.net/wp-admin/admin.php on line 12

Warning: Cannot modify header information - headers already sent by (output started at /home/.ankelfraeseren/friendklay/ravichhabra.net/wp-content/plugins/get-a-post.php:58) in /home/.ankelfraeseren/friendklay/ravichhabra.net/wp-admin/admin.php on line 13

Spiff
Comment » November 24, 2005 @ 11:54 am

Thanks, just what i have been looking for to show some author info in the sidebar. It’s simple and it works.

dojng
Comment » December 22, 2005 @ 4:41 pm

if id would default to the last post, this plug would be perfect for me.

Kaf
Comment » January 1, 2006 @ 10:24 pm

Good suggestion, dojng. I’ll update Get-a-Post so it defaults to latest post or Page (I’ll set a special argument so the function knows which one) once my “2.0″ updates to a few other plugins are out.

karl
Comment » February 1, 2006 @ 1:16 am

im new to wp - i really need this pluggin - ive been at it for hours and failing

i want my 1 post ( at bottom ) to appear at the top - can someone please help me:(

http://piercingthedarkness.info/blog/

thank you

David McDonald
Comment » February 14, 2006 @ 12:07 am

If it could take arguments so it could get the latest post, or the last 10 posts without having to insert the code 10 times, that would be helpful.

eyerouge
Comment » February 22, 2006 @ 3:53 am

Excellent. Thanks for the plugin. Have it installed on my site to display a picture in my sidebar that I change once in a while (yeah, I didn’t want random, prefer to choose myself and have it there in periods). You script lets me do that (once installed) without having to edit my sidebar.php file any more.

Kaf
Comment » February 28, 2006 @ 3:16 pm

David McDonald, I like the idea of defaulting to the latest post (or Page), which I note in an earlier comment above. Everyone consider it crayoned in for the next update. However, handling multiple posts is not what this plugin was designed for.

Jon
Comment » March 11, 2006 @ 1:33 pm

I’ve been fiddling with the plug-in for about two hours now and can’t get it to work. I’ve even tried editing the source code to make it work, but no luck. When I insert the function into my template like this:

get_a_post(38);
echo the_ID();

It returns 2 and displays the last page I created, rather than post 38. For the life of me, I can’t figure out why.

I’m using WordPress 1.5.1.3

Help please

Mark Fleming
Comment » March 17, 2006 @ 2:50 pm

Your plugin is returning a different “page” than I am requesting. I sepcify a page id of 12 and it keeps returning a page I have with an ID of 10. I’ve tried with and without single quotes, and I’ve tried other pages, but it always display page ‘10′

Too bad, I really wanted to use this.

I’m on R2

Josh
Comment » March 22, 2006 @ 10:37 am

Great plugin, Kaf. What would you think about adding a category option, so you could ‘get a post’ from a specific category, and only that category?

Joe
Comment » March 22, 2006 @ 12:38 pm

Great plugin! Just wanted to second Josh’s request. It would be great to pull out the latest post from a specific category. Any plans for this?

Joe
Comment » March 22, 2006 @ 2:05 pm

Kaf,
Hope you won’t mind, but I decided to do a quick hack job that will pull the latest post only in a specific category.

My hatchet-job is located here:
http://mudbomb.com/images/files/get-a-post.php.txt

It ain’t pretty, but it works in Wordpress 2.0. Be sure to set $mycategory = 6; to your category.

btw: Kaf- feel free to salvage anything you can to use in your plugin.

Jennifer
Comment » March 22, 2006 @ 5:22 pm

Not working for me on 2.0.2. Defaulting to last page created. Much sadness.

Rob
Comment » March 23, 2006 @ 9:40 pm

I’m having the same problem as Mark Fleming and Jon above… it does not return the page I specify, rather a completely different page. ‘GETPAGE’ works, but I don’t want the last page created. Can anyone shed some light?

Rob
Comment » March 23, 2006 @ 10:28 pm

Those with my problem (Jon, Mark Fleming, Jennifer)… try putting parentheses around the last $query_suffix string, like this:

$query_suffix = “(post_status = ‘publish’ OR post_status = ’static’)”;

It worked for me.

pati
Comment » March 24, 2006 @ 8:13 am

@rob - thx a lot for the tip. it helped me with the problem. how long did you search for this detail?!

Rob
Comment » March 24, 2006 @ 8:53 am

Pati - glad it worked for you too. I had been fiddling with the plugin code for about an hour. I narrowed the problem down the &query_suffix string. I wasn’t absolutely certain this one simple change alone actually solved the problem… nice to get confirmation.

Kaf - is this a bug?

Nick
Comment » March 25, 2006 @ 9:43 am

This last solution doesn’t solve my problem. When I put parentheses it gets no post at all. When I do not use them, it gets a completely irrelevant post.

Anybody has other ideas?

Nick
Comment » March 26, 2006 @ 3:24 am

I think the problem is I have Wordpress 2.0 installed. Right?

Kaf
Comment » March 26, 2006 @ 12:16 pm

I think the problem is I have Wordpress 2.0 installed. Right?

Not if you’re using the recent update. For everyone dealing with this issue, I’ll try to get a fix up here by the end of the day.

Joe, once I deal with this issue of incorrect Pages being displayed, I’ll check out your work.

Nick
Comment » March 28, 2006 @ 4:04 pm

Anything new yet about fixing this issue????

Alex Wx
Comment » April 3, 2006 @ 4:22 pm

I too was having trouble with it retrieving a “random” post; looks like it’s just missing parentheses in the query:

SELECT *
FROM wp_posts
WHERE ID = '10'
AND post_date < = '2006-04-03 14:07:05'
AND post_status = 'publish' OR post_status = 'static'

which returns more than one record. Should be instead:

AND ( post_status = 'publish' OR post_status = 'static' )

I fixed mine (on line 60), seems to work fine for me with numeric or slug IDs on WP 2.0.2
Cheers,
–Alex

chairs
Comment » April 4, 2006 @ 3:30 am

Hi,
There is one same post that I want to be seen on my homepagge from one of the categories. Someone redirect me to your plugin but I am having problems because the instruction is not clear to me. I am a newbie. I uploaded the plugin to my wp-content/plugins/ directory, and activate the plugin. But i don’t know where will I add the code

Can you kindly help me out? There are some posted articles on the homepage already and I only want the same article (#17)to appear on my frontpage. I tried to post the code but i got some error page. Thanks!

skube
Comment » April 17, 2006 @ 11:41 am

I’m using WP1.5.2 and had the same problem where it was getting an irrelevant post. Adding in the parentheses as Rob suggested worked for me.

Brad Bice
Comment » April 18, 2006 @ 9:04 am

I also had to add the parentheses to that last line on my Wordpress 2.0.2 installation.

Kaf
Comment » April 21, 2006 @ 2:19 pm

Sorry for the delay on the bug fix everybody. For your patience, I added the new ‘GETSTICKY’ id. See the April 21st update.

jpfieber
Comment » April 28, 2006 @ 8:45 pm

Very useful plugin. I have it working on my setup, but I need it to grab the most recent post from a specific category. I tried the hacked code that Joe posted above, and it does work to show the latest post from the specified category, but in the process it removes the checks for time, so it ends up showing scheduled posts. Any way you can include the ability to specify a category, but not allow scheduled posts to appear?

coxis
Comment » May 22, 2006 @ 4:19 pm

i want to set a sticky post on the top with this plugin
what will be the code for it
thanks for help !!!

Subir Ghosh
Comment » June 3, 2006 @ 1:39 pm

Is there a way I can use it outside the loop?

I have a static front page in that I have removed the loop totally. In different slots I want to call in specific items.

I have been trying this function: but it hasn’t been working:

$posts = get_posts(’category=63′);
if( $posts ) :
get_a_post(4592);
the_title the_excerpt
endif;

Subir Ghosh
Comment » June 4, 2006 @ 8:36 am

I think I must clarify a bit on my prev msg.

It works fine on the site but on my box every instance of its use is showing up one specific ‘page’ and NOT the particular ‘posts’ that I am calling in different areas of the homepage.

I can’t figure out what can be the reason. The same sets of plugins are active both on the site as well as on my comp.

Could it have something to do with the Options?

There are many ‘pages’ on the site. It is the FIRST page (in terms of post ID) which is showing up in all distinct instances that I am calling “get-a-post”

(Apologies Kaf, for the cross-posting)

Raymond.CC
Comment » June 5, 2006 @ 3:09 am

Is there any demo on what can this plugin do?
Sorry as I can’t really understand the description…

Marc
Comment » June 16, 2006 @ 11:41 am

Very good plugin. Very usefull. It can be use to “include” a text of a different page or post in a post or an article if use in conjonction with EzStatic.
Thank you!

A question: Is that possible to limit (cut) the excerpt to a paragraph (or two) instead of a certain number of words?

Adam
Comment » June 17, 2006 @ 8:29 pm

Hello… great plugin. Just discovered it and it works great. I am using the GETSTICKY plugin on index.php to display a special post at the top of the page in its own div. If I remove the “sticky” keyword and value from the post, the div remains and WP tries to display the postmetadata. I would like for the frontpage to appear normal (as it would without the plugin - most recent posts). That way, the site administrators can decide to just add/remove sticky designations to any post as they please and it will either show the sticky post if there is one available, or show nothing. Is that possible?

Thanks for all your help, and writing some very useful plugins.

Adam

Moises Kirsch
Comment » June 20, 2006 @ 7:39 am

Is there a way to see if there is any content after calling the Get A Post function?

I would like to setup something like an Alert System… if the page (called alerts) has any content display the html… if not, do not display anything at all.

If I can use get a post it would be great… and If I need to modify anything it ok… I’m just looking for the best (and simplest) solution.

Thanks

Hans Chee
Comment » June 24, 2006 @ 12:14 pm

I’ve uploaded the plugin but can’t locate it in my Plugin menu. I’m using WP 2.02, is there something I missed?

I hope this will help me to get the uri of the LATEST “page”, which is what I’m looking for.

Thanks.

Stacker
Comment » August 9, 2006 @ 4:57 pm

Hello
This looks great. Thanks for all your work on this plugin.

I have one question:

I am using this code

Above the title appears ????
Also, above the content appears ????

Do you knw how I can remove these questions marks?

Thanks.

Stacker

arlan
Comment » August 15, 2006 @ 9:13 pm

I’ve tried the plugin and it works and displays the current post, but it ignores “more” . I really don’t want to put a long post in my front page, could anyone suggest a hack?

Jason Cramer
Comment » August 29, 2006 @ 4:53 am

THANK YOU THANK YOU THANK YOU!!

I searched for probably 3 hours for a way to make my custom static home page show just the excerpt of only the most recent post. Your plugin made it a breeze.

To arlan: use the function called the_excerpt(); and it will use the more tag to break it off or else only allow a preset number of words. I’m sure you can come up with a good way for showing the “read more” permalink.

ali
Comment » September 18, 2006 @ 11:52 pm

thank you for this one. it worked out perfectly!

Dave
Comment » September 21, 2006 @ 8:01 am

What is the call that I’d use if I want to pull in an external post?

Tim
Comment » September 24, 2006 @ 8:19 am

This should be an official WordPress plugin. Can their team give a match? ;)

Robert
Comment » September 28, 2006 @ 5:06 am

Great plug-in. Thanks!
I will suggest that if you want the sticky post to be shown only in the first page using WP2.0 style, do:
if (is_home() && !is_paged()) {
get_a_post(1);
echo “”;
the_title();
echo “”;
the_content();
}

Sam Stevens
Comment » October 6, 2006 @ 12:28 am

Great plugin! I’m using it with 2.0.2 and getting some errors in the admin area though, specifically on the Links tab, and also whenever I activate/deactivate a plugin. It would be awesome if this could be remedied!

Sam Stevens
Comment » October 13, 2006 @ 12:28 pm
marek
Comment » November 6, 2006 @ 12:08 pm

Great plugin, starting to use it with conditional tags at the top of my pages/categories. I can’t figure out the conditional tags for Jerome’s Keyword plugin, something like:
elseif(is_tag(’mykeyword’)) {
get_a_post(’keywordpagetext’);
the_content();
}
Ofcourse is_tag doesnt work! Probably missing something simple.
Thanks again
Marek

marek
Comment » November 6, 2006 @ 6:53 pm

ok I am dumb.
elseif('index.php?tag=mykeyword')
{ get_a_post(’keywordpagetext’);
the_content();}

works lovely.

Paul
Comment » December 22, 2006 @ 11:05 am

Looks very promising. But in my Firefox 2.0.0.1 the page looks slightly different that in IE. I’ll double-check, may be I missed something, it was late night :*)

Adam k
Comment » December 22, 2006 @ 6:58 pm

HEy was wondering if anyone else is having this problem, Using the get_a_post plugin, when I am showing a trucated post on the main page of the site I am getting the  in various place in the site. Can any one let em know what is causeing this? Using the latest version of this plugin and WP 2.0.5

Thanks

Jenn
Comment » February 12, 2007 @ 3:07 pm

Does anyone have this working in Wordpress 2.1? If so, what changes did you have to make? I get this error:
Fatal error: Call to undefined function get_a_page() in /var/www/html/ltp/wp-content/themes/spi/sidebar.php on line 44
I think its because the plugin code uses $table.

Colin
Comment » February 20, 2007 @ 1:01 pm

@Jenn - it works perfectly for me in Wordpress 2.1. No problems at all.

Thank you Kaf for this excellent plug-in!

santiago
Comment » February 22, 2007 @ 12:24 pm

perfect in 2.1, great plugin.
my only problem is that the (more…) link isn’t translated with a spanish language package for WP, how can i make it work??
regards.

jeremy
Comment » February 23, 2007 @ 3:31 pm

Kaf, get-a-post works great now that the (id) defaults to the last post, but what if I only want the last post of a specific category?

John
Comment » February 25, 2007 @ 4:38 pm

Ok…. i put this in home.php, just before

then all my post have the same content!!!???

John
Comment » February 25, 2007 @ 4:40 pm

(the above thing is broken!!!)

(the underscores in front of)

after this:

then all my posts display the same thing???

Mark McLaren
Comment » March 20, 2007 @ 3:17 am

Kaf,
Awesome plugin. This is something I have been trying to figure out for a long time. It will make my life much easier. It’s another step toward making WordPress the best CMS available for small and medium-sized mainstream websites, not just blogs.

I am using it on the home page of this site: http://www.park-creative.com/ so that the site owner can edit the text in the green box, which is not part of The WordPress Loop.

Ninjaboy
Comment » April 4, 2007 @ 5:22 am

I love this plugin, and have rolled it out to a number of sites with no trouble.

However, I just couldn’t work out a way for it to select random pages (yup, pages, not posts - which creates an issue with categories), so I put the page slugs into an array, and selected randomly from those, inserting a variable into the get-a-post argument.

It worked fine, but is there an easier way to do this? I see that ‘random’ is mentioned a couple of times in the comments, but there is no indication on how to actually do this!!

neospyce
Comment » April 20, 2007 @ 3:14 am

Great plugin! I am new to php but an old hand at hard-coding html. I installed with no probs. Except when I enter the parameters as per your first example, the post appears twice. I only want the introductory post to be displayed once, not again immediately underneath it. Hope that makes sense. (In other words, the title and content are fine and appears where it should, but then the original content appears directly underneath what was pulled. It’s like a double post. I am at a loss. Please Help. The syntax is correct, my parameters somehow are lacking, I think.) I reverted back to the original index.php code. I would really like to use get-a-post, but I just need a little guidance as to the parameters.

ubustu
Comment » April 20, 2007 @ 3:24 am

The greatest WordPress plugin ever created!

neospyce
Comment » April 20, 2007 @ 3:48 am

Got It! I had to create a new page with the desired text and then called up by id on page instead of id on a post. Works like a charm.

BigCheese
Comment » April 23, 2007 @ 12:46 am

Great plugin! I’ve made a little redirect to show the SINGLE page since calling get a post doesn’t seem to extend comment functionality… this way whenever someone goes to your site, the first thing they’ll be shown is your most recent post.

ID;
header( $insert ) ;
?>

check it out at http://www.fearfulcheese.com/news/

BigCheese
Comment » April 23, 2007 @ 12:47 am

oops, this comment box nixed some of my code…

ID;
header( $insert ) ;
?>

Mogeilen
Comment » May 7, 2007 @ 4:08 pm

Hi, could anyone tell me how to do posting starting with each alphabet to display separately. Here is the example :

A…..
A…..
A…..

Only posts start with the alphabet A to be display from a specific category, let say cat1. I need to insert the code in alphabetical Tab menu in my site http://www.123indianonline.com

Thanks in advance!

Jayce
Comment » May 21, 2007 @ 4:50 pm

Perfect! I needed just what you have. Now at the top of each category page is a brief blurb (along with the MORE tag) about that category. Following the blurb is the most recent post. Your plugin does exactly what I needed. Thanks.

David
Comment » May 28, 2007 @ 11:47 am

Is there a way to put wp_title - or a php variable defined as such - inside the get_a_post tag, in place of a fixed page name or slug?

I’m trying to match up a pull-quote, named foo-pullquote, for corresponding page foo, so that an author can:

A) create a new Page or Post, and then
B) create a matching new pullquote as another Page or Post, and then
C) have the pullquote page/post auto-called by generating its name (plus “-pullquote”) from the current page

So, instead of get_a_post(’about-pullquote’), I’m trying to generate the coded equivalent of get_a_post (’(wp_title)-pullquote’) or get_a_post(’$variable-pullquote’).

Any ideas?

David
Comment » May 28, 2007 @ 3:01 pm

Nevermind, PHP variable works fine, I was using faulty syntax (php newbie here).

Ian Harris
Comment » June 5, 2007 @ 8:19 am

Hi David,

I’m trying to do the exact same thing as you - please could you outline how you managed to do it?

Many thanks!

Ian

John
Comment » July 15, 2007 @ 6:20 pm

I’m trying to output just the content of a page. I’m using get-a-post(26) which is the id of the page. I’m putting this into a static homepage and the only other php code I have is require(’wp-blog-header.php’) to make use of everything. I’m not getting any errors back but its not outputting any content from the page either. I’m using WP2.2. Am I doing something wrong or do I need an updated version of somekind?

Hint
Comment » August 6, 2007 @ 3:34 pm

Hi, Great plugin. I’m having a problem with the next page previous page option for posts in my middle column. I have used your plugin on both the left and right sidebars to show a content page that links to other pages inside the middle column. Everything works fine until I break a post with the {!–nextpage–} option. When you go to the next page, all the content goes to the side bars in addition to the center content. I know that this is because of the {?php the_content(); ?} coding that goes into the sidebar.php but is there a way to make it stay, a code that can be added as an alternate so that the content from posts won’t go in the content for my get a postie’s? Thanks

gymgangsta
Comment » August 25, 2007 @ 3:34 pm

This works great with excerpt reloaded.

Dave
Comment » September 5, 2007 @ 12:09 pm

Is there any way to make the Title a link? Great plugin, by the way!

Dave
Comment » September 5, 2007 @ 12:14 pm

Never mind, I just figured it out. Just wrap the permalink tag around it.

Benoît G.
Comment » September 28, 2007 @ 1:21 pm

I made some change to your function (http://pastebin.ca/718721), adding optionals parameters in the function ($sort=’DESC’,$status=’publish’) that you can specify.

For example, if you want to have an intro post for a category; change its date so it’s the older and put its status to DRAFT; and modify the template for the choosen category !

alias
Comment » October 17, 2007 @ 2:22 pm

how to get the read more link to appear ?

miss li
Comment » October 27, 2007 @ 4:03 am

how to get the read more link to appear ?

Kaf
Comment » October 27, 2007 @ 5:50 am

The ‘read more’ link should be appearing if:

  1. You are using the <!--more--> quicktag in your posts.
  2. You are using the_content() to display your posts.
    Josh
    Comment » January 5, 2008 @ 12:47 pm

    How can I pass a variable to get_a_post(insert variable here)

    pro01
    Comment » January 21, 2008 @ 5:57 am

    Yep, good plugin, except for the unpleasant bug I encountered - if the post is paged, each page besides the first will display the content of the current post instead of the content of the post you want to fetch. Ideas how to fix this anyone?

    Wizzoh
    Comment » January 27, 2008 @ 9:06 pm

    Kaf… Do you avoid posts about “specific category” on purpose ? Everybody here wants to display the latest post from a specific category!

    PLG
    Comment » February 4, 2008 @ 11:05 am

    I want to display latest post from a specific category. I know a hack has been posted here… but it do not work with recent version of WordPress… Can someone help me to do it ?

    mrbloggr
    Comment » June 13, 2008 @ 1:50 pm

    I’m using this exact example as above and I’m not getting the post id I specific but instead get the last post.

    <?php get_a_post(123); ?>

        <h3><?php the_title(); ?></h3>
        <?php the_content(); ?>

    Help?

    jhz
    Comment » June 27, 2008 @ 2:49 pm

    mrblogger,

    I’ll bet you need to change the post ID example (123) to a post ID that exists within your blog.

    jhz
    Comment » June 27, 2008 @ 3:34 pm

    I love this plugin–thanks! I’m not great at PHP–has anyone wrapped an if statement around this so it won’t display if the post doesn’t exist? I’m using it for an alert with a background set on the div, so the background still shows if the post is unpublished.

    My work-around was to embed the styling in the post but I’d rather not…TIA…

    jhz
    Comment » June 29, 2008 @ 12:38 pm

    Correction and comment: I need to use an if statement to display a post ID (with special DIV) and but do nothing (NOT display DIV) if the publish status is unpublished. It seems simple but I just can’t get it. I’d be willing to donate if I could use get_a_post in this way…again, TIA.

    Thomas
    Comment » July 14, 2008 @ 3:48 am

    Hello…

    your skript is wonderful, but i have one question:

    if i’ve got a picture in my post, why isn’t it displayed.

    is there a way to display the picture??

    please help me S.O.S

    with regards

     

    * Required field (e-mail is not published). Breaks and paragraphs are automatic. HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>