Hot answers tagged frontpage
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
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 ...
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
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
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 ...
3
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 ...
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
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
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
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
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
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
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 ...
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 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
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.
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
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
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 ...
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
...
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
Create a page with a custom page template, then create a custom WP_Query object to return your last posts.
You can get something like:
<?php
/*
Template Name: Blog Page
*/
get_header();
$args = array(
'post_type' => 'any', #all post types
'posts_per_page' => 10 #get 10 posts
);
$query = new WP_Query( $args );
if($query->have_posts()):
...
2
If you want both logged in and non-logged in user to see the same thing then you only want 'published' post status, at least it doesn't make sense to me to show 'private' posts to non-logged in users. Alter you query to include that condition.
$most_recent_sticky_post = new WP_Query(
array(
'post_status' => array( 'publish' ),
// Only sticky ...
Only top voted, non community-wiki answers of a minimum length are eligible
