Community Forums › Forums › Archived Forums › Design Tips and Tricks › Show line of text between blog title and image on primary blog page
- This topic has 8 replies, 2 voices, and was last updated 4 years, 4 months ago by Jackiejoh.
-
AuthorPosts
-
August 25, 2020 at 1:32 pm #500767JackiejohParticipant
Hi there,
I'd like to be able to have a short line of text show up on the main blog page between the title and image.
The hope:
-Title
-short line of text (I want to use the meta description)<-- this is what I need help with.
-image
-text
-Read moreI'm able to manually enter it and it appear when I click on the post itself, but I'd love for it to appear on the main page before clicking through.
I'm using Atmosphere Pro.
Thanks so much in advance.
https://jackiejohansen.com/blog/August 26, 2020 at 6:10 am #500770andytcParticipantAdd this to the end of your childthemes functions.php - The description (if it has one) will show on blog home page , single posts and cat archives in a h3 , change that to whatever you need. Adjust conditional to suit
// Add Genesis SEO Meta Description after entry titles - posts page - archives - single posts . add_action( 'genesis_entry_header', 'pl_custom_meta_description' ); function pl_custom_meta_description () { if ( is_home () || is_archive() || is_single( ) ) { $custom_meta = genesis_get_custom_field( '_genesis_description' ) ; if ( genesis_get_custom_field( '_genesis_description' ) ) { echo '<h3>' .$custom_meta. '</h3>'; } } }
August 26, 2020 at 8:56 pm #500780JackiejohParticipantThanks for your help, Andytc. I added the code but I'm not seeing any changes on my blog page. I'm wondering if I missing anything.
August 27, 2020 at 2:11 am #500783andytcParticipantAt the moment your blog page is broken , i can see code appearing in your description meta - see below
<meta property="og:description" content="[ic_add_posts template='template-in-theme-dir.php'] <?php //* Do NOT include the opening php tag //* Modify the Genesis content limit read more link add_filter( ‘get_the_content_more_link’, ‘sp_read_more_link’ ); function sp_read_more_link() { return ‘… <a class=”more-link” href=”‘ . get_permalink() . ‘”>[Continue Reading]</a>’; }">
It looks like you've added read more link changes from studiopress , but you missed the bit that said
"<?php //* Do NOT include the opening php tag"
Where did you add that ?
Also , a shortcode is appearing -[ic_add_posts template='template-in-theme-dir.php']
where did you add that and how ?
If you fix those errors first , see if it shows up , remember that this is for the genesis meta description , not one created by any other SEO plugins.
August 27, 2020 at 10:39 am #500789JackiejohParticipantHmmm,
So I found that code. When I go to the blog page and hit "edit page" vs "customize" it's there hanging out in a text block.
This is the total of what it says on my end:
[ic_add_posts template='template-in-theme-dir.php'] <?php//* Do NOT include the opening php tag //* Modify the Genesis content limit read more linkadd_filter( 'get_the_content_more_link', 'sp_read_more_link' );function sp_read_more_link() {return '... <a class="more-link" href="' . get_permalink() . '">[Continue Reading]</a>';}
I'm not sure exactly what to do with it. I tried deleting it to see if it did anything and the page is still broken. I put it back. I also took out the code for the meta tags we were working with, just for the time being, to see if I could at least get the page fixed but it's still showing up broken. I'd love your thoughts. Thank you!
August 27, 2020 at 2:25 pm #500793andytcParticipantYou should delete it for sure , it has no business being there , the code for the 'read more' belongs in the childthemes functions.php , the shortcode you can see can also be deleted for now. you can get back to that later.
Once you've deleted it all , update the page , if you don't see any change on the front end , try clearing your browser cache and deactivate any cache plugin you might have active. we'll go from there , can't check anything else until that code is gone. the page editor won't accept php code.August 27, 2020 at 2:58 pm #500794JackiejohParticipantYou're brilliant. Thank you! Got it deleted and disabled the Siteground Optimizer plug-in I was using for caching. That fixed the page. I reactivated it and found that the "combine CSS Files" setting in the plug-in caused of the problem. I added back in your original code to the functions.php and it's working great after disabling Yoast.
I hate to ask, but is it possible to keep using Yoast? It seems like it has to be one or the other. I've done a lot of work with Yoast and hate to lose it, plus I like the features. Maybe Genesis is just as good?
Thanks again for all your help.
August 27, 2020 at 4:06 pm #500795andytcParticipantOk , that's great , all back to normal , as a tip , it's always best to deactivate cache plugins and minify stuff if you're developing a site , they'll have you running in circles for hours and hours thinking things aren't working when they are ... always clear your browser cache after CSS changes , it's best to use DEV tools in whatever browser you're using when working on a site , it can tell you a lot.
Anyway , back to the main event , sure , you can use Yoast if that's your preference , but the original code I gave you won't work for that , you'll have to use the new code below which is for Yoast Meta descriptions. I've changed the H tag to a p and given it a class so it'll be easier for you style it how you want , don't think you'll want a massive h3 🙂
I've tested this with Atmosphere and Yoast and it's all good , the code MUST only go in the functions.php file of the child theme , nowhere else , add it at the very end. If your not familiar or comfortable adding code to functions , you'll need to find someone to add it for you, getting it wrong can bring your whole site down temporarily , so be sure you know what you're doing. That said , here's the code -
// // Display YOAST SEO Meta Description after entry titles - posts page - archives - single posts . add_action( 'genesis_entry_header', 'pl_yoast_meta_description' ); function pl_yoast_meta_description () { if ( is_home () || is_archive() || is_single( ) ) { $meta = get_post_meta( get_the_ID(), '_yoast_wpseo_metadesc', true ); if ($meta) { echo '<p class="custom-meta">' . $meta . '<p>'; } } }
and to style it use this in the customiser > additional css section , add your styles as needed -
p.custom-meta { /*add your syles here*/ }
August 27, 2020 at 5:14 pm #500796JackiejohParticipantOh my gosh, thank you so much. It worked like a charm. I so appreciate all your help, thoroughness and clarity with how you explained things. Super grateful for your time. Thanks again.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.