How do I set the front page programmatically?

If you manually enter the admin URL wp-admin/options.php you’ll see a list of all options and their values. show_on_front is page when a page is selected to show on front. page_on_front and page_for_posts are 0 when no pages are chosen. You can use update_option to change these values, there is no set_option function.

Static page homepage not showing the_content

You don’t really have a Loop. <?php get_header(); ?> <div class=”content”> <div class=”welcome_area”> <div class=”welcome_area_title”><?php the_title(”);?></div> <div class=”welcome_area_text”><?php if (have_posts()) { while (have_posts()) { the_post(); the_content(); } } ?> What is happening is: You use have_posts() to check that you have post content. You can use an else clause to provide default content if you … Read more

How do I show sticky posts on a static front page that also contains content?

Something like this should work: $sticky = get_option( ‘sticky_posts’ ); if ( !empty( $sticky ) ) { // don’t show anything if there are no sticky posts $args = array( ‘posts_per_page’ => -1, // show all sticky posts ‘post__in’ => $sticky, ‘ignore_sticky_posts’ => 1 ); $query = new WP_Query( $args ); if ( $query->have_posts() ) … Read more

Custom query_var causes displaying posts archive on front page

After detailed debugging of WP::parse_request() and WP_Query::parse_query() I found out that unset( $query_vars[‘date’] ); in ‘request’ filter helps. It basically unsets date query var before WP_Query::parse_query() is invoked so is_home() returns false. add_filter( ‘request’, function( $query_vars ) { global $wp_query, $wp; if ( ! $wp_query->is_main_query() ) { return $query_vars; } $qv_keys = array_keys( $wp->query_vars ); … Read more

Filter front page posts by category

Try adding this code to functions.php file: add_action(‘pre_get_posts’, ‘ad_filter_categories’); function ad_filter_categories($query) { if ($query->is_main_query() && is_home()) { $query->set(‘category_name’,’news, uncategorized’); } } category_name is the slug or the nicename of the category. Add a comma separated list of the categories you wish to include.

Facebook comments box on front page

Fast ‘n’ Hacky The problem can be solved by changing line 319 in facebook.php to the following: if (is_home()) { This way, the front page is not treated as a home page but as a regular page, for which the facebook feature settings can be applied (and will be handled correctly). More Elegant/Complex Here is … Read more

How to prevent the default home rewrite to a static page

The redirect is thanks to redirect_canonical() – we can simply swoop in with a filter and disable it for the front page: function wpse_184163_disable_canonical_front_page( $redirect ) { if ( is_page() && $front_page = get_option( ‘page_on_front’ ) ) { if ( is_page( $front_page ) ) $redirect = false; } return $redirect; } add_filter( ‘redirect_canonical’, ‘wpse_184163_disable_canonical_front_page’ ); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)