Shortcodes not rendering in WordPress

I have tried to use several plugins that use shortcodes in the post of page, such as, [contact] or [download].

But when I view the page, the shortcode is not rendered, instead is just shows me the shortcode.

To fix this, your template just have the following code in it:

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
	<?php if ( is_front_page() ) { ?>
		<h2><?php the_title(); ?></h2>
	<?php } else { ?>
		<h1><?php the_title(); ?></h1>
	<?php } ?>
	<?php the_content(); ?>
<?php endwhile; ?>
That will fix all your shortcode problems.
Advertisements

Getting WordPress to work on GoDaddy’s free hosting account…finally!

Aye….another failed attempt.  Close.   If someone can provide some suggestions, I think we can get there….

Tested in Firefox 3.6.6  Does not work in Chrome.  IE….won’t even try.

It took me a few tries….okay, a bunch of tries, but in the end it’s a really simple fix to get WordPress 3.0 to work on GoDaddy’s free hosting account.

From my experience, I have not had any issues on the front end of wordpress, it is only the admin that breaks.

To fix this, you’ll have to edit some files, but it’s not a big edit.

To get started, open up wp-admin/index.php

Change the top of index.php file to look like this:

<?php

ob_start();

/**

* Dashboard Administration Panel

All we’ve done here is add the line ob_start();

Next, at the very, very bottom of that page…I mean the very bottom, put the following code:

<?php
$buffer = ob_get_contents();
ob_end_clean();
$buffer = str_replace(array(‘<html>’, ‘</html>’), ”, $buffer);
$handle = fopen(“./temp.html”, ‘w+’);
fwrite($handle, $buffer);
fclose($handle);
?>
<script type=”text/javascript”>
$(document).ready(function() {
$(“head”).remove();
$(“body”).remove();
$.get(“./temp.html”, function(data){ $(“html”).append(data); } );
});
</script>
That’s it!
Save that, and refresh your admin index page.
What we have done here is essentially grab all the data that would be output by WordPress before GoDaddy’s get’s is greasy fingers on it, store that in a file.  Then we wait for the entire page to load, let GoDaddy do what they need to do, then wipe the page clean.  We then send out a request to get the non-abducted code and make that your page.  The ole switch-a-roo!
Of course, you probably stopped reading this after you saw that it worked and are now back here reading again to find out why none of the links work. 🙂
Well, we only changed the index.php page.  If you notice in your browser, you are probably now on post.php or edit.php.  This means that each file will need to have the above fix added to it.  I know, so much work, but totally worth it for about a half hour of work.
Caveat: GoDaddy’s puts those ads in there for a reason, so I’d advise to leave them on frontend of your site.  Yeah, I know, I hate them, but hey, a free account for a banner ad, not a bad price to pay.   I took them off my admin for one, because it broke it!, but two because, I’m the admin!!!  They don’t need to advertise to me, I already have an account with them.
-Happy coding!

Common Linux Commands I use

unzip archive:

> unzip filename.zip

or

>tar cfv test.tar test/

to get hidden files as well

Move contents of directory A to directory B

> mv -i ./A/* ./B

Copy contents of directory A to directory B

> cp -r ./A/* ./B

Remove directory

>rmdir ./A

or

>rm -rf ./A to remove all subdirectories and file

Untar file

tar -xvf ./file.tar

if zipped also use -zxvf

Taken from: http://www.geekvenue.net/chucktips/jason/chuck/994016279/index_html

If you would like to preserve the permissions of the files you backup, use the p option with the tar command. This will save the uid, gid as well as the specific permission attributes of the files (read, write, execute etc.)

tar pzcvf tarball.tgz .

You should also use the p option with the tar extraction command:

tar pxvf tarball.tgz .

PHP include vs require_once

After 10 years of PHP programming, it has finally settled with me the difference between require_once() and include().

Now, there are other differences as recorded in the manual, but I never really cared about it, until today.

I have 4 files: index.php, config.php, functions.php, and plugins/config.php.  All of which are nested inside the other respectively using an include.

In the last config.php file, I am declaring a function…say, function what(){ }

While using include, I get the error, cannot redeclare function what as previously declared.  The interesting thing was that the two places it said that it was begin redeclared in were the same file!

Strange.  I happened to realized that during the order in which PHP includes files, was that it was redeclaring the function as it bubbled up the chain of includes.

changing to require_once() fixed the problem!

Magento Nav Function for Dynamic Menus

I finally got tired of messing with Magento Menus.  The drawItem function really sucked when I needed to customize something.

Here is a little function that WORKS!!

function allebrumNav($parentId, $levels=1, $exclude=array(), $current_level=1){
if($current_level == 1){ $menu .= ‘<li><a href=”‘.Mage::getModel(‘catalog/category’)->load($parentId)->getUrl().'”>’.Mage::getModel(‘catalog/category’)->load($parentId)->getName().'</a><ul>’; }
$i = 1;
foreach(Mage::getModel(‘catalog/category’)->load($parentId)->getChildrenCategories() as $cat){
if(!in_array($cat->getId(), $exclude)){
$menu .= ‘<li><a href=”‘.$cat->getUrl().'”>’.$cat->getName().'</a>’;
if($current_level != $levels){ $menu .= ‘<ul>’.allebrumNav($cat->getId(), $levels, $exclude, $current_level+1).'</ul>’; }
$menu .= ‘</li>’;
$i++;
}
}
if($current_level == 1){ $menu .= ‘</ul></li>’; }
return $menu;
}

To Use the function simple call:

The 1st Parameter is the Parent Category ID to start with. It will start there and read all the children categories.

The 2nd Parameter is how many levels down to read into.

The 3rd Parameter is and array of Category IDs to exclude from the list. Example: array(“32”, “35”, “6”)

TinyMCE Advanced, WordPress 3.0, Google Chrome, Custom Styles

I was using the TinyMCE Advanced plugin for WordPress and needed to add some custom styles to it for a client.  I kept Googling it and everyone seemed to think it was very easy.

I was at a loss.

There were all the suggestions to clear your browser’s cache if you were on Firefox.  I was using Chrome and thought I would give it a try.  No luck.  After about an hour, I finally closed my tab and opened a new tab in my browser.  Holy crap! Styles came in, but they were old styles that I was playing around with earlier.

I cleared the cache again, closed my tab, opened it back up, and low and behold, my styles that I defined in wp-content/plugins/tinymce-advanced/css/tadv-mce.css finally showed up correctly.

Now, to get them to show up on the front side, I just added the classes to my themes stylesheet and it worked.

SilverStripe 2.4.0 CMS Admin “Website Error” after clean install

Wanted to try out a new CMS today….The first two hours turned into a nightmare.

I did a clean install of SilverStripe 2.4.0 on a Linux box.  Install went through fine…had a little bit of trouble detecting modrewrite, but I ignored it and went ahead with the install.

After install, prefilled website came up fine.

When I went to the admin (index.php/admin/) I got a lovely, “Website Error”.  It said a little more, but it was about as pointless as that.

I had to open up the ./mysite/_config.php file.  mysite is the actual folder…not really your site.  Took me a little bit to figure that out 🙂  I must have been a little slow today.  I threw this Director::set_environment_type(“dev”); on the the second line after the <?php, refreshed the admin page, and now I had something to work with.

You may have to do a build by calling index.php/dev/build/?flush=1 just a little fyi.

A support ticket that was closed as resolved had me put $_ENV[‘TMPDIR’] = TEMP_FOLDER; in the sapphire/_config.php file.  That did NOT work for me.

I finally found a post that had me edit the ./sapphire/thirdparty/Zend/Cache/Backend/File.php on line 90.

I changed that line to be ‘cache_dir’ => ‘./silverstripe-cache/’,//null, refreshed my admin, and that was it.

I’ll let you know how the rest of my ventures with building this site go.

Previous Older Entries Next Newer Entries