Set a static front-page as a landing page programmatically

You can do it by targeting get_option(‘show_on_front’); some code which could help would be: function themename_after_setup_theme() { $site_type = get_option(‘show_on_front’); if($site_type == ‘posts’) { update_option( ‘show_on_front’, ‘page’ ); update_option( ‘page_for_posts’, ‘page-name’ ); } } add_action( ‘after_setup_theme’, ‘themename_after_setup_theme’ ); This will run on theme activation only, remember to change the page-name to the page you want … Read more

Shortcode not working on static front page

It looks like you need to change your front-page.php page, you are using the wrong variable. $static_page_content = get_the_content(); to $static_page_content = the_content(); Edit: I see you just updated your question to this, yes this will work fine. Shouldn’t see any negative side effects from this.

Disable front-page.php template

Maybe template_include filter would get the job done for you. Something along these lines, function prefix_another_front_page_template( $template ) { if ( is_front_page() ) { $another_front_page_template=”something.php”; // adjust as needed $new_template = locate_template( array( $another_front_page_template ) ); if ( !empty( $new_template ) ) { return $new_template; } } return $template; } add_filter( ‘template_include’, ‘prefix_another_front_page_template’, 99 );

Static Front-Page Excerpts

Is there any particular reason not to use the front-page.php template file, and just not bother with trying to pull WordPress headers into external files? Using the front-page.php template file is easy: Create a new static Page, with any arbitrary name (let’s call it “Front Page”) Go to Dashboard -> Settings -> Reading and set … Read more

Custom URL for all posts in WordPress

Create a page with a custom page template, then create a custom WP_Query object to return your last posts. You can get something like: <?php /* Template Name: Blog Page */ get_header(); $args = array( ‘post_type’ => ‘any’, #all post types ‘posts_per_page’ => 10 #get 10 posts ); $query = new WP_Query( $args ); if($query->have_posts()): … Read more

How to show only posts with images?

No need for post IDs what has no thumbnail. Use meta query to get only those what has thumbnail. Add meta query function get_only_posts_with_images( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘meta_query’, array( array( ‘key’ => ‘_thumbnail_id’ ) ) ); } } add_action( ‘pre_get_posts’, ‘get_only_posts_with_images’ ); Or use custom query. $query … Read more