• 0

Calling Wordpress Functions in DMS text areas


Question

Posted · Report post

I find myself duplicating the title of my Wordpress page titles in my Highlight and Hero sections and such.

 

It would be very convenient to be able to put the wordpress function, 'the_title' in there and make a template from it, that way I wouldn't need to type it again every time.

 

Is this something that is possible?

Share this post


Link to post
Share on other sites

11 answers to this question

  • 0

Posted · Report post

Hi,

 

Check http://codex.wordpress.org/Function_Reference/wp_title

 

You'll see some PHP code for the title. If you use Shortcode Exec PHP, you can conver the PHP code to a shortcode and apply that shortcode as desired.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Excellent. This is exactly what I wanted! Thank you.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Sometimes... not often enough... I get it right :D

 

Glad to have helped!

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hmmm...so then shouldn't I also be able to put the code for a year in the footer text box for copyright? It's not working:

 

Copyright &#169;<?php print(Date("Y")); ?

 

Is there a way to make this also work? I don't want to have to manually update the year every year.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Hmmm...so then shouldn't I also be able to put the code for a year in the footer text box for copyright? It's not working:

 

Copyright &#169;<?php print(Date("Y")); ?

 

Is there a way to make this also work? I don't want to have to manually update the year every year.

 

sheilahoff

 

You wouldn't do it like that.

 

You need to use the plug in to create a short code for the date. Then you use the short code generated by the plugin (it can be whatever you want e.g. [the_date], [the_year] etc.) and then you type Copyright [the_year] where ever you wanted to to appear.

1 person likes this

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Thanks. I"m trying that now but so far not quite getting it. I don't know coding. But I have the plug-in installed. Can you tell me what exactly to put in the php box?
I tried php print(Date("Y")); as it said not to use the <?php and ?> tags. Then I named it copyright_year and put [copyright_year] in the text box I also tried [shortcode arg="copyright_year"] to no avail. Clearly I don't know what I'm doing! Thanks for the assist.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Sorry. I don't think the_date can be used like that. I doesn't get today's date. I gets the date from the meta date of the post or page the function has been called on. Not sure if there is a function for what you're after.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

There SHOULD be a way to do this. This code Copyright &#169;<?php print(Date("Y")); ?> absolutely displays the current YEAR which is what one wants in the footer. This isn't about the date of a post. I have successfully used that very code in the footer of several websites done in Headway. I just don't know how to make it work in DMS.

Share this post


Link to post
Share on other sites
  • 0

Posted (edited) · Report post

Sorry. I don't think the_date can be used like that. I doesn't get today's date. I gets the date from the meta date of the post or page the function has been called on. Not sure if there is a function for what you're after.

 

There is...

 

Put this in your short code box and delete the parts that you don't need.

 

echo date('l jS F Y');

 

If that doesn't work, drop the echo.

Edited by magichew
1 person likes this

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

BINGO! You're brilliant magichew! With that date in the plug-ins code box all I had to do was add [copyright_year] where I want the year in the footer! YAY! That was worth the price of admission! thank you so much!

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Great! Glad to help out.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now