• Resolved vectyr

    (@vectyr)


    Client wants to style each page of his site differently. Using this to display two custom fields.

    <?php $mymeta = get_post_meta($post->ID, 'background_image', true); if ($mymeta) {echo '<style type="text/css" media="screen">.background {background-image: url('.$mymeta.') !important;'; } ?>
    	<?php $mymeta = get_post_meta($post->ID, 'background_color', true); if ($mymeta) {echo 'background-color: #'.$mymeta.' !important;} </style>'; } ?>

    Problem is that I created a main page that displays child pages and on the main page, I think the first child custom fields are overriding the parent page’s custom fields.

    Parent Page: http://sugareffect.com/dev/works/
    1st Child Page: http://sugareffect.com/dev/works/sugar-effect-into-sequence/

    Is there a way to display the custom fields for the current page only while ignoring the custom fields from the child pages?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Are you sure there is really a parent’s custom field ?

    Is your parent page a real page or archive ?

    Thread Starter vectyr

    (@vectyr)

    You know, you’re right, these ARE archive pages. I’m looking at the blog and post pages and particularly a custom post type archive page.

    Thread Starter vectyr

    (@vectyr)

    Still need a solution though, any ideas?

    Conditionally fire your CSS from meta, like for example

    if ( 'works' == get_post_type() ) { <-your css from meta goes here-> }

    or

    if ( !is_post_type_archive() ) { <-your css from meta goes here-> }
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Child page custom field overriding partent custom fields’ is closed to new replies.