• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

RESOLVED How to add html-code to the header of one specific page

Messages
8
Likes
0
Points
1
#1
Здравствуйте!
Столкнулась с такой проблемой - нужно добавить html-код в шапку одной конкретной страницы. Но как это сделать, не могу понять. В плагине Woody есть возможность вставить код можно либо в режиме авто-размещения (и там можно указать, куда код должен вставляться) либо в режиме шорткода. Но в авто-размещении он засунет этот код на все страницы, а мне это не нужно. А вот шорткод - куда его вставлять-то? Если просто на странице разместить, он же появится в блоке body, а мне нужно в head. Также я пыталась в режиме авто-размещения включить фильтр "Текущая страница" с указанием нужного url, но ничего не поменялось, текста снипета я в коде страницы не нашла (может неправильно искала?). Я пользуюсь Elementor, так что просто вставить код в режиме обычного редактирования страницы тоже не получается.
Подскажите пожалуйста, как это решается?

Hello! I faced such a problem - I need to add html-code to the header of a specific page. But I can't figure out how to do it. The Woody plugin has the ability to insert code either in auto-placement mode (and there you can specify where the code should be inserted) or in shortcode mode. But in auto-placement, it will shove this code into all pages, and I don't need it. And here is the shortcode - where should I insert it? If it's just on the link page, it will also appear in the body block, and I need it in the head. I also tried to auto-enable the "Current page" filter with the required URL, but nothing changed, I could not find the snippet text in the page code (maybe I was looking wrong?). I use Elementor, so I can't just paste the code in normal page editing mode either. Please tell me how this is solved?
 

Temyk

Developer & Support
Messages
1,129
Likes
42
Points
48
#2
Здравствуйте.

Вы можете настроить размещение сниппеты в через Дополнительную логику размещения. Вы уже пробовали, насколько я прочитал. Текущая страница - это не полный URL, а все что идет после домена.

Вуди позволяет вставлять сниппеты только внутрь <body>. Что вы хотите вставить в <head>?
 
Messages
8
Likes
0
Points
1
#3
Спасибо за ответ!
Мне нужно добавить в страницу
<meta name = "robots" content="noindex, nofollow">
чтобы удалить страницу из индексации. Вроде как эту строку нужно добавлять в head
 
Messages
8
Likes
0
Points
1
#5
Спасибо за ответ!
Прошу прощения, но я, к сожалению, вообще не шарю, особенно в php. Попыталась почитать что-нибудь про этот хук, но всё равно ничего не ясно. Правильно ли я Вас поняла, что мне нужно создать в плагине Woody php-сниппет (а не html), записать в нём вот такой код:

<?php
add_action("wp_head", "wp_head_meta_tag");

function wp_head_meta_tag() {
echo '<meta name = "robots" content = "noindex, nofollow" />';
}

И включить выполнение сниппета Везде, безо всякой фильтрации? Разве в таком случае он не будет действовать по всем страницам сайта, а не конкретно на той, которая мне нужна?
 

Temyk

Developer & Support
Messages
1,129
Likes
42
Points
48
#6
Код правильный.

Фильтрация конечно нужна, если вы хотите выполнять этот сниппет на определенных страницах. Используйте универсальный снипппет - в нем есть фильтрация
 
Messages
8
Likes
0
Points
1
#7
Ещё раз здравствуйте!
Когда я попыталась опубликовать этот универсальный спиппет с вышеприведённым кодом и фильтрацией "Текущая страница" с указанием адреса после домена, появилось вот такое сообщение:


Don't Panic
The code snippet you are trying to save produced a fatal error on line 6:

syntax error, unexpected '<', expecting end of file
The previous version of the snippet is unchanged, and the rest of this site should be functioning normally as before.

Please use the back button in your browser to return to the previous page and try to fix the code error. If you prefer, you can close this page and discard the changes you just made. No changes will be made to this site.

Естественно, я всё откатила назад и сниппет отключила, но не пойму, о какой ошибке говорится? вроде все теги закрыты...
 

Temyk

Developer & Support
Messages
1,129
Likes
42
Points
48
#8
Пришлите скриншот кода сниппета, чтобы было видно номера строк
 

Temyk

Developer & Support
Messages
1,129
Likes
42
Points
48
#10
Добавьте в конце кода закрывающий php тэг - ?>
 

freshweld

New member
Messages
4
Likes
0
Points
1
#11
I have the same problem with woocommerce products .. I have a remarketing js code from google ads platform .. and I need to add this code to specific pages like Woocommerce> All Products Page. I am using both to try Universal or JS or PHP snippets but doesn't work. I cant see my code at my source. both external or internal.

Actually just the shortcode version is running only in manual created pages. but some pages created automatically by woocommerce, so I cant place my shortcode to those automatic generated pages.

I spent 2 days now. please help.

here is my settings screen for Universal snippets
universal.jpg



and here is the JS code sample
jscode.jpg
 

freshweld

New member
Messages
4
Likes
0
Points
1
#13
Hello,
this is not a solution my friend. I was try every alternates .. Or, And whatever I try using it with One execution. no .. this cant solve .. I cant see my code at my page source.:(
 

freshweld

New member
Messages
4
Likes
0
Points
1
#14
wrong alert not working well .. works on only own Products page. But still the auto generated pages cant show the code.

this is universal snippets with auto injection to page> equals> Products (woocommerce) you will see the kod at source file with searching aw_
M1 / 1100MobilEco Emme Ünitesi - FRESHWELD

but in this page. how can I place my code :( this is auto generated category page
MOBİL FİLTRELER - FRESHWELD


1624958150003.png