Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter mmetsalu

    (@mmetsalu)

    Thanks again vjpo. I got it to look like I need it to by doing the following:

    <?php	  
    
    $args = array(
      'post_type' => 'project');
    $projects = new WP_Query($args);
    if ($projects->have_posts()) {
    
      while ($projects->have_posts()) {
        $projects->the_post(); ?>
    
    		  <div class="post item span4 isotope-item strategy">
    		  <a href="<?php bloginfo('template_url'); ?>/img/header1.jpg" class="project-wrp fancybox" rel="group1" title="Project!"><div class="profile-photo"><div class="profile-icon">f</div><?php echo types_render_field( "project-image", array( "alt" => "Project image",
    		  "width" => "370","proportional" => "true" )); ?></div> 
    
    		  <div class="project-name"><?php echo types_render_field( "project-title", array( "alt" => "Project title")); ?></div>
    			<div class="project-client"><?php echo types_render_field( "project-client", array( "alt" => "Project client")); ?></div></a></div>
    
    	<?php
       }
      }
      ?>

    But now the image is opening the templates sample image, it’s something I’ll look into. Now the only thing I’m still struggeling with are the categories I created in the projects admin panel. I have this just before the post code:

    <?php
    
    $orderby = 'name';
    $show_count = 0; // 1 for yes, 0 for no
    $pad_counts = 0; // 1 for yes, 0 for no
    $hierarchical = 1; // 1 for yes, 0 for no
    $taxonomy = 'genre';
    $title = '';
    
    $args = array(
      'orderby' => $orderby,
      'show_count' => $show_count,
      'pad_counts' => $pad_counts,
      'hierarchical' => $hierarchical,
      'taxonomy' => $taxonomy,
      'title_li' => $title
    );
    ?>
    <ul>
    <?php
    register_taxonomy( 'project_category', 'project', $args );
    wp_list_categories($args);
    ?>
    </ul>

    But no errors or nothing.

    Thread Starter mmetsalu

    (@mmetsalu)

    My bad, adding the_content() works as it should. I appreciate you helping out. Many thanks! Custom post types are not my speciality. I’ve got one last question which is not really related to the issue but how would you add a class to the custom post type so you could style it?

    Thread Starter mmetsalu

    (@mmetsalu)

    I’ve added the relevant code on github here. And when I write the_editor($content); it brings in the whole editor metabox. How do I get it show only the content?

    Thread Starter mmetsalu

    (@mmetsalu)

    Hi vjpo.

    The project is a separate file called project.php and it’s called in functions.php file:

    <?php
    
    require 'project.php';
    
    ?>

    I changed the code in index.php:

    <?php get_header(); ?>
    
        <div id="posts" class="row isotope ">
         <!-- Start Project -->
        <?php   
    
        $args = array(
      'post_type' => 'project'
    );
    $projects = new WP_Query($args);
    if ($projects->have_posts()) {
      while ($projects->have_posts()) {
        $projects->the_post();
        the_title();
      }
    }
    
        ?>
       </div>
    
        <?php get_sidebar(); ?>
        <?php get_footer(); ?>

    When I inspect the page I see that the title is actually brought in but for some reason it’s height is 0px. Plus the content from the editor box is not showing up. Do I need to call it like the_title(); was called?

    Thread Starter mmetsalu

    (@mmetsalu)

    I addedd

    'has_archive'   => false,
    'rewrite' => array('slug'=>'/','with_front'=>false),

    to my argument and

    function add_cpt_to_home($qry) {
      if (is_front_page() || is_home()) {
        $post_type = (array)$qry->get('post_type');
        $post_type[] = 'post';
        $post_type[] = 'project';
        $post_type = array_unique(array_filter($post_type));
        $qry->set('post_type',$post_type);
      }
    }
    add_action('pre_get_posts','add_cpt_to_home');

    to my index.php file but the custom post is not showing up.

Viewing 5 replies - 1 through 5 (of 5 total)