The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Display Comments fo...
 
Share:
Notifications
Clear all

Question [Solved] Display Comments for Alternate Post ID

5 Posts
2 Users
0 Reactions
245 Views
Posts: 4
Topic starter
(@sjf-i)
Active Member
Joined: 1 month ago

Hi there, i created a custom page template that displays different data based on the parameters in the URL, and im trying to alter the post id that wpdiscuz saves to.

For example, the page is .../Music/Artists/?ArtistID=150&Album=5

The problem im having is that the same comments thread is showing for all artists and albums, because its using the post id for the /Music/Artists/ page - i see this in the admin comments section.

My approach:

I created a custom post with wp_insert_post, titled "Album Discussions - (ArtistName/AlbumName)" with MusicThreads as the type. That generates a Post ID that i can save the comment thread to.

I've added MusicThreads to the default form in wpdiscuz settings.

The question i have is how can i call a wpdiscuz comment section and point it to the new post id instead of the page's post id? 

Thank you so much for your time, expertise and assistance!

4 Replies
Asti
Posts: 7719
 Asti
Support
(@asti)
Illustrious Member
Joined: 7 years ago

Hi,

Please note that wpDiscuz works with the global post. Before displaying the page, it requires modifying the global post.

Reply
Posts: 4
Topic starter
(@sjf-i)
Active Member
Joined: 1 month ago

Hello, i spent quite a bit of time before posting here trying to modify the global post with the alternate post id, calling comments_template(), and then reverting the global post, but that did not work. I even tried modifying the global wpquery.

Modifying the global post did however work when i disabled commenting on the page, but it displayed the generic wp comment system and not wpdiscuz, so that led me here to see if someone with the inside scoop could help pinpoint a filter or something to override the post with. 

I was also wondering if it was maybe something to do with the caching features? I dont know where to start with that though.

I'm ok with pro support reaching out too if required.

Thanks!

Reply
2 Replies
Asti
 Asti
Support
(@asti)
Joined: 7 years ago

Illustrious Member
Posts: 7719

@sjf-i 

We're sorry, but we’re unable to assist you further with this question.

Reply
(@sjf-i)
Joined: 1 month ago

Active Member
Posts: 4

@asti

I figured it out! I narrowed the issue down to the comments being submitted with the wrong post id. So the solution involved injecting the correct post ID in to the wpd ajax object with js when the page loads. This was required in addition to modifying the global post to render the appropriate comment thread.

document.addEventListener("DOMContentLoaded", function () {
    if (typeof wpdiscuzAjaxObj !== "undefined") {
        wpdiscuzAjaxObj.wc_post_id = ALTERNATE_POST_ID; 
    }
});
Reply
Share: