Reputation: 1637
I am creating my first Wordpress theme, initially I would like to understand How do I control the index.php in admin?
<h3>Service<h3>
<img src="<?php bloginfo ('template_directory'); ?>/img/iamgeservice1.png" class="img-responsive" alt="">
<h3>Service 2<h3>
<img src="<?php bloginfo ('template_directory'); ?>/img/imageservice2.png" class="img-responsive" alt="">
In case each service would be a page or post, and displaying in index.php only the title and the highlighted image.
Only the services (pages or post) that are selected should appear
What Wordpress function should I use in function.php?
Upvotes: 0
Views: 83
Reputation: 609
As per my understanding, you just want to display the services in the home page/ index.php file.
Create a Post type for adding your services: Use this plugin for creating a new post type https://wordpress.org/plugins/custom-post-type-ui/ or use https://codex.wordpress.org/Function_Reference/register_post_type
You can display the contents by using the following query, change your post type name
<?php $query = new WP_Query( array( 'post_type' => 'services' ) );
if($query->have_posts()) {
while ( $query->have_posts() ) {
$query->the_post(); ?>
<h3>
<?php the_title(); ?>
<h3>
<?php the_post_thumbnail(); ?>
<?php }
} ?>
Upvotes: 3