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->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!