Currently, I am in the process of converting a Bootstrap one-page template into a WordPress template. My goal is to incorporate a custom post type that will display items in the services portfolio while maintaining the same CSS styling. Here is the code snippet for my services section:
<!-- Services -->
<section id="services" class="services bg-primary text-white">
<div class="container">
<div class="row text-center">
<div class="col-lg-10 mx-auto">
<h2>Our Services</h2>
<hr class="small">
<div class="row">
<?php
$args = array( 'post_type' => 'service', 'posts_per_page' => 10 );
$the_query = new WP_Query( $args );
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="col-md-3 col-sm-6">
<div class="service-item">
<span class="fa-stack fa-4x">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-flask fa-stack-1x text-primary"></i>
</span>
<h4><?php the_title(); ?></h4>
<p><?php the_content(); ?> </p>
<a href="<?php the_permalink(); ?>" class="btn btn-light">Learn More</a>
</div>
</div>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
</div>
<!-- /.row (nested) -->
</div>
<!-- /.col-lg-10 -->
</div>
<!-- /.row -->
</div>
<!-- /.container -->
</section>
I am currently unsure of which function to add and how to proceed. Additionally, I need guidance on what needs to be replaced in the index.php file for different sections as well as the code for functions.php.
// Our custom post type function
function create_posttype() {
register_post_type( 'service',
// CPT Options
array(
'labels' => array(
'name' => __( 'Services' ),
'singular_name' => __( 'Service' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'service'),
)
);
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype'
);
After implementing the above code, I encountered a syntax error. Any suggestions on how to resolve this issue would be greatly appreciated.