I have created a plugin that has the frontend content in a file named showmap.php, I currently have a shortcode that includes the contents of showmap.php on the page the shortcode is placed.

I addition to the shortcode, I have created an option to allow the user to choose a page to include the content on. The reason is that I have a search widget that needs to post to that page so I had to have a way of detecting it.

$db_showmap_options = get_option( 'db_showmap_options' );
$chosen_page = $db_showmap_options['page_id'];

How do I detect the chosen page and include showmap.php? Do I have to take permalinks into account. I'm afraid I'm really lost on this one.

Thanks in advance for any help.

1 Answer 1


How you do this could be more or less hard depending on where the content is supposed to be included in the page, and you don't explain that, but assuming you are including it in the post body...

  function($content) {
    global $post;
    $db_showmap_options = get_option( 'db_showmap_options' );
    if (!empty($db_showmap_options['page_id']) && $post->ID == $db_showmap_options['page_id']) {
      $content = "whatever you need to do".$content;
    return $content;

Untested but I am fairly sure that will work.

You may need output buffering, depending on how your showmap.php is written.

  • I used $content = do_shortcode('[db_showmap]'); and it worked like a charm, thank you for the answer.
    – Russ
    Commented Nov 2, 2013 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.