Danny+ 1,327 Report post Posted June 13, 2011 Hi, I want to show the latest blog post on my homepage, I have installed the plugin PHP exec to do this but I'm not sure on what the code is to do so, can anyone help me please? Thanks Dan Please search our forums, before posting! Share this post Link to post Share on other sites
Kate 3 Report post Posted June 13, 2011 Hi Danny, Is this because you want to have static elements on the home page? Just curious... You just need the code for the latest post? Please check out this post: http://codex.wordpress.org/Function_Reference/query_posts Share this post Link to post Share on other sites
Danny+ 1,327 Report post Posted June 13, 2011 Hi Kate, Yes, I have a static page set as my homepage and so I want to show 1 post from a particular category on the homepage i.e. the lastest post from that category. I have looked at the link you provided and I cant seem to get it to work. I am currently using this but it isnt working how I intend it too. <?php query_posts( 'posts_per_page=5' ); // the Loop while (have_posts()) : the_post(); the_content( 'Read the full post ?»' ); endwhile; ?> Danny Please search our forums, before posting! Share this post Link to post Share on other sites
cmunns 16 Report post Posted June 13, 2011 http://www.wpbeginner.com/wp-tutorials/how-to-display-recent-posts-in-wordpress/ Share this post Link to post Share on other sites
Danny+ 1,327 Report post Posted June 13, 2011 Thanks for the link Adam, I tried that and it works but not to the way I intend it to. I am using the following code: <?php query_posts('showposts=1'); ?> <?php while (have_posts()) : the_post(); ?> "><?php the_title(); ?> <?php the_content(__('(more??¦)')); ?> <?php endwhile;?> [/code] And the end result is this: http://img844.imageshack.us/img844/7715/likethisp.jpg But I want it to look like this: http://img833.imageshack.us/img833/4048/insteadthis.jpg Any help would be appreciated. Thanks Please search our forums, before posting! Share this post Link to post Share on other sites
catrina 103 Report post Posted June 14, 2011 You should remove the bullets so that they don't appear on the page. Please read the docs before posting. Please do not private message me unless I ask you to. Designer | Catrina Dulay Founder | Catrina and Mouse Share this post Link to post Share on other sites
Danny+ 1,327 Report post Posted June 14, 2011 I know I should be removing the bullets, but if you look at the first image there is a sort of list of that Hello World post, then underneath the actual post, now on image 2 there is no list of the post, only the post itself. Thats how I want it to look, and not sure what I should be changing to get the effect I want. Please search our forums, before posting! Share this post Link to post Share on other sites
Kate 3 Report post Posted June 14, 2011 Hi Danny, Try this: ` <?php wp_reset_query(); query_posts('showposts=1'); while (have_posts()) : the_post(); the_title(); the_content(); endwhile;?> ` Share this post Link to post Share on other sites
Danny+ 1,327 Report post Posted June 14, 2011 The code above gave me this look: http://img24.imageshack.us/img24/7735/hmmmpa.jpg Its how I want it but without the double post. Please search our forums, before posting! Share this post Link to post Share on other sites
Kate 3 Report post Posted June 14, 2011 Hmmm... Well, the second post is the one that appears by default on your home page, correct? That was there earlier as well. So, are you wanting to display the latest posts with an offset of 1 (post)? Share this post Link to post Share on other sites
Danny+ 1,327 Report post Posted June 14, 2011 No I dont think it is a post that appears on my homepage by default, you see when I completely remove the code all I end up with is edit page and nothing else. Basically, I just want to show 1 post, which is the latest post. And thank you for your assistance so far Please search our forums, before posting! Share this post Link to post Share on other sites
cmunns 16 Report post Posted June 14, 2011 Oh then you should just go to your SETTINGS . READING and choose the option for showing posts per page to 1 Share this post Link to post Share on other sites
Danny+ 1,327 Report post Posted June 14, 2011 Although, as soon as I read your reply Adam, I thought thats it, that has to be the problem, it unfortuately didnt solve it Im still getting a double Hello world post. Please search our forums, before posting! Share this post Link to post Share on other sites
catrina 103 Report post Posted June 15, 2011 If you're getting a double Hello world post, that probably means you have excerpts AND full post content enabled. Check your Blog And Posts settings to make sure that both excerpts and full post content are not enabled at the same time. Please read the docs before posting. Please do not private message me unless I ask you to. Designer | Catrina Dulay Founder | Catrina and Mouse Share this post Link to post Share on other sites
Danny+ 1,327 Report post Posted June 15, 2011 OK, I've disabled all excerpts and full post content settings and it removed all of the second post but the title remains? Please search our forums, before posting! Share this post Link to post Share on other sites
cmunns 16 Report post Posted June 15, 2011 Remember that if you have the posts page as the home page (default) and set to show posts 1 you don't need the custom query loop that you had been working on . Share this post Link to post Share on other sites
Danny+ 1,327 Report post Posted June 15, 2011 I set my Homepage as the static frontpage and using the feature page template, when I changed it to the post page, I couldnt use any Pagelines meta data, all I got on the page options is use settings. So setting my homepage to post page is not the answer unfortuately. So back to my previous post, is there anyway to remove to simply so one post on the homepage? Again thanks for the support/assistance so far, just really want to get this to work. Please search our forums, before posting! Share this post Link to post Share on other sites
catrina 103 Report post Posted June 16, 2011 You can set the number of posts in Settings > Reading. Please read the docs before posting. Please do not private message me unless I ask you to. Designer | Catrina Dulay Founder | Catrina and Mouse Share this post Link to post Share on other sites
Danny+ 1,327 Report post Posted June 16, 2011 Ok, I finally resolved this problem, of showing the 1 latest blog post on the homepage. To do this I used the following code: <?php query_posts('showposts=1&cat=18'); while(have_posts()) : the_post(); ?> <?php endwhile; ?> This removes the unwanted double post. Please search our forums, before posting! Share this post Link to post Share on other sites
Danny+ 1,327 Report post Posted June 16, 2011 Hmmm... I've ran into another problem, for some reason the php code for showing the latest post is appearing underneath the edit post link and tags. Is there anyway I can but them below the latest post? http://img196.imageshack.us/img196/1314/hmmm2j.jpg Please search our forums, before posting! Share this post Link to post Share on other sites
Kate 3 Report post Posted June 16, 2011 Hi Danny, Are we able to get a link to your site, please? Share this post Link to post Share on other sites
Danny+ 1,327 Report post Posted June 16, 2011 Sure. http://test.inglorious-basterds.eu/ Please search our forums, before posting! Share this post Link to post Share on other sites
cmunns 16 Report post Posted June 16, 2011 Are you adding this code via a hook? which one? Share this post Link to post Share on other sites
Danny+ 1,327 Report post Posted June 16, 2011 Hi Adam, Im sorry but I dont have a clue what you mean lol. Basically, I installed the plugin PHP Exec and Im add this code: <?php query_posts('showposts=1&cat=18'); while(have_posts()) : the_post(); ?> <?php endwhile; ?> To the page in the page editor, where you normally put your content. Please search our forums, before posting! Share this post Link to post Share on other sites
catrina 103 Report post Posted June 17, 2011 Ah, so it's a plugin, not a hook. (Hooks are explained here: http://www.pagelines.com/docs/base-child-theme) PHP cannot be added to the page editor (or post editor). Only HTML is allowed (or regular text if you're using the text editor instead of the HTML editor). Please read the docs before posting. Please do not private message me unless I ask you to. Designer | Catrina Dulay Founder | Catrina and Mouse Share this post Link to post Share on other sites