1096 posts
  • 5 Years of Membership
  • Affiliate Level 1
  • Beta Tester
  • Collector Level 2
+5 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

743 posts
  • Elite Author
  • Weekly Top Seller
  • Featured Item
  • Most Wanted Winner
+5 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.

1096 posts
  • 5 Years of Membership
  • Affiliate Level 1
  • Beta Tester
  • Collector Level 2
+5 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/

1845 posts LoveThemes
  • Elite Author
  • Author Level 7
  • Exclusive Author
  • Trendsetter
+10 more
LoveThemes
says
<?php 
global $post;
include(ABSPATH . './wp-content/themes/voucher-wp/rss-'.$post->post_name.'.php'); ?>
?>
1096 posts
  • 5 Years of Membership
  • Affiliate Level 1
  • Beta Tester
  • Collector Level 2
+5 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 :)

1845 posts LoveThemes
  • Elite Author
  • Author Level 7
  • Exclusive Author
  • Trendsetter
+10 more
LoveThemes
says

No problem.

by
by
by
by
by
by