I am attempting to do something similar to the accepted answer on this question Is it possible to use a single custom post as the site front page
My problem is that this implementation causes a redirect.
So for example if I add the code below to twentyeleven functions.php on a default WordPress install, and then select the Hello World
post from the reading->front page
drop down my home url such as mysite.com
will redirect to mysite.com/?p=1
. So it is impossible to actually stay on the home page because of this redirect.
Is it possible to avoid this redirect? If so, the solution below will be great for showing a post or custom post as the home page.
add_filter( 'get_pages', 'add_pages_to_dropdown', 10, 2 );
function add_pages_to_dropdown( $pages, $r ){
if ( ! isset( $r[ 'name' ] ) )
return $pages;
if ( 'page_on_front' == $r[ 'name' ] ) {
$args = array(
'post_type' => 'post'
);
$portfolios = get_posts( $args );
$pages = array_merge( $pages, $portfolios );
}
return $pages;
}