Jump to content

Any web developers familiar with Wordpress?


ted123
 Share

Recommended Posts

This is reallyyyyy annoying me now and I can't find an answer that has actually worked anywhere on the internet.

You'll need to be familiar with Wordpress to understand.

On my website, basically I have a single page theme which displays a single post. The single post has multiple parent and child categories.

I can display all categories using

the_category(' ');

The post uses a registered custom taxonomy of "wpecbd" and I am trying to display ONLY the CHILD categories for that post. Can anyone help?

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

If you need a better understanding, basically each single post is a listing in a business directory.

The category format is

-A

-- Air Conditioning

-- Child

-- Child

-B

-- Builders

-- Child

-- Child

-C

-- Child

-- Child

The post can have multiple categories such as "Air Conditioning" and "Builders" which would fall under A and B respectively. I only want to show the child as I have no interest in displaying the parent (A/B).

Can anybody help? :)

Edited by ted123
Link to comment
Share on other sites

This is reallyyyyy annoying me now and I can't find an answer that has actually worked anywhere on the internet.

You'll need to be familiar with Wordpress to understand.

On my website, basically I have a single page theme which displays a single post. The single post has multiple parent and child categories.

I can display all categories using

the_category(' ');

The post uses a registered custom taxonomy of "wpecbd" and I am trying to display ONLY the CHILD categories for that post. Can anyone help?

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

If you need a better understanding, basically each single post is a listing in a business directory.

The category format is

-A

-- Air Conditioning

-- Child

-- Child

-B

-- Builders

-- Child

-- Child

-C

-- Child

-- Child

The post can have multiple categories such as "Air Conditioning" and "Builders" which would fall under A and B respectively. I only want to show the child as I have no interest in displaying the parent (A/B).

Can anybody help? :)

I found this snippet in an old PHP file that I used when I would help develop on a WordPress site.

I'm not 100% sure if this will give you what you need but it's worth a try, and fiddling a little.

<?php
    global $post;
    // grab terms of current post, replace taxonomy name
    $terms = get_the_terms($post->ID, 'name_of_custom_taxonomy');
    // define arguments of following listing function
    $args = array (
        'child_of' => $terms[0], // current post's (first) category 
        'title_li' => '', // disable display of outer list item 
        'taxonomy' => 'name_of_custom_taxonomy' // replace as well
    );
    // list child categories
    wp_list_categories($args);
?>
Link to comment
Share on other sites

I found the same snippet online and wp_list_categories lists them either in an unordered list or using <br />

I preferably wanted them to appear inline :(

Link to comment
Share on other sites

I found the same snippet online and wp_list_categories lists them either in an unordered list or using <br />

I preferably wanted them to appear inline :(

Ah, I see.

You could try adding a class to the UL, and add some styling to the class in order to make them appear inline?

Link to comment
Share on other sites

I guess I could duplicate the wp_list_categories function and change how it outputs.

Link to comment
Share on other sites

I'am a web developer, designed websites for many people but I must admit word press isn't my strongest point! Google something for a plugin?

Link to comment
Share on other sites

 Share

×
×
  • Create New...