Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Oh, I meant to say that search within the theme files, that is to say that search in the code of those files.

    Like in the code you posted in one of your previous posts, you can see comments_popup_link, right? Just replace that with my_comments_popup_link, and wherever else you are using this function.

    Okay, here’s what you can do for comments…

    Open your favourite text editor and paste the following code in it:

    <?php
    function my_comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
    global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb;
    global $comment_count_cache;

    if (! is_single() && ! is_page()) {
    if ( !isset($comment_count_cache[$id]) )
    $comment_count_cache[$id] = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';");

    $number = $comment_count_cache[$id];

    if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) {
    echo $none;
    return;
    } else {
    if (!empty($post->post_password)) { // if there's a password
    if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
    echo(__('Enter your password to view comments'));
    return;
    }
    }
    echo '<a href="';
    if ($wpcommentsjavascript) {
    if ( empty($wpcommentspopupfile) )
    $home = get_settings('home');
    else
    $home = get_settings('siteurl');
    echo $home . '/' . $wpcommentspopupfile.'?comments_popup='.$id;
    echo '" onclick="wpopen(this.href); return false"';
    } else { // if comments_popup_script() is not in the template, display simple comment link
    if ( 0 == $number )
    echo get_permalink() . '#respond';
    else
    comments_link();
    echo '"';
    }
    if (!empty($CSSclass)) {
    echo ' class="'.$CSSclass.'"';
    }
    echo ' title="' . sprintf( __('Comment on %s'), strip_tags($post->post_title) ) .'">';
    comments_number($zero, $one, $more, $number);
    echo '</a>';
    }
    }
    }
    ?>

    Make sure that there are no empty spaces before <?php and after ?>. Now save the file as my-hacks.php and upload it to your root wordpress directory.

    Next, in the administration panel, go to Options > Miscellaneous and check “Use legacy my-hacks.php file support”.

    Now, search for comments_popup_link in your theme’s files. Replace every occurrence with my_comments_popup_link. You don’t have to change the function’s parameters.

    That should work.

    (Also, about post titles, you also need to change the code for your post titles in single.php, just like you did for index.php.)

    Open the index.php file in your theme and find this line:

    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>

    Now change it to this:

    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php echo strip_tags( the_title('', '', false) ); ?>

    It should work, since I use the same to take care of the spans I have in my post titles. You’ll also notice that the the comments link is also fishy when you use spans in the title. I fixed it by changing the core comments_popup_link() function (which isn’t a neat solution, since you might have to change it manually after a WordPress version upgrade).

    Thread Starter Saadat

    (@nastaliq)

    OK, I checked the code of previous- and next-posts’ links functions, played a little, and then made a small plugin out of the tweaked code to do the job. Thanks for pointing, blogtackular! ??

    Thread Starter Saadat

    (@nastaliq)

    Well, the functions can exclude posts from a specific category, or they can show posts from the same category, but I want to do neither.

    *scratches head*

    Thread Starter Saadat

    (@nastaliq)

    Thanks for responding blogtackular (that was fast!).

    However, I might not have been able to explain properly. In the loop, it’s easy. In fact, I do change the font for Urdu content wherever the loop is being used through ‘if cat’. But it’s the previous and next post titles I am having trouble with. They are displayed in the sidebar, and in sidebar.php I check if it’s the single post and then display that post’s category, related posts and posts which are next and previous to it. I want to format the titles of next and previous posts (if they are in ‘Urdu’ category) and couldn’t find any way to determine their categories.

    I have been trying to get the navigation fix at https://www.blueblurry.com/navigation-fix/, but it keeps displaying the “Server not found” error. Anyone else who could send me the fix, or direct me to somewhere from where I can obtain it?

    Thanks ??

Viewing 7 replies - 1 through 7 (of 7 total)