Community Forums › Forums › Archived Forums › Design Tips and Tricks › Automatically insert permalinks into Posts
Tagged: permalinks
- This topic has 7 replies, 3 voices, and was last updated 9 years, 8 months ago by robsp.
-
AuthorPosts
-
July 30, 2014 at 5:23 pm #116385robspMember
Hi All,
Is there a way to automatically have permalinks added within each post?
Ideally I would like to the the post's permalink added at the end of the post. Here's an example (in this case the permalink symbol used is #):
http://randsinrepose.com/blog/
Rob
July 31, 2014 at 12:23 am #116403neilgeeMemberYou could use the genesis_after_entry hook
//Add Permalink after post function themeprefix_permalink_after_post() { echo '<p><a href="' . get_permalink() .'">'; the_title(); echo '</a></p>'; } add_action( 'genesis_after_entry','themeprefix_permalink_after_post' );
Neil Gee
WP Beaches
Coolest GuidesJuly 31, 2014 at 6:05 pm #116494neilgeeMemberslight edit - change the_title to get_the_title
//Add Permalink after post function themeprefix_permalink_after_post() { echo '<p><a href="' . get_permalink() .'">' . get_the_title() . '</a></p>'; } add_action( 'genesis_after_entry','themeprefix_permalink_after_post' );
Neil Gee
WP Beaches
Coolest GuidesJuly 31, 2014 at 7:59 pm #116512robspMemberThanks Neil! That almost worked. The permalink did show at the bottom of posts, but only when viewing the post's full page. It didn't show on the homepage (which for my site is also the blog page). I guess that makes sense in a way.
Also I encountered this odd error.
1-Click to viewpost's full page
2-Return to homepage
3-Permalink now appears...but above the post title.July 31, 2014 at 8:03 pm #116515robspMemberWhat I ended up doing is placing the permalink in the date, using the code found here:
http://genesissnippets.com/add-permalink-post_date-shortcode/
However, I'm not sure this is what I want, so I may revisit this.
July 31, 2014 at 9:36 pm #116523Genesis DeveloperMember//Add Permalink after post function themeprefix_permalink_after_post() { if( is_singular('post')) : echo '<p><a href="' . get_permalink() .'">' . get_the_title() . '</a></p>'; endif; } add_action( 'genesis_entry_header', 'themeprefix_permalink_after_post' );
August 2, 2014 at 2:39 pm #116705robspMemberThanks genrock. That works. It places the permalink under the title when viewing the post's page.
August 2, 2014 at 3:36 pm #116719robspMemberIn case anyone is interested in what I ended up doing, I opted to place the permalink next to the post date.
Step 1: Create a permalink shortcode by placing this into the child theme's functions file:
// Create Shortcode for Permalink function permalink_shortcode() { if (!is_page()) { $permalink = get_permalink(); $permalink_symbol = ' <a href="'.$permalink.'">#</a> '; return $permalink_symbol; }} add_shortcode('permalink', 'permalink_shortcode');
Step 2: If not already installed, install the awesome Simple Edits plugin:
http://wordpress.org/plugins/genesis-simple-edits/Step 3:
Add this shortcode in the 'Post Info' field of Simple Edits:
[permalink]This will place the permalink symbol "#" next to the post's date. Much appreciation to anyone that wants to improve upon my newbie method/code.
-
AuthorPosts
- The topic ‘Automatically insert permalinks into Posts’ is closed to new replies.