Tag Info

Hot answers tagged

13

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

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


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

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(),


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

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

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


3

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

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


2

You don't have to make any template or other programmatic changes just to use a static Page as your site front page: Create a static Page, give it any arbitrary name (e.g. "Front Page", but it can be anything), and add whatever content to it that you need/want If you need to display a blog posts index, create a second static Page, again give it any ...


2

You can use WP_Query in your template to select groups of posts by type, category, tag, custom taxonomy, meta field, etc., and create additional loops: <?php $news = new WP_Query("post_type=mynews&posts_per_page=1"); while($news->have_posts()) : $news->the_post(); the_title(); endwhile; $events = new ...


2

I am not sure why you need pages over posts here. Using posts gives you ready made index home page, slugs and pretty permalinks give you link structure you want. You can just add some blurb on home page that says "bookmark this puzzle" with direct permalink.


2

First, you need to use the front-page.php template file. In WordPress parlance, Home refers to the Blog Posts Index, whether on the site front page or another static Page, and Front Page refers to the Site Front Page. Second, you have several options for exposing a UI to manage your front-page quotes (in order of preference): Make the Front Page a dynamic ...


2

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 "Front Page Displays" ...


2

With oEmbed support in both WordPress and on Vimeo's end, why not just use the [embed] shortcode? [embed]http://vimeo.com/24474320[/embed] This is easy to explain, and users are generally pretty comfortable with just copy-and-pasting a URL directly, rather than having to extract just the ID out of it. You can also turn on the option to just use the URL ...


2

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



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