[Resolved] Include php code on static page using GP sections … ?

Home Forums Support Include php code on static page using GP sections … ?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #115276
    lock-e73

    Hi,
    Just a quick question, and again I apologise if it’s been asked or answered before! I’m creating a static landing page using the GP sections plugin and was wondering how I go about including the most recent blog post in one of the sections? I’ve tried adding the following code but it essentially comments the php out.

    <?php
     global $post;
     $myposts = get_posts('numberposts=1&category=3');
     foreach($myposts as $post) :
     ?>
     <?php the_title(); ?>
     <?php the_content(); ?>
     <?php endforeach; ?>

    Any help would be very much appreciated!
    Thanks,
    lock-e73

    #115303
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    WordPress doesn’t allow for PHP to be executed through the content editor.

    You might be better off using something like this: https://wordpress.org/plugins/display-posts-shortcode/

    Then you can use a shortcode to display your most recent blog posts 🙂

    #115466
    lock-e73

    Hi Tom,

    Ah, that would explain a lot! 🙂

    Thanks for the pointer to the plugin. I’d actually had a look at that one as well as this one – – which also includes shortcodes and ability to customise with CSS. Will have a bit more of a play with both and see what I can do.

    Once again thanks for your quick response!

    Cheers,
    lock-e73

    #115467
    lock-e73

    Hrmm … stripped the link to the other plugin for some reason. Here ’tis again – Recent Posts Widget Extended
    Thanks!

    #115501
    Tom
    Lead Developer
    Lead Developer

    That’s a good one as well, but requires a widget area unless you use a plugin like “Widget Shortcode”.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.