Documentation › Common PHP Snippets to Use in the Custom Code Block

Common PHP Snippets to Use in the Custom Code Block

One of the most powerful blocks in Headway is the Custom Code Block because you can insert plain text, PHP, HTML javascript, shortcodes! If you combine the power of the Custom Code Block with the power of PHP, your options are endless!

We know that PHP is not everyone’s strong suit, so we put together some common PHP snippets that you may want to use in your Custom Code Block!

Just copy and paste the snippet you want to use!

Show Information About Your Blog/Site

Show Blog Title (Set in WordPress > Settings > General)

<?php bloginfo( name ); ?>

Show Blog Tagline(Set in WordPress > Settings > General)

<?php bloginfo( description ); ?>

Show Blog/Site URL (Set in WordPress > Settings > General)

<?php echo home_url(); ?>

Show a Link to your Blog (Uses Blog Title and Blog/Site URL)

<a href="<?php echo home_url(); ?>"><?php bloginfo('name');?></a>

Show Information About The Current Post or Page

Show the Post or Page Title

<?php echo get_the_title(); ?>

Show links to the categories that the current post is in, separated by a comma

<?php the_category(', '); ?>

For more options displaying the categories, please see this article in the WordPress Codex

Show only the first category assigned to the post (not a link)

<?php
$category = get_the_category();
echo $category[0]->cat_name;
?>

Show a comma separated list of links to the tags assigned to a post

<?php the_tags(); ?>

For more options displaying the tags, please see this article in the WordPress Codex


Last Updated for version 3.8.3

Copyright © 2016 Vesped Inc. All Rights Reserved. Proudly Powered by Headway and WordPress