Tony
Tony

Reputation: 19181

How do I create a custom WordPress page?

I want my WordPress blog to have a page called music. On that page I will query the DB for posts with the category music and then change around the look and feel of the posts. So I can't just put a link to /categories/music/ because I want to do custom work on the posts.

Should I put this code in a separate php file and link to it? I think I may lose access to all the nice WordPress API calls if I do that.

I was thinking about using a filter, but I am not sure which one to use. I was thinking something like the following except the_title has not been grabbed yet so I cannot check the title.

function show_music(){

    if( is_page() && the_title('','',false) == 'music' ){
        echo "got here";
    }
}
add_filter('pre_get_posts', 'show_portfolio');

How would you go about this?

Upvotes: 1

Views: 321

Answers (2)

Abdul Rahim Panhwer
Abdul Rahim Panhwer

Reputation: 11

You need to create custom page within your theme. If you dont have idea how to create custme page or template page in WordPress theme then view my easy tutorial How to create template page in WordPress

Upvotes: 0

Tyler Carter
Tyler Carter

Reputation: 61587

You need to put the below code in the file, and then put the file in the Theme folder. Then you can create a page using Wordpress pages and select a page template with the name you put in this comment:

/*
Template Name: Something Goes Here
*/

Upvotes: 6

Related Questions