• I’m using WP as a CMS for a very large website. There are 12 different locations and each one needs their own contact info to display in the footer. Conditionals are no problem. I’m using a combination of tree, category and home conditionals and I can get text to echo without a hitch.

    <?php
    wp_reset_query();
    global $post;
    if (is_home()) {
    	echo 'Home';
    }
    elseif (is_tree(10)) {
    	echo 'Bridgeport YMCA';
    
    }
    elseif (is_category('bridgeport')) {
    	echo 'Bridgeport Category';
    }
    else {
    	echo 'General';
    }
    ?>

    The problem is that I need to display content based on a certain page ID. I do this sort of thing elsewhere on the site with no problems, but I’m having a hard time getting this right within a conditional statement. I’ve scoured the Codex and something is missing for me. If someone could give me a nudge in the right direction, I’d appreciate it.

    I’ve tried a couple of different methods. I’m sure that I must not be calling the page content correctly, but I can’t find an example that works out for me.

    else {
    query_posts('page_id=53');
    the_content();
    }
    else {
    get_page(53);
    echo apply_filters( 'the_content' , $post_id_53->post_content );
    }
Viewing 1 replies (of 1 total)
  • Thread Starter saramac

    (@saramac)

    I found a solution, but I’d love to know if there are better ways to accomplish this sort of thing.

    Custom function added:
    https://pastebin.com/ZVagWx9h

    Can now add page content via echo getPageContent():

    if (is_home()) {
    echo getPageContent(53);
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Conditional Content in Footer’ is closed to new replies.