# Template hook for Discourse Plugin "Join Discussion Link" section?

**URL:** https://meta.discourse.org/t/template-hook-for-discourse-plugin-join-discussion-link-section/323878
**Category:** WordPress
**Created:** [August 28, 2024, 9:52pm UTC](https://meta.discourse.org/t/template-hook-for-discourse-plugin-join-discussion-link-section/323878 "2024-08-28T21:52:23Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Kayla](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kayla/32/128523_2.png) [@Kayla](https://meta.discourse.org/u/Kayla)
#### Post date: [August 28, 2024, 9:52pm UTC](https://meta.discourse.org/t/template-hook-for-discourse-plugin-join-discussion-link-section/323878/1 "2024-08-28T21:52:23Z")

</div>

I see where I can change the link text itself when the ‘Link to Comments Without Displaying Them’ option is selected, but is there a way to add text/html above/below this link? Sort of like the discourse\_replies\_html filter but for altering what is inside the .wpdc-join-discussion div and where the Join Discussion Link would go in there.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [August 28, 2024, 10:16pm UTC](https://meta.discourse.org/t/template-hook-for-discourse-plugin-join-discussion-link-section/323878/2 "2024-08-28T22:16:23Z")

</div>

Hey Kayla, there’s currently no filter or template to change the html in the `wpdc-join-discussion` div. Could you share your desired outcome, i.e. what html you’d like to end up with? I’ll see if I can add a filter in to support your (and perhaps others’) use case.

---

<div class="post-metadata">

### Author: ![Kayla](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kayla/32/128523_2.png) [@Kayla](https://meta.discourse.org/u/Kayla)
#### Post date: [August 28, 2024, 11:57pm UTC](https://meta.discourse.org/t/template-hook-for-discourse-plugin-join-discussion-link-section/323878/3 "2024-08-28T23:57:37Z")

</div>

Hi Angus,

The use case is for the same website as

> [@Using Wordpress Comments \*alongside\* Discourse](https://meta.discourse.org/t/using-wordpress-comments-alongside-discourse/312786):
>
> It seems that once you ‘publish to Discourse,’ the Wordpress comment submit box disappears, even if you’ve unchecked use Ajax and you’ve opted not to remove Wordpress comments. Is it possible to allow visitors to leave Wordpress comments alongside the Discourse-linked discussion? I’m going for

so there’s private Discourse comments alongside the public Wordpress comments on a site using a classic theme. I’d like to be able to add a heading and some text explanation above the Join Discussion Link for context/user experience. I’m able to fake it visually with a theme-default widget area that comes after the post entry and a bunch of CSS, but it’s not ideal document structure-wise (in this case the widget gets picked up as part of the article in reader view/mode, while the actual .wpdc-join-discussion div doesn’t). I could create a new widget area that sits outside the article layer, but this customization logically belongs inside the .wpdc-join-discussion div along with the Join Discussion Link.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [August 29, 2024, 2:24am UTC](https://meta.discourse.org/t/template-hook-for-discourse-plugin-join-discussion-link-section/323878/4 "2024-08-29T02:24:53Z")

</div>

Ok, thanks, I’ll look at supporting this use case in the next version.

---

<div class="post-metadata">

### Author: ![Kayla](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kayla/32/128523_2.png) [@Kayla](https://meta.discourse.org/u/Kayla)
#### Post date: [August 29, 2024, 8:29pm UTC](https://meta.discourse.org/t/template-hook-for-discourse-plugin-join-discussion-link-section/323878/5 "2024-08-29T20:29:58Z")

</div>

Thanks for the consideration! I’d prefer an open-ended type of solution like discourse\_replies\_html so I could have the flexibility of adding an internal “wrapper” div inside .wpdc-join-discussion or whatever else is needed in the future. I hope that keeps it simple from a plugin development standpoint as well (no new admin interface settings).

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [September 18, 2024, 9:43am UTC](https://meta.discourse.org/t/template-hook-for-discourse-plugin-join-discussion-link-section/323878/6 "2024-09-18T09:43:59Z")

</div>

@Kayla It will soon be time to cut another version of the plugin and I want to be sure I’m serving your case. I’m thinking of adding a `wpdc_join_discussion_link_html` filter [here](https://github.com/discourse/wp-discourse/blob/f6e6c5057e94513fed85059616072b0e85534416/lib/discourse-comment-formatter.php#L216)

```php
$link_html = '<div class="wpdc-join-discussion"><a class="wpdc-join-discussion-link" href="' . esc_url_raw( $discourse_permalink ) . '"' . $new_tab . '>' . esc_html( $link_text ) . '</a></div>';
$link_html = apply_filters( 'wpdc_join_discussion_link_html', $link_html, $comments_count, $post_id );
return $link_html;

```

This would perform the same role as the `discourse_replies_html` filter, but for the link html.

Does that work for you?

---

<div class="post-metadata">

### Author: ![Kayla](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kayla/32/128523_2.png) [@Kayla](https://meta.discourse.org/u/Kayla)
#### Post date: [September 18, 2024, 8:33pm UTC](https://meta.discourse.org/t/template-hook-for-discourse-plugin-join-discussion-link-section/323878/7 "2024-09-18T20:33:24Z")

</div>

Yes, I think so. Just so I’m clear, because I’m only at the PHP knowledge level of taking a pattern/example and running with it, I could go about using this filter like so?

```plaintext
function custom_discussion_link( $input ) {  
  ob_start();
  ?>
  <div class="wpdc-join-discussion">
    <div class="custom-wrapper-div">
      <h3>Heading</h3>
      <p>Explanation/context yada yada.</p>
      <?php echo '<a class="wpdc-join-discussion-link" href="' . esc_url_raw( $discourse_permalink ) . '"' . $new_tab . '>' . esc_html( $link_text ) . '</a>'; ?>
    </div>
  </div>
  <?php
  $link_html = ob_get_clean();
  return $link_html;
}
add_filter( 'wpdc_join_discussion_link_html', 'custom_discussion_link' );

```

Hopefully that’s not too hilariously off the mark. 🫣

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [September 19, 2024, 6:32am UTC](https://meta.discourse.org/t/template-hook-for-discourse-plugin-join-discussion-link-section/323878/8 "2024-09-19T06:32:16Z")

</div>

Ok, so I think I’ll need to make sure you’ve got the variables you’re interpolating there, which does make sense for this filter, i.e.

```php
apply_filters( 'wpdc_join_discussion_link_html', $link_html, $discourse_permalink, $new_tab, $link_text )

```

Which you’d then use like so (note the number of arguments)

```php
function custom_discussion_link( $link_html, $discourse_permalink, $new_tab, $link_text) {  
  ob_start();
  ?>
  <div class="wpdc-join-discussion">
    <div class="custom-wrapper-div">
      <h3>Heading</h3>
      <p>Explanation/context yada yada.</p>
      <?php echo '<a class="wpdc-join-discussion-link" href="' . esc_url_raw( $discourse_permalink ) . '"' . $new_tab . '>' . esc_html( $link_text ) . '</a>'; ?>
    </div>
  </div>
  <?php
  $link_html = ob_get_clean();
  return $link_html;
}
add_filter( 'wpdc_join_discussion_link_html', 'custom_discussion_link', 10, 4 );

```

That new filter will be in the next version. There will be a slight delay in the release due to some logistics, so the next version will be arriving in early October.

---

<div class="post-metadata">

### Author: ![Kayla](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kayla/32/128523_2.png) [@Kayla](https://meta.discourse.org/u/Kayla)
#### Post date: [September 19, 2024, 4:59pm UTC](https://meta.discourse.org/t/template-hook-for-discourse-plugin-join-discussion-link-section/323878/9 "2024-09-19T16:59:58Z")

</div>

Thank you so much! I’ll watch for that next release. 🥳

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [October 19, 2024, 5:00pm UTC](https://meta.discourse.org/t/template-hook-for-discourse-plugin-join-discussion-link-section/323878/10 "2024-10-19T17:00:15Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
