S
S
stichii2015-11-12 19:05:28
WordPress
stichii, 2015-11-12 19:05:28

How to make a link to the desired Wordpess page?

Good afternoon! Please tell me, there is a condition if the category id is something, then such a button is displayed. Clicking on it will take you to the desired page. The question is, how to make links to pages correctly? Since in this form it is probably not done correctly (
Below is the code:

<?php
if( in_category( '2' ) ){
    echo '<div class="buttons_categorij">
            <form action="http://primer/primer1/">
                <button type="submit">Тратата</button>
            </form>
          </div>';
}elseif ( in_category( '4' ) ){
    echo '<div class="buttons_categorij">
             <form action="http://primer/primer2/">
                <button type="submit">Тратра 2</button>
            </form>
          </div>';
}
;?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Ksenia Mikhailova, 2015-11-13
@arizona

mm... And what for to you the form in that case? Just btn you can
And links to form throughecho get_the_permalink ( $id )

S
stichii, 2015-11-13
@stichii

Thank you! Understood) I did this:

<?php
if( in_category( '2' ) ){?>
<a href=" <?php echo get_the_permalink ( 311);?>" class="buttons_categorij"> Предложить новость</a>

<?php }elseif ( in_category( '4' ) ){?>
    <a href="<?php echo get_the_permalink (299);?>"  class="buttons_categorij">Отправить отчет</a>

<?php } ;?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question