Jump to content

Wordpress 3.1 HOW to Display PARENT Category for any sub-category post


ThunderVike

Recommended Posts

I am using the Classipress Classified Ads theme which must disable various WP functions and rewrite them to work at all.  Classipress uses the wp_term_taxonomy table to assign ALL categories in the "taxonomy" field the value "ad_cat".

 

So, all queries are by default looking for Categories and sub-categories of posts that are marked by "ad_cat" in this taxonomy.

 

So post category id 142 might be one child of category id 12, etc. etc.  But all posts are grouped by the common distinction of "ad_cat" so that they can be separated from pages and blogs.

 

A series of posts are then listed as ADS belonging to such groups as Parent Category... Rentals....sub-category ... Apartments ( with, in my case just two levels...Parent...child of)

 

But I cannot find a single wordpress function or query which in or outside of the loop of posts looks at the ad/post category id number and then goes UP the hierarchy to retrieve the PARENT Category which the child belongs to and then display the "nice name" such as "Rentals".

 

It seems that there ought to be a query that keeps track of the parent category of every child category with that information ready to be displayed in every single ad every single time no matter where it is called from or how the ad is sorted.

 

I created a function which shows the Parent category name extracted from the breadcrumb script but it only returns this information on pages related to the parent category to start with.

 

Is there a fool-proof "always on" query which displays the Parent category of each post whether as a post summary in a list of posts or on a single post page as easily as it already displays the post title, sub category name, and all post particulars?

 

So an Ad for "Apartment Rentals" as the sub-category or for "House Rentals" as the sub-category, whether shown in a list of Ad summary boxes or on a single page by itself, always has the Parent category name displayed with the Title and other information?

 

So that, for instance, a search for NEWEST ADS might show the following....(right now it just shows the "Sub category" name)

 

Breadcrumbs relies on current page values for categories.... I need something INDEPENDENT of the page values where the ads might be displayed

 

----------------------------------------

New Apartment in Belle Haven

 

"Rentals" >> "Apartment Rentals"

 

----------------------------------------

----------------------------------------

Customized Chevrolet Bel Air

 

"Cars" >> "Customizations"

 

----------------------------------------

 

Thank you very much for your help!

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.