Pass custom field value to get_category_link
-
I’m using the following code which echoes the custom sub field, which is the category ID (Advanced Custom Fields plugin)
<?php echo the_sub_field('site_cat_link'); ?>
I then want to use the following code to get the category link:
<?php $category_id = get_sub_field('site_cat_link'); $category_link = get_category_link( $category_id ); ?> <a href="<?php echo esc_url( $category_link ); ?>" title="Category Name">Category Name</a>
But that doesn’t seem to grab the category ID.
Any ideas?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Pass custom field value to get_category_link’ is closed to new replies.