How to create custom template for a page in WordPress

If you wish to create a custom template for your wordpress page then please follow this tutorial.

1. Create the page first.

Go to Dashboard > Pages > Add New

2. Add title, content, images as necessary and publish the page.

3. Remember the id of the page. You can find the id at the url of the page edit tab.

In this example, 7 is my page id. You will need to remember it for the upcoming steps.

4. Create Template file and write the custom code.

While you can practically create the template file anywhere, generally its a good practice to create the template file inside templates directory of your child theme.

Create a file called “content-custom.php” inside your-child-theme/templates directory. Once you have created the file you can write the code and save the file.

4. Route the page to the template from page.php

Check if your child theme has page.php, or else, copy the page.php from your parent theme and paste it onto your child theme.

While page.php can be coded in different ways in different themes, the general idea is the same across all the page.php. They follow the following principle:

Page.php runs a while loop to get all pages and inside the loop, it runs different logics or calls other template parts to render the page’s content. We will need to place our code so that this loop calls our custom template when our custom page is being rendered. So the generic logic would be:

while(have_posts()):
if(custom_page detected) {
     call the custom template
} else {
    do the usual thing you were doing.
}

endwhile;

For our example we will be adding following code in page.php:

while ( have_posts() ) :
    
//check if current page is our page. Remember the page id was 7 in our example.
//Put your page id here.
if(is_page('7')) {
    //call custom template is detected
get_template_part('templates/content-custom');} //Else run the normal business
else {
	the_post();
	get_template_part( 'template-parts/content/content-page' );

	// If comments are open or there is at least one comment, load up the comment template.
	if ( comments_open() || get_comments_number() ) {
		comments_template();
	}
}//Close if loop
endwhile; // End of the loop.

Save page.php and bam your page will pickup the new template.

You can add required styling, scripts to your pages. To get the dynamic contents such as page title, excerpt, featured images, custom fields, content, etc, you will need to use WordPress/PHP functions. Few examples are:

get_the_title();
get_the_post_thumbnail();
get_the_content();
get_post_meta($post->ID,'meta_name',true);
.
.
.

Hope you like this tutorial. If you have any problems please comment down and I will try my best to provide solution.
Cheers,
Bibek

11,293 thoughts on “How to create custom template for a page in WordPress”

  1. I’m not sure where you’re getting your info, but great topic. I needs to spend some time learning more or understanding more.
    Thanks for magnificent info I was looking for this information for my mission.

    1. Common breast cancer susceptibility alleles are associated with tumour subtypes in BRCA1 and BRCA2 mutation carriers results from the Consortium of Investigators of Modifiers of BRCA1 2 tadalafil generic vs cialis I ve also can completely understand taking a step back from medical intervention, we ve only been trying for 6 months and I think about taking a break already

    1. A healthcare provider makes tiny incisions into your abdomen and, using a very small camera to assist in visualizing your internal organs, makes small burns on the enlarged ovarian follicles cialis generic buy And women with IBS may have more symptoms during their monthly menstrual cycles

    2. Preparations for parenteral administration must be carefully formulated, often in propylene glycol or polyvinyl pyrrolidone with additional dispersing agents, to provide stable solutions propecia for sale in usa I had a monofocal Alcon hydrophobic acrylic model put in, targeted for distance

    3. Mineral oil and olive oil are not recommended due to the danger of inhaling mineral oil and the high dose of fat in olive oil causing digestive upset cheap cialis If two eggs are released, you may conceive non- identical twins

    1. HSVSMC were also able to synthesize VEGF, as shown by the presence of immunofluorescence Fig cialis tablets for sale The use of Plavix is indicated for the prevention of atherothrombotic complications in adult patients with myocardial infarction in adult patients with an acute coronary syndrome

    2. Besides, inhibition of expression or function of the voltage gated Ca 2 channel may, in part, mediate effects of chronic estrogen treatment on cerebrovascular tone cialis generic name All women underwent testing for tubal patency by hysterosalpingography, evaluation of pelvic anatomy by transvaginal ultrasound, and assessment of basal hormones on day 3 of the menstrual cycle

  2. Antibiotics are medicines that fight bacterial infections in people and animals. They work by killing the bacteria or by making it hard for the bacteria to grow and multiply.
    Special offer for you – buy antibiotics online (no prescription required) and get fast & free delivery, safe & secure payments and two free pills (Viagra or Cialis or Levitra). Available with every order!

    1. is fine because it s tiny and can easily be hidden in food buy generic cialis online safely Propranolol Generic Cheap Inderal 10 mg Best Price Where Can I Purchase Inderal Billig Cheap Inderal Uae Generic Inderal 20 mg Without Prescription Where To Buy Cheap Inderal Chicago Where To Buy Cheap Inderal Norge Combien Cheap Inderal L espagne Discount Generic Propranolol Propranolol Best Buys Inderal Rx Online Inderal Buy Online Reviews Where To Purchase Inderal 10 mg Brand Online Buy Cheap Inderal Online Without Prescription Needed Order Canadian Propranolol Ny Cheap Inderal Where To Buy Safest Place To Buy Inderal Inderal Pills No Prescription Where To Buy Inderal Brand Online Safe Place Buy Propranolol Online Online Inderal Cheap Propranolol Mail Order Generic Propranolol No Prescription Cheapest Price Branded Inderal For Sale Gb Inderal Where To Order Where To Buy Cheap Inderal Switzerland Where Can I Purchase Generic Inderal Inderal Propranolol For Sale Propranolol Pill Cheap Costo Inderal Once A Day Real Propranolol Online Propranolol Kopen Bij Apotheek How Do I Buy Inderal Can I Buy Real Inderal Online Cuanto Cuesta Inderal Farmacia

    2. A kilo of alfalfa alone would therefore go a long way towards replacing the likely calcium loss through sweating buy viagra and cialis online Furosemide Injection is given to help treat fluid retention edema and swelling that is caused by congestive heart failure, liver disease, kidney disease, or other medical conditions

    1. com 20 E2 AD 90 20Ile 20Kosztuje 20Viagra 20W 20Polsce 20 20Gibt 20Es 20Viagra 20Fr 20Frauen 20Flssig gibt es viagra fr frauen flssig TEHRAN, Iran Гў Iran s supreme leader formally endorsed Hasan Rowhani as president Saturday, allowing the moderate cleric to take charge of a country weakened by economic sanctions over its nuclear program generic 5mg cialis best price

    2. Viagra should take it most tetracyclines overnight cialis delivery Many medical disciplines and services, including general practice, emergency medicine, surgery, infectious diseases, gastroenterology, gynaecology, and mammography services, are well placed to recognise HS and refer patients to dermatologists for early effective treatment

    1. This would be consistent with recommendations from evidence based tool kits from the broader healthcare field suggesting that health education materials be easy to interpret by clients with a fourth to sixth grade reading level, 64 66 and that certain basic strategies can be used to simplify information and promote comprehension for all clients order cialis online The effectiveness of gabapentin for CIPN has been documented, 30 but in one study it was not effective

    1. After menopause, as the ovaries stop making estrogen from androstenedione, some production continues in other tissues, with DHEA as the primary precursor of androgens that are ultimately converted to estrogen best price cialis 20mg There are many memory enhancing nootropics available today, some made in Switzerland and others made elsewhere usually the US and Russia

    1. Patients who fail to achieve guideline recommended doses of these medications due to hyperkalaemia have a worse prognosis, but this may be because of concomitant renal dysfunction or hypotension buy cialis online Set routine times to go to the bathroom to help re train the bladder

    1. In criminal law, a TJ approach may be achieved through restorative justice, such as restorative circles that incorporate storytelling in lieu of formal disciplinary meetings, or teen court instead of formal court proceedings propecia uk Rogge groped for a moment, then telmisartan amlodipine torrent said softly, You re obedient, baby, it s useless to hide

  3. шкафы купе спб
    шкафы купе на заказ в петербурге
    шкафы купе на заказ в спб недорого

    http://mebelalpo.com/

  4. Amoxicillin is used to treat many different types of infections caused by bacteria, such as ear infections, bladder infections, pneumonia, gonorrhea, and E. coli or salmonella infection.
    Buy amoxicillin canadian pharmacy – Save UP to 201.99$ and get two free pills Viagra or Cialis or Levitra (available with every order).
    Highest Quality Generic Drugs. Safe & Secure Payments. Fast & Free Delivery.

    1. It is a difficult position for the caregiver, but this assurance that the vast majority of people I work with demonstrate this is at least mildly comforting commander acheter levitra en ligne Call your physician if you have a temperature over 100 F, have a cough that is different from other coughs you had before the transplant; are feeling overly tired or short of breath; are dizzy; or have any sores, blisters, new growths or lumps check your neck, armpits and groin and women should check their breasts for lumps

    1. For television personality, author, and lifestyle maven Sandra Lee, who has donated much of her time to charitable causes, the roots of her controversial decision to have a bilateral mastectomy go back to her childhood, when her grandmother was diagnosed with an advanced and aggressive form of stomach cancer generic finasteride international Antibiotic prophylaxis in cardiothoracic surgery results of a second survey

  5. Levothyroxine(Levothroid) is indicated for the treatment of hypothyroidism as a replacement or supplemental therapy in congenital or acquired hypothyroidism of any etiology, except transient hypothyroidism during the recovery phase of subacute thyroiditis.
    https://qmc.com.au/wp-content/plugins/slide/buylevothyroxineonline/ – Save UP to 250.47$ and get two free pills Viagra or Cialis or Levitra (available with every order).
    Highest Quality Generic Drugs. Safe & Secure Payments. Fast & Free Delivery.

    1. However, the differences in the effect of TMEM16A overexpression on cancer cell proliferation may arise from differences in experimental conditions or techniques among studies pastillas priligy en mexico Of the two patients who ovulated, one received hCG on day 16, and became pregnant

    1. They Are Fantastic On Their Own, In Addition To Added To Recipes For Flavor And Crunch Nikhita Mahtani Is An Nyc Based Freelance Journalist Covering Primarily Well Being And Design Not Many Individuals Can Agree On The Means To Make Their Martinis And We Totally Understand That It S Definitely A Private Desire And Typically Even An Acquired Taste Getting Past The Guilt Of Type 2 See How One Affected Person Discovered To Handle Her Weight And Diet People Who Have Diabetes Can Get Ketoacidosis, Or Diabetic Ketoacidosis, When They Do Not Take Enough keto diet and periods Insulin cost finasteride Continue To Diet And Train As Hard As You Were On Cycle Once You Go Off Cycle

    1. cheap generic cialis Unfortunately, niosomes suffer from some problems related to physical stability such as fusion, aggregation, sedimentation and leakage on storage that prevent many promising vesicular formulation from moving from the experimental scale to the market as stated by Ko Abhinav et al

    1. hydrochloride mestinon 60 mg price in egypt Facing rising international pressure, the Obama administration continued its push Sunday to shore up support ahead of a vote by the Senate this week on a resolution authorizing military force in Syria cialis cost

    1. Bring up any concerns you have about certain hair products, and tell them how water changes your hair for example if water makes your hair too curly or large to fit under the cap buy cialis usa Abrupt discontinuation or dose reduction has been associated with the appearance of new symptoms that include dizziness, nausea, headache, irritability, insomnia, diarrhea, anxiety, fatigue, abnormal dreams, and hyperhidrosis

    1. The way to use supplements is to find a good wholistic Dr that will only prescribe what is actually needed based on objective studies tests where to buy cialis online safely Signs of serotonin syndrome include agitation, anxiety, restlessness, disorientation, sweating, increased heart rate, nausea, vomiting, tremor, and flushed skin

    1. Liu PY, Wishart SM, Handelsman DJ A double- blind, placebo- controlled, randomized clinical trial of recombinant human chorionic gonadotropin on muscle strength and physical function and activity in older men with partial age- related androgen deficiency generic for cialis

    1. Furthermore, our findings show significant variability in national patterns of RS testing and chemotherapy use for grade 3 disease, which suggests opportunities for more comprehensive national guidelines for RS testing in high grade tumors priligy tablets price

    1. First pregnancy here I have PCOS and take metformin no clomid, though; which is kind of a funny story can i buy cialis online Abbreviations used RM, recurrent miscarriage; PCOS, polycystic ovary syndrome; BMI, body mass index; FSH, follicle- stimulation hormone; LH, luteinizing hormone; AMH, anti- Mullerian hormone

    1. We talk about energy and everything there levitra generique en bretagne A study published in the Journal of Sexual Medicine reported that 70 percent of the 994 cancer treated patients who were sexually active at the time of diagnosis reported that they were still experiencing sexual difficulties two years after cancer treatment ended

    2. Each tooth also has an associated nerve, which resides within a root canal passing from the tooth s root into the dental pulp buy cheap cialis discount online Because furosemide can cause an imbalance in water andelectrolytes salts in the body or affect kidney function, your veterinarian will likely want to do bloodtests to check for these effects

    1. The black flame behind captopril efferent arteriole Ofirok was burning silently, Not even the light of the golden lion could hide it finasteride generic A wide selection of performance enhancing drugs were scheduled to be regulated under the MDA in 1996

    1. Furosemide is a loop diuretic water pill used to treat fluid retention edema in dogs, cats, and horses with congestive heart failure, liver disease, or certain kidney disease buy cialis canadian Anaprilin; anapriline; anaprilinium; anapryline; arcablock; arcablock retard; authus; avlocardyl; avlocardyl retard; ay 64043; bedranol; beprane; bercolol; betadipresan; beta neg; betaneg; betaprol; betares; betaryl; beta tablinen; beta tablinen retard; beta timelets; cardinol; ciplar; corbeta; deralin; dextrolevo propranolol; dideral; dl propanolol hydrochloride; dl propranolol; dociton; docitone; dociton retard; durabeton; efektolol; efektolol retard; elbrol; frekven; 1 2 hydroxy 3 isopropylaminopropoxy naphthalene; ici 45520; ikopal; inderal; inderal la; inderal retard; inderex; indobloc; ipran; 1 isopropylamino 3 1 naphthoxy 2 propanol; 1 isopropylamino 3 1 naphthyloxy 2 propanol; 1 isopropylamino 3 1 naphthyloxy propan 2 ol; lederpronol; levo propranolol; levopropranolol; l propranolol; napriline; nsc 91523; obsidan; obsin; obzidan; prandol; prano puren; pranopuren; prolol; pronovan; propabloc; propal; propanolol hydrochloride; propercuten; prophylux; propral; propranolol hydrochloride; propranolol isomer; propranur; propra ratiopharm; proprasylyt; proprasylyte; sagittol; stapranolol; sumial; Propranolol; anaprilin; ay64043; innopran; innopran xl

    1. Then Donovan, player of the match, tucked in a second goal in the 78th minute on a cross down low from substitute Mix Diskerud, deflected by Clint Dempsey for an assist cialis generic buy Class IIb There is conflicting evidence and or divergence of opinion about the drug, and the potential arrhythmic effect in Brugada syndrome patients is less well established by evidence opinion

    2. Dana our Nurse is like family order proscar for hair loss Both types of mice possess an enhanced green fluorescent protein EGFP gene regulated by four copies of estrogen response elements EREs, while the latter lacks a functional aromatase gene, which encodes an enzyme catalyzing conversion of androgens to estrogens

    1. Received 23 Jan 2018 First Decision 3 Mar 2018 Revised 15 Mar 2018 Accepted 22 Mar 2018 Published 30 Mar 2018 Received 23 Oct 2019 First Decision 9 Dec 2019 Revised 13 Dec 2019 Accepted 20 Dec 2019 Available online 19 Mar 2020 cialis otc

    1. For example, your dermatologist may develop an acne treatment plan that incorporates both oral minocycline and topical clindamycin, as well as another topical treatment to help resurface the skin and fight the root cause of your acne levitra 20mg belgique

    1. As shown in Table 6, the groups showed no significant improvement in the biochemical parameters for assessing insulin resistance except metformin group but it did not reach the level of significance overnight cialis delivery You have two inguinal lymph nodes one on each side of your pelvis

    2. That is, maybe the next person who might drive two or three hours home might benefit from knowing what you found out about the episode, that it was just a minor pseudo seizure buy cialis online overnight shipping Dianabol side effects for men also include androgenic side effects such as severe acne, oily scalp, and male pattern baldness

    1. A unified holy alliance may no longer be just a dream, Thus blood pressure scales broke can i lower blood pressure naturally out the civil war of the Holy Alliance cialis for sale online com reference Book 26, Hadith 1 USC MSA web English reference Book 26, Hadith 1 Arabic reference Book 26, Hadith 1070

    1. Kramer and colleagues 1974 measured the fluoride content of meals and water samples from 12 cities with fluoridated drinking water and four cities without fluoridation propecia online australia I wasn t totally surprised when I got the cold wing upon my eventual entrance a day late Griffin often does that when I ve been away for any length of time

    1. I SPY2 endocrine optimization protocol EOP A pilot neoadjuvant endocrine therapy study with amcenestrant as monotherapy or in combination with abemacicilib or letrozole in molecularly selected HR HER2 clinical stage 2 3 breast cancer SABCS 2021 when does viagra kick in Pfob CH, Ziegler S, Graner FP, et al

    1. 7 mg kg, the extract induced a transient decrease in mean arterial blood pressure of about 4 buy cialis online india Patients with infection calculi may present with symptoms of acute pyelonephritis, including fevers, chills, flank pain, dysuria, frequency, urgency, and malodorous, cloudy urine

    1. Incidence of aneurysm formation after Dacron patch aortoplasty repair for coarctation of the aorta long term results and assessment utilizing magnetic resonance angiography with three dimensional surface rendering cialis 10mg

    1. cialis dosage Countless electric lights rose from the feet of the dwarves who were escaping rapidly, and a radius of several hundred meters suddenly turned into a forest of thunder and fire, The sickle that never left his does hemp lower blood pressure hand was constantly wriggling and growing like a living creature

    1. I was sad but there s still more time for it to work I hope purchasing cialis online Brand IVERHEAL Brand Name IVERHEAL Strength 3 mg, 6mg, 12mg Packaging Size 10 10 Box 100 Tablets Tablets in a Strip 10 10 100 Tablets in 1box Manufacturer Name HEALING PHARMA Packaging Type Strip Manufacturer HEALING PHARMA Composition Salts Ivermectin Composition Ivermectin Usages Covid Preventive Medicine

    1. BYSTOLIC is a prescription medicine that belongs to a group of medicines called beta blockers best generic cialis Prolyl endopeptidases have potential for treating coeliac sprue, a disease of the intestine caused by proteolytically resistant peptides from proline rich prolamins of wheat, barley and rye

    1. Environmental poisoning of children lessons from the past dapoxetina comprar online com 20 E2 AD 90 20Viagra 20Apteka 20 20Viagra 20Combien 20De 20Temps viagra combien de temps It s a pity that Secular mindedГ‚ Muslims who don t subscribe to the radicalism espoused by their brethren don t stand a chance in shaping the future of their community

    1. Denny, USA 2022 06 17 23 04 12 generic name for cialis Streptococcus pneumoniae remains the most common pathogen of CAP among patients requiring admission to hospital, as well as the pathogen most often associated with bacteraemic disease, need for intensive care unit ICU treatment and death 12, 30

    1. buspar meloxicam ndir Oct 22 Reuters Standard Poor s owner, McGraw HillFinancial Inc, reported a higher than expected 56percent jump in quarterly profit due to strong growth at therating agency and S P Dow Jones indices buy cialis It has been reported that FOXO1 can act as a transcription factor for ERО± in breast cancer 40, 41, which may contribute to positive feedback formation

    1. real cialis online Recent preliminary data have shown that low endogenous testosterone levels are associated with lower high- density lipoprotein HDL cholesterol and higher low- density lipoprotein cholesterol, triglyceride, and total cholesterol levels 18

    1. buy propecia 5mg Sinusitis, chronic, when evidenced by chronic purulent nasal discharge, hyperplastic changes of the nasal tissue, symptoms requiring frequent medical attention or X ray findings h Larynx ulceration, polyps, granulated tissue or chronic laryngitis j

    2. com 20 E2 AD 90 20Viagra 20Dure 20D 27action 20 20Viagra 20Purchase viagra purchase Detroit wound up in bankruptcy court because, while itsrevenue is higher than other Michigan cities on a per capitabasis, there was not enough cash to cover services where can i buy priligy online safely 100 A second option is to check FSH levels at the end of the 7 day placebo week twice, 6 8 weeks apart

    1. Ingredients and materials suitable for a selected dosage form and intended route of administration are well known in the art, and acceptable ingredients and materials for a chosen dosage form and method of administration may be determined using ordinary skill in the art where to buy cialis online Wu Qingshui smiled bitterly and said, Then what else can you do Su Su sighed and sat down again, still not very happy, Anyway, it s really embarrassing for Xiao Gu to see me like this

    1. sulfasalazine increases levels of vancomycin by decreasing renal clearance lamictal the new viagra Step H Methyl 3 benzyloxycarbonylamino 4 4 bis 2 chloroethyl amino 2 methyl phenyl butanoate 4h Following the General Procedure for of Description 7 Variant A, methyl 3 benzyloxycarbonylamino 4 4 bis 2 chloroethyl amino 2 methyl phenyl butanoate 4h was prepared from methyl 4 4 amino 2 methyl phenyl 3 benzyloxycarbonylamino butanoate 4g 200 mg, 0

    1. Interestingly, recent evidence shows that mice lacking SIRT3 have development of severe age related pathologies in the heart, such as hypertrophy, attributable to mitochondrial swelling and dysfunction, possibly because SIRT3 can modulate directly the mitochondrial permeability transition pore, a multiprotein complex involved in age related mitochondrial diseases cheap cialis generic online

    1. buying cialis online safely In some embodiments, the cancer can be a solid tumor selected from the group consisting of breast cancer, melanoma, lung cancer, ovarian cancer, pancreatic cancer, colorectal cancer, prostate cancer, brain cancer, gastroesophageal cancer, and kidney cancer

    1. Obstet 115 1141 9 mexican viagra brands Advanced Accelerator Applications, a Novartis company and leader in nuclear medicine theragnostics, will present an update on outcomes from the NETTER 1 study evaluating Lutathera lutetium Lu 177 dotatate in patients with progressive midgut neuroendocrine tumors

    1. Our demons really only focus on strength and regard heroes with strength, but this is not contradictory to protecting the children of our own race, it s all Lithium And Furosemide for survival, Sigh, lithium and furosemide Let s talk about a few brothers, Very beautiful, he is an aristocrat, but what the hell is his life, When I was in the capital, a prostitute might have been robbed propecia online no prescription

    1. Thus, we selected the cell lysis protocol for 2 h at 60 C as it saves a lot of time without altering the amplification efficiency cheap viagra 100 Parakeratosis pustulosa either regresses spontaneously or evolves in nail psoriasis

    1. Animals in these groups were also associated with improvement in estrous cyclicity during the treatment phase cialis professional When in doubt, just ask the manufacturer of the product you are using and they can let you know how to correctly use the product and if it is safe during pregnancy