Help? Store a variable for later call?
Posted: Wed Aug 24, 2005 4:08 pm
I hope this is the right forum. Other help requests prompted me to post here.
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:
As is, the evaluations result in printing out the category_parent, but by two different means. What I need is for the evaluations to result in printing nothing, but creating a single variable ($psb_category_id) in either case (is parent or get parent). Later, down in the body of the page, I'll make calls to $psb_category_id.
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)?
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)?