This seems to be exactly what I was looking for.
Thank you, thank you, thank you!!!
Ok this seems to be the answer to my question, but I am expiriencing problems with the API functionality.
using this function to use a custom meta desc for my dynamic content pages:
function yoastMetadesc($defaultMeta) {
switch($pagename){
case "xyz":
$x = ($wp_query->query_vars["x"]) ? $wp_query->query_vars['x'] : "x";
switch($x){
case "y":
return "123";
break;
default:
return "custom default desc";
}
break;
default:
return $defaultMeta;
}
}
add_filter( 'wpseo_metadesc', 'yoastMetadesc', 10, 1 );
My problem now is that my custom meta desc only gets shown on the frontpage. there is no meta desc inside my blog postings or on my dynamic pages 🙁 Only if I enter something manually inside the meta desc box widget inside on the “edit page” page. shouldnt it display the excerpt if I dont enter something manually?
All templates use the same header.php, which calls wp_head(), so this is not the problem.
Can somebody tell me what the problem is? Why isnt the meta desc populating inside my blog postings?
What are your settings on the SEO->Titles & Meta page ?
If the meta description box there is empty, no meta description will be added and the filter will not be called/run.
Hmmmm, not sure if this is what I want to achieve…
On articles, I want the articles excerpt to be the meta description (which is the default behavior of this plugin AFAIK). On Pages, it should be the custom meta description, which I want to define via the function posted above.
I now filled the fields you mentioned with default meta descriptions & titles, but they are now shown on every article/page, instead of the excerpt.
What am I missing?
I’m not sure I understand completely what’s going on now. Are you using the %%excerpt%% variable or not ? If you’re unclear on how to fill in the templates, have a look at the Help tab.
Otherwise, if that’s not the issue, could you show me a screenshot of what you’ve entered in the SEO->Titles & Meta’s settings now ?
And may be give me a link to one of the offending pages/posts ?
No no, the problem was something different, but I managed to fix it now… I removed the default parameter from the function and used the global $pagename var – now it works.
%%excerpt%%
This one solved my problem for the articles tho – big thanks!