XenForo 2.0 Missing field "url" (optional) in Xenforo 2.2

lbebulk

Member
Registered
Joined
Apr 8, 2019
Messages
9
Points
13

Reputation:

How do I add this feature in templates ?
= Add URL field in schema.org script in xenforo 2.2.2 ?

Screenshot 2022-10-08 at 15-04-38 Rich Results Test - Google Search Console.png
 

Thanos Crax

Collaborate
Collaborate
Registered
Joined
Sep 25, 2020
Messages
325
Points
73

Reputation:

/var/www/html/vhosts/craxpro.to/src/XF/ThreadType/AbstractHandler.php
1732432276727.png


PHP:
return [

            "@context" => "https://schema.org",

            "@type" => "DiscussionForumPosting",

            "@id" => $threadLink,

        

            /*added url as thread link*/

            "url" => $threadLink,

            "headline" => \XF::app()->stringFormatter()->snippetString($thread->title, 110),

            "articleBody" => $this->getLdSnippet($firstDisplayedPost->message) ?: $thread->title,

            "articleSection" => $thread->Forum->title,

            "author" => [

                "@type" => "Person",

                "name" => $thread->User->username ?? $thread->username,

            

                            /*added url as profile link but this one didnt work bcs cant figure out url for thread owner*/

                "url" => $thread->User

            ],

            "datePublished" => gmdate('c', $thread->post_date),

            "dateModified" =>  gmdate('c', $thread->last_post_date),

            "image" => $this->getLdImage($thread, $firstDisplayedPost, $extraData) ?: $metadataLogo,

            "interactionStatistic" => [

                "@type" => "InteractionCounter",

                "interactionType" => "https://schema.org/ReplyAction",

                "userInteractionCount" => $thread->reply_count

            ],

            "publisher" => $this->getLdPublisher($metadataLogo),

            "mainEntityOfPage" => [

                "@type" => "WebPage",

                "@id" => $threadLink

            ]

        ];

    }

in browser:
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"@id": "https://craxpro.to/threads/cp-company-config-full-capture.1461005/",
"url": "https://craxpro.to/threads/cp-company-config-full-capture.1461005/",
"headline": "CP-COMPANY CONFIG | FULL CAPTURE",
"articleBody": "jakecarder submitted a new resource:\n\nCP-COMPANY CONFIG| FULL CAPTURE - CP-COMPANY CONFIG | FULL CAPTURE\n\nCPM => 100\nCaputre - Full\nType => Svb\nFor More Private Tools Join My Tg Channel:\nTelegram Channel : \n\n:hyperwow...",
"articleSection": "Configs",
"author": {
"@type": "Person",
"name": "jakecarder",
"url": {}
},
 

Splicho

Synapse-Themes.cc Owner
Staff member
Moderator
Collaborate
Registered
Joined
Jan 21, 2022
Messages
822
Points
153

Reputation:

/var/www/html/vhosts/craxpro.to/src/XF/ThreadType/AbstractHandler.php
View attachment 41026

PHP:
return [

            "@context" => "https://schema.org",

            "@type" => "DiscussionForumPosting",

            "@id" => $threadLink,

        

            /*added url as thread link*/

            "url" => $threadLink,

            "headline" => \XF::app()->stringFormatter()->snippetString($thread->title, 110),

            "articleBody" => $this->getLdSnippet($firstDisplayedPost->message) ?: $thread->title,

            "articleSection" => $thread->Forum->title,

            "author" => [

                "@type" => "Person",

                "name" => $thread->User->username ?? $thread->username,

            

                            /*added url as profile link but this one didnt work bcs cant figure out url for thread owner*/

                "url" => $thread->User

            ],

            "datePublished" => gmdate('c', $thread->post_date),

            "dateModified" =>  gmdate('c', $thread->last_post_date),

            "image" => $this->getLdImage($thread, $firstDisplayedPost, $extraData) ?: $metadataLogo,

            "interactionStatistic" => [

                "@type" => "InteractionCounter",

                "interactionType" => "https://schema.org/ReplyAction",

                "userInteractionCount" => $thread->reply_count

            ],

            "publisher" => $this->getLdPublisher($metadataLogo),

            "mainEntityOfPage" => [

                "@type" => "WebPage",

                "@id" => $threadLink

            ]

        ];

    }

in browser:
Thanos CraxBro? This post is from 2022
 
Top