Support » Themes and Templates » Insert data depending on ID number of post

  • Hi,

    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'); ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Michael


    Forum Moderator

    i think this would be the proper syntax:

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

    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Insert data depending on ID number of post’ is closed to new replies.