Community Forums › Forums › Archived Forums › Design Tips and Tricks › Display content at top of post inside genesis entry content
Tagged: genesis_entry_content
- This topic has 9 replies, 3 voices, and was last updated 9 years, 1 month ago by
photoaddictsa.
-
AuthorPosts
-
June 15, 2017 at 5:54 am #207773
photoaddictsa
MemberOk, as the title suggests I want to display inserted content at the top of my post content.
I add the content in the hook: genesis_entry_content but it sits at the bottom of the post, how do I get it to sit at the top of the post content?
For an example of what I'm trying to achieve see http://inthebunch.co.za/2017/06/test-post-dont-edit-or-delete/ it's the overlapping content at the top right.
June 15, 2017 at 6:16 am #207774Victor Font
ModeratorChange the priority of the hook. Assuming everything in your theme is using the Genesis defaults, genesis_entry_content displays the post content with the default priority of 10. If you change your hook to priority 9, it will display before the post content. For an example, the adjusted priority will look like:
add_action( 'genesis_entry_content', 'my_custom_content', 9 );
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?June 15, 2017 at 7:07 am #207783photoaddictsa
Memberahh ok,
That makes perfect sense.
ok one more question, can I just change the priority?
The reason I'm asking is I am using Genesis simple hooks and inserted the content there? If not then I will re-write my code as you explained.
June 15, 2017 at 7:34 am #207788Victor Font
ModeratorGenesis Simple Hooks executes its hooks at priority 10. You can't change the priority in the plugin. You have to move your code to functions.php.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?June 15, 2017 at 7:36 am #207789photoaddictsa
MemberI thought as much but had to take a chance 🙂
Thanks for all your help, much appreciated.
June 19, 2017 at 6:39 am #207930photoaddictsa
MemberI had to re-open this one.
Victor, the solution you gave me worked but with a twist.
I'm currently using this code:
add_action( 'genesis_entry_content', include( get_stylesheet_directory() . '/yarpp-template-list.php'), 9);Problem is that when I do that, the info jumps completely out and sits in the top left corner of the browser. See:

Here is the code of the php file I'm including:
<div class="yarppinline"> <h3>Related Posts</h3> <?php if (have_posts()): $postsArray = array(); while (have_posts()) : the_post(); $postsArray[] = '<a href="'.get_permalink().'" rel="bookmark">'.get_the_title().'</a><!-- ('.get_the_score().')-->'; endwhile; echo implode(', '."\n",$postsArray); // print out a list of the related items, separated by commas else:?> <p>No related posts.</p> <?php endif; ?> </div>Am I doing something wrong?
June 20, 2017 at 12:36 am #207965Brad Dalton
ParticipantWhy don't you hook in a new widget area before the content and use the Yarpp widget.
June 20, 2017 at 12:52 am #207966photoaddictsa
Memberoohh, yea, that's also a great, idea.
In that case (after registering the widget area) my code would look like this?
add_action( 'genesis_entry_content', 'add_genesis_widget_area', 9 ); function add_genesis_widget_area() { genesis_widget_area( 'custom-widget', array( 'before' => '<div class="custom-widget widget-area">', 'after' => '</div>', ) ); }June 20, 2017 at 1:00 am #207967Brad Dalton
ParticipantYes but you need to add a conditional tag for single posts
add_action( 'genesis_entry_content', 'add_genesis_widget_area', 9 ); function add_genesis_widget_area() { if ( is_singular('post') ) { genesis_widget_area( 'custom-widget', array( 'before' => '<div class="custom-widget widget-area">', 'after' => '</div>', ) ); } }And the code to register the widget.
June 20, 2017 at 1:05 am #207968photoaddictsa
MemberAwesome!!
Thanks very much Brad. Will be subscribing to your site, loads I can learn there.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.