D
D
Di Da2018-03-07 08:19:12
WordPress
Di Da, 2018-03-07 08:19:12

Is it possible to embed php, js code directly into a post?

I need to make it random in the entry, that is, I add the entry, then there is the content, and then the button, when pressed, the random text will be displayed. How to set this to "record"?
Button and random in the record itself?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan Hasanli, 2018-03-07
@Di21H

Hello.
Ready-made plugin - https://ru.wordpress.org/plugins/wp-random-button/
In general, it is not recommended to embed PHP code in the post itself, but nevertheless it is possible. Can be embedded in single.php post template (more recommended). And you can insert it directly into the post
. If you need the second option, then you will need to install the plugin - https://wordpress.org/plugins/wp-exec-php/
And if the question is how to implement it .... then the easiest option:
- js button that translates a specific block into display: block; || display:none;
- WP_Query loop that randomly selects one post randomly

V
Vladislav Lyskov, 2018-03-07
@Vlatqa

link

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question