Can I do this?
-
Hi I am after adding some code to my home page but gotton a liitle confused as to how I am doing it
ok I am using graphene theme, and using yoast wordpress SEO plugin
and what I want to do on my home page is, when displaying posts check for the post meta description (for each the one post) and post it instead of the page content like it does now, the code below does just that, but it also still posts the post content?
<?php
$yoast_meta = get_post_meta($post->ID, '_yoast_wpseo_metadesc', true);
if ( $yoast_meta ) {
echo "$yoast_meta";
} else {
echo "do_action('graphene_after_post_content')";
}
?>can anyone help me do something like this =
if meta description is there, post it
else
if meta description is not there post 100 words of post content
==
but then both need to still post a continue reading button to the post, hope you understand what I mean? thanks
Why don’t you just put the same description in the Excerpt field?
the code
<?php
add_filter('excerpt_length', 'custom_excerpt_length');
function custom_excerpt_length($length) {
return 20; // Change this to whatever you want.
}
?>doesnt seem to limit the length of the excerpt thats been added in that field? it will limit the standard content that is used from the pages (the auto excerpt)
think I am going mad with this
Mod
That’s correct. You can use the above filter to alter the default excerpt length (which is 55 words), but this will always be overridden by whatever you add to the Excerpt field, whether it’s one word or a hundred words.
Viewing 7 posts - 1 through 7 (of 7 total)
- You must be logged in to reply to this topic.