Articles of frontpage

How to show only posts with images?

I want to hide posts without images on the front page, so I need get an array of ids of those posts. I know how hide posts on the home page by id, but I need to show only posts with images. This is what I have already: function exclude_post($query) { if ($query->is_home) { $query->set(‘post__not_in’, […]

Performing a POST action on homepage goes to posts page

On every page of my site I got a contact form that will send an email to the respective address. On this site also I’ve set the front page display to a static page. The contact form will basically post to self and if successful will take the user to a new page, otherwise will […]

How to target only the front page (not subsequent paginated pages) in theme/plugin?

I’d like to switch on the front page ONLY. Not subsequent paginated pages (like ?paged=2). I want to output certain output only on the “true” front page of the site. I’ve tried: <?php if (is_front_page() && get_query_var(‘paged’, 1) == 1 || 0): ?> but this only works if the paged variable is present (ex:

Paginated pages are showing correct content but pagination links are not

I am using a custom WP_Query to display posts on static front page. and generating numbered pagination links with paginate_links functions. This is the code I have… $latest_args = array( ‘post_type’ => ‘post’, ‘category__not_in’ => array( 3 ), ‘ignore_sticky_posts’ => 1, ‘paged’ => $paged, ); $latest_query = new WP_Query( $latest_args ); if ( $latest_query->have_posts() ) […]

Custom background for the index page only?

I am stuck at add_custom_background. I can change background color/image but I only want to change my index page. Currently, the changes apply on the whole page. I want to make the changes from WP-admin. How can I specify it to a specific page ? Edit: I just checked im running 3.3.1. So my version […]

wp_title() empty on a static front page

I’m trying to use wp_title() to create a heading for my pages, but I’m using a static front page and, while all of the other pages render the title properly, the front page won’t. This is what I’m working with: <div id=”main-content”> <h1><?php wp_title(“”, true); ?></h1> <?php while( have_posts() ) : the_post() ?> <div class=”pagecontent”> […]

How to display thumbnail and excerpt of a page on homepage?

How to display attached thumbnail and excerpt (about 200 words) of a page on homepage? <?php $page_data = get_page( 401 ); // Get page ID 401 echo ‘<h3>’. $page_data->post_title .'</h3>’; echo apply_filters(‘the_content’, $page_data->post_content); ?> I don’t know how to display attached image as thumbnail. May be i use mb_substr php function to cut the content […]

is_home() in HTML head

Is there a way to check if the current page is the home page from within the head? My style.php needs the number of posts in the slider, but only on the home page. So I count my posts like this: <?php $meta_key = ‘teaser’; $posts_per_page = 6; $sql = “SELECT count(DISTINCT pm.post_id) FROM $wpdb->postmeta […]

Reading Settings -> Front Page displays “Static Page” being reset

Every day my WordPress blog is going from a static page, back to “your latest posts”. I am not setting this setting, something is doing this automatically! Any ideas what to check for? Is there any audit log that shows what is making this change? I am using WordPress 3.9.2 and haven’t had issues till […]

Setting a static home page and blog page without using the settings

This may seem like a stupid question, and it probably isn’t possible, but is it possible for me to set a static home page (using front-page.php) and a blog page (using home.php, I think) in my theme, and have the blog page appear on a separate slug WITHOUT changing the page settings in my WordPress […]