• Resolved kgagne

    (@kgagne)


    Hello!

    I would like my site’s homepage to have a static, sticky page at the top, with the typical blog chronology beneath that.

    The difference between what I’m envisioning and just creating a sticky blog post is when clicking on the header: I want the link to point to the page, not a blog post.

    Is there a way to combine these two content formats on my homepage?

    -Ken

Viewing 11 replies - 1 through 11 (of 11 total)
  • Well, if your blog is setup to display posts on the home page… then making a sticky post will “stick” it to the first position on the home page.

    Then, in your post that is sticky, use the “page links to” plugin to link it to another “page” you create with the same name.

    So, when clicking the “sticky”.. it’ll take you to the page.

    Thread Starter kgagne

    (@kgagne)

    Thanks! I wasn’t aware of the “page links to” plugin. I’ll take a gander!

    One potential problem, though: wouldn’t this require I maintain a post and a page with identical content?

    Will you always be using the same page, or at least for a reasonable period of time where you won’t be changing it? If so, I would create a custom function in functions.php.

    function showHeaderPage($pageID) {
       $post = get_post($pageID);
       $content = $post->post_content;
       $content = wpautop(do_shortcode($content));
       return $content;
    }

    See: get_post, do_shortcode, wpautop

    Then above the Loop on your template, just call the function
    <?php echo(showHeaderPage(##)); ?>
    Where ## is whatever post ID you’re dealing with.

    No, not necessarily. Just setup your sticky to display what you want on the home page. Then, you can create the “page” with whatever content you want. It can duplicate the “sticky” or be different.

    Wait… I’m not sure I understand exactly what you are wanting. Do you not want them to have identical content?

    Rebecca provides a MUCH more elegant solution… however you’ll want to make sure you have a child theme installed first.

    Thread Starter kgagne

    (@kgagne)

    Rebecca: Yes, in fact, the content of the page changes only once a year, but it’s always the same pageID. I will play with this solution. Thanks!

    Josh: Sorry, maybe I’m not explaining myself well. Better perhaps to provide an example:

    https://www.worcesterdance.org/

    I want the dance schedule to always be at the top of the homepage, as well as available at this URL:

    https://www.worcesterdance.org/schedule/

    Right now, the only way I know of to do that is to maintain the schedule in two places: the above page, and the sticky blog post currently on the homepage.

    -Ken

    Thread Starter kgagne

    (@kgagne)

    Josh: Thanks! I have in fact created and am using a child of the Fiver theme for such mods.

    I gotcha. So you are wanting a “sticky” post.. with dynamic content ??

    Then yes, I believe Rebecca’s solution is going to be better for your needs. That way, it will update in both places when you change one.

    I thought you just wanted to display static content… that wouldn’t change on either the post or the page.

    Thread Starter kgagne

    (@kgagne)

    Thanks, Josh. The content changes so rarely (only annually) that I almost think of it as static — but since it’s updated so rarely, it’s easy for me to forget that I have to do it in two places. The suggestions in this thread should alleviate that need.

    Thanks again to both of you!

    -Ken

    Thread Starter kgagne

    (@kgagne)

    Yup — Rebecca’s code works great for my needs. Thanks!

    I’m confused, it appears that you have your schedule as a sticky post and also as a page so that you can have a menu item “schedule” and a permalink “https://www.worcesterdance.org/schedule/&#8221;. You should be able to do this without any custom changes at all.

    WordPress lets you have a Post as menu item (open up your Screen Options when you are on your Menu settings if you don’t see your Posts to add to the menu). Then you only need to update the “schedule” Post once a year. The Post will be sticky on the home page and also be available as a single post page available as a permalink and as a menu item. You only need to make changes on one place and it will appear in both “locations”.

    Since you only seem to be creating one post per month you might consider changing your permalink settings to just the post-name instead of the year/month/post-name format to make your permalinks simpler.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Page & posts as homepage’ is closed to new replies.