Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Output component title?
#1
Question 
Been searching all over, but couldn't see a way to do this, so thought I would ask.

In a theme, when I have a component, I use
PHP Code:
<?php get_component('component_name'); ?>

Is it possible to include the title of the component in a theme?

So, for example, If I create a component to list some popular links, and I call it "Epic Link List", I could simply spit out the HTML behind it using

PHP Code:
<?php get_component('Epic-Link-List'); ?>

But if I didn't want to put a H4 tag in the component itself, could I in fact pull back the title separately?

Any ideas?
Reply
#2
(not tested)
Insert this in your theme's functions.php file (create the file if it doesn't exist):

PHP Code:
function get_component_h4($compname) {
  echo 
'<h4>',$compname,'</h4>',"\n";
  
get_component($compname);


Now use this instead of get_component, like:
PHP Code:
<?php get_component_h4('Epic-Link-List'); ?>
Reply




Users browsing this thread: 1 Guest(s)