using a shortcode like an include

hi.

I have a site where we want to have this same identical html table on the top of each Category page.

So, I'm about to go put this on like 20 pages. But I was wondering if there was a smarter way to do it.

Do you know of a good way to do this with a shortcode or something so that I can update have the actual information in just one spot so that if I have to edit it later I'm not touching 20 pages again?

  • Predrag Dubajic

    Hey @tilpro,

    Hope you're doing well today :slight_smile:

    Yes you can do this by using shortcode, below is an example of code that you can add to your functions.php file or create new .php file and place the code there (in this case place <?php before the code).

    // Add Shortcode
    function custom_shortcode() { ?>
    
    <table>This is my awesome table</table>
    
    <?php }
    add_shortcode( 'my_custom_table', 'custom_shortcode' );

    Put your table html instead of my table example and you can use it now on your site by pasting this shortcode:
    [my_custom_table]

    Hope this helps.

    Best regards,
    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.