• Hey, folks! Bear with me – I inherited this censored site and am working on rapidly replacing it with something more well coded. However, in the meantime, I have this situation to resolve:

    One portion of our website is based on WordPress, with a blog having been created but never used, and a dozen or so pages of the site being run via that blog. Now, I have a user who would really like to have the blog up and running.

    If you’d like to check this out, the blog itself is https://www.riverstoneschool.org/news-events/ . If you go to https://www.riverstoneschool.org/news-events/updates-announcements/, that’s one of the pages that is currently run via the blog.

    OK, the pages are working fine right now. The problem is that the blog itself, which isn’t currently used in the site, doesn’t come up properly. The cause is the header.php code, which throws a bunch of page-specific HTML code out, depending on to which of the various sections of the website the page being requested belongs. For the pages, it checks for the page Title and then uses an if tree to determine which code to generate. So far, so good, albeit clunky. Here’s a snippet of that part:

    <?php if ( is_page() || is_single() ) :
        global $id;
        $id = $post->ID;
        $paget = c2c_get_custom('pgtitle');
        if (($paget)=="high-school"){ echo ...

    What I haven’t been able to work out, is how to generate code when there is no page title: for the blog itself. I’ve tried using if (empty($paget)){ echo and even if (($paget)==""){ echo... but to no avail. It’s still borked. In desperation, I even tried adding an extra variable set to the if tree, such that for every successful if:

    if (($paget)=="this-title" {
    echo('content...');
    $isdone = 1; }

    and then output the code if $isdone was still 0 after the if tree, but that didn’t work either. ??

    Any tips will be greatly appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • How about:

    if( $paget =="high-school" ){ echo ...
    elseif( $paget == 'foobar' ) echo ...
    else { ...

    You might also want to have a look at WordPress conditionals – especially is_page() which does pretty much the same thing as your current code.

    Thread Starter matthewm

    (@matthewm)

    Thank you so much for your assistance, esmi!

    I tried the if/elseif/else block, as well as a case/switch block, but either had some mis-coded line or another problem, because every time I tried I got a completely blank page. I reverted it back to the original if tree.

    Anyway, I think the problem lies elsewhere, because:

    1. First thing I tried was to extract the common code out of the blocks in the if tree in the header.php. Then I viewed the ‘home’ blog page (https://www.riverstoneschool.org/news-admin/) – the formatting related to the parts I extracted appeared but because the rest of the header formatting was still missing, it is still rather borked.
    2. Next, I tried switching Settings->Reading from “Your Latest Posts” to “Static Page” and setting the Posts page to a subpage formatted the way I want the ‘home’ to look (https://www.riverstoneschool.org/news-events/updates-announcements/). Result: that subpage page then appeared borked exactly as was the ‘home’ page.
    3. Next, tried adding a “is_home()” section to the if tree in header.php, with no change in results.
    4. Switching it back to using ‘Your Latest Posts’ fixes the updates-annoucements page, but I’m again left without a page showing the posts which I can also format with our site’s CSS, Header, and Footer.

    I’m confused about all this, so if my explanation needs clarification, just let me know! ?? As always, your tips will be appreciated!

    Thread Starter matthewm

    (@matthewm)

    Update – the if/elseif/else problem was definitely a coding error – I’ve gotten that working fine now. Unfortunately, it doesn’t address the issue! I assumed if I could have an “else” case in there, it would apply to the ‘home’ page (the blog posts page) but it doesn’t work!

    Here’s a snippet from the current header.php, showing the last elseif and the final else, which works great on all the static pages but fails on the /news-events/ root or ‘home’ page:

    ...
    elseif (($paget)=="employment"){ echo ('<title>Job Employment Opportunities | Riverstone International School Boise, ID USA</title><meta name="description" content="Learn about job employment opportunities at Riverstone International School in Boise, ID."><meta name="keywords" content="job, jobs, employment, career, careers">'); }
    else { echo ('<title>Updates & Announcements | Riverstone International School Boise, ID USA</title><meta name="description" content="Read about updates and announcements at Riverstone International School in Boise, ID USA."><meta name="keywords" content="updates, announcements, news, events">'); }
    
    endif;
    ...

    There is another similar section in header.php, after the universal stuff I already extracted from these page-specific IF trees.

    <sigh> Still puzzled; more than ever, in fact.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘header for multiple pages Plus the blog itself’ is closed to new replies.