title: Wordpress WP_Query/get_posts where post_title equals returns all results
body: <p>I've created a custom post type called 'snippets' where there are snippets of data like 'address' that the client can change.</p>
  
  <p>The title of the snippets are all unique:
  <a href="https://i.stack.imgur.com/4AY5j.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4AY5j.png" alt="Custom Post Type"></a></p>
  
  <p>I have created a simple function to return these snippets however it's not working quite right and I'm not sure why.</p>
  
  <p>Function:</p>
  
  <pre><code>function get_snippet($snippet_title) {
      $snippet_page = new WP_Query(array(
          'post_type' =&gt; 'snippets',
          'post_title' =&gt; $snippet_title
      ));
      return $snippet_page-&gt;posts[0]-&gt;post_content;
  }
  </code></pre>
  
  <p>Here is an example call to the function:</p>
  
  <pre><code>echo get_snippet('footer_address');
  </code></pre>
  
  <p>The issue is:</p>
  
  <p>It will always return all the snippets and not filter by post_title.</p>
  
  <p>Even if I use <code>get_posts()</code> it will always return all snippets in the same order and will not return the single snippet based on the post_title.</p>
  
  <p>The result is instead the equivalent to: </p>
  
  <pre><code>$snippet_page = new WP_Query(array(
      'post_type' =&gt; 'snippets'
  ));
  </code></pre>
  
  <p>Why will it not filter by 'post_title'?</p>
  
  <p>Thanks</p>
  
  <p>(I am also using multisite)</p>
  
  <p>Here is my custom post type init code:</p>
  
  <pre><code>function snippets() {
      $labels = array(
          'name'                =&gt; _x( 'Snippets', 'Post Type General Name', 'text_domain' ),
          'singular_name'       =&gt; _x( 'Snippet', 'Post Type Singular Name', 'text_domain' ),
          'menu_name'           =&gt; __( 'Snippets', 'text_domain' ),
          'name_admin_bar'      =&gt; __( 'Snippets', 'text_domain' ),
          'parent_item_colon'   =&gt; __( 'Parent Item:', 'text_domain' ),
          'all_items'           =&gt; __( 'All Snippets', 'text_domain' ),
          'add_new_item'        =&gt; __( 'Add New Snippet', 'text_domain' ),
          'add_new'             =&gt; __( 'Add New Snippet', 'text_domain' ),
          'new_item'            =&gt; __( 'New Snippet', 'text_domain' ),
          'edit_item'           =&gt; __( 'Edit Snippet', 'text_domain' ),
          'update_item'         =&gt; __( 'Update Snippet', 'text_domain' ),
          'view_item'           =&gt; __( 'View Snippet', 'text_domain' ),
          'search_items'        =&gt; __( 'Search Snippet', 'text_domain' ),
          'not_found'           =&gt; __( 'Not found', 'text_domain' ),
          'not_found_in_trash'  =&gt; __( 'Not found in Trash', 'text_domain' ),
      );
      $args = array(
          'label'               =&gt; __( 'snippets', 'text_domain' ),
          'description'         =&gt; __( 'For custom snippets of code/data.', 'text_domain' ),
          'labels'              =&gt; $labels,
          'supports'            =&gt; array( ),
          'hierarchical'        =&gt; false,
          'public'              =&gt; false,
          'show_ui'             =&gt; true,
          'show_in_menu'        =&gt; true,
          'menu_icon'           =&gt; 'dashicons-tagcloud',
          'menu_position'       =&gt; 5,
          'show_in_admin_bar'   =&gt; true,
          'show_in_nav_menus'   =&gt; false,
          'can_export'          =&gt; true,
          'has_archive'         =&gt; true,      
          'exclude_from_search' =&gt; true,
          'publicly_queryable'  =&gt; false,
          'capability_type'     =&gt; 'page',
      );
      register_post_type( 'snippets', $args );
  }
  add_action( 'init', 'snippets', 0 );
  </code></pre>