Notifications
Clear all

Suggestion [Solved] Anchor links to quoted posts

5 Posts
2 Users
4 Likes
948 Views
Wendell
Posts: 242
Topic starter
(@wendell)
Reputable Member
Joined: 7 years ago

When someone replies with a quote, it would be great if a link could be added to the quote somehow that would take you back to the quoted text (see attached image).

If that's not possible, perhaps the quoted text could just link back to the post quoted from instead of the specific text within the post.

4 Replies
Chris
Posts: 3650
(@chris)
Famed Member
Joined: 3 years ago

Hi @wendell,

1. Download and Install "Code Snippets" Plugin for WordPress

2. Open Dashboard > Snippets > Add New 

3. Write a Title

4. Add the Below Code, Check the "Only run on site front-end" Checkbox and press Save Changes and Activate

add_action( 'wp_footer', function () { ?>
<script>

	jQuery(document).ready( function($){
		let blockquotes = $('blockquote[data-postid]');
		blockquotes.css('cursor', 'pointer');
		blockquotes.on('click', function(){
			let postid = parseInt( $(this).data('postid') );
			if( !isNaN(postid) ) window.location.hash = 'post-' + postid;
		});
	});

</script>
<?php } );

 

2 Replies
Wendell
(@wendell)
Joined: 7 years ago

Reputable Member
Posts: 242

@chris 

Wow! Thank you for this. 🙂

I've implemented it with a custom functions plugin and it works great.

If I may be so bold, do you think it could be implemented with an icon and link instead of the entire blockquote box? https://share.getcloudapp.com/4guP5q9k (just a thought, certainly not required) 🙂

Chris
(@chris)
Joined: 3 years ago

Famed Member
Posts: 3650

@wendell,

There are many changes needed for that, not only coding also design, so it will take time to finish the work, we have added it in our to-do list, so it will be added in wpForo 2.0.0 update.

Wendell
Posts: 242
Topic starter
(@wendell)
Reputable Member
Joined: 7 years ago

Thanks Chris! 🙂