{"id":287,"date":"2010-07-02T14:58:24","date_gmt":"2010-07-02T20:58:24","guid":{"rendered":"http:\/\/www.cavanaugh.pro\/sean\/?p=287"},"modified":"2011-03-10T17:03:49","modified_gmt":"2011-03-10T23:03:49","slug":"wordpress-menu-problems-with-custom-templates","status":"publish","type":"post","link":"https:\/\/www.cavanaugh.pro\/sean\/wordpress-menu-problems-with-custom-templates\/","title":{"rendered":"wordpress menu problems with custom templates"},"content":{"rendered":"<p>I am assuming if you found this post you were using google!<\/p>\n<p>ANYWAYS! The problem I was having on one of my sites was that the css   implementation with my theme was no longer working.\u00a0 Specifically I  was  using custom templates for certain pages and when I was on one of  those  pages the link to that page in the navigation menu would not be   highlighted.\u00a0 So usually wordpress takes care of this functionality with   a css class called-&gt; &#8216;.current_page_item&#8217;<\/p>\n<p>A lot of times in themes you will see an implementation like this! <!--WCS[1]--><\/p>\n<p>This would make the current page item white, so in my case when you   click the &#8216;About&#8217; Page you would get all your links as red except the   current page, &#8216;About&#8217; which would be in white.\u00a0 This is awesome for user   experience because not only do they see the title usually in h1 or h2   format as &#8216;ABOUT!&#8217; they will see the about link formatted the way you   want (in this case bright white!)<\/p>\n<p>My problem was that if you use custom templates this can easily upset   the normal wordpress functions.\u00a0 I solved this problem by using a   simple php that grabbed the address bar to see what page you were on   since the function is_page(), is_home() and is_front_page() also do not   work when using custom templates (not always, i see it work sometimes,   but it is easier to fix it this way then dive into every theme and   implementation.<\/p>\n<p>When I grab the address bar I do a &#8216;if&#8217; statement to check what page I   am in, then throw a div tag so I can format the link appropriately.\u00a0  In  my case my code looks like this-&gt;<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">&lt;?php if($_SERVER&#x5B;'REQUEST_URI']==\u201d\/2.0\/blog\/\u201d) echo \u201c&lt;div id=\u2019sean_override2?&gt;\u201d; ?&gt;\r\n&lt;?php if($_SERVER&#x5B;'REQUEST_URI']==\u201d\/2.0\/videos\/\u201d) echo \u201c&lt;div id=\u2019sean_override_videos\u2019&gt;\u201d; ?&gt;\r\n&lt;?php wp_list_pages(\u2018title_li=&amp;sort_column=menu_order&amp;exclude=\u2019.get_option(\u2018tbf2_exclude_pages\u2019)); ?&gt;\r\n&lt;?php if($_SERVER&#x5B;'REQUEST_URI']==\u201d\/2.0\/blog\/\u201d) echo \u201c&lt;\/div&gt;\u201d; ?&gt;\r\n&lt;?php if($_SERVER&#x5B;'REQUEST_URI']==\u201d\/2.0\/videos\/\u201d) echo \u201c&lt;\/div&gt;\u201d; ?&gt;<\/pre>\n<p>My css is as follows, but obviously this will be very different   depending on what you are doing.<br \/>\n<!--WCS[3]--><br \/>\nSo I threw a div id tag when I was on my video page (which has id-24)   so then I can over-ride any problems with the div tags and force it to   white despite the is_wordpress functions failing.\u00a0 YAY!\u00a0 You can check   out my implementation on <a href=\"http:\/\/www.capsoffplease.com\/2.0\">http:\/\/www.capsoffplease.com\/2.0<\/a><\/p>\n<p>The video page on that page is throwing out some custom code to only   grab the posts with the category tag &#8216;videos&#8217; and this messed up the   built in &#8216;current_page_item&#8217;.\u00a0 My implementation does not only work   awesomely, but does not slow my server down at all because it is only   adding one conditional statement.\u00a0 YAY!\u00a0 If you found this post drop me a   line, I like seeing where people come from!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am assuming if you found this post you were using google! ANYWAYS! The problem I was having on one of my sites was that the css implementation with my theme was no longer working.\u00a0 Specifically I was using custom templates for certain pages and when I was on one of those pages the link &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.cavanaugh.pro\/sean\/wordpress-menu-problems-with-custom-templates\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;wordpress menu problems with custom templates&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-287","post","type-post","status-publish","format-standard","hentry","category-coding"],"_links":{"self":[{"href":"https:\/\/www.cavanaugh.pro\/sean\/wp-json\/wp\/v2\/posts\/287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cavanaugh.pro\/sean\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cavanaugh.pro\/sean\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cavanaugh.pro\/sean\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cavanaugh.pro\/sean\/wp-json\/wp\/v2\/comments?post=287"}],"version-history":[{"count":13,"href":"https:\/\/www.cavanaugh.pro\/sean\/wp-json\/wp\/v2\/posts\/287\/revisions"}],"predecessor-version":[{"id":340,"href":"https:\/\/www.cavanaugh.pro\/sean\/wp-json\/wp\/v2\/posts\/287\/revisions\/340"}],"wp:attachment":[{"href":"https:\/\/www.cavanaugh.pro\/sean\/wp-json\/wp\/v2\/media?parent=287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cavanaugh.pro\/sean\/wp-json\/wp\/v2\/categories?post=287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cavanaugh.pro\/sean\/wp-json\/wp\/v2\/tags?post=287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}