title: WordPress - How to find a page with slug that matches the current custom post type archive page?
body: <p>I'm using the Theme Customizer to create a custom post type page. Using the following PHP code and some additional jquery I'm able to set a default Custom Post Type archive page. </p>
  
  <pre><code>$id = get_option('cptarchive-page'); 
  $p = get_page($id); 
  echo apply_filters('the_content', $p-&gt;post_content);
  </code></pre>
  
  <p>This basically grabs the page I select in the Theme Customizer, finds it's ID, then the jQuery injects the content into the default archive page.</p>
  
  <p>But I want to be able to set a different page for each different CPT. </p>
  
  <p>Now, I have created a custom post type called Staff, and a new page called Archive Staff.</p>
  
  <p>Is it possible to filter through the pages and look for a page with a title <code>Archive [cpt name]</code> (<strong>Archive Staff</strong> in this case), and show that page?</p>
  
  <p>If it doesn't exist, then show the default one I have selected in the theme customer.</p>
  
  <p>And this should work for all custom post types registered. Each CPT archive should find a page that matches their name and show that page.</p>
  
  <p><strong>SUMMARY</strong></p>
  
  <p>(I realized this may be unclear so here's another explanation:)</p>
  
  <p>I currently have, inside the Theme Customizer, an option to select a page to use as the default Custom Post Type archive page using PHP &amp; jQuery. Now I want to be able to automatically use a different page for each registered CPT archive <strong>IF</strong> a page titled "Archive [CPT name]" is published.</p>
  
  <p><strong>EXAMPLE</strong></p>
  
  <p><strong>Registered CPTs</strong>: Staff, Practitioners</p>
  
  <p><strong>Pages created</strong>: Archive Practitioners</p>
  
  <p>So the flow would be:</p>
  
  <ul>
  <li>Find all registered custom post types, excluding built-in post types (Staff, Practitioners)
  
  <ul>
  <li>FOR EACH registered CPT
  
  <ul>
  <li>If page with name “Archive [CPT name]” EXISTS:
  
  <ul>
  <li>get the_content</li>
  </ul></li>
  <li>If NOT EXISTS:
  
  <ul>
  <li>Use chosen default custom archive page</li>
  </ul></li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>So for the Staff archive, the default archive page would be used because there isn't a page called Archive Staff.</p>
  
  <p>But for the Practitioners archive, the default archive page would be the Archive Practitioners page that I created.</p>