896 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+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.

896 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+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/

1724 posts LoveThemes
  • Nominated Community Superstar of the month
  • Contributed a blog post
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
+8 more
LoveThemes says
<?php 
global $post;
include(ABSPATH . './wp-content/themes/voucher-wp/rss-'.$post->post_name.'.php'); ?>
?>
896 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+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 :)

1724 posts LoveThemes
  • Nominated Community Superstar of the month
  • Contributed a blog post
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
+8 more
LoveThemes says

No problem.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by