Has Category?

This topic is: resolved
Viewing 4 posts - 1 through 4 (of 4 total)
Author Posts
May 31, 2013 at 3:52 am #3142
Bart Dabek
Post count: 24

ugh having a rough time with a simple if… need to check if the current post type has any category taxonomies assigned…

this isn’t working

if ($wf->the->has(‘category’)):
<h2>Categories:
foreach ($wf->the->categories() as $cat) echo $cat->link()
</h2>
endif

May 31, 2013 at 3:56 am #3144
Bart Dabek
Post count: 24

also on the back of this… how would you insert a , after each printed result if there is more then one result? do you have to use a counter or is there a nifty way of inserting a separator?

May 31, 2013 at 4:00 am #3145
Bart Dabek
Post count: 24

saw this for the 2nd question so I’m good

https://www.masterpressplugin.com/support/topic/separator-at-relatedterm

May 31, 2013 at 10:22 am #3146
traversal
Post count: 207

Hey Bart,

The has method is not intended for taxonomy handling, that’s more for fields and field sets. Try:

if (count($wf->the->categories()))

or

if ($wf->the->categories->count)

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Latest From the Blog

Ability to deactivate licence domains within MasterPress account management

25th October 2024

We have just rolled out an account management feature which allows licence holders to have better control over the domains that use their licence key. From the MasterPress Account Management page, the list of Active Sites that use your licence now includes a function that allows you to remove a domain from your licence. Simply… 

Plugin Requirements

MasterPress requires a minimum of WordPress version 4.9, MySQL 5.6, and PHP version 5.6.20.

We also recommend that PHP is configured to use a memory limit of 64MB per request (128MB may be required for sites with higher complexity).

This plug-in is not compatible with the WordPress.com hosted service.

Three AM