Forum Replies Created

Viewing 15 replies - 46 through 60 (of 68 total)
  • Thread Starter ajcke

    (@ajcke)

    I finally have the chance to get back to this. The debug message says:

    Notice: load_plugin_textdomain was called with an argument that is deprecated since version 2.7 with no alternative available. in /wp-includes/functions.php on line 2714 Notice: load_plugin_textdomain was called with an argument that is deprecated since version 2.7 with no alternative available. in /wp-includes/functions.php on line 2714 Parse error: syntax error, unexpected T_ELSE in /wp-content/themes/themename/header.php on line 115

    Line 115 of header.php
    else {

    Here’s the code.

    <?php
    if($page_title == "Elementary") {
        $div_id = "topHeaderElementary";
    }
    elseif ($page_title == "High School") {
        $div_id = "topHeaderHighSchool";
    // Add in as many extra ID's as you need in their own elseif() blocks
    else {
        $div_id = "topHeader";
    }
    ?>
    <div id="<?php echo $div_id ?>">div content</div>

    Thread Starter ajcke

    (@ajcke)

    Okay. Now I’m getting somewhere. I tried the following.

    if ($page_title == "Elementary") {
        echo "img1.jpg";
    }
    elseif ($page_title == "High School") {
        echo "img2.jpg";
    }
    // Add in as many extra ID's as you need in their own elseif() blocks
    else {
        echo "default.jpg";
    }

    This puts the text img2.jpg on the page. I think the proper solution would be to change the css class or id since I’m using this to change the header background image. I tried the following but there is something wrong with the code. My page displays white.

    <?php
    if($page_title == "Elementary") {
        $div_id = 'topHeaderElementary';
    }
    else if ($page_title == "High School") {
        $div_id = 'topHeaderHighSchool';
    else {
        echo "topHeader";
    }
    ?>
    <div id="<?php echo $div_id ?>">div content</div>

    Thread Starter ajcke

    (@ajcke)

    How would I code something like this?

    if page root id = 1 display header image1.png
    if page root id = 2 display header image2.png
    if page root id = 3 display header image3.png
    else display header imageDefault.png

    Thread Starter ajcke

    (@ajcke)

    Is there a way to do either of these two methods?

    Thread Starter ajcke

    (@ajcke)

    Thanks! That did the trick.

    Thread Starter ajcke

    (@ajcke)

    I also tried adding the code in the second post to my 404.php file. It just displays

    Error 404 – Page Not Found
    Please use the main navigation or the back button on your browser to find what you’re looking for.

    Thread Starter ajcke

    (@ajcke)

    I’ve tried adding the code above and the code below to the page loop right after <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    The code below still returns the 404 error. Am I putting the code in the wrong place?

    <?php
    	$slug = basename($_SERVER['REQUEST_URI']);
    	$query = 'SELECT * FROM wp_posts WHERE post_name = "'.$slug.'" LIMIT 1';
    	$page_query = $wpdb->get_results($query, OBJECT);
    	$private = ( is_object($page_query[0]) && $page_query[0]->post_status == 'private' );
    ?>
    
    <?php if ( !$private ) { ?>
    	<h1>Error 404 - Page Not Found</h1>
    	<p>Please use the main navigation or the back button on your browser to find what you're looking for.</p>
    
    <?php } else { ?>
    	<h1>Authorization required - please log in.</h1>
    	<?php get_template_part('login'); ?>
    
    <?php } ?>
    Forum: Fixing WordPress
    In reply to: Echo Root Title
    Thread Starter ajcke

    (@ajcke)

    Rajesh your first snippet of code works perfectly. I’m not sure why it wasn’t displaying correctly…user error!

    Forum: Fixing WordPress
    In reply to: Echo Root Title
    Thread Starter ajcke

    (@ajcke)

    I tried, but my site displays a white screen with the if statement code. Can you post an example of what it should look like? Is ?> not properly closing the php?

    Forum: Fixing WordPress
    In reply to: Echo Root Title
    Thread Starter ajcke

    (@ajcke)

    I’m banging my head over this one. I get a white screen with the following code. I don’t see any issues with it.

    <?php
    if ( is_home() ) {
    // This is a homepage
    <h1>Homepage</h1>
    } else {
    // This is not a homepage
    <h1>Not Homepage</h1>
    }
    ?>
    Forum: Fixing WordPress
    In reply to: Echo Root Title
    Thread Starter ajcke

    (@ajcke)

    I tried the following code to resolve the homepage issue. It gave my site the white screen of death and if I remove the code I can’t get my site back.

    <?php
    if ( is_home() ) {
        <h1><?php bloginfo('name'); ?></h1>
    } else {
        <?php $root_page_id = ( empty( $post->ancestors ) ) ? $post->ID : end( $post->ancestors ); ?>
        <h1><?php echo get_the_title($root_page_id);?></h1>
    }
    ?>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Forum: Fixing WordPress
    In reply to: Echo Root Title
    Thread Starter ajcke

    (@ajcke)

    And one more thing. When a post page is displayed the code displays the post title. How could this code display the site title instead of the post title?

    Forum: Fixing WordPress
    In reply to: Echo Root Title
    Thread Starter ajcke

    (@ajcke)

    That does the trick. On the home page it this code displays the latest post title. I would probably need some type of if statement to detect the homepage and display the site title. What code could I use for that?

    ajcke

    (@ajcke)

    You don’t need a plugin. I’m using the following code to accomplish this. This code displays the parent page with the h2 tag and then the children pages are listed in an unordered list.

    <div id="menu-secondary">
    
    <?php
      if($post->post_parent) {
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
      $titlenamer = get_the_title($post->post_parent);
      }
    
      else {
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      $titlenamer = get_the_title($post->ID);
      }
      if ($children) { ?>
     <h2 class="parent"> <?php echo $titlenamer; ?> </h2> 
    
    <ul>
      <?php echo $children; ?>
      </ul>
    <?php } ?>
    </div>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Ahhhh…I would have never looked in the footer.php file. So I will also need to create a second footer page.

    Thanks!

Viewing 15 replies - 46 through 60 (of 68 total)