Forums

my-hacks question, how to call the functions? (3 posts)

  1. Roar
    Member
    Posted 7 years ago #

    I have read everything on http://wiki.wordpress.org/my-hacks.php and everything I can find on here.

    As best as I understand it, in the my-hacks file, I enter code as follows:

    'function get_post_word_count() {
    global $wpdb, $tableposts;
    $words = $wpdb->get_results("SELECT post_content FROM $tableposts WHERE post_status = 'publish'");
    foreach ($words as $word) {
    $post = strip_tags($word->post_content);
    $post = explode(' ', $post);
    $count = count($post);
    $totalcount = $count + $oldcount;
    $oldcount = $totalcount;
    }
    echo number_format($totalcount);
    }''

    What do I then put in my footer.php or index.php to call that function?

    I also think I am going to set my-hacks.php to look like this example: http://wordpress.org/support/topic.php?id=2793#post-16385

    I hope my question makes sense.

    Thank you in advance for your help. I really have searched for this, here and on scriptygoddess and on a couple sites on the web.

  2. Kafkaesqui
    Moderator
    Posted 7 years ago #

    "What do I then put in my footer.php or index.php to call that function?"

    <?php get_post_word_count(); ?>

    And podz knows what he's doing. ;)

  3. Roar
    Member
    Posted 7 years ago #

    ah! so it somehow knows it is in the my-hacks.php?

    Yes, I know podz knows.

    I even had some REAL USD to donate tonight.

    Thanks team!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.