• Resolved Legendary Lion

    (@legendary-lion)


    I’m attempting to pull in a custom variable from a specific post (Youtube Embed).

    The code works on the home page, but not on the inside pages.

    <?php
    	if ( is_page(24) ) {
    	    // This is Podcast
    	    echo get_post_meta(570, "Youtube Video", true);
    	} else if ( is_page(25) ){
    	    // This is Video
    	    echo get_post_meta(568, "Youtube Video", true);
    	} else if ( is_page(26) ){
    	    // This is the Home Page
    	    echo get_post_meta(550, "Youtube Video", true);
    	} else {
    		//Other Pages
    	}
    ?>

    This code works on the home page with both the conditional of page 26 or using the if (is_front_page() ) conditional.

    I can change the post meta call to any of these three for the home page and it works… So I know all of the custom variables there there and in working order.

    However, something is preventing the custom variables from working on the inside pages (pages 24 and 25).

    Thoughts?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Legendary Lion

    (@legendary-lion)

    UPDATE:
    With the following code;
    The if is_front_page works only on the homepage
    The else statement is applied to all other pages

    <?php
    	if ( is_single( '24' ) ) {
    	    // This is Podcastwp_reset_query();
    	    echo get_post_meta(570, "Youtube Video", true);
    	    	} else if ( is_single ( '25' ) ){
    	    // This is Video
    	    echo get_post_meta(568, "Youtube Video", true);
    	} else if ( is_front_page ( '26' ) ){
    	    // This is the Home Page
    	    echo get_post_meta(550, "Youtube Video", true);
    	} else {
    		//Other Pages
    		echo '<h1>TESTING</h1>';
    	}
    ?>
    Thread Starter Legendary Lion

    (@legendary-lion)

    Solved.

    These items were categories, not pages.

    The resulting code works like a charm.

    <?php
    	if ( is_category( 'podcast' ) ) {
    	    // Display Podcast Specific Content
    	    echo get_post_meta(570, "Youtube Video", true);
    	    } else if ( is_category ('video') ){
    	    // This is Video
    	    echo get_post_meta(568, "Youtube Video", true);
    	} else if ( is_front_page () ){
    	    // This is the Home Page
    	    echo get_post_meta(550, "Youtube Video", true);
    	} else {
    		//Other Pages (Display Home Page Video)
    		echo get_post_meta(570, "Youtube Video", true);
    	}
    ?>

    Thanks for your attention and time!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘If Page Code with Custom Variable’ is closed to new replies.