1

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; ?>

1 Answer 1

0

Based on the code in your question, I can only see one problem.

  • under "Show all category links", you've got an "endwhile", but no "while", and an "endif", but no "if". Delete both the "endwhile" and "endif" and the code runs fine.

The "Projects page code" works fine. I can't reproduce your specific custom fields but then you didn't flag them as an issue, so that shouldn't be a problem. FWIW, "showposts" has been deprecated in favour of "posts_per_page" but it still works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.