P
P
Pista2021-07-18 14:15:43
WordPress
Pista, 2021-07-18 14:15:43

How to make a clickable banner on the main page of Wordpress?

I installed a picture in the theme header, you need to open another page by clicking this picture. It works, but how to fix the code so that the /test link also opens on the main page when you click on the picture, it works everywhere, except when the main page is open.

<?php
    if ( ! empty( $logotype_image ) ) {
        if ( is_front_page() ) {
            if ( is_home() && is_paged()  ) {
                echo '<div class="site-logotype"><a href="'. esc_url( home_url( '/test' ) ) .'">' . $logotype_html . '</a></div>';
            } else {
                echo '<div class="site-logotype">' . $logotype_html . '</div>';
            }
        } else {
            echo '<div class="site-logotype"><a href="'. esc_url( home_url( '/'test ) ) .'">' . $logotype_html . '</a></div>';
        }
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Zolin, 2021-07-21
@Pista

If I understood correctly, then you want to write a condition like this

if ( ( is_front_page() || is_home() ) && !is_paged() ) {
  echo '<div class="site-logotype">' . $logotype_html . '</div>';
} else {
  echo '<div class="site-logotype"><a href="'. esc_url( home_url( '/test' ) ) .'">' . $logotype_html . '</a></div>';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question