How To Load an HTML File As A WordPress Page (With No 301/No Redirect)

You can use the template_include hook to accomplish this. Add this to your active theme’s functions.php file (or create a plugin). add_filter( ‘template_include’, ‘wpse376643_load_html_page’ ); function wpse376643_load_html_page( $template ) { if ( is_page( ‘the-page’ ) ) { // You’ll have to use the server path to your index.html file. $template=”/path/to/your/content/oct2020/index.html”; } return $template; }

Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]

There is indeed an unwanted ; (semicolon) in your function (try to look at line 99 in the twentytwentyone-child/functions.php file) which likely is the cause to the syntax error. So just remove that ; and the error would be gone: function my_service_template_footer_data() { echo “<script type=”application/ld+json”> { ‘@context’: ‘https://schema.org/’, ‘@type’: ‘Service’, ‘serviceType’: ‘ ” . … Read more

How do I get the trackback count of a post in wordpress without writing an SQL query?

You can specify what kind of comment you want to retrieve using get_comments(). // Assumes you’ve set $post_id somewhere. $args = array( ‘type’ => ‘trackback’, ‘post_id’ => $post_id, ); $trackbacks = get_comments( $args ); $trackback_count = count( $trackbacks ); Edited to add: As Sally CJ points out in the comments, you can do this in … Read more

Using shortcode in template file

the_post_thumbnail() echos the thumbnail and returns nothing. You probably want to use get_the_post_thumbnail() which returns it as a string. Your code currently is equivalent to this: if (has_post_thumbnail()) { // Echo the thumbnail the_post_thumbnail(); // Apply the filter but do nothing with the result. apply_filters( ‘the_content’, “[frame_left]”.”[/frame_left]”); } if (has_post_thumbnail()) { // Echo the thumbnail … Read more

What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?

Completely skipping wp_head and wp_footer doesn’t seem like a good idea, many core components and plugins depend on these hooks. Instead, you could create a light header and footer, and load them via an extra argument to get_header() and get_footer(). get_header( ‘light’ ) will load header-light.php instead of the regular header file. Create one without … Read more

Taxonomy Parent Name

<?php $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); $parent = get_term_by( ‘id’, $term->parent, get_query_var( ‘taxonomy’ ) ); if($parent): echo $parent->name; endif; ?>