WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

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.

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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