0
votes

I'm trying to insert a include_once inseide a echo do_shortcode and my line is this:

<?php $activar = get_option("activar-pelicula"); ?> 
<?php 
if ($activar == "true") { 
  echo do_shortcode('[to_like]' .include_once "includes/single/player.php"; . '[/to_like]');
} ?>

this is the error I'm getting:

Warning: include_once(includes/single/player.php[/to_like]): failed to open stream: No such file or directory in /home/novosfil/public_html/wp-content/themes/grifus/single.php on line 8

Warning: include_once(): Failed opening 'includes/single/player.php[/to_like]' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/novosfil/public_html/wp-content/themes/grifus/single.php on line 8

I'm trying to get this line (original line)

<?php 
$activar = get_option("activar-pelicula"); 
if ($activar == "true") { 
include_once "includes/single/player.php";
} ?>

inside the locker with this

<?php 
echo do_shortcode('[to_like]' HER GOES THAT PART OF THE PAGE '[/to_like]');
} ?>

ok that's it.

1
That's not how include_once works. It does not return a string, it executes PHP code. You need a different approach. What is in player.php?Alexander O'Mara
Do you need it to be interpreted or the contents echo'd straight out?trickyzter

1 Answers

1
votes

you can try this way:

<?php $activar = get_option("activar-pelicula"); ?> 
<?php 
if ($activar == "true") { 
  ob_start();
  include_once "includes/single/player.php";
  $out1 = ob_get_contents();
  ob_clean();
  echo do_shortcode('[to_like]' . $out1 . '[/to_like]');
} ?>