Insert data depending on ID number of post (3 posts)

  1. krushinfo
    Posted 6 years ago #


    I've run into a bit of a problem. I've used WordPress for an online store. Initially it was great but as my product base expanded I'm finding it very time consuming to update prices etc..

    Is there a way I can insert something automatically depending on the ID number of a post perhaps?

    So say post number 17 is showing, I could use PHP to include 17.php which would have the payment code for that specific product?

    Any help would be appreciated..

    I did try this but it threw up an error as it wouldn't parse the ID number code...

    <?php include('payment/<?php the_ID(); ?>.php'); ?>

  2. Michael
    Forum Moderator
    Posted 6 years ago #

    i think this would be the proper syntax:

    <?php include('payment/' . get_the_ID() . '.php'); ?>

  3. krushinfo
    Posted 6 years ago #

    Hey alchymyth,

    Thanks, that pulls the correct PHP file in just fine.

    I can now have a folder with all the payment details in each individual .PHP file.

    Does anyone have any ideas how I can organise this? Probably a bit of a silly question really. Just wish I had thought about this before scaling up!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.