Change "Read More" text based on Category of Post

Community Forums Forums General Discussion Change "Read More" text based on Category of Post

This topic is: not resolved

This topic contains 2 replies, has 2 voices, and was last updated by  shaunac 1 year, 6 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #40081

    shaunac
    Participant
    Post count: 4

    Hi – I would like to change the read more copy on the home page and on the archive/category pages based on whether a post is in a certain category or not.  For example (or for real):

    If the post is in category id 86, 87 and/or 88 – I would like the read more link to read: [Read More]

    If the post is in any other category – I would like it to read: [Members Only]

    BUT: Posts that are in categories: 86, 87 and 88 could ALSO be in other categories….they would still need to read: Read More (essentially, these are featured posts that are open to the public)

    Here is the code that I was playing with – that is NOT working the way I would like
    /** Modify the Genesis content limit read more link */
    add_filter( ‘excerpt_more’, ‘lifestyle_read_more_link’ );
    add_filter( ‘get_the_content_more_link’, ‘lifestyle_read_more_link’ );
    add_filter( ‘the_content_more_link’, ‘lifestyle_read_more_link’ );

    function lifestyle_read_more_link() {
    if (!is_category( ’86, 87, 88′ ))
    return ‘<a class=”more-link” href=”‘ . get_permalink() . ‘” rel=”nofollow”>Members Only</a>’;
    }

    Thanks for any help!!  :)

    • This topic was modified 1 year, 6 months ago by  shaunac.
    • This topic was modified 1 year, 6 months ago by  shaunac.
    http://174.120.127.91/~learners/
    #40099

    braddalton
    Participant
    Post count: 10568

    This code is tested and works but i guess you might also want the Members Only posts to link somewhere else?

    Code not displaying? Grab it on Github.

    Please copy this code from the view raw link and paste it at the end of your child themes functions.php file using a code editor like Notepad++.


    #40100

    shaunac
    Participant
    Post count: 4

    This works perfectly!  I have another plugin that will redirect them if they aren’t members so we are good there!  Thanks so much!!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.