651 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Provided great contribution to our forums
  • Has been a beta tester for an Envato feature
+4 more
Gareth_Gillman says

Trying to add a automatic importer into WP e.g.

File is called rss-pc-world.php, now I want to include this on a WP page called pc-world.

I would use the following code normally

   <?php include(ABSPATH . './wp-content/themes/voucher-wp/rss-pc-world'); ?>

BUT I want to be able to do this automatically, I would build the PHP files but I want the above code to grab the file which has the same name as the page, I know I would use wp-title but not sure on how to include it in the above code.

I have tried the following:

   <?php include(ABSPATH . './wp-content/themes/voucher-wp/rss-'.wp-title().'.php'); ?>

This doesn’t work, can anyone help with this?

Thanks

741 posts
  • Had an item featured on Envato Market
  • Won a Most Wanted contest
  • Has been part of the Envato Community for over 5 years
  • Has sold $40,000+ on Envato Market
+4 more
Orbital_Themes says

Well, to use wp_title() like this you’d have to do it like that:

wp_title( "", false )

I don’t know what you are trying to do but I can tell you it’s not a good practice.

651 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Provided great contribution to our forums
  • Has been a beta tester for an Envato feature
+4 more
Gareth_Gillman says

Well, to use wp_title() like this you’d have to do it like that: wp_title( "", false ) I don’t know what you are trying to do but I can tell you it’s not a good practice.

How would you do it then? I need to include a different file on each page, the file included will be the same as the slug for the page e.g.

rss-pc-world.php would be included in mydomain.com/pc-world/

1289 posts LoveThemes
  • Has referred 100+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
LoveThemes says
<?php 
global $post;
include(ABSPATH . './wp-content/themes/voucher-wp/rss-'.$post->post_name.'.php'); ?>
?>
651 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Provided great contribution to our forums
  • Has been a beta tester for an Envato feature
+4 more
Gareth_Gillman says

<?php 
global $post;
include(ABSPATH . './wp-content/themes/voucher-wp/rss-'.$post->post_name.'.php'); ?>
?>

Ta very much, works a treat :)

1289 posts LoveThemes
  • Has referred 100+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
LoveThemes says

No problem.

by
by
by
by
by
by