J
J
jozess2015-11-12 21:32:38
WordPress
jozess, 2015-11-12 21:32:38

How to make a shortcode to display a link to the current category in the middle of an article?

What needs to be written in function.php to display the text in the post in this form?

<a href="Линк на категорию"/> Название категории </a>

Here is a simple shortcode that displays text:
function cwc_donate_shortcode1( $atts ) {
    extract(shortcode_atts(array(
        'text' => 'Этот текст выведется на странице поста',
        'account' => 'REPLACE ME',
        'for' => 'Habr',
    ), $atts));
    global $post;
    if (!$for) $for = str_replace(" ","+",$post->post_title);
    return '';
}
add_shortcode('donate1', 'cwc_donate_shortcode1');

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question