Forum Replies Created
-
AuthorPosts
-
lucaslem
MemberThat post you wrote about the before sidebar hook is exactly what led me to try the same logic with the content-entry.
The conditional tag worked a treat 🙂
Two of these fields will have dates and a register button inside a styled div. If that workshop is not currently scheduled then obviously those fields will be empty and the page is left with an empty styled box. If I take this a step further, is it possible to set a condition to avoid displaying the div if the editor leaves those custom fields blank?
My current code looks like this:
add_action( 'genesis_before_entry_content', 'ismh_workshops_acf' ); function ismh_workshops_acf() { if ( 'workshops' == get_post_type() ) echo '<p class="workshop_intro">' . genesis_get_custom_field('workshop_intro') . '</p> <div class="registration-cta"> <p class="workshop_date">' . genesis_get_custom_field('workshop_date') . '</p> <a class="button" href="' . genesis_get_custom_field('registration_link') . '">Register Now!</a> </div>'; }
lucaslem
MemberHi Brad, thanks so much for the resources. I had actually been reading a bunch of your tutorials (wow, priceless, thanks so much) and then it occurred to me to try something. If my goal is to get the content to display between the title and content, why not just try:
add_action( 'genesis_before_entry_content', 'ismh_workshops_acf' ); function ismh_workshops_acf() { the_field('workshop_intro'); the_field('registration_details'); }
What do you know, genesis_before_entry_content worked like a charm, but something tells me this is waaay too easy and there are ramifications which I am not aware of...? Do you see possible issues with this?
Agreed about adding the code to my functions file rather than a template. My php coding is barely at novice stage so I wanted to get the basics right before I moved this over the functions.php and all the conditional coding this will require (using it for a cpt). These forums and sites like yours have been worth their weight in gold and it's all starting to sink in.
September 17, 2013 at 1:18 pm in reply to: Help With Single Page Template and Advanced Custom Fields #63029lucaslem
Member@David Chu, I followed that article closely and while it worked ok for everything else, the line with
get_the_content()
would not output any content. Seems from the comments to the post that I was not the only one with that problem.
@nunotmp Wow, thanks for taking the time to lay this out.I really wish there was a more complete level of documentation for Genesis. It's definitely a no-brainer to use their very-well documented hooks and filters if one wants to gently customize their themes, but creating your own child theme with custom layouts etc from the basic framework is really tough when you're used to the more standard wordpress theme templates which show all the html scaffolding and so on.
September 16, 2013 at 3:03 pm in reply to: Help With Single Page Template and Advanced Custom Fields #62879lucaslem
MemberI also would love a step by step on this. Been searching too... pretty rough.
lucaslem
MemberWould love to know more about this as well...
lucaslem
MemberThanks so much!
lucaslem
MemberIt doesn’t have to be organized like that. You could simply code it to look affirmatively for that menu, and when found, do something.
Given that I have several menus, that was exactly the approach I was trying with
if ( 'Primary Navigation' == $args['menu'] ) { return $menu; }
Where "Primary navigation" is not the theme_location but the menu name. This is the part I am still dumbfounded by. It's as if using the $menu parameter rather than the $theme_location parameter just didn't work.
And yes I wholeheartedly agree regarding the PHP abilities. I am doing the tutorials, reading the books, and being a good student. But also the best way to learn is to do and take things apart in order to understand. Thanks for all your feedback as you have contributed to that process.
lucaslem
MemberFor anyone interested I got a solution to the issue (largely came from support from the language swithcer plugin developer):
wp_nav_menu_items
is a filter-hook. You should check what is in$items
and$args
. Why not just check the name of the handle?
Read on here: http://wordpress.stackexchange.com/questions/2143/customizing-only-a-specific-menu-using-the-wp-nav-menu-items-hookThis does not explain to me why the last code block I posted here does not work, but it did fix my issue.
lucaslem
MemberQuick fix. To remove the header, footer, etc from a specific page you need to first target a page specific class in your body tag. I will give you an example using the about page of your site: http://thevideomarketingguys.com/about
.page-id-339 #header, .page-id-339 #nav, .page-id-339 #sidebar, .page-id-339 #footer { display: none; }
lucaslem
MemberDavid, Primary Navigation just happens to be what I called my main nav in the admin; in this case it is the name of the menu. I have also tried it with other menus registered on the site (one called "minor nav" etc). Still no dice. Thanks for your patience and final answer. Will keep searching.
Thanks Sridahr, will explore this avenue as well though at first glance it's not quite what I'm after.
lucaslem
MemberNope, that just adds it everywhere. Ugh.
lucaslem
MemberAaahhhhh, just saw my syntax error!
Needed to change
if ( 'Primary Navigation' !== $args['menu'] )
to
if ( 'Primary Navigation' == $args['menu'] )
Going crossed-eyed!
lucaslem
MemberHmmmm, I love this proposed solution to target by menu name rather than theme_location, but it doesn't seem to be working. The name of my navigation (from admin panel) is Primary Navigation. So here is the code changed accordingly (using your block of text example as a test):
// add block of text to menu add_filter('wp_nav_menu', 'dc_add_nav_text', 10, 2); function dc_add_nav_text ( $menu, $args ) { $args = (array)$args; if ( 'Primary Navigation' !== $args['menu'] ) { return $menu; } $text = '<div id="navExtra">Creative ways to grow your business</div>'; return $text . $menu; }
Something just isn't right...? Sorry for dragging this out, but I really can't figure out where the issue lies and google is not helping.
lucaslem
MemberOh yes, Genesis packed with source sass files would be amazing! Definite +1 on that.
lucaslem
MemberOr (even better) is there a way of targeting the nav in the header-right widget either by ID or theme location?
lucaslem
MemberOk, I see where my problem lies. I am misleading by referring to my "primary navigation" which, in the studiopress demo is the full-width nav (located after the genesis header) and for which your code works perfectly. However, in my case I wanted the primary nav to be aligned with the logo and so I chose to place it in the header right widget area (genesis_header_right). In other words, there is no
primary
fortheme_location
Will keep digging. Perhaps there is a better way for me to structure my nav using CSS rather than using the header widget area.lucaslem
MemberHi Dave,
Pretty new to backend dev (PHP) so it's all slow going and not always clear to me where I can use genesis-specific code and where I need to incorporate general wordpress code.
I can across this link which includes some of your code. I'll poke around all of this and give feedback as to the failure or success in what I am trying to achieve.
In the mean time if anyone else has a Genesis-specific approach to this, I'm all ears.
lucaslem
MemberRegarding the hooks I am indeed using the Genesis 2.0 Sample Child Theme with HTML 5.0 enabled, so not sure what's going on there but I will do some digging. I'm certain it has to do with my shoddy coding.
The issue for the subnav got resolved in a single block of code (thanks a million for the cpt conditional tag which I had come across but had made a few syntax errors!). This way the sub nav appears in all the places I wanted (workshops archive page, workshops categories, and single workshop):
add_action('template_redirect', 'remove_subnav_specific_pages'); function remove_subnav_specific_pages() { if ( 'workshops' !== get_post_type()) remove_action('genesis_after_header', 'genesis_do_subnav'); }
Brandon, I can't thank you enough for taking the time. There is certainly a lot there to get me on the right track. Will explore your proposed resources. Noted for separate questions.
lucaslem
MemberHi there,
If I understand you would like to remove the white background when you hover over the menu item correct?
Try this in your css file
.menu-primary li a:hover { background-color: inherit; }
For the centering:
.menu-primary { text-align: center; } .menu-primary li { float: none; display: inline-block; }
If you are also wanting to center the right-hand menu item (the twitter link in the demo site):
.menu li.right { float: none; }
lucaslem
MemberBrad, many thanks for the incredibly valuable information.
- Your code snippet worked perfectly for the one page, but in fact I was not quite accurate in my need for the secondary nav. I need it to appear on all the cpt related sections. So I need the conditional to be something like this (which obviously doesn't work but will hopefully illustrate what I'm after:`add_action('template_redirect', 'remove_subnav_specific_pages');
function remove_subnav_specific_pages() {
if ( !is_page('345') )
OR
if ( !is_workshop-categories )
OR
if ( !is_single_post_type ('workshops')
remove_action('genesis_after_header', 'genesis_do_subnav');
}`The plugin was useful for the categories, but the dropdown does not display on the single cpt edit screen (I assume it needs another item in the supports arg?). In any case, for the posts I think it would make more sense to resolve this with code anyway as making that selection each time a workshop is created seems quite excessive. I suppose I can just add this in my single_cpt.php, which does work (not sure what is best practice):
add_action( 'genesis_after_header', 'genesis_do_subnav' );
As for the main workshops page (domain.com/workshops) it does not show the "edit page" button on the front end admin bar. I don't understand why (and this is true regardless of which template I select). I assume this has to do with the template hierarchy, but I'm finding templates extremely confusing/frustrating in Genesis compared to a standard wordpress theme (in which the php files are easier to comprehend for someone coming from an HTML/CSS background). If you could point me towards documentation which explains the structure I would appreciate it.
- Great, will definitely do that!
- That snippet isn't working for some reason.
- It's really a minor detail at this point so I will create a new thread a little further down the line
I found this and assume it might be a good general read http://designsbynickthegeek.com/tag/genesis-explained
Thank-you for your patience.
- Your code snippet worked perfectly for the one page, but in fact I was not quite accurate in my need for the secondary nav. I need it to appear on all the cpt related sections. So I need the conditional to be something like this (which obviously doesn't work but will hopefully illustrate what I'm after:`add_action('template_redirect', 'remove_subnav_specific_pages');
-
AuthorPosts