• Resolved arickrol

    (@arickrol)


    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?

Viewing 15 replies - 1 through 15 (of 17 total)
  • 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

    Thread Starter arickrol

    (@arickrol)

    If my wp-blog-header.php is at https://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 https://wargamingforums.com/tagcloud.html

    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.

    Thread Starter arickrol

    (@arickrol)

    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.

    oops dupe.

    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

    https://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:

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

    Its intended for your last.fm profile page.

    Thread Starter arickrol

    (@arickrol)

    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 https://wordpress.pastebin.ca/737401 ]

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    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.

    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.

    https://wordpress.pastebin.ca/737401

    Thread Starter arickrol

    (@arickrol)

    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

    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.

    Thread Starter arickrol

    (@arickrol)

    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).

    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

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

    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?

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Show the Tag Cloud Outside of the Blog?’ is closed to new replies.