[wp-hackers] the home.php problem: does it asks for a posts.php ?
Leo germani
leogermani at gmail.com
Mon Aug 27 22:15:53 UTC 2012
Yes, I see the root fo the confusion now.
Sometimes I just think that those optinos in the readin panel are dangerous
for the user. I dont want to have a dummy page called "blog" to list my
blog posts. The user can accidentally delete this page and break the site.
or tweak that option...
As a theme developer, what Im looking for is a way to force what will be
displayed in the front page and where the visitor will find the blog.
If I write a front-page.php file and access the root of my site. I have
whatever I want there, despite of what is selected on the reading settings.
But then I dont have a URL to acccess my blog... see?
I could make a custom rewrite rule, Ive done it sometimes, but I just
though I would bring this up here cause its seems something lots of people
want to do and that should have a better support. But I understand now that
we can not do somethig thar ignores the reading settings...
hmmm...
side note: according to you guys this page shoulbe be banned from the
codex:
http://codex.wordpress.org/Making_Your_Blog_Appear_in_a_Non-Root_Folder
Leo,,
On Mon, Aug 27, 2012 at 7:06 PM, Justin Tadlock <justin at justintadlock.com>wrote:
> Not necessarily. You could always set up custom rewrite rules. It's just
> easier to do it through the reading settings.
>
> You don't need a page template for it though. Actually, I don't think you
> can even use a page template at all anyway. WP will automatically use
> "home.php" or, if it doesn't exist, fall back to "index.php".
>
>
> On 8/27/2012 5:00 PM, Leo germani wrote:
>
>> I actually forgot to ask in my email if I was missing something huge here.
>> But beleive me, I see a lot of people running into the same problem.
>>
>> I understand the difference between home.php and front-page.php better
>> now,
>> but the question that brought me here is: if I have a front-page.php file
>> in my theme, what link my visitor will have to access to see my latests
>> posts? Does it have necessarily to be done through the Reading options and
>> setting up a page template?
>>
>> Leo,,
>>
>> On Mon, Aug 27, 2012 at 6:32 PM, Justin Tadlock <justin at justintadlock.com
>> >**wrote:
>>
>> I think you're just getting confused with the "home" and "front page"
>>> terminology a bit.
>>>
>>> home.php is your blog posts template (i.e., your 'post' post type
>>> archive). It's always used when is_home() is true, even if this is not
>>> the
>>> front page of your site. You should never "put anything you want in
>>> there"
>>> with this template. It's for showing your blog posts.
>>>
>>> front-page.php is to override anything shown on the front page of the
>>> site, regardless of any other settings.
>>>
>>> Maybe that helps explain it a bit.
>>>
>>>
>>> On 8/27/2012 4:11 PM, Leo germani wrote:
>>>
>>> Hi all,
>>>>
>>>> Imagine you create a home.php or front-page.php template in your theme.
>>>>
>>>> Ok, now the visitor sees this template when visiting your sites front
>>>> page.
>>>> You can put anything you want there, in a template totally different
>>>> from
>>>> the blog template. Cool.
>>>>
>>>> Now you want to have a link to the lists of posts of your site, right?
>>>> Of
>>>> course it should be easy. But here you get in a weird situation with no
>>>> good solution so far.
>>>>
>>>> Solution 1 - Page template
>>>>
>>>> You create a page template, with a simple code that executes
>>>> query_posts()
>>>> and load your index.php.
>>>>
>>>> This is not a good solution for at least 2 reasons. First, body_class()
>>>> does not work well in this situation. Second, it requires the user to
>>>> create the page and assign the template, this means he/she can break the
>>>> site if this page is edited or deleted
>>>>
>>>> Solution 2 - Use the Reading settings as usual, and create 2 page
>>>> templates. In this case, you will probably have to edit the name of your
>>>> home.php file because sometimes it conflicts with these options. In
>>>> other
>>>> words, this scenario makes home.php useless.
>>>>
>>>> So, isnt it a good idea to have a posts.php template? Lets think about
>>>> this
>>>> solution:
>>>>
>>>> We have now post type archives, so, in theory, we could have a
>>>> archive-post.php and if we access mysite.com?post_type=post we would
>>>> see
>>>> our blog there. It works, but it does not look very good when we're
>>>> using
>>>> beatiful permalinks.
>>>>
>>>> If we follow the same structure we have for others CPTs, visiting
>>>> mysite.com/post would take me to the same place. But it does not,
>>>> because
>>>> this rewrite rule doesnt exist.
>>>>
>>>> Adding this rule could be a solution, but not a good one. /post/ is not
>>>> a
>>>> good URI for a blog.
>>>>
>>>> So what I think that could be done:
>>>>
>>>> . add a default rewirte rule that redirects /blog/ (or /posts/) to
>>>> ?post_type=post (and then we use archive-post.php in our theme).
>>>>
>>>> . add an option in the permalinks page that lets the user change the
>>>> posts
>>>> base URI, as they do with categories and tags.
>>>>
>>>> What do you think about that?
>>>>
>>>> Leo,,
>>>>
>>>>
>>>> ______________________________****_________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.****com <wp-hackers at lists.automattic.**com<wp-hackers at lists.automattic.com>
>>> >
>>> http://lists.automattic.com/****mailman/listinfo/wp-hackers<http://lists.automattic.com/**mailman/listinfo/wp-hackers>
>>> <ht**tp://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>>> >
>>>
>>>
>>
>>
> ______________________________**_________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
> http://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>
--
leogermani.com.br
More information about the wp-hackers
mailing list