0

I have a meta_key value 'গল্প' inside wp_post_meta as shown value: enter image description here

Now I want to show all post having meta_key value 'গল্প'. Is there any template file to manage this option like tag.php?

1

You might give it a shot this way:

add_filter( 'template_include', 'check_post_meta_template_include' );
function check_post_meta_template_include( $template ) {
    if ( !is_single() ) {
        return $template;
    }
    global $post;
    if ( $post->post_type != 'post' ) { // Proceed only if post type = post
        return $template;
    }
    $category_meta = get_post_meta( $post->ID, 'Category', true );
    if ( $category_meta != 'গল্প' ) {
        return $template;
    }
    // Use locate_template() here.
}

Reference: locate_template

0

Template files are the 'responsibility' of the theme you are using. If your theme doesn't contain a template that meets your need, then you can modify one of the theme's templates and change the query to do what you want.

Modifying a theme's files directly is not recommended, as any mods you do will get overwritten on a theme update. So it's best to create a Child Theme, then create a version of the template from the parent theme that you store in the Child Theme's folder. (Copy the parent theme template to the Child Theme folder, and modify that file, not the original theme.)

Then change the name of the copied template, modify the query, save/upload to your site, and create a page that uses that modified template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.