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


8

There are many solutions to this problem. And every one of them is correct, I guess. It depends on what you really want and what will be most friendly/clear to user/administrator of this page. I usually use 3 ways to solve this. Which one of them I chose? It depends on situation. Sometimes I use 2 of them simultaneously. 1. Static front page solution. ...


7

Update Eliminating all of the other solutions, there is at least one remaining: template_redirect: function wpse121308_redirect_homepage() { // Check for blog posts index // NOT site front page, // which would be is_front_page() if ( is_home() ) { wp_redirect( get_category_link( $id ) ); exit(); } } add_action( ...


7

Hi @Alkaline: I think you are looking for this: // $page is a post where post_type=='page' if (get_option('show_on_front')=='page') { $page_id = get_option('page_for_posts'); $page = get_post($page_id); } else { $page = false; }


6

Maybe so? Refined version of my earlier solution. add_filter( 'wp_dropdown_pages', 'add_cpt_to_front_page_dropdown', 10, 1 ); /** * Adds CPTs to the list of available pages for a static front page. * * @param string $select Existing select list. * @return string */ function add_cpt_to_front_page_dropdown( $select ) { if ( FALSE === strpos( ...


6

If you are using the default home page, which in most cases is a list of most recent posts, is_home() should work. If you have set a static page to be your front page (in Settings >> Reading), is_front_page() should work. If you are not getting the results you expect using this: if (is_front_page()) { //the code you want to execute } perhaps you can ...


6

When the installer runs it calls wp_install(), that in turn calls populate_options() defined in wp-admin/includes/schema.php, which runs the following.. if ( !__get_option('home') ) update_option('home', $guessurl); Prior to that $guessurl is defined by.. $guessurl = wp_guess_url(); The guess URL function is defined in wp-includes/functions.php and ...


6

You don't want a post to be the front page, you want a custom post type entry to be the front page. Now that we have the terminology right, yes it's possible. A client once asked me to do the exact same thing. They had a custom post type they needed displayed on the front page. Doing so was as simple as adding a filter to allow them to select a "stack" ...


6

Let's see if I can confuse myself. If either of your two OR conditions is true the code executes. is_home and is_front_page can return true for different pages, negated in your case. If you have a static from page, which it sounds like you do, then is_home is the blog index page. Note: WordPress 2.1 handles this function differently than prior ...


5

I think you can set your post to private to view it privately on the homepage. Once you change the visibility to private, the post or page status changes to "Privately Published" as shown. Private posts are automatically published but not visible to anyone but those with the appropriate permission levels (Editor or Administrator). See here. ...


5

This is really not enough information, so I have to guess. A) The div is part of the content Use PHP, check for front-page, and if not, handle the div: <?php if (! is_front_page()) : ?> <div /> <?php endif; ?> B) The div is located somewhere else on the page Give the div an ID and use jQuery: <?php if (! is_front_page()) : ...


5

I solved it using the offset query parameter. This allowed me to edit the query in the pre_get_posts hook, and seems to be the cleanest way to do this, without a new query. Now the home page shows only one post, and page/2/ shows posts 2-11. All links keep working, no other modification is required. add_action('pre_get_posts', 'set_offset_on_front_page'); ...


5

First, if you want to target the site Front Page, you need to use is_front_page(). The is_home() conditional returns true when the blog posts index is displayed, which may or may not be on the site Front Page. Second, you need to hook your function into an appropriate hook, which it appears in this case is wp_enqueue_scripts. (Also: what is ...


4

Why not just create a front-page.php template file, that uses either a normal query/Loop, or (if a custom Theme option is set to display the CPT on the Front Page), outputs a custom query/Loop, based on the CPT? The issue there is that you would have to create a separate Theme option to control the Front Page output, while at the same time instructing users ...


4

To be able to use the comments template in your loops, add global $withcomments; $withcomments = true;


4

If I remember right (template hierarchy gets messy in these parts) when you assign page to be posts page then its template is ignored in favor of home page template branch. So try editing home.php (if you have it) or index.php.


4

<div id="posts"> <?php // define query arguments $args = array( 'posts_per_page' => 8, // your 'x' goes here 'nopaging' = true // possibly more arguments here ); // set up new query $tyler_query = new WP_Query( $args ); // loop through found posts while ( $tyler_query->have_posts() ) : ...


4

I'd suggest creating a metabox for the home.php page template. This is easily done with the Advanced Custom Fields (ACF) plugin. You can even use "ACF Lite" if you'd like to build these into your theme, instead of using the plugin. Here's quick and easy way to implement exactly what you're looking for. Create A Custom Metabox that only shows up on the ...


3

For me I'd used a little different approach: use an endpoint to create an url like http://example.com/no-formats/ hooking pre_get_posts to set the proper query if needed filter template_include to force WP to use home.php instead of duplicating it No more. add_action('init', 'add_no_format_endpoint'); function add_no_format_endpoint() { ...


3

You're calling it on the wrong hook, and you're calling the wrong conditional function to test. When the after_setup_theme hook is fired, WordPress hasn't finished processing wether you're on a page or a homepage yet. You should also never pass in hardcoded post IDs. In this case is_home works, as might is_front_page. If you really must reference a ...


3

Before I address your main issue, I must point out a glaring syntax error: <?php if( !is_home() || !is_front_page() ) { ?> <p><?php the_time('F Y'); ?></p> <?php endif } ?> Why is the endif there? It makes no sense whatsoever, and everything in programming has a purpose/reason. You might as well change it to ...


3

First check that there isn't a page set as a front page in "Reading Setting". If that is set, index.php is not used as the home page, but the template of the page you set as front page. In that case, you need to find that template and add you conditional is there. <?php if(is_user_logged_in()) { get_header(); ?> <div id="primary" ...


3

Yes of course. One of the ways to achieve this is by adding an extra category to your posts which you call 'sticky' or 'important' or something like that. For the example I will choose 'important'. To only get the important posts you can write a loop which loops through this category. For example: <?php $args = array( //arguments for the loop ...


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

admin-ajax.php is called with the following action: wpp_update. Look for whatever this action does, it may be doing a remote request, a big query, or something else that takes a long time to execute. A quick search for wpp_update reveals the plugin to be WordPress Popular Posts. This function is being called ...


3

First, you need to familiarize yourself with the WordPress Template Hierarchy, so that you ensure that you are modifying the appropriate template file: Home: Blog Posts Index page; template file: home.php Front Page: Site Front Page; template file: front-page.php I am assuming that you want to display a static front page, and to display your blog posts ...


3

You might want to try is_front_page() instead of is_home(). is_home() returns true when your most recent posts are being displayed on your home page; is_front_page() returns true if you've set it to be a static page in Settings > Reading. See this article for more info: http://codex.wordpress.org/Conditional_Tags#The_Conditions_For_... Hope this helps!


3

@Joseph's answer is probably what you're after. But if the first and subsequent pages are going to be sufficiently different so as to require a complete different template you can hook into the template_include filter. add_action('template_include','wpse57122_change_on_p2'); function wpse57122_change_on_p2( $template ){ if( is_front_page() && ...


3

Create a file front-page.php with the following content: locate_template( 'category-image-gallery.php', TRUE, TRUE ); That’s all. For the theme’s functions.php If you want to restrict the front page content to posts from that category, filter the front page query: add_action( 'pre_get_posts', 'wpse_74225_frontpage_categories' ); function ...



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