Lengkap Macam macam kode script wordpress


Lengkap Macam macam kode script wordpress





Berikut adalah beberapa contoh kode script WordPress yang umum digunakan:

  1. Menampilkan judul halaman:
php
<?php bloginfo('name'); ?>
  1. Menampilkan deskripsi halaman:
php
<?php bloginfo('description'); ?>
  1. Menampilkan menu navigasi:
php
<?php wp_nav_menu(); ?>
  1. Menampilkan daftar posting:
php
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <?php the_content(); ?> <?php endwhile; endif; ?>
  1. Menampilkan sidebar:
php
<?php get_sidebar(); ?>
  1. Menampilkan footer:
php
<?php get_footer(); ?>
  1. Menampilkan gambar thumbnail:
php
<?php if ( has_post_thumbnail() ) : ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <?php the_post_thumbnail(); ?> </a> <?php endif; ?>
  1. Menampilkan form pencarian:
php
<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>"> <label> <span class="screen-reader-text"><?php _x( 'Search for:', 'label' ); ?></span> <input type="search" class="search-field" placeholder="<?php echo esc_attr_x( 'Search &hellip;', 'placeholder' ); ?>" value="<?php echo get_search_query(); ?>" name="s" /> </label> <button type="submit" class="search-submit"><?php echo esc_html_x( 'Search', 'submit button' ); ?></button> </form>
  1. Menampilkan daftar tag:
php
<?php the_tags( 'Tags: ', ', ', '<br />' ); ?>
  1. Menampilkan daftar kategori:
php
<?php the_category(', '); ?>
  1. Menampilkan daftar halaman:
php
<?php wp_list_pages(); ?>
  1. Menampilkan komentar:
php
<?php if ( comments_open() || get_comments_number() ) : comments_template(); endif; ?>
  1. Menampilkan jumlah posting pada halaman:
php
<?php $count_posts = wp_count_posts(); echo $count_posts->publish; ?>
  1. Menampilkan daftar posting terbaru:
php
<?php $args = array( 'posts_per_page' => 5 ); $recent_posts = wp_get_recent_posts( $args ); foreach( $recent_posts as $recent ){ echo '<li><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"].'</a> </li> '; } ?>

Itu adalah beberapa contoh kode script WordPress yang umum digunakan. Namun, sebaiknya Anda memahami konsep dasar WordPress dan penggunaan hook, filter, dan fungsi WordPress yang ada untuk memaksimalkan fungsionalitas situs WordPress Anda.


Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Next

نموذج الاتصال