Tag Info

Hot answers tagged

16

is_front_page() returns true if the user is on the page or page of posts that is set to the front page on Settings->Reading->Front page displays So if you set about us as the front page then this conditional will only be true if showing the about us page. is_home() return true when on the posts list page, This is usually the page that shows the ...


7

There are a few functions that come in handy here: unstick_post - Unstick a post stick_post - Stick a post is_sticky - Figure out if a post is sticky With those three in mind, all we need to do is stick them together with some admin menu bar glue. First off, let's wrap everything in a class for fun and profit. This class will have some constants that ...


6

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 a non-hackish version. Put the following in ...


5

You can use the wordpress template hierarchy to do just that. Specifically, you can put the code you want in front-page.php and then use index.php for the rest of them, though that's a rather bland way of doing design with what you have on your hands. Alternately, there are the wordpress conditional tags which can be used to detect whether you're on a ...


4

wp_title() is for the html title tags in your websites head section. It's not for outputting a title. Use the_title(), or get_the_title(),


4

That maybe normal behavior, depending on how exactly you're using is_front_page in your functions file. If you just dropped it inside the file, it's not going to work. Why? Because WordPress loads functions.php before the $wp_query object has been set up with the current page. is_front_page is a wrapper around around $wp_query->is_front_page(), and if ...


4

This is expected behavior. The functions.php file is parsed before the query is setup and available, so if you have if ( is_front_page() ) sitting naked inside of functions.php, it will return false, because there's no query yet. What you need to do is to put your is_front_page() conditional inside of a callback function, that is then hooked into an ...


4

If I'm understanding you correctly, you want to show only the most recent sticky post only on the front page. I had the same issue a month or two ago, and got some fantastic help from the community here at WordPress Answers. The solution is to run two loops in your index.php file. One to pull only the most recent sticky post, and the second to display all ...


4

I think this small source code is your solution. It currently doesn't have frontend feedback for the Sticky Post change, but you can enhance this string, class or whatever you want in the function fb_stick_post. The first function adds the item in the Admin Bar and creates a new Url with a param value. Also, on click calls a function to read the Url param ...


4

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 ...


4

Don't use query_posts. Use a filter on pre_get_posts. function no_front_sticky_wpse_98680($qry) { if (is_front_page()) { $qry->set('post__not_in',get_option( 'sticky_posts' )); } } add_action('pre_get_posts','no_front_sticky_wpse_98680'); By running query_posts you clobber the main query, over-writing it with another query. That is why you ...


4

get_page_by_title() returns an object. Use $homepage->ID. You should also check if you really got a usable return value: $homepage = get_page_by_title( 'Front Page' ); if ( $homepage ) { update_option( 'page_on_front', $homepage->ID ); update_option( 'show_on_front', 'page' ); }


3

Is your home page blog index or static page? is_home() is meant to check if we are on blog index (latest posts), while is_front_page() checks if home is static page set in Settings > Reading.


3

Glad you got it sorted out, but to answer your original question: 1) The front-page.php template file, if it exists, will be used to generate Front Page content, whether the Front Page is set to display the blog posts index or a static Page. 2) The home.php template file, if it exists, will be used to generate the blog posts Index, whether the blog posts ...


3

I don't have the plugin to test this, but looking at the lines to hack, as pointed by @tf: if ( is_home() || is_front_page() ) { $enabled_features = get_option( sprintf( $option_name, 'home' ) ); } else if ( is_archive() ) { // all archives wrapped in one option // is_post_type_archive || is_date || is_author || is_category || is_tag || is_tax ...


3

Well first of all, if you set your page as the static front page, you don't need to associate the template with the page, and the template doesn't need a header. WordPress automatically uses the front-page.php template for a static front page, as per the template hierarchy. To answer your question though, you need to call the_post() first to set up the ...


3

init is too early for conditional tags to work. It marks when core finished loading, but no environment is set up yet. For admin area only you can hook into admin_init. For conditionals on front end earliest hook you can reliable use is template_redirect.


3

From @Ray Mitchel's answer the tutorial shows you how to set a specific page in your blog to be the front page. Assuming you're using the TwentyEleven theme, you need to learn about page templates. The WordPress site has an article: http://codex.wordpress.org/Pages#Page_Templates. So you can create a page template by starting by copying the home.php file ...


3

Here is a much simpler solution that will get the job done using the_content filter hook add_filter('the_content','simplest_sticky_solution'); function simplest_sticky_solution($content){ global $post; //early exit if not needed if (!is_single() || !current_user_can('edit_post',$post->ID)) return $content; //check if form is ...


3

The template naming is a bit confusing in this situation, but what is happening is normal behavior in the Template Hierarchy. home.php shows your posts page, whether it's on the front page, or assigned to another page when using a static front page. If you want your home.php template to be used for your static front page, rename it front-page.php. In the ...


3

You can use get_post for that Example: <?php $post = get_post($id); //assuming $id has been initialized setup_postdata($post); // display the post here the_title(); the_excerpt(); the_post_thumbnail(); wp_reset_postdata(); ?>


3

Simply put, the WordPress template hierarchy reserves home.php for the homepage, but if you set a Front Page post, it will display that instead. If WordPress core developers reserved it for the homepage, I do not believe it would cause issues with any servers, because they would be putting everyone at risk. Hope that explains it for you. :) It is completely ...


3

If you look at the source of wp_title() you will see that there is not output planned for a static front page. Use the_title() for visual output as @Chris_O suggested. But for the title in the <head> section you have to filter wp_title() and fill it if it is empty. Sample code (download from GitHub): // Hook in very late, let the theme fix it first. ...


3

offset overrides pagination, because when you get down to the query level, it's paginated via offset. You can still use offset though, you just have to do some math to multiply your desired offset by the current page number (note that this calculation works because posts per page and offset are both 5, you may have to use the posts_per_page value in your ...


3

Static pages doesn't work with paged query variable, they need the page variable. This is the reason why your second code block makes the query work: it uses the page var when available. However, your paginated links code always use paged: ... 'format' => '?paged=%#%', ... So you are sending paged query var but looking for page var. Solution is to ...


2

You need to find the most recent date with posts and use that to construct the $current_ fields. $last_date = $wpdb->get_var("SELECT DATE(MAX(post_date)) FROM {$wpdb->posts} LIMIT 1"); if (!empty($last_date)) { list($current_year,$current_month,$current_day) = explode('-',$last_date); query_posts( ...


2

Switching the actual template file could work in the same way as above using get_template_part(). For example... <?php if ( wp_is_mobile() ) { // If it is a mobile device get_template_part( 'mobile-front', 'page' ); } else { // If it is not a mobile device get_template_part( 'desktop-front', 'page' ); } // end wp_is_mobile() To take this a step ...


2

Is this expected behaviour? Yes, it is expected behavior. The genesis_register_sidebar() function is just a call to register_sidebar() with a few predefined defaults for $args and a filter named 'genesis_register_sidebar_defaults': function genesis_register_sidebar( $args ) { $defaults = (array) apply_filters( ...


2

You can check in your callback function if you are an the front page. Sample code for the theme’s functions.php: add_action( 'after_setup_theme', 'wpse_67480_theme_setup' ); function wpse_67480_theme_setup() { $bg_options = array ( 'wp-head-callback' => 'wpse_67480_background_frontend', 'default-color' => 'f0f0f0', ...


2

loop-page.php is the wrong context for what you are trying to do. If you want it to appear on the home page, then you need to edit loop.php, so in your child theme you can either create a file called, loop.php ...which should take precedence over the loop.php found in the parent TwentyTen theme or better yet create a file called, loop-index.php ...



Only top voted, non community-wiki answers of a minimum length are eligible