How to get current page title inside a page itself in a shortcode and in page content
When i add the
<?php the_title(); ?>
to a page template file it works and is able to pull the page title inside html tags however if i wanted to add
<?php the_title(); ?>
to a single page itself how would i do so?
Also to provide more context; i want to add the
<?php the_title(); ?>
inside a shortcode in order to have the shortcode replace part of it with the specific page’s title, how would i do that?
Use
[post_title]
shortcode to display the title of the post or page.You can create a shortcode to fetch the title of current page. Try copying the following snippet in your child theme’s functions.php
function post_title_shortcode(){ return get_the_title(); } add_shortcode('post_title','post_title_shortcode');
Bài viết liên quan :
Thêm ký tự vào trước và sau giá sản phẩm trong WooCommerce
Lựa chọn đơn vị thiết kế website uy tín, giá rẻ tại Thái Bình Web
Chia sẻ Slider Revolution 6.5.8 mới nhất Responsive WordPress Plugin 2021
Công cụ web DMCA hoặc Đạo luật bản quyền kỹ thuật số thiên niên kỷ bảo vệ bản quyền tác giả
Kinh Nghiệm Chọn Công Ty Thiết Kế Web Chất Lượng Chuẩn SEO
Dịch vụ tối ưu tốc độ website Thái Bình web