I'm using a php plugin in wordpress that allows you to shortcode php and have it post. My PHP script then calls a random line from a text file. In this file, I want there to be another call on some lines that pull from yet another file, or run a shortcode themselves. Issue is, I run the first shortcode, and it posts the 1st lv just fine, but the codes then in that one don't post. Is there a way to have random lines in a file echoed, that also can pull random lines? (or call a shortcode)
The code stored in XYZ PHP SNIPPIT, in shortcode [stage1]
<?php
$file = "scenarios.txt";
$file_arr = file($file);
$num_lines = count($file_arr);
$last_arr_index = $num_lines - 1;
$rand_index = rand(0, $last_arr_index);
$rand_text = $file_arr[$rand_index];
echo $rand_text;
?>
in the scenarios file it has something like, say "[person1] and [person2] go for a walk" with both of those being shortcodes for other php list calls. the issue is, it just shows the [person1] and doesn's call the shortcode. So I also tried making the lines more like this:
<?php echo do_shortcode('[person1]'); ?> and <?php echo do_shortcode('[person2]'); ?> go for a walk
Again it calls up the first Scenario short code, but the person1/2 ones end up just showing blank and not being called up. How do I embed layers of shortcode or php shortcode calls in wordpress?
Aucun commentaire:
Enregistrer un commentaire