the_title syntax

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DaveWillett
Forum Newbie
Posts: 2
Joined: Mon Mar 16, 2015 3:21 am

the_title syntax

Post by DaveWillett »

Hello.
I'm trying to pass a Wordpress post-page name to a url.
I can return the name with the following:

<?php the_permalink(); ?>" title="<?php the_title_attribute() ?>" ><?php the_title() ?>
or
<?php the_title() ?>
or
<?php get_the_title() ?>

But trying to get the title in a url is causing me a problem.
The url is:

if (($handle = fopen('http://www.mywebsite/client-private/210965/data.csv', 'r')) !== FALSE)

and I need to replace the 210965 part with the page title.

Can anyone help?

Kind Regards
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: the_title syntax

Post by Celauran »

Is this not basically what you want?

Code: Select all

$title = get_the_title();
$url = "http://www.mywebsite/client-private/{$title}/data.csv";
DaveWillett
Forum Newbie
Posts: 2
Joined: Mon Mar 16, 2015 3:21 am

Re: the_title syntax

Post by DaveWillett »

Celauran wrote:Is this not basically what you want?

Code: Select all

$title = get_the_title();
$url = "http://www.mywebsite/client-private/{$title}/data.csv";
Hi. I'll try it out and see if it works. I haven't tried that version.

Thanks You
Post Reply