How to access parmalink of current page dynamically?

Posted in: Newspaper
Post count: 9

I have to add the below code under every article:


<div class="fb-comments" data-href="phpcode for dynamic permalink" data-width="100%" data-numposts="5" data-order-by="social" data-colorscheme="light"></div>

I want the link of current page URL for data-href=

How do I get that?

Please help.

Post count: 35449

Hi yadavrohit,
I think that this can be done only in theme files, for this I need some more details about your website, a link to a post will help to see what kind of templates are you using, in this way I will be able to guide to the page that need to be edited.
Thank you!

Post count: 9

Hi Calin,

We are using Single Post Template – Default PRO.
Here’s the link to one of the articles. I hope this helps. Let me know if you need more information.

Post count: 35449

Hi yadavrohit, if it was only html, css or js, then you could use the html, css column text and text with title to set your code with tagDiv Composer inside the single post template, but because it is a php code, for the moment this can be set only in theme plugin files -> wp-content/plugins/td-cloud-library/shortcodes/single now the problem is to get the data-href -> https://developer.wordpress.org/reference/functions/get_permalink/
Here is a similar thread -> https://forum.tagdiv.com/topic/partsheader-ad-wheres-the-new-place-to-put-my-php-code/
Hope this will help you!

Post count: 9

Oh! so I cannot add php with raw html or text with title element.

So do I have to add a php file with a new name at the location (~..shortcodes/single) you mentioned? plugin files -> wp-content/plugins/td-cloud-library/shortcodes/single

What all code do I have to add there? The code:
<div class="fb-comments" data-href="php code to get the parmalink" data-numposts="5" data-width=""></div>, or the code for getting parmalink?

And then how do I use it to get that thing running under every article?

The thread that you shared did not help.

Post count: 121

The name is permalink and not parmalink!

Post count: 35449

Hi,
Unfortunately, the php code can not be set in our theme, sorry. Also is no need fore new php files, you need to set the code in an existing php file, it will be recommended to be in a php file with an element that you use.
Now I’m not a developer, and this is kind of custom request. therefore I can not say the exact code for this, but it should be like this:
<div class="fb-comments" data-href="'. get_post_permalink().'" data-width="100%" data-numposts="5" data-order-by="social" data-colorscheme="light"></div>
Using this code for a standard post template it should work, but for cloud I do not know if will get the post permalink or cloud template permalink.
Thank you for your understanding!

Post count: 9

Yes, that code is not working with the Single Post Template – Default PRO.

But, aren’t you all the one who developed the website? I am not asking for making those changes. Since you all have developed the website, you should be able to tell how things work (to get permalink).

Post count: 35449

Hi,
I’m only a support member, I’m not a developer, I try to help as I can, but this is a custom request, also the implementation for cloud template need very good skill, and since I’m just a support member, I can guide you with the theme files, but not with the code.
Please try this code:
$buffy .='<div class="fb-comments" data-href="'. get_permalink($post_views_data['post_id']) .'" data-width="100%" data-numposts="5" data-order-by="social" data-colorscheme="light"></div>';
This should work on cloud files and get the permalink from the article not template.

Thank you for your understand!

Post count: 9

But, you can connect with the developer to get the solutions, right? I would not even take 5 min for someone who had made the theme. I am not requesting for custom code, rather how the website works–how does the website return permalink.

Anyway, where do I have to add this code?

$buffy .='<div class="fb-comments" data-href="'. get_permalink($post_views_data['post_id']) .'" data-width="100%" data-numposts="5" data-order-by="social" data-colorscheme="light"></div>';

I tried adding it in the raw HTML element, it did not work.

Post count: 35449

Hi yadavrohit, I understand what you are saying, but since we work from home is no longer so easy to get in contact with the team developers.
As I mentioned above, since this is a code with php it need to be set inside the theme or plugins files. The raw html is only for html can not read the php code, one solution is to set the code on one of those elements from this directory -> wp-content/plugins/td-cloud-library/shortcodes/single one parameter that you are using on your website.
Thank you!

Post count: 9

This is not going anywhere. Leave it.

Post count: 35449

Hi yadavrohit, I think that this was a misunderstanding, I said in my first reply that there is no option in our theme to set a php code in theme, and that it can be set only in theme or plugins files -> https://i.imgur.com/B3edwFj.png also this was a custom request.
Thank you for your understating!

Viewing 13 posts - 1 through 13 (of 13 total)
The forum ‘Newspaper’ is closed to new topics and replies.