длина «description»

#356893
  • Resolved Valeriy Voloshyn
    Rank Math free

    Здравствуйте. Я пытаюсь сделать такой вот такой «%excerpt% Читайте в Германии, Польше, Украине – %currentyear%.» шаблон для моих мета описаний на записях сайта.

    Ну то есть я хочу чтобы вначале была цитата \ отрывок из статьи, а дальше в описании дописывались нужные мне ключи (Топонимы + год).

    Но проблема в том, что выводится всего 150-160 символов в поле meta description на самом сайте.

    Подскажите есть ли возможность сделать «Описание отдельной страницы Запись» длиной 300 символов например?

    И есть ли возможность ограничить переменную %excerpt% в количестве символов которое вставляется в описание? Например в 150 символов, а остальной текст уже будет тот что у меня в шаблоне…

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    You can use this filter to extend the limit of description so your meta description templates will capture all of those words with a limit of 300:

    add_filter('rank_math/frontend/description',function($description){
            $description=mb_substr(strip_tags($description),0,300);
            return $description;
    });

    The filter should be added to your active theme’s functions.php file. Here’s another way to apply the filter using the rankmath.php file:
    https://rankmath.com/kb/filters-hooks-api-developer/#adding-filters-and-hooks-in-rank-math-php

    Please note that the filter may not be visible while editing the posts as it only works when your posts load in a browser. You can check the published/saved post’s meta description via its source code.

    You can also check the meta description using this tool:
    https://www.heymeta.com/

    I hope that helps.

    Thank you.

    Спасибо больше за ответ, Reinelle!

    Хочу еще один вопрос задать. Подскажите есть ли возможность изменить функцию \ переменную %excerpt% – она сейчас выводит отрывок текста в описание.

    Например я хочу ограничить длину текста которую выводит «%excerpt%».

    Не знаю сколько сейчас там выводится символов, но мне кажется что там ограничение идёт от абзаца. А я бы хотел например задать количество символов которое будет выводится с помощью этой переменной. Надеюсь я смог объяснить что я имею ввиду… 🙂
    Вот на таких страницах моего сайта выводится сейчас описание с этой переменной.

    Hello,

    Unfortunately, that variable cannot be changed, the only way to limit how the meta description is displayed is through the filter code my colleague presented. The filter will limit the output of the meta description you entered on the SEO meta description field but not the output of the %excerpt%.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘длина «description»’ is closed to new replies.