title: Wordpress check if you're on the current page (not menu)
body: <p>I am creating a little shortcode that acts like the custom menu widget, but I'm choosing the pages from a dropdown list, instead of creating a menus inside the wordpress (I'm also adding a color to it, so I can't just use regular wordpress menus widget).</p>
  
  <p>So far so good, it's just one thing that's bothering me. I want to check if the page I'm on matches the one in my list (on the real page). I googled and searched a bit and found that with</p>
  
  <pre><code>$actual_link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
  </code></pre>
  
  <p>I can get the current page I'm on (the link I see in my browser). Perfect!</p>
  
  <p>So if I want to add a class called current page, all I need to see if my <code>$actual_link</code> matches with my selected link from the dropdown list.</p>
  
  <p>I'm working this within a page bulder plugin The Creator, so I know how to create a working shortcode in it. My pages dropdown is created by making an array that will have page url as key and page name as a value. My loop is:</p>
  
  <pre><code>$args = array (
      'post_type' =&gt; 'page',
      'posts_per_page' =&gt; -1,
      'orderby' =&gt; 'menu_order',
      'order' =&gt; 'ASC',
  );
  $pages = get_posts($args);
  
  $forms = array();
  if(is_array($pages)){
      foreach ($pages as $page) {
          $forms[$page-&gt;url] = $page-&gt;post_title;
      }
  }
  </code></pre>
  
  <p>And it works perfectly. Except that the url I get from this is of the form:</p>
  
  <pre><code>http://www.example.com/?page_id=150
  </code></pre>
  
  <p>Whereas I set my permalinks to be nice so the actual link in my browser is </p>
  
  <pre><code>http://www.example.com/my_page_name
  </code></pre>
  
  <p>The id is correct, and if I click on my 'menu' link I'll get to that page (desired result). But now I cannot just go and say:</p>
  
  <pre><code>$current = ($actual_link == $link) ? 'current_page' : '';
  </code></pre>
  
  <p>where <code>$link</code> is the variable that holds the link to the page from the dropdown, so that I can append this to my list to check if I'm on the current page (adds a current_page class). I need this class for the styling purposes - if I'm on the page that has this menu shortcode, next to the link that matches this page I'll get chevron (>).</p>
  
  <p>So my question is, how to get the matching urls, no matter what permalink setting I use? Is there a way to specify this in the <code>get_posts()</code> query, or with the <code>$_SERVER[]</code> variable?</p>
  
  <p>I am trying to avoid javascript with this one, and do everything server side.</p>