• Resolved mcho

    (@mcho)


    Hi, I like the ability to add the custom title, description, and image to the <og:> fields for the posts, categories, etc., but I don’t see an option to add these fields to the user editing page. Is this not possible?

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    This feature isn’t available in TSF yet. You can follow its progression here: https://github.com/sybrew/the-seo-framework/issues/515.

    There, you’ll also find two example filters that allow supplementing the output. Feel free to ask for pointers ??

    Thread Starter mcho

    (@mcho)

    Oh, OK. Thank you for letting me know! I’ll try the workaround and ask you more questions. Should I ask questions in the github issue or in this www.ads-software.com support ticket?

    Plugin Author Sybre Waaijer

    (@cybr)

    Cheers ??

    I prefer to use these forums for general support and GitHub for feature requests and bug reports only. I forward valid feature requests and bug reports submitted on these forums to GitHub.

    Many developers get notified about new issues at GitHub, which isn’t ideal when support happens there. I saw a handful of developers “unwatch” the repo after numerous support queries came in at once.

    Thread Starter mcho

    (@mcho)

    Hi, thanks! So it works for description. See my code below as a reference. I want to do the same with an ACF field for an image that can popular og:image tags, etc. Do you have a workaround for that? I don’t see anything equivalent to the_seo_framework_generated_description for the seo image in your codes, though.

    add_filter('the_seo_framework_generated_description', function($desc, $args) {
        if (null === $args && tsf()->is_author()) {
            $tsf = tsf();
            $user_id = 'user_'.$tsf->get_the_real_ID();
            if (get_field('seo_description', $user_id)) {
                $desc = get_field('seo_description', $user_id);
            }
        }
        return $desc;
    }, 10, 2 );
    Plugin Author Sybre Waaijer

    (@cybr)

    Hello! Sorry for my belated reply.

    You can find the filters for images here: https://tsf.fyi/docs/api/filters#image-related.

    Since the images are obtained via a PHP generator for improved performance, you require two methods: One to register the generator, and the generator itself. I understand it gets tricky, so here’s a template adjusted for your needs. You need to adjust my_author_image_field to your image field name:

    add_filter( 'the_seo_framework_image_generation_params', function( $params = [], $args = null, $context = 'social' ) {
    
    	// Let's not mess with non-social sharing images.
    	if ( 'social' !== $context ) return $params;
    
    	if ( null === $args ) {
    		// In the loop.
    		if ( is_author() ) {
    			// Prepend our most generator, so it'll run first.
    			$params['cbs'] = array_merge(
    				[ 'custom_author' => 'my_tsf_custom_author_image_generator' ],
    				$params['cbs']
    			);
    		}
    	}
    
    	return $params;
    }, 10, 3 );
    
    function my_tsf_custom_author_image_generator( $args = null, $size = 'full' ) {
    
    	$url = function_exists( 'get_field' ) ? get_field( 'my_author_image_field', tsf()->get_the_real_ID() ) : '';
    	$id  = 0; // Got an ID? Put it here to allow further parsing.
    
    	if ( $url ) {
    		yield [
    			'url' => $url,
    			'id'  => $id, // Optional. Used for alt-tag fetching and dimension testing.
    		];
    	}
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can I add custom title, description, image fields to the user?’ is closed to new replies.