• Hi,

    I have a ‘contact’ page on my site and I would like to display a set of posts from a particular category, in the middle of the page.

    Would this be a case of hacking up the ‘page.php’ and saying “if is_category(3), show these posts”, or could I add some PHP into my actual Page Content?

    Many thanks for looking and helping if you can ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • I’d recommend you create a different page template with a separate loop.

    More on page templates.

    Custom loop extracted from here:

    // Get the last 10 posts in the special_cat category.
    <?php query_posts('category_name=special_cat&showposts=10'); ?>
    
    <?php while (have_posts()) : the_post(); ?>
        <!-- Do special_cat stuff... -->
    <?php endwhile;?>

    You have to either edit your page.php template or use a plugin that lets you execute php code in posts and pages.

    https://www.ads-software.com/extend/plugins/exec-php/

    Thread Starter michaelmcguk

    (@michaelmcguk)

    Crikey, like waiting for buses this! ??

    Thank you both very much, I’ll look at the two options and see how I go.

    Cheers!

    LOL iridiax’s post was so similar to mine, I thought I double-posted.

    I will note though, that in principle I agree with wp_guy, use the plugin only if you can’t avoid inserting the php in the middle of your content.

    michaelmcguk, wait until you start asking difficult questions, then see the response rate drop off ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Embed WP PHP in my Page?’ is closed to new replies.