Your shortcode is getting the title, but you haven’t told it to return anything, so a small tweak should fix things:
<?php
function post_title_shortcode(){
return get_the_title();
}
add_shortcode('post_title','post_title_shortcode');
?>
You could also continue setting get_the_title()
to $variable
and add a line to return $variable
, but the above is the simplest, shortest option.
Related Posts:
- Newbie question: no index.php? in my plain wordpress permalink
- Missing sidebar parameter “fix” – before_content
- How to change redirection route to a php page for making it only accessible by logged-in members?
- parts of url disappear when using # inside href=”” [closed]
- Create custom permalinks to show Custom Post Type’s relationship?
- Add .htm extention to a custom taxonomy
- Show latest posts in a plain HTML website custom widget [closed]
- Widget back end radio button issue
- How do i add slugs to a URL, but still redirecting to the same page
- Nginx WordPress and another Web app URL structure
- How to use title attributes in sidebar widget?
- Modifying WP URL handing code?
- How to deal with a GET variable of ‘name’?
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Add Link to PHP message
- How does one make a URL return dynamic JSON with custom Content Type?
- How to include checkbox in widget backend form?
- How do I make an HTML table from a database table?
- How to get the custom header image’s alt text?
- Modify previous and next text from pagination links
- How can I modify the permalink via a filter?
- Calling a method from functions.php on a click of a button
- WordPress widget in custom theme
- Two posts in same div – WP loop
- Concatenate site_url and string doesn’t work
- Anything I can add to functions.php to make text widgets accept PHP?
- What’s the proper way to use wp_enqueue_script/style?
- WordPress menu deletes when trying to add a hook
- How can I add a specific, custom widget to my theme’s header.php?
- Get widget settings function?
- Widgets not showing in my custom theme
- To echo or not to echo?
- Extract subdomain and relative address from a url
- Correct syntax to html php conversion
- Why does WordPress remove my variables in the URL?
- Getting a specific post values to another div or modal
- Why do WordPress rewriites seem to work differently for posts vs pages?
- Performance impact of rewriting WordPress URLs
- search and replace preword from author
- Embed html in php code
- WP grandchild categories in nested ul li
- How to modify URL (add GET values) after front end form submission?
- Settings API callback function inserts html quotes from nowhere
- How create a Shortcode with hover and complex options
- WordPress Multiple Navigation bars
- Adding a widget function into the php theme file
- How to edit widget code to add unique class name to each div?
- Scrape external webpage for first image and add it to new post
- Login to wordpress by clicking a link and specifying usernaname and password in url
- Make PHP work with HTML tags
- Widgets in the loop if active
- Function returns text instead of html [closed]
- How i can get post data from database when i am getting post id from url in wordpress
- Hook called before text widget save
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- wp_insert_post() with HTML tags using PHP
- Where can I find the inline-css of my theme header?
- Make textarea required. Help [closed]
- How can I display Custom Post type Custom Columns and its Content in a Dashboard Widget?
- Remove   from the_excerpt
- Website completely messes up when logging out
- Calling PHP Titles inside Javascript Markup
- How can I use custom menus with a Bootstrap WordPress theme?
- How do I include an external PHP file in a subdir WordPress install?
- Replacing WordPress Icons (menu,icons32, etc)?
- HTML Form Question
- I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics
- How a HTML form can trigger a PHP function?
- Hide A Class and Add Custom HTML Code Using WordPress
- Add other class content with reference class value
- How to use data URL in WordPress?
- HTML comment cause issue in functions.php script root
- How to stop hiding buttons forward / backward in pagination?
- Slug duplicates once clicking on link
- How to find and delete a menu item in php?
- Rewrite rule not working, but only when parameter is text
- My single.php page skips the first div tag
- opens like sitename.com/URL
- WordPress Slider is not working
- How to display post meta bellow every posts
- WordPress/NGINX not respecting the category URL for new posts
- Meta inserted through wp_insert_post gets messed up
- Woocommerce custom attributes list help
- Switch position of elements in the footer [closed]
- Can’t get_users info by using json_encode
- scroll scrpit to particular button position to next id when click button
- Widget Update problems using a for loop
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- Non-static method error when trying to use class in widgets
- WordPress HTML Helper
- List sibling pages widget, exclude current page
- Removing all my hardcoded URLs with get_site_url()
- get_post_meta is always empty when I use wp_mail
- Edit the Publish Widget Options
- Whats wrong with my code? Need To add String to shortcode? [closed]
- Implement “No related posts for this entry” into the loop?
- ACF repeater image in video poster with jquery
- append special url end of my website urls
- Advanced Custom Fields Show PHP in Text Areas
- How can I change the URL via add_rewrite_rule()