One of the most powerful blocks in Headway is the Custom Code Block because you can insert plain text, 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
This list is by no means comprehensive – it is just meant to get you started thinking about the possibilities. If you have a specific question, post below and we may be able to help!
Hi,
While I understand PHP and HTML I am new to Headway. I have navigated my way to the Code Editor but I can’t find, nor does ANYONE want to tell me, how to save the code that I enter into a Custom Code block. Does it simply get saved along with the rest of the site when I click the blue Save button in the top right corner? If so, this seems a little “loose” to an old programmer like me!
Mat,
Yes, it gets saved when you click the blue save button. I’m not sure what you mean by no one wanting to answer your question. I wasn’t able to find a ticket or a thread by you where you asked the question.