The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Novice question - capitalise function return
will.birch
post Apr 28 2020, 03:44 PM
Post #1





Group: Members
Posts: 2
Joined: 28-April 20
Member No.: 27,305



Hi guys/gals

Really novice to this but trying my best.

All I want to do is capitalise the return of the function to then be replaced in the wordpress shortcode.
What am I missing here!

CODE

// Page Title Shortcode - page_title
function page_title_sc( ){
    return get_the_title();
}
$titleupper = strtoupper('page_title_sc');
add_shortcode( 'page_title', $titleupper );
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Apr 28 2020, 04:15 PM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



You are passing a string instead of the function name, like this:
CODE
$titleupper = strtoupper(page_title_sc());
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Apr 28 2020, 04:20 PM
Post #3


.
********

Group: WDG Moderators
Posts: 9,628
Joined: 10-August 06
Member No.: 7



Hi!

Alas I'm not familiar with Wordpress, also I don't know from where you get the string(s) to capitalize from in the first place.

QUOTE(will.birch @ Apr 28 2020, 10:44 PM) *

return get_the_title();

Where is the above function defined?

QUOTE
add_shortcode( 'page_title', $titleupper );

I suppose the above calls a WP function, but I don't know what arguments that function expects.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
will.birch
post Apr 28 2020, 04:27 PM
Post #4





Group: Members
Posts: 2
Joined: 28-April 20
Member No.: 27,305



They are Wordpress values I believe

Thank you for your help

Charles seems to have sorted it
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th March 2024 - 03:28 AM