Closed vladopandzic closed 1 year ago
you'll have to await the call, like this: var result = await client.Posts.Update(wordpressPost);
does this work?
@ThomasPe
I've tried the code above but it doesn't appear to work. It doesn't return an error but the meta title isn't updated in WP and isn't shown on the site.
var metaSample = new { title = "test" }; postSample.Meta = new List
var result = await client.Posts.Update(postSample);
Any advice would be appreciated.
And thanks for creating this library!
I this still an issue? Sorry for the late reply...
Has anyone come up with the proper way to update the yoast meta description? I have tried every combination or keyword I can think of. A working example would be truly appreciated.
Can anybody confirm they have logged in using the jwt-auth before they tried?
Creating something like this would require elevated privileges on WordPress.
var client = new WordPressClient(ApiCredentials.WordPressUri);
client.AuthMethod = AuthMethod.JWT;
await client.RequestJWToken(ApiCredentials.Username,ApiCredentials.Password);
// check if authentication has been successful
var isValidToken = await client.IsValidJWToken();
if( isValidToken){
var metaDescYoast =new { _yoast_wpseo_metadesc = finalWord };
wordpressPost.Meta = new List
{
metaDescYoast
};
var result = await client.Posts.Update(wordpressPost);
}
I am able to log in successfully, retrieve posts, create a new post. No problem. Just can't get the Yoast properties to stick.
However, I will say this reference to Meta = new List { metaDescYoast } does not even seem to be valid C#, you need some kind of type parameter. I'm doing new List
I am able to log in successfully, retrieve posts, create a new post. No problem. Just can't get the Yoast properties to stick.
However, I will say this reference to Meta = new List { metaDescYoast } does not even seem to be valid C#, you need some kind of type parameter. I'm doing new List to make that work.
Yup, the code example was based off the above. Was just asking more about the auth part.
Do you have the show_in_rest = true for meta properties of Wordpress Post?
Hello i resolved with this plugin: https://it.wordpress.org/plugins/rest-api-meta-support/
Just install and enable it in wordpress, then you can store meta title and description in yoast using the Meta
field
Meta = new Dictionary<string, string>
{
{"yoast_wpseo_title", "your meta title"},
{"yoast_wpseo_metadesc", "your meta description"},
}
I tried udpating yoast meta description field which is called "_yoast_wpseo_metadesc". However, when I try to update nothing changes. var metaDescYoast =new { _yoast_wpseo_metadesc = finalWord }; wordpressPost.Meta = new List