I'm very, very new to PHP. I'm learning more by deconstructing and editing code--working up to writing it myself.
I'm trying to get a particular PHP script on my WordPress blog running, but I'm having no luck with my modifications. The script works to spit out text, but I'm trying to get it to simply create a variable (in the page header area) that I can later call from the body.
Here's the original script:
Code: Select all
<!-- Actual CATEGORY SNIFFER Begin -->
<?php $psb_category_id = get_category($cat); ?>
<!-- If category is parent, list it -->
<?php if ($psb_category_id->category_parent == 0) { ?>
<p><?php echo get_category_link($cat); ?></p>
<?php $psb_category_id->category_parent = $cat; ?>
<?php } else { ?>
<!-- If category is not parent, list parent category -->
<?php $parent_category = get_category($psb_category_id->category_parent); ?>
<p><?php echo get_category_link($parent_category->cat_ID); ?></p>
<?php } ?>
<!-- Actual CATEGORY SNIFFER End -->I realize this is a very nOOb process, but I'm a nOOb. Would someone give me the rewrite to get the script I need (and maybe an explanation of that rewrite)?