• Resolved Amie

    (@sunburntkamel)


    ok, so i really dig the static front page thing. i’m trying to find a way to make a link to the page of blog posts, and make it work universally, for the likely event that i release it as part of a theme. here’s what i’ve got so far:

    $mytheme_frontpage = get_option('show_on_front');
    $mytheme_page_for_posts = get_option('page_for_posts');
    $mytheme_blog_page = get_post($mytheme_page_for_posts, Array_A);
    $mytheme_blog_url = $mytheme_blog_page->guid; ?>
    
    <a href="<?php if ( $mytheme_frontpage = page ) { echo $mytheme_blog_url; } else { bloginfo('home'); } ?>" title="home">Blog</a>

    it works once. after that, the variables stop updating. so if i switch back to showing blog posts on the front, the link still goes to whatever static page i had previously defined.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You have two problems. Both of which are maddening when you are debugging.
    1. You have a single = instead of a == so you are setting the variable $mytheme_frontpage to page instead of checking the conditional statement for equals using ==.
    2. You are missing quotes around the value you are checking the variable $mytheme_frontpage against. So instead of checking to see if it is equal to the string ‘page’ you are checking if it is equal to the memory space of the constant page.

    It should be:

    <a href="<?php if ( $mytheme_frontpage == 'page' ) { echo $mytheme_blog_url; } else { bloginfo('home'); } ?>" title="home">Blog</a>

    –[moderated sig]–

    Thread Starter Amie

    (@sunburntkamel)

    very awesome, thanks.

    After researching this situation in as many posts as I could before feeling totally lost, this one comes about the closest to what I’m trying to make happen.

    I like the “Freshy” theme so I’d like to continue to work with it.

    It has its own option for setting the label of the homepage menu link, and of course WP2.1 has its option for setting a “page” to be the static front page, and another “page” to be the posts page. The problem is I have to actually make pages called home and blog, and they get listed in the navigation bar at the top when there’s already a home label there.

    https://spellrightnow.com

    I’m leaving it broken for now until I can wrap my head around this confusing situation for good.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘New Static Front Page, link to Blog Page’ is closed to new replies.