WordPress.org

Forums

P2
Remove the "Permalink" action on P2 posts (4 posts)

  1. Mathias
    Member
    Posted 12 months ago #

    Hi there,

    I am customizing P2 as a child theme for my own private internal chatroom, and there are 2 things I want to do:

    1. Remove the tag count between brackets on the posts.
    2. Remove the "Permalink" action link (next to "Reply | Edit") on posts and comments, which I find pretty useless.

    For #1, I normally just go inside the functions.php get_tags_with_count and replace:

    $tag_link = '<a href="' . get_tag_link( $tag ) . '" rel="tag">' . $tag->name . ' ( ' . number_format_i18n( $tag->count ) . ' )</a>';

    by

    $tag_link = '<a href="' . get_tag_link( $tag ) . '" rel="tag">' . $tag->name . '</a>';

    Is there a better/cleaner way to do that without having to make that change every time P2 gets updated?

    For #2, the problem seems more complicated... I've done some Googling and it seems I may have to not only edit functions.php but also some other files. My first attempt seems to have made a mess as when I use the Search box on my site it now displays the search result in complete random order (as opposed to chronological).

    Any help and suggestions appreciated!

    Thanks in advance,
    Mathias

    https://wordpress.org/themes/p2/

  2. designsimply
    Member
    Posted 11 months ago #

    Try adding the following to your child theme's functions.php file to see if it does the trick:

    add_action( 'tags_with_count', 'tags_without_count', 10, 3);
    function tags_without_count( $post, $format = 'list', $before = '', $sep = '', $after = '' ) {
            global $post;
            $posttags = get_the_tags($post->ID, 'post_tag' );
    
            if ( !$posttags )
                    return ''; 
    
            foreach ( $posttags as $tag ) {
                    if ( $tag->count > 1 && !is_tag($tag->slug) ) {
                            $tag_link = '<a href="' . get_tag_link( $tag ) . '" rel="tag">' . $tag->name . '</a>';
                    } else {
                            $tag_link = $tag->name;
                    }    
    
                    if ( $format == 'list' )
                            $tag_link = '<li>' . $tag_link . '</li>';
    
                    $tag_links[] = $tag_link;
            }    
    
            return '<br>Tags: ' . implode( ', ', $tag_links);
    }
  3. Mathias
    Member
    Posted 11 months ago #

    That looks very similar to what I was doing hacking the original P2 functions.php, so thanks for the proper way to do it via the child theme!

    Now, has anybody got any ideas for #2?

  4. designsimply
    Member
    Posted 11 months ago #

    2. Remove the "Permalink" action link (next to "Reply | Edit") on posts and comments, which I find pretty useless.

    You could simply hide the link using custom CSS. Here is an example that might work for you:

    .actions {
    	visibility: hidden;
    }
    .actions a {
    	visibility: visible;
    }
    .thepermalink {
    	display: none;
    }

Reply

You must log in to post.

About this Theme

About this Topic