Community Forums › Forums › Archived Forums › Design Tips and Tricks › Customizing Read More
- This topic has 10 replies, 3 voices, and was last updated 9 years, 8 months ago by SimplyMeBrittany.
-
AuthorPosts
-
July 22, 2014 at 3:26 pm #115448SimplyMeBrittanyMember
I want to customize the Read More link so that it's specific to the type of post. For instance instead of it reading "Read More..." I'd like it to say "View Full Gallery" or "view Full Video".
How would I go about doing this?
July 22, 2014 at 4:04 pm #115453saxismeMemberHi SimplyMeBrittany,
You could use this function from Bill Erickson
<?php /** * Customize Read More Link * @author Bill Erickson * @link http://www.billerickson.net/read-more-link * * @param string * @return string */ function be_more_link($more_link) { return sprintf('<p><a href="%s" class="more-link">%s</a></span></p>', get_permalink(), 'View Full Video'); } add_filter( 'excerpt_more', 'be_more_link' ); add_filter( 'get_the_content_more_link', 'be_more_link' ); add_filter( 'the_content_more_link', 'be_more_link' );
Using also WordPress conditional tags depending if your content is a Custom Post Type or a Category.
If is a CPT and if you are in the CPT archive page an example could be:
`if ( is_post_type_archive ( array( 'video-post-type-name-here' ) ) {
...above code here...
}Hope it helps.
July 22, 2014 at 4:50 pm #115457Brad DaltonParticipantJuly 23, 2014 at 7:36 pm #115635SimplyMeBrittanyMemberHow would I go about making this category specific? Would I add the category name or category id?
This is what I have so far?
//* Add Category Image to bottom of post. add_action('genesis_entry_content', 'runpro_include_catimg', 11); function runpro_include_catimg() { if(is_single() || is_category( '42' )) { ?> <a class=href="' . get_permalink() . '"><img src="<?php echo get_stylesheet_directory_uri(); ?>/images/vfg.png" alt="CatImg" /> <?php }}
July 23, 2014 at 8:39 pm #115637Brad DaltonParticipantDepends but all these work and are slightly different.
if ( in_category( '42' ) ) {
Or
if ( is_category( '42' ) ) {
Or
if ( is_singular('post') && in_category( '42' ) ) {
July 23, 2014 at 8:52 pm #115638SimplyMeBrittanyMemberI have the first one in, but it's showing for every category. My site is http://shesaving.com/
July 23, 2014 at 9:08 pm #115641Brad DaltonParticipantYou can see the conditionals on the Codex http://codex.wordpress.org/Conditional_Tags#A_Category_Page
in_category('42') Returns true if the current post is in the specified category id
July 23, 2014 at 9:15 pm #115643SimplyMeBrittanyMemberI don't know if there's something I'm missing or what, but I have it that way and I'm still getting the image on every post instead of just the ones in category 42. Here's the exact code I have in my functions.php
//* Add Category Image to bottom of post. add_action('genesis_entry_content', 'runpro_include_catimg'); function runpro_include_catimg() { if(is_home() || in_category('42')) { ?> <a class="more-link" href="' . get_permalink() . '"><img src="<?php echo get_stylesheet_directory_uri(); ?>/images/vfg.png" alt="CatImg" /></a> <?php }}
July 23, 2014 at 9:28 pm #115645Brad DaltonParticipantJuly 23, 2014 at 9:35 pm #115647SimplyMeBrittanyMemberAhh thank you thank you thank you!!
Now in terms off getting the permalink function to cooperate.
July 24, 2014 at 12:15 pm #115725SimplyMeBrittanyMemberI'm still not able to get the get_permalink() function to work properly. Any suggestions?
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.