Im creating a theme which have a custom setting page. I know the best method to choose a static page is by going to Settings -> Reading, but my client wants to have all in the same place.
I already got the dropdowns on the settings page and i did the front page by creating the front-page.php file and added
$options=get_option('pa_opciones');
<? query_posts( 'page_id='.$options['front_page'] ); ?>
This is working but im not sure if its the best method or cleanest method. Im trying to make a nice new theme using get_template_parts ,etc.
How should i proceed with the blog page?
currently on my page.php i got:
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php comments_template( '', true ); ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
And on my index.php:
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php else : ?>
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'No se encuentra la pagina', 'defotografos' ); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<p><?php _e( 'Lo sentimos pero no se puede encontrar lo que busca. tal vez si realiza una búsqueda podrá encontrar algo similar.', 'defotografos' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<?php endif; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Im trying to make all these nice and clean but im getting a bit lost.
Thanks for your comments and suggestions
the front page displays setting as set under settings > reading is stored in the options table under
show_on_front
, with value eitherposts
orpage
.if page is selected, the selected pages are stored in options
page_on_front
andpage_for_posts
, with the id of the selected pages as value.you can update these options yourself from your settings page.