Tag Info

Hot answers tagged

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

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()) : ...


4

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


4

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

<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() ) : ...


3

Thanks to @toscho for the useful answer, but it felt a bit hackish to me, so I poked around a bit and figured out I could add a filter instead: function wpa18013_add_pages_to_dropdown( $pages, $r ){ if('page_on_front' == $r['name']){ $args = array( 'post_type' => 'stack' ); $stacks = get_posts($args); ...


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

If the redirect comes from WordPress code, you can find out who is calling wp_redirect() by hooking into it: add_filter( 'wp_redirect', 'wpse12721_wp_redirect' ); function wpse12721_wp_redirect( $location ) { // Get a backtrace of who called us debug_print_backtrace(); // Cancel the redirect return false; }


3

Changing the word count on the home page is easy: if( is_home() ) add_filter( 'excerpt_length', create_function( '', 'return 300;' ) ); Just replicate that code and change the conditional check to add this to other pages. The other option is to just insert the code on the template page (home.php, tag.php, etc.), so you know it's going to be set on the ...


3

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.


3

Look somewhere after the "Loop" starts (it starts with <?php while( have_posts() ): the_post(); ?>) in your index.php file. Find <?php the_content(); ?> and change it to <?php the_excerpt(); ?>. If you don't want any content, just remove the_content() all together. If you're using a theme from wordpress.org, it would best to do this in a ...


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


3

The modern way would be to use html5 which does support geolocation: simple demo A bit longer explanation how this could be added to a web-app here A nice php script that uses a web service called geoplugin (the api is nice, no idea about the company, ymmv!) And last but not least, using the html5 geolocation from php (which you would need for wordpress) at ...


3

Register a widget, and call it on the front-page when the the_post action is called second time: add_action( 'wp_loaded', 'wpse_80202_register_banner_widget' ); function wpse_80202_register_banner_widget() { // used on the first page of main loop only register_sidebar( array ( 'name' => 'Banner front-page ', ...


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


2

Category page can't be home page (just doesn't work like that). There are two other options: Limit home page to posts from specific category (close but not the same thing). Redirect home page to actual category page. Since you seem fine with redirect try following. Create home.php template in your theme directory with following content: <?php ...


2

You can either manually enter content into the_excerpt section or use this code in your functions.php file in your theme function custom_excerpt_length( $length ) { return 200; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); Change the number 200 to the number of characters you want until it's the number of lines you're looking for.


2

Ok, maybe this is a strange or complicated way to do this, but I had a similar problem (I wanted to display a welcome text and the three newest posts of a specific category on the front page. So I did: Created a new page called home and put my welcome text on it. Deactivated the default home page and set my custom home page as the start page Created a new ...


2

I don't think you fully understand the meaning of templates in WordPress. You do not choose template by including it in URL, WordPress deals with choosing template by making sense of URL request. See Template Hierarchy in Codex.


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



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