javascript - Changing CSS based on URL or if child of parent (Wordpress) -


this seems pretty straightforward cant seem find solution...

i have border-bottom on header , want change colour of border depending on section user in.

example parent pages below:

home | parent 1 | parent 2

id if on 'parent 1' or child page of 'parent 1', change border-color to... else if on 'parent 2' or child page of 'parent 2' change this.. , on.

thanks

try this:

function mycustom_style() {       $pageid = wp_get_post_parent_id(get_the_id());  //get parent page id     if(!empty($pageid))     {         //can use switch case         if($pageid=='16')  //your page id         {             echo "<style>.myclass{ border-color: red}</style>";         }     } } add_action( 'get_header', 'mycustom_style'); 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -