- for creation theme :
Get all file from : https://underscores.me/
1.header ) :
Resiterter Menu
function.php–
function register_my_menus() {
register_nav_menus(
array(
'header' => __( 'Header Menu' ),
'other' => __( 'Other Menu' )
)
);
}
add_action( 'init', 'register_my_menus' );
And header.php —
resister on template
<?php wp_nav_menu( array( 'theme_location' => 'header' ) ); ?>
Or 👍
if the class is not working then use the –
wp_nav_menu( array(
'theme_location' => 'header',
'menu_class' => 'nav navbar-nav'
) );
For Logo
For logo – header.php
———–
<?php
the_custom_logo();
if ( is_front_page() && is_home() ) :
?>
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
<?php
else :
?>
<p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
<?php
endif;
$businessmaker_description = get_bloginfo( 'description', 'display' );
if ( $businessmaker_description || is_customize_preview() ) :
?>
<p class="site-description"><?php echo $businessmaker_description; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<?php endif; ?></div>
For function.php
—————–
<?php
function my_theme_setup() {
add_theme_support( ‘custom-logo’ );
}
add_action( ‘after_setup_theme’, ‘my_theme_setup’ );
?>
for Home page url-
<?php echo esc_url( home_url( ‘/’ ) ); ?>
Footer
Register the theme modification settings:
IN FUNCTION.PHP
*****************
function theme_register_customizer_settings($wp_customize) {
// Footer Description
$wp_customize->add_setting(‘footer_description’, array(
‘default’ => ‘Default footer description’,
‘sanitize_callback’ => ‘sanitize_text_field’,
));
// Add control for Footer Description
$wp_customize->add_control(‘footer_description’, array(
‘label’ => ‘Footer Description’,
‘section’ => ‘title_tagline’, // Customize section to add the control to
‘type’ => ‘textarea’,
));
}
add_action(‘customize_register’, ‘theme_register_customizer_settings’);
*********************
IN HTML FILE : ( USING get_theme_mod FUNCTION )
<div class=”single-footer-widget”>
<div class=”logo”>
<?php $footer_logo = get_theme_mod(‘footer_logo’, ”); ?>
<?php if ($footer_logo) : ?>
<a href=”<?php echo esc_url( home_url( ‘/’ ) ); ?>”>
<img src=”<?php echo esc_url($footer_logo); ?>” alt=”logo”></a>
<?php else : ?>
<a href=”<?php echo esc_url( home_url( ‘/’ ) ); ?>”>
<img src=”<?php bloginfo(‘template_directory’); ?>/assets/img/footer-logo.png” alt=”logo”></a>
<?php endif; ?>
</div>
<p><?php echo get_theme_mod(‘footer_description’, ‘Default footer description’); ?></p>
<!– Rest of the footer content –>
</div>
2.ACF :
-> 1. for link with text ;
<?php $value = get_field(‘h6’); ?>
<a href=”<?php echo $value[‘url’]; ?>”
target=”<?php echo $value[‘target’]; ?>”>
<?php echo $value[‘title’]; ?>
</a>
-> for backgrounf image :
background= “<?php the_field(‘banner1’); ?>
->For text :
<?php $value1 = get_field(‘h_on_banner’); echo “$value1”; ?>
-> for repeter :
<?php
$rows = get_field(‘about_us_list’);
if($rows)
{
echo ‘<ul>’;
foreach($rows as $row)
{
echo ‘<li>’ . $row[‘text’] . ‘</li>’;
echo ‘<li>’ . $row[‘text_copy’] .'</li>’;
echo ‘<li>’ . $row[‘text_copy2′] .'</li>’;
}
echo ‘</ul>’;
}
?>
==========================
For Pages
for single page.php
—
<div id=”primary” class=”content-area”>
<main id=”main” class=”site-main”>
<?php
while (have_posts()) :
the_post();
?>
<article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
<header class=”entry-header”>
<h1 class=”entry-title”><?php the_title(); ?></h1>
</header><!– .entry-header –>
<div class=”entry-content”>
<?php the_content(); ?>
</div><!– .entry-content –>
</article><!– #post-<?php the_ID(); ?> –>
<?php endwhile; ?>
</main><!– #main –>
</div><!– #primary –>
====================================
<?php
/**
*
* Template Name: Home
*/
get_header();
?>
==================
<?php
get_footer();
?>
=========================
<?php bloginfo(‘template_directory’); ?>/
in Contact form 7
<?php echo apply_shortcodes( ‘
/***** Show Category according to post ***/
<div class=”sidebar-widget”>
<h4>Category</h4>
<ul class=”category”>
<?php
// Define your post type (replace ‘post_type’ with your actual post type)
$post_type = ‘post_type’;
// Get categories for the specified post type
$categories = get_categories(array(
‘taxonomy’ => ‘category’, // Replace ‘category’ with your taxonomy if different
‘post_type’ => $post_type,
‘hide_empty’ => 0, // Show empty categories as well
));
foreach ($categories as $category) {
echo ‘<li><a href=”‘ . esc_url(get_category_link($category->term_id)) . ‘”>’ . esc_html($category->name) . ‘<i class=”bi bi-arrow-right”></i></a></li>’;
}
?>
</ul>
</div>
/********** show latest post type according to post ****/
?php
// Get the post type from the current URL
$current_post_type = get_post_type();
// Display recent posts for the current post type
$recent_posts = wp_get_recent_posts(array(‘numberposts’ => 5, ‘post_type’ => $current_post_type));
foreach ($recent_posts as $post) {
echo ‘<div class=”recent-post”>’;
echo ‘<div class=”recent-thumb”><a href=”‘ . get_permalink($post[‘ID’]) . ‘”><img src=”‘ . get_the_post_thumbnail_url($post[‘ID’], ‘thumbnail’) . ‘” alt=””></a></div>’;
echo ‘<div class=”recent-post-cnt”>’;
echo ‘<span>’ . get_the_date(‘d.m.Y’, $post[‘ID’]) . ‘</span>’;
echo ‘<h5><a href=”‘ . get_permalink($post[‘ID’]) . ‘”>’ . esc_html($post[‘post_title’]) . ‘</a></h5>’;
echo ‘</div>’; // .recent-post-cnt
echo ‘</div>’; // .recent-post
}
?>