Duplicate your page.php
template, name the duplicate page-facebook.php
, give it a template name:
/*
Template Name: My Facebook Meta Key Page
*/
More information here: http://codex.wordpress.org/Page_Templates
To get the right posts with get_posts
use something like this:
<?php
$args = array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'facebook',
'value' => 'yes',
)
)
);
$fbposts = get_posts( $args );
foreach($fbposts as $post) : setup_postdata($post); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_content(); ?>
<?php endforeach; ?>
More information here: http://codex.wordpress.org/Template_Tags/get_posts
Of course you can do it with WP_Query
like GhostToast suggested, it is pretty similar, take a look here: http://codex.wordpress.org/Class_Reference/WP_Query
Get the posts with WP_Query
like this:
<?php
$args = array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'facebook',
'value' => 'yes',
)
)
);
$fbposts = new WP_Query( $args );
if ( $query$fbposts->have_posts() ) {
while ( $fbposts->have_posts() ) {
$fbposts->the_post();
echo '<h2><a href="'. the_permalink() .'">'. the_title() .'</a></h2>';
echo the_content();
}
} else {
}
wp_reset_postdata();
?>