Twitter Description is not display and social image can’t automatic get

#355149
  • Resolved Lisungroup
    Rank Math pro

    I have two small questions:
    1. Now our twitter description didn’t dispaly but facebook description can display, could you please let our whole site twitter description can show?
    2. Could you please let RANK MATH social image automatic get?

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

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    1. We checked a couple of products and they have their descriptions empty in the Social tab of Rank Math SEO Controls so it’s normal that you don’t see them in the source code:
    Description

    ​​​​​​​You can either add a description there or edit the following filter to get the description that you desire to parse into that field: https://rankmath.com/kb/filters-hooks-api-developer/#change-specific-social-meta

    2. If you would like to automate this with some custom functions you can use the following filter: https://rankmath.com/kb/filters-hooks-api-developer/#change-opengraph-image

    This filter needs to be edited as per your requirements.

    The previous time you got in touch with us about this we went back and forth and our team made extensive code snippets to help you but in the end, you decided that this was not enough, so we encourage you to find a developer familiar with Rank Math that can implement this on your website correctly.

    Don’t hesitate to get in touch if you have any other questions.

    Last time your code is for automatic get the focus keywords from ACF will slow our system, we don’t need focus keywords from ACF automatic at present. But the below two issues need to be solved:

    1. Could you please add the code for me to let the social description to display for the whole site or at least the single-product/single-news/single-cases/single-standards/single-applications? (Please make sure don’t let the meta description to display when the social description to display)
    2. Our developer told us that he already added the below code to functions.php, but the single-product/single-news/single-cases/single-standards/single-applications social image can’t automatic get:
    * Allows developers to change the OpenGraph image within theme.
    *
    * The dynamic part of the hook name. $network, is the network slug. Can be facebook or twitter.
    *
    * @param string $attachment_url The image we are about to add.
    */
    add_filter( “rank_math/opengraph/{$network}/image”, function( $attachment_url ) {
    return $attachment_url;
    });

    Hello,

    Both code snippets need to be highly customized and not simply copied and pasted there.

    This high level of customization falls outside the scope of Rank Math support and as such you would need to hire a developer familiar with this to create those customizations on your website.

    Don’t hesitate to get in touch if you have any other questions.

    I don’t think this two small issues are too difficult:
    1. Please let me know the three $ right value, then I copy to functions.php will be ok, right?
    add_filter( “rank_math/opengraph/{$network}/$og_property”, function( $content ) {
    return $content;
    });

    2. Please also let me know the three $ right value, then I copy to functions.php will be ok, right? Of course the image I will replace to the right CPTs value such as product-image for single-products
    add_filter( “rank_math/opengraph/{$network}/image”, function( $attachment_url ) {
    return $attachment_url;
    });

    The problem is that last time I asked you to don’t display all meta description, but the social description is also don’t display. Then I asked you to display the social desciption, you did it but some days later I found the social description is not fully display. Then I asked questions 1 and 3.

    I compared with Yoast, SEO PRESS and Rank Math, To be honest, I think Rank Math service support is the best. We will choose Rank Math Pro to buy next week, due to our website is special designed, I know it needs some addtional supports from you, now only two small issues, please support in your side, many thanks!

    Hello,

    We understand that, but as we mentioned before, this high level of customization falls outside the scope of Rank Math support, and to create those sorts of filters with this complexity you will need to hire a developer.

    When someone asks for a simple filter to change the canonical or to change some setting we usually go beyond the usual scope of our work and provide it to them, but this level of customization we, unfortunately, cannot support.

    Don’t hesitate to get in touch if you have any other questions.

    So, could you please only solve the question 1 and 3? This is you solved half because we don’t know how you disable meta description and then enable facebook descriptions but twitter description why not display.

    The question 2, we will solve in our side.

    Regarding to question 1, Do you remember last time: I asked you disable display the meta description? You did it but then we found the social description is also don’t display, one day later you replied that the description is display, we check the og:description is display but we didn’t noted the twitter display is not display.

    We guessed you enable social description display with default value. But could you please use %customfield(description)% to insert all social description such as single-products, single news, single-cases, single standards and single applications?

    Please help check the below two code to solve 1 and 2, we don’t know whether it is right or not, you can try in our site:
    1. To solve the social description automatic get:
    function fix_cat_url_themepark($url, $type_of_url) {
    if ( $type_of_url != ‘single’ && $type_of_url != ‘page’ )
    $url = trailingslashit($url);
    return $url;
    }
    add_filter(‘user_trailingslashit’, ‘fix_cat_url_themepark’, 10, 2);

    function sp_social_og_desc($html) {

    if (get_field(‘description’)) {
    $html = ‘<meta property=”og:description” content=”‘.get_field(‘description’).'” />’;
    }

    return $html;
    }
    add_filter(‘rank_math_social_og_desc’, ‘sp_social_og_desc’);
    function sp_social_twitter_card_desc($html) {

    if (get_field(‘description’)) {
    $html = ‘<meta name=”twitter:description” content=”‘.get_field(‘description’).'” />’;
    }

    return $html;
    }

    add_filter(‘rank_math_social_twitter_card_desc’, ‘sp_social_twitter_card_desc’);

    2. To solve the product-image automatic get:
    function sp_social_og_thumb($html) {
    $id = get_the_ID();
    if( have_rows(‘product-image’, $id) ) {
    // Loop through rows.
    $html = ”;
    while( have_rows(‘product-image’, $id) ) {
    the_row();

    // Load sub field value.
    $image = get_sub_field(‘product-image-item’);
    if( !empty( $image ) ) {
    $html .= ‘<meta property=”og:image” content=”‘.esc_url($image[‘url’]).'” />’;
    $html .= ‘<meta name=”twitter:image:src” content=”‘.esc_url($image[‘url’]).'” />’;
    }
    }
    }

    return $html;
    }
    add_filter(‘rank_math_social_og_thumb’, ‘sp_social_og_thumb’);

    add_filter(‘rank_math_social_twitter_card_thumb’, ‘sp_social_og_thumb’);

    Please ignore the above two codes, we just tried in our demo sites, has problems and the whole site can’t visit. Please give solution in your side to solve at least questions 1. Thanks!

    Hello, could you please only solve the questions 1? Some weeks ago, the social description is no problem, it was no description when you disable the meta description. Thanks!

    1. Solve Rank Math Social Description can’t automatic get from ACF Description, Rank Math reply solution: https://rankmath.com/kb/filters-hooks-api-developer/#change-specific-social-meta

    2. Solve Rank Math Social Image can’t automatic get from ACF, Rank Math reply solution: https://rankmath.com/kb/filters-hooks-api-developer/#change-opengraph-image

    When we use SEO PRESS plugin, the SEO Social description and image also can’t get from ACF automaticly, but their developer used the below codes in functions.php to fully solve the above two problems. Due to SEO PRESS is not so good than Rank Math, so we sill need to use Rank Math. Could you please refer the code in sensitive data to solve Rank Math above two issues?

    Hello,

    I have added a filter in the filter given below in the Code Snippets plugin and the social image is now being fetched from the ACF fields:

    function opengraph( $attachment_url ) {
    	$id = get_the_ID();
    	if( have_rows('product-image', $id) ) {
    		// Loop through rows.
    		while( have_rows('product-image', $id) ) {
    			the_row();
    
    			// Load sub field value.
    			$image = get_sub_field('product-image-item');
    			if( !empty( $image ) ) {
    				$attachment_url = esc_url($image['url']);
    			}
    		}
    	}
    	return $attachment_url;
    }
    
    add_filter( "rank_math/opengraph/facebook/image", 'opengraph');
    add_filter( "rank_math/opengraph/twitter/image", 'opengraph');

    And the description is already being fetched from the ACF field.

    Please check and let us know if you need any other assistance.

    Thanks.

    Have you added in our live site? I didn’t see this codes were added in functions.php? the description and image also didn’t automatic got. Could you please double confirm? Thanks!

    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 15 replies - 1 through 15 (of 22 total)

The ticket ‘Twitter Description is not display and social image can’t automatic get’ is closed to new replies.