Viewing 6 replies - 1 through 6 (of 6 total)
  • 1. open file:
    wp-favorite-posts/wpfp-page-template.php

    2. find row 22:
    echo "<li><a href='".get_permalink()."' title='". get_the_title() ."'>" . get_the_title() . "</a> ";

    3. add class=’my-class’

    4. look like this:
    echo "<li><a class='my-class' href='".get_permalink()."' title='". get_the_title() ."'>" . get_the_title() . "</a> ";

    Thread Starter andy999

    (@andy999)

    Hi Alex,

    That adds a class to posts on the favourite posts PAGE, to the list of them.

    I want to add a class to the link you see on the posts single page itself, the one that says ‘Add to favourites’ or ‘remove from favourites’.

    This is because I’m not using the favourite posts page, I’m using the sidebar widget and I want it to be obvious which posts are favourited when you’re on the page.

    Hi Andy,

    1. I think that
    – for link ‘Add to favourites‘ you can use the class name .wpfp-link
    – for link ‘remove from favourites‘ you can use the class name .remove-parent

    These styles already added in the code (right click – Inspect element).

    2. Also You can open wp-favorite-posts files (for example wp-favorite-posts.php) and try to find a bit of code including
    class="wpfp-link"
    and
    class="wpfp-link remove-parent"
    and add new class.

    For example:
    class="wpfp-link my-class"

    I hope this will help.

    Thread Starter andy999

    (@andy999)

    I think we’re misunderstanding each other here, Alex.

    The link on the single page outputs this code.

    <span class='wpfp-span'><img src='http://192.168.1.141:8888/wp-content/plugins/wp-favorite-posts/img/loading.gif' alt='Loading' title='Loading' class='wpfp-hide wpfp-img' /><a class='wpfp-link' href='?wpfpaction=add&postid=647' title='Add to favorites' rel='nofollow'>Add to favorites</a></span>

    ie, it has the class wpfp-link, now I can add another class to the code quite easily, but that doesn’t achieve what I’m trying to do, which is have a different class when it says ‘Add to favourites’ and when it says ‘remove from favourites.

    This is the code it outputs when the story being viewed is already in favourites.

    <span class='wpfp-span'><img src='http://192.168.1.141:8888/wp-content/plugins/wp-favorite-posts/img/loading.gif' alt='Loading' title='Loading' class='wpfp-hide wpfp-img' /><a class='wpfp-link' href='?wpfpaction=remove&postid=647' title='Remove from favorites' rel='nofollow'>Remove from favorites</a></span>

    Same class…

    If I add a class to the wp-favourite-posts.php here

    function wpfp_link_html($post_id, $opt, $action) {
        $link = "<a class='wpfp-link' href='?wpfpaction=".$action."&postid=". $post_id . "' title='". $opt ."' rel='nofollow'>". $opt ."</a>";
        $link = apply_filters( 'wpfp_link_html', $link );
        return $link;
    }

    It adds it for both remove and add.

    Try find <a class='wpfp-link' (in some line)

    1. next rename wpfp-link, and check changes for ‘Add to favourites’ link.
    if its work – good

    else
    2. find next <a class='wpfp-link' in new line and go to 1.

    Thread Starter andy999

    (@andy999)

    Unfortunately it uses the same function to output both the ‘Add to favourites’ and ‘Remove from favourites’ link, therefor adding the new class to one adds to to the other also.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add CSS class for 'favourited' post?’ is closed to new replies.