• Resolved deputy05

    (@deputy05)


    This is my blog page for reference.

    I am having difficulty modifying the following elements (I still struggle with php coding):

    1. I have added a read more button for the post excerpts and therefore, I would like to remove the links associated with all post titles on all pages (blog and archive). (Just want a normal black title.)
    2. On the author’s archive page, I would like to remove the link associated with the author in the archive header. (Just want a normal black heading.)
    3. I used this snippet to change the single post navigation buttons text but it does not replace the existing text, just adds to it. What am I missing? (The list post navigation buttons text snippet works, but I noticed in the core files the two are not quite constructed the same way.)

    4. I would like an opinion if my code below is acceptable for changing all archive headings (it works, but since I struggle with php, I want to make sure it is proper):

    /* CHANGE POST ARCHIVES HEADINGS FROM H1 TO H3 */
    
    add_filter('tc_archives_headings' , 'my_archives_heading');
    function my_archives_heading($output) {
    return preg_replace('|h1|', 'h3', $output);
    }

    As always, Thank You for any assistance you can provide me. If I am not clear about what I am looking for, just let me know. Thanks again.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter deputy05

    (@deputy05)

    Okay…for #1 and #2 above…

    I found the CSS property “pointer-events:none;”…is it good form to tackle these items with this?

    Thanks.

    4. fine, but you can also use the cheaper str_replace(‘h1′,’h3’, $output). Consider that if you have a “h1” for some reason lets say.. in the title (rare), it will be replaced. But really isn’t this big deal ??
    If you want would be more appropriate using tc_archives_header_content

    3. Yea there isn’t a filter to remove the post title easily. You should build a more complex preg_replace and act on the whole html provided by the filter tc_post_nav and checking if is_singular() [look that is_singular() is different by is_single()]. But you can use something dirty like this instead (replacing that snippet):

    add_filter('next_post_link', 'my_nav_button_text');
    add_filter('previous_post_link', 'my_nav_button_text');
    function my_nav_button_text($link){
            if ( ! is_single() )
                return;
    
            if ( 'next_post_link' == current_filter() )
                $string = "Newer Posts →";
            else
                $string = "← Older Posts";
            return preg_replace("|(<a.*?>).*?(</a>)|", '$1<span class="meta-nav">'.$string.'</span>$2', $link);
    }

    About author and post links .. sorry you should filter the whole heading content html, and do another dirty preg replacement, There would be also another solution in css but it will not work in opera and ie.
    For example .. for post lists something like:

    .archive .entry-title > a {
        color: inherit;
        cursor: text;
        pointer-events: none;
    }

    Now I have to sleep, if you still need it maybe tomorrow I could wrote down the preg_replace .. or maybe someone else more trained than me can do it, and of course you can ??

    Thread Starter deputy05

    (@deputy05)

    Thank you…us wannabes marvel at your expertise. ??

    I will try to see what I can do…but…help is always appreciated.

    First I have to tell you that it was tc_archive_header_content and not tc_archives_header_content, sorry for that.
    So the code should be:

    // replace h1 with h3 in archive headers
    add_filter('tc_archive_header_content' , 'my_archives_heading');
    function my_archives_heading($output) {
        return str_replace('h1', 'h3', $output);
    }
    // remove author link in author pages
    add_filter('tc_author_header_content', 'remove_author_link');
    function remove_author_link($html){
        return preg_replace('|(<span class="vcard">)<a class=.*?>(.*?)</a>(</span>)|','$1$2$3',$html);
    }
    // remove post links in blog/categories
    add_filter('tc_content_headings', 'my_content_headings');
    function my_content_headings($html){
        return preg_replace('|<a .*?rel="bookmark".*?>(.*?)</a>|', '$1', $html);
    }

    Note that these aren’t perfect at all, pretty specific but should work, let me know.
    And thanks for your kind words,

    Thread Starter deputy05

    (@deputy05)

    Yes…I caught that last night…no need for apologies.

    Well…to my limited knowledge, I wouldn’t know what is imperfect about them…they appear to work (my attempts last night did not), so I am happy for that. ??

    Thanks again for volunteering your knowledge and skill to all of us newbies…it is greatly appreciated. ??

    You’re welcome and, for what is worth, I appreciate when you share your experience/knowledge too ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Need help with post-related elements’ is closed to new replies.