Tagged: x
-
AuthorPosts
-
October 16, 2016 at 2:17 pm #1218415
jhm707ParticipantHi
I’m using an Ethos child theme and want to edit the metatag display.
For the post carousel, on mouseover I’d like to display the post title and an assignable author name (not necessarily the user who puts up the post). I’d be interested in making the tag of the post fill this role. So:
Post or Page Title
“By ” TagWithin the posts themselves, I’d like the metatag info to be assigned author (Tag) and on the next line an assignable title “like contributor or nurse or doctor, etc.)
by John Smith
Doctor
220 x 105 imageno date no comments, no category.
Please see attached image.
If it is possible to include font and size option in the code I would greatly appreciate it.
The site is at
johnharpermedia.com/testeroo
the password to view is 3m3r4ld
WP: 4.6.1
X:4.6.2
COrnerstone: 1.3.2October 16, 2016 at 8:16 pm #1218749
Rue NelModeratorHello There,
Thanks for writing in!
1] To have a custom carousel entry cover, please insert this following code in your child theme’s functions.php file.
// Custom Carousel Entry Cover // ============================================================================= function x_ethos_entry_cover( $location ) { if ( $location == 'main-content' ) { ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <a class="entry-cover" href="<?php the_permalink(); ?>" style="<?php echo x_ethos_entry_cover_background_image_style(); ?>"> <h2 class="h-entry-cover"><span><?php x_the_alternate_title(); ?></span></h2> </a> </article> <?php } elseif ( $location == 'post-carousel' ) { ?> <?php GLOBAL $post_carousel_entry_id; ?> <article <?php post_class(); ?>> <a class="entry-cover" href="<?php the_permalink(); ?>" style="<?php echo x_ethos_entry_cover_background_image_style(); ?>"> <h2 class="h-entry-cover"><span><?php ( $post_carousel_entry_id == get_the_ID() ) ? the_title() : x_the_alternate_title(); ?></span></h2> <div class="x-post-carousel-meta"> <span class="entry-cover-title"><?php x_the_alternate_title(); ?></span> <span class="entry-cover-tags">By <?php $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { echo $tag->name . ', '; } } ?> </span> </div> </a> </article> <?php } } // =============================================================================2] And to change the Post meta tag, please insert this following code in your child theme’s functions.php file.
// Custom Entry Meta // ============================================================================= function x_ethos_entry_meta() { // // Author. // $author = sprintf( '%1$s %2$s', __( 'By', '__x__' ), get_the_author() ); // // Post Tags // $posttags = get_the_tags(); $tag_list = ''; if ($posttags) { foreach($posttags as $tag) { $tag_list .= $tag->name . ', '; } } $tag_list .= ''; // // The Image // $image = '<img src="http://placehold.it/220x105/ff0000" alt="The Image">'; // // Output. // if ( x_does_not_need_entry_meta() ) { return; } else { printf( '<p class="p-meta">%1$s<br/> %2$s<br/> %3$s</p>', $author, $tag_list, $image ); } } // =============================================================================We would loved to know if this has work for you. Thank you.
October 17, 2016 at 2:48 am #1219038
jhm707ParticipantWow, that’s great. I have installed it. Feel free to check it out.
There are a few issues.
There is a comma after the “author name” even if there is only one author. Can we remove the comma if there is only one tag?
On the post page, it uses the actual author of the piece. Can the meta data also be the tag, just like on the carousel?
Finally, can I have the 210 x 105 image only on the post page? And is it possible to call different images for each page? My solution would be to call it the name of the tag (the ‘author’) plus “signature.jpg”. There probably needs to be a date call to deal with the way wordpress stores files by date.
SO:
img = directory/wp-content/uploads/ –date call function that list 4 digit year/2 digit month/–tag call–“signature”I would upload jpg files named “[author]signature.jpg” if the tag was “author” they would go in the current month’s wp-content/uploads folder so right now it would be domain/wp-content/uploads/2016/10/authorsignature.jpg
You guys are great, thank you.
October 17, 2016 at 4:16 am #1219111
LelyModeratorHi There,
To remove the extra comma at the end and add custom image, please update the code to this:
// Custom Entry Meta // ============================================================================= function x_ethos_entry_meta() { // // Author. // $author = sprintf( '%1$s %2$s', __( 'By', '__x__' ), get_the_author() ); // // Post Tags // $posttags = get_the_tags(); $tag_list = ''; if ($posttags) { foreach($posttags as $tag) { $tag_list .= $tag->name . ', '; } } $tag_list .= ''; $tag_list_clean = rtrim( $tag_list, ', ' ); // // The Image // // $image = '<img src="http://placehold.it/220x105/ff0000" alt="The Image">'; $image = '<img src="'.do_shortcode( '[cs_acf field="custom_image"]').'" alt="The Image">'; // // Output. // if ( x_does_not_need_entry_meta() ) { return; } else { printf( '<p class="p-meta">%1$s<br/> %2$s<br/> %3$s</p>', $author, $tag_list_clean, $image ); } } // =============================================================================Unfortunately, I am not sure about this:
On the post page, it uses the actual author of the piece. Can the meta data also be the tag, just like on the carousel?Finally, can I have the 210 x 105 image only on the post page? And is it possible to call different images for each page? My solution would be to call it the name of the tag (the ‘author’) plus “signature.jpg”. There probably needs to be a date call to deal with the way wordpress stores files by date.-> This can be achieve by adding/attaching an image on your post/page using custom field. We can use ACF Pro plugin:https://community.theme.co/kb/integrated-plugins-acf-pro/. See attached screenshots.
I have commented this line:
$image = '<img src="http://placehold.it/220x105/ff0000" alt="The Image">';
Then replace with the following, calling the custom image we have added using ACF PRO:
$image = '<img src="'.do_shortcode( '[cs_acf field="custom_image"]').'" alt="The Image">';Hope this helps.
October 17, 2016 at 12:08 pm #1219593
jhm707ParticipantIt did not work, I actually blew out my functions.php file and now have an error. Can you help me get the functions.php file back to the default file?
October 17, 2016 at 1:45 pm #1219726
DarshanaModeratorHi there,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
October 17, 2016 at 3:05 pm #1219816
jhm707ParticipantThis reply has been marked as private.October 17, 2016 at 9:56 pm #1220242
LelyModeratorHi There,
I can see that you have remove it already.
Since it was already remove, I am not sure which one is not working or caused an error. The changes that happen from the previous code is this:We have added this line of code:
$tag_list_clean = rtrim( $tag_list, ', ' );
After this line:
$tag_list .= '';That line of code that was added remove the extra comma and space at the end of the tag.
In case you didn’t add Custom field as suggested, this line will not work and probably caused the error:
$image = '<img src="'.do_shortcode( '[cs_acf field="custom_image"]').'" alt="The Image">';You might want to test the code first with this:
$image = '<img src="http://placehold.it/220x105/ff0000" alt="The Image">'; // $image = '<img src="'.do_shortcode( '[cs_acf field="custom_image"]').'" alt="The Image">';Check if that works.
October 18, 2016 at 1:42 pm #1221193
jhm707ParticipantThis reply has been marked as private.October 18, 2016 at 1:47 pm #1221204
jhm707ParticipantUploads for previous reply.
October 19, 2016 at 2:45 am #1221946
LelyModeratorHi There,
Please add this custom CSS to hide it:
.x-post-slider-entry .featured-meta { display: none; }Hope this helps.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1218415 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
