Skip to main content
edited tags
Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459
edited title
Link

How do I listoutput all category with custom field?

Source Link

How do I list all category with custom field?

I want to list my custom field category. I'm using the Advanced Custom Fields Plugin in my project code. I want to combine the project code with the category links code together so The image and text is should use the category link. My category page will show up in the front-page.php . The project archive page I use Custom Fields. The category a tag should be project a tag. This is my show all category links.

    <?php

    $category_id = get_cat_ID('Category Name');
    $categories = get_categories(array('child_of' => $category_id));
    foreach($categories as $category) { 
        echo '<a href="' . get_category_link( $category->term_id ) . '">' . $category->name.'</a>';
    }

    ?>

<?php endwhile;


endif;

Below is my projects page code:

<?php 
    $temp = $wp_query; 
    $wp_query = null; 
    $wp_query = new WP_Query(); 
    $wp_query->query('showposts=18&post_type=projects'.'&paged='.$paged); 

    while ($wp_query->have_posts()) : $wp_query->the_post(); 
?>

<article class="work-wrap">
    <a href="<?php the_permalink(); ?>" class="work-img">
        <img src="<?php echo(types_render_field('thumbnail', array('raw' => true) )); ?>">

        <header>                
            <h1><?php echo(types_render_field('projects-title', array('raw' => true) )); ?></h1>
            <h2><?php echo(types_render_field('projects-sub-title', array('raw' => true) )); ?></h2>

        </header>
    </a>
</article>

<?php endwhile; ?>