Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed assistance w/ dynamic highlighting an image-sprite navigation menu in wordpress
    primarykey
    data
    text
    <p>I have an image based menu on a wordpress site Im building that Id like to be able to dynamically highlight for each section &amp; <strong>more importantly highlight while each visitor is viewing a child page or post within its respective page</strong>. </p> <p>I've sorted out how to get each section to highlight just fine when viewing that parent page, however Ive run into some trouble with achieving the same effect when I choose to view a post or subpage.</p> <p>Since <strong>Im utilizing categories to filter content to specific pages</strong> I was able to get each section to still highlight when viewing a post by using: <code>&lt;?php if ( is_page('page-name') || is_category('cat-name') || in_category('cat-name')) { echo ' class="xxxx_highlight" '; } ?&gt;</code> yet this also caused a few problems as well unfortunately....What happened was, as soon as there was content posted to both the BLOG &amp; MEDIA section - both sections would highlight simultaneously which is obviously not what were going for here. Couldn't really figure out why that occurred however so I removed the <code>in_category()</code> &amp; <code>is_category()</code>...</p> <p>Ive been looking through the conditional tags section up and down for the last couple weeks with no avail as to what additional tags are at my disposal in order to achieve this with a sprite menu. What would be ideal rather then targeting "categories" would be if there were a tag to simply look for if a single.php page &amp; subpage of a parent in the menu was in use...couldn't really find anything that worked however so Im hoping some php/wordpress guru can point in the right direction hopefully! </p> <p>Here is my current markup:<br/> <strong>HTML MENU</strong> </p> <pre><code>&lt;ul id="nav"&gt; &lt;li&gt; &lt;a href="/" id="logo"&gt;&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="/" id="home" &lt;?php if ( is_front_page('events')) { echo ' class="home_highlight" '; } ?&gt;&gt;&lt;/a&gt;&lt;!-- HOME --&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="/artists" id="artists" &lt;?php if ( is_page('artists')) { echo ' class="artists_highlight" '; } ?&gt;&gt;&lt;/a&gt;&lt;!-- ARTISTS --&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="/media" id="media" &lt;?php if ( is_page('media')) { echo ' class="media_highlight" '; } ?&gt;&gt;&lt;/a&gt;&lt;!-- MEDIA --&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="/blog" id="blog" &lt;?php if ( is_home('blog')) { echo ' class="blog_highlight" '; } ?&gt;&gt;&lt;/a&gt;&lt;!-- BLOG --&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="/store" id="store" &lt;?php if ( is_page('store')) { echo ' class="store_highlight" '; } ?&gt;&gt;&lt;/a&gt;&lt;!-- STORE --&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="/contact" id="contact" &lt;?php if ( is_page('contact')) { echo ' class="contact_highlight" '; } ?&gt;&gt;&lt;/a&gt;&lt;!-- CONTACT --&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload