Community Forums › Forums › Archived Forums › Design Tips and Tricks › Paragraph tags a problem in the entry meta
Tagged: .post-info, entry-meta, paragraph tags
- This topic has 8 replies, 2 voices, and was last updated 4 years, 11 months ago by
Brad Dalton.
-
AuthorPosts
-
June 10, 2018 at 11:30 am #220717
CeeDeeLight
MemberI love the Simple Share Buttons plugin and have used it before, but this time I need the icons to display in the entry meta. The only things on that line under the post title is the date and then the icons.
It's easy enough adding the shortcode and then styling with CSS. The problem is that the entry meta is wrapped in paragraph tags, which forces the share icons down onto a new line.
When I type a word next to the date, it shows up inside the paragraph tags and on the same line. When I replace it with the shortcode, the markup shows that the share icons are not inside the paragraph tags.
// CUSTOMIZE ENTRY META HEADER add_filter( 'genesis_post_info', 'themeprefix_post_info_filter' ); function themeprefix_post_info_filter( $post_info ) { $post_info = '[post_date] HELLO'; return $post_info; }
The shortcode is wrapped in divs. I thought that perhaps removing the paragraph tags and replacing them with divs would be a good fix, but I can't figure out how to remove the tags.
Any suggestions? Thanks!!
(My website isn't live right now. I'm using the eleven40 Pro theme.)
June 10, 2018 at 11:37 am #220719CeeDeeLight
MemberWhen I use Safari's inspector tool, I can slide the div that wraps the share icons up into the paragraph tags. And when I change their width to 50%, they display inside the paragraph tags and on the same line.
June 10, 2018 at 3:31 pm #220721CeeDeeLight
MemberI saved a copy of my parent post.php file. Then I altered that file by removing the paragraph tags from the markup array and adding the shortcode. Now it works: the date and share icons are on the same line when I adjust the CSS.
But I couldn't successfully replicate this with the child theme. I created a child post.php file and placed it in the eleven40 Pro folder. It didn't work, so I added a structure folder inside lib, and still nothing.
What aren't I understanding about child theme files? Grrr.
The easier way would be a snippet in the functions file. But while I can remove the author and edit link and add the shortcode, I can't remove the paragraph tags. I'd really welcome some help with this.
Thank you.
June 10, 2018 at 3:33 pm #220723CeeDeeLight
MemberSorry, I meant to share the code from the parent post.php that I altered. Where you see XXX is the location of the removed p tags.
add_filter( 'genesis_post_info', 'do_shortcode', 20 ); add_action( 'genesis_entry_header', 'genesis_post_info', 12 ); add_action( 'genesis_before_post_content', 'genesis_post_info' ); /** * Echo the post info (byline) under the post title. * * By default, only does post info on posts. * * The post info makes use of several shortcodes by default, and the whole output * is filtered via <code>genesis_post_info</code> before echoing. * * @since 1.0.0 * * @return void Return early if post type lacks support for <code>genesis-entry-meta-before-content</code>. */ function genesis_post_info() { if ( ! post_type_supports( get_post_type(), 'genesis-entry-meta-before-content' ) ) { return; } $filtered = apply_filters( 'genesis_post_info', '[post_date][ssba-buttons]' ); if ( false == trim( $filtered ) ) { return; } genesis_markup( array( 'open' => '', XXX 'close' => '', XXX 'content' => genesis_strip_p_tags( $filtered ), 'context' => 'entry-meta-before-content', ) ); }
June 10, 2018 at 7:45 pm #220731Brad Dalton
ParticipantI would create a custom shortcode for this rather than modify the post.php file.
Or
Filter the original function in your child theme.
June 10, 2018 at 9:08 pm #220738June 11, 2018 at 12:19 pm #220758CeeDeeLight
MemberThanks, Brad.
So, is the idea to create a shortcode that filters the post info and removes the p tags? I would add the social share shortcode to this and then create a function that uses the new shortcode to accomplish this task?
I struggle with ADHD and have a hard time locking in on what I'm seeing long enough to make sense of it. It's frustrating.
The 'edit post info' code snippet provided by StudioPress doesn't filter out the p tags. The shortcode would rewrite the entire post info section, and a new function would be added that embeds this new shortcode, thereby wiping out the p tags.
Is that correct?
June 11, 2018 at 1:01 pm #220760CeeDeeLight
MemberFor now I removed the entire post info section (what's the number for?):
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
And then I created a simple shortcode from one of your tutorials:
function new_post_info() { return '[post_date] [ssba-buttons]'; } add_shortcode('new_pi', 'new_post_info');
The p tags are gone and the date and share buttons are now on equal footing. I'll figure out how to wrap it in a div and get the buttons to display on the same line, and then maybe I'll replace the shortcode and write this out as a function that automatically places this under the entry title.
I'm not sure this is ideal, but so far it's working. Does Yoast SEO get the post date from the entry meta only? Could doing this affect how my content appears on Google?
June 11, 2018 at 8:49 pm #220762Brad Dalton
Participant -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.