Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 112466

LucyRyder on "Using is_page to display parent page lin in a menu"

$
0
0

I've now tried to code below, which works on the first 'if statement' of displaying the parent page link in my secondary side menu - when on the parent page.
The for the 'elseif statement' i'm trying to say; if on a childpage of this parent, still display the parent page link; but don't give it a class of current page. This second statement does not work.

$parent_title = get_the_title($post->post_parent);
		if(is_page('page-2b')){
		echo "<li class='current_page'><a href='".get_permalink($parent_title->ID)."'>".get_the_title($parent_title->ID)."works</a></li>";
		}

		elseif (is_page('page-2b') || $post->post_parent=="20") {
		echo "<li><a href='".get_permalink($parent_title->ID)."'>".get_the_title($parent_title->ID)."works</a></li>";
                 }
		else {}

(this 2nd attempt is different to me instead trying to list the child pages on the second if/elseif as above)

Anyone for any suggestions pleeeeaaaasssseee? - I feel like i'm nearly there, but oh so far!

Many thanks :)


Viewing all articles
Browse latest Browse all 112466

Trending Articles