Forums

[resolved] Show the Tag Cloud Outside of the Blog? (18 posts)

  1. arickrol
    Member
    Posted 4 years ago #

    I want to show my tag cloud either in a page (via post-page) or a separate web page outside of the blog.

    I tried using <?php wp_tag_cloud('smallest=8&largest=30&'); ?> in a page as that worked in my sidebar (via a php widget) but it didn't perform.

    Then I tried putting the php in a separate web page but that didn't do anything.

    Any thoughts?

  2. whooami
    Member
    Posted 4 years ago #

    you cannot just "use" wp functions in stand alone pages "outside of the blog". you need to lay a little groundwork first.

    <?php
    /* Don't remove this line. */
    require('path-to//wp-blog-header.php');
    ?>

    needs to be on the the top of any stand alone page you want to use WP functions on. And note that you need to edit the path to wp-blog-header.php

  3. arickrol
    Member
    Posted 4 years ago #

    If my wp-blog-header.php is at http://wargamingforums.com/wp-blog-header.php

    does the code have to look like

    <?php
    /* Don't remove this line. */
    require('wargamingforums.com//wp-blog-header.php');
    ?>

    Also, does it need to be //wp-blog-header.php or is /wp-blog-header.php okay?

    Lastly, when you say it needs to be at the top does it need to come before all the code (i.e. before <html> or <head>)? Or, just before <?php wp_tag_cloud('smallest=8&largest=30&'); ?>

    I'm trying to put the Tag Cloud at http://wargamingforums.com/tagcloud.html

  4. whooami
    Member
    Posted 4 years ago #

    2 things.

    First, you cannot** use PHP code on a page that ends with .html

    that .html extension tells the web server how to serve up the page to browsers.

    Rename the page to tagcloud.php

    Next, the newly named file is in the same directory as wp-blog-header.php so it would look like this:

    <?php
    /* Don't remove this line. */
    require('./wp-blog-header.php');
    ?>

    the ./ indicates its in the same directory.

    My double slashes above was just a typo.

    ** You can actually, but its unnecessary in this instance, and way beyond the scope of this forum to explain how to.

  5. arickrol
    Member
    Posted 4 years ago #

    Thank you for your help! I'm used to the echo situation, I'm not good with PHP but some of my pals just do echo so it'll work, and forgot to change it to .php.

    I copied your above and it works...sorta. I'm getting an error regarding headers. Apparently there's some clash with the WP-Post Ratings plugin.

    Warning: Cannot modify header information - headers already sent by (output started at /home2/cwf/public_html/tagcloud.php:14) in /home2/cwf/public_html/wp-content/plugins/postratings/postratings.php on line 652

    Not sure how to fix that. Do you think this is impacted cause of the Tag Cloud? If not, I'll post a thread in that plugin's area for assistance.

  6. whooami
    Member
    Posted 4 years ago #

    oops dupe.

  7. whooami
    Member
    Posted 4 years ago #

    whats inside tagcloud.php? If its not to long, paste the contetns here and enclose what you paste in backticks

    If you dont know what backticks are, just click the box labeled "code" above this window it will insert them for you

  8. whooami
    Member
    Posted 4 years ago #

    http://wargamingforums.com/tagcloud.php

    I dont see any error -- it looks fine to me.

    Off Topic: Nice blog, and since youre on last.fm, I recommend this:

    http://badges.village-idiot.org/

    Its intended for your last.fm profile page.

  9. arickrol
    Member
    Posted 4 years ago #

    I disabled the postratings plugin. But, I'll re-enable it so you can see the error at tagcloud.php. Here's the code for tagcloud.php btw (and under that is the code from the postratings plugin).

    Thanks for the props on the blog and the last.fm idea. I'll take a peek at that.

    [ moderated code pasted at http://wordpress.pastebin.ca/737401 ]

  10. Otto
    Tech Ninja
    Posted 4 years ago #

    whooami: I see his error perfectly. He has something being output before his require line.

    Move that require line to the very tip-top of the PHP file, nothing else before it. That should eliminate the problem.

  11. whooami
    Member
    Posted 4 years ago #

    ah yes, it's there now.

    im going to guess the trouble is this:

    <?php /* Don't remove this line. */
    require('./wp-blog-header.php');
    ?>

    that must go at the VERY top of that file. Not where you presently have it.

    http://wordpress.pastebin.ca/737401

  12. arickrol
    Member
    Posted 4 years ago #

    I'm not sure. When I deactived the postratings plugin the error goes away. But, I lose the abilities of the postratings plugin. I tried moving that code, as you suggest, to the very top but it always gets removed when I save the file. Then I end up with the below error

    Fatal error: Call to undefined function wp_tag_cloud() in /home2/cwf/public_html/tagcloud.php on line 29

  13. whooami
    Member
    Posted 4 years ago #

    huh? what do you mean it always gets removed??

    are you putting that code on a WP generated page??

    You indicated above this was a stand alone page "outside of the blog"..

    A WP generated page isnt one of those.

    --

    If thats NOT the case, then how you editing and saving the file?

    download the file tagcloud.php.
    open it with a text editor, and put that include stuff at the top, per otto and myself.
    save the changed file.
    upload it.

  14. arickrol
    Member
    Posted 4 years ago #

    I've done it in NVU and TextEdit. NVU removes it and TextEdit creates a page of gibberish (I save it as a txt first cause it won't let me save as php and then I change the extension to .php).

  15. whooami
    Member
    Posted 4 years ago #

    As for what you are editing with, I cannot speak to those, since I dont use them. If need be, use NOTEPAD.

    you are making this much much harder than it needs to be.:P

    http://www.village-idiot.org/broke/meh.php.txt

  16. etoile
    Member
    Posted 4 years ago #

    Perhaps you could create it as a page (using any of the many plugins that allow php in pages) and then simply include that page wherever you're wanting it to show up?

  17. arickrol
    Member
    Posted 4 years ago #

    I'm on a Mac and TextEdit is the Mac version of Notepad. NVU is free software like Dreamweaver or Frontpage.

    I appreciate the help even though it hasn't worked. I ended up disabling WP-Post Ratings for the time being. Maybe the plugin creator has a working solution for me.

    Much obliged for all your time and effort.

  18. sciencebase
    Member
    Posted 3 years ago #

    @whooami

    > First, you cannot** use PHP code on a page that ends with .html

    Of course you can. You just add a little snippet of code to .htaccess to tell the server to read a .html file as a php file. Indeed, I have some legacy pages on my sciencebase.com site that have the .asp extension but I set them to render as php.

    The necessary code is

    AddHandler application/x-httpd-php5 .php .html .htm .asp

Topic Closed

This topic has been closed to new replies.

About this Topic