Community Forums › Forums › Archived Forums › Design Tips and Tricks › Move page title, add custom field
Tagged: actions, Custom fields, hooks
- This topic has 7 replies, 3 voices, and was last updated 12 years, 5 months ago by
river-bum.
-
AuthorPosts
-
April 9, 2014 at 8:46 am #99343
river-bum
MemberHello -
I'm trying to move my page title and insert a custom field underneath it, but I can't get the custom field to show up. Here's the code I have:add_action( 'genesis_before', 'move_title' ); function move_title () { remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); add_action( 'genesis_before_content', 'genesis_do_post_title', 0 ); } add_action( 'genesis_after_post_title', 'bench_location' ); function bench_location () { genesis_custom_field( 'bench-location' ); }The title gets moved above the sidebar content and page content, but 'bench_location' will not appear. When I use another hook, such as 'genesis_before_entry_content', it works.
Hope someone can help. Thank you in advance!
http://www.gregseitz.com/artbenchtrail/?page_id=11April 9, 2014 at 11:35 pm #99443essaysnark
ParticipantSo, crazy question: Have you enabled HTML 5 support in your theme?
April 10, 2014 at 7:24 am #99477Brad Dalton
ParticipantYou're using both XHTML and HTML 5 loop hooks. http://my.studiopress.com/docs/genesis-loop-hooks-comparison/
genesis_entry_header genesis_after_post_title
This works
add_action( 'genesis_entry_header', 'bench_location' ); function bench_location () { genesis_custom_field( 'bench-location' ); }Use the 3rd parameter for positioning priority if you want to change the output below the post info
add_action( 'genesis_entry_header', 'bench_location', 12 ); function bench_location () { genesis_custom_field( 'bench-location' ); }
April 10, 2014 at 7:54 am #99484river-bum
MemberThank you! Did I mention I'm new to this?
I realized I was approaching it a bit sideways, and figured out rather than trying to position it after the post title, which I was moving, I could also just put the custom field above the content, too.
Does this code make sense?
add_action( 'genesis_before', 'move_title' ); function move_title () { remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); add_action( 'genesis_before_content', 'genesis_do_post_title', 0 ); } add_action( 'genesis_before_content', 'custom_field_before_content', 15 ); function custom_field_before_content() { echo '<div class="after-title">'. genesis_get_custom_field('bench-location') .'</div>'; }Thanks again. (By the way, yes, I have HTML5 enabled, but had a feeling I was doing something wrong by using an XHTML hook...)
April 10, 2014 at 8:14 am #99489Brad Dalton
ParticipantApril 10, 2014 at 8:15 am #99490river-bum
MemberIt works!
April 10, 2014 at 8:15 am #99491Brad Dalton
ParticipantLooks ok to me.
How did it test?
You did a good job for being new!
April 10, 2014 at 8:31 am #99496river-bum
MemberThanks! Sure took me a while and some frustration to figure it out. Really appreciate your help (and I've now subscribed to WP Sites).
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.