Questions tagged [templates]

Within the context of WordPress Theme-ing, the term 'template' refers to PHP files used to display content.

415 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
1answer
1k views

How do I display two separate taxonomy archives for two post types that share a single taxonomy?

I have a custom content type, "products", which shares the category taxonomy with posts. We're using posts to discuss and review products. The idea is to have two separate URLs: /discussion/...
3
votes
0answers
119 views

Unable to create custom search results template page

I'm trying to create a search results page for our website and referring to the following documentation: https://codex.wordpress.org/Creating_a_Search_Page I created a new page template searchpage....
3
votes
0answers
150 views

Change Theme from Plugin based on query_vars

I'm working from about 4 months on developing a Plugin. This plugin make in a page an entire app, using the powerful of Wordpress. So, I've decided to create a serires of rewrite rules using command ...
3
votes
0answers
79 views

Page with page template not using template in Preview

I am using a page template created by myself, which is showing and working correctly in page backend. It also works on the front end. The problem: Preview shows the normal "page.php" instead of ...
2
votes
0answers
27 views

Unable to include a template

On the home.php, which is in the same folder where style.css is kept I am try to call a template: <?php get_template_part( 'template-parts/content', 'home-default' ); ?> template-parts is a ...
2
votes
1answer
20 views

I am trying to output portfolio items with a picture. This code doesn't seem to be working. What am I doing wrong?

<?php $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query('showposts=21&post_type=portfolio'.'&paged='.$paged); $count = 0; while ($wp_query-&...
2
votes
0answers
129 views

Login WordPress website using wp-rest api

I am using WordPress 4.8 and i am new to rest api . I have 2 websites , one is www.example.com and second is www.example.com/site2. That is second website is installed inside the first . In example....
2
votes
0answers
645 views

ACF image field to WordPress featured image

I am working with a CPT that is using ACF fields to manage content and the hero image. With the new Archive page template, I wish to have featured images alongside the content. Earlier we did not ...
2
votes
1answer
508 views

Custom taxonomy query for a custom post type

I have a custom post type called news with a custom taxonomy called news category. Right now I have a template called taxonomy-news_category-press.php where press is one of the news_categories. The ...
2
votes
0answers
48 views

Wordpress Template not affecting the working, keeps defaulting to the index.php template

I thought this would be incredibly simple, but it has not. I have an index.php file that has my default template for my site. I then made a new file called magazine.php for a template file so that I ...
2
votes
1answer
258 views

Help with CPT template pagination

i created a themes CPT using the following code function pp_themes_post_type() { $args = array( 'public' => true, 'label' => 'ProfilePress Themes', '...
2
votes
0answers
788 views

Turning on the 404 page on localhost

I'm using my localhost (XAMPP client) to test my WordPress website and everything works fine, till it comes to verifying how does my 404.php template looks like. I can't preview any changes, because ...
2
votes
0answers
287 views

Checking for page templates in child theme

I have a simple problem I'm hoping someone can shed some light on. I have a child theme with a custom page template and I'm simply trying to check weather or not the template is in use. Under normal ...
2
votes
1answer
100 views

Strange Behaviour with is_home()

I'm having an odd issue, although I can understand why it works like this I do need to find a way around it. I have used the the request filter to modify the query for the home/index page to select ...
1
vote
1answer
15 views

creating custom archive template within plugin for custom post type using archive_template filter

I'm trying to create category and tags archive template from my plugin that has custom post type 'product'. I used the below code to display search results in template file located at plugin_dir_url(...
1
vote
1answer
18 views

Display different gutenberg template from selected post attributes

According to https://developer.wordpress.org/block-editor/developers/block-api/block-templates/, I have managed to add a template to the custom post type with the following code - /** * Portfolio ...
1
vote
0answers
62 views

The default code for “posts_nav_link” on category.php isn't working

I am trying to make my own simple WP theme from scratch and I have run in to some difficulties. Maybe someone can help. I have a category named "News", whose slug is "news". The permalink structure ...
1
vote
1answer
28 views

Can I override a CPT template on a per post basis with Gutenberg block editor?

I have a CPT defined in code called event, and there is a template file for the markup (single-event.php). I am wondering if it is possible to override a post within the Event CPT with the Gutenberg ...
1
vote
0answers
48 views

Is there a way to create a block template that is not limited to a post type?

So, I have been reading up on block templates and from what I understand, they limit the ability to create them to one per post type. I just need to be able to add groupings of blocks without having ...
1
vote
1answer
71 views

How to add php to theme to show alt attributes

I am trying to figure out how to add PHP / code to my template so that my alt tags show up for my images. The theme has been modified by a company that is no longer around so I can't ask how to ...
1
vote
1answer
2k views

WooCommerce template page for category

How do I change the WordPress template used for the WooCommerce category pages? I can change the product pages by using the single-product.php template, but the category pages just use page.php which ...
1
vote
0answers
387 views

Gutenberg Editor - Template Doesn't Match Error

I have updated the current page template so that it is locked and uses two of custom blocks that i have created. function.php function my_add_template_to_posts() { $post_type_object = ...
1
vote
0answers
19 views

Facebook Messager Plugin

I deregister Wordpress's default jquery and register the latest jquery. The problem I faced with the Facebook Messenger plugin relied on Wordpress's default to function. Also when I hashed out the ...
1
vote
1answer
233 views

Use same page template for parent and child pages in a theme

I am working on a template which one uses on both parent and child pages. Suppose I have a: template name: TEST I need to use that template on both parent and child pages: Parent page name -> ...
1
vote
0answers
442 views

Echoing Elementor page content in template, but it doesn't get styles and some widgets are missing

I built a page with Elementor, and I want to use it as my home page. When I use a static home page with my theme, it still gets wrapped with the header, footer, and content container, which I don't ...
1
vote
1answer
22 views

displaying category and subject posts

I have single post pages, that displays the page subheading based on the category name or subject name. I am having issues display category titles as well as subject name. Essential what I am trying ...
1
vote
1answer
34 views

How to show “teaser” posts on blog / archive pages, otherwise full posts

Forgive me, I'm a PHP noob and writing too much of it makes my eyes glaze over; I'm sure this is a super simple solution and probably a dumb question. I'm working on a custom theme where I want to ...
1
vote
1answer
40 views

How can I hardcode template selection?

I'm trying to adapt Codex 'template include' for multiple conditional instances. I'm using this... add_filter( 'template_include', 'set_templates', 99 ); function set_templates( $template ) { if ( ...
1
vote
1answer
1k views

Woocommerce custom taxonomies page

I am trying to add a custom taxonomy to woocommerce, which I did. It is working nicely. However, WordPress is not displaying it as woocommerce category page. Instead, it tries to load it as a regular ...
1
vote
1answer
302 views

Set up Custom-Post-Type Author Archive

I’ve set up a custom-post-type on a site for jobs, and this all works fine. When I click on the author (my name) on the Custom Post Type though it goes to the archive.php file (as you can see in the ...
1
vote
1answer
48 views

Content vs Template on custom post

I just wrote a custom post (suppliers) as a plugin (with meta content) that works great. I've also created a template page (single-suppliers.php) within the same plugin to display the data. I wrote it ...
1
vote
2answers
349 views

How to duplicate a page template but make minor changes to the header?

I will apologize in advance, I am very new to this. I have been teaching myself php as a hobby, but now I need it for work! I don't work as a web designer, but to try and save some money, I need to ...
1
vote
2answers
38 views

Use of Templates in a Plugin

I´am creating a Plugin. For this I wrote my own templates. Now I want to have the templeates files in my Plugin directory. But that doenst work fine. Since I used the Plugin directory, wordpress ...
1
vote
0answers
37 views

Changing layout programmatically

I have a theme that offers 2 choices of layouts within its options, stretched and boxed layout. I wanted to try and make the front page keep the stretched layout look, while the rest of the site ...
1
vote
0answers
81 views

Sort wp_query by sum of two meta fields

Hi I have two custom fields amount1 and amount2. I want to sort my posts in descending order of the sum of amount1 & amount2. How can I achieve this? I know for a single custom field I can do this:...
1
vote
0answers
30 views

Add comments for template variables

I am writing a small plugin that uses a custom template to render content. The plugin uses extract() to add variables that can be used inside the template. I was wondering if there is a standard for ...
1
vote
0answers
83 views

How to use custom template files in deeper directory?

On an install to which I've just returned (and forgotten much of what I'd done), I'd had my custom templates in folders a level deeper than 'page-templates', using a function (example below)to enable ...
1
vote
1answer
60 views

Adding Query to Custom Page Template

Probably a simple, stupid question, but: I'm trying to create a page that displays a list of all pages that include a specific ACF value. I copied page.php from my active theme folder, renamed it ...
1
vote
1answer
18 views

Make custom page look exactly as homepage

I want to make a custom page that looks exactly the same as index.php, while showing different content. Right now, on index.php I'm showing only posts under the "News" category, but on my custom page ...
1
vote
1answer
70 views

How to make the Primary Menu stay the same in the PC and mobile versions of the Twenty Sixteen theme

I'm new to WordPress, using which I was able to create this site over here: http://wtfai.pl/ It's almost complete, save for one change I would like to make: to make the Primary Menu stay exactly the ...
1
vote
0answers
9 views

Markup is visible when I view sample data from my template

I am just getting into Wordpress and I need your help. I have recently downloaded a template and I have uploaded the sample data but when I go to modify my template I notice that the markup is mixed ...
1
vote
0answers
35 views

Wordpress Doesn't Generate Taxonomy Archive

I have a post type named 'publication' and a taxonomy named 'area'. For some reason, I cannot seem to get Wordpress to generate a taxonomy archive for the terms of 'area' from my custom taxonomy.php ...
1
vote
1answer
721 views

theme_page_templates not working

I'm trying to filter the contents of my page template dropdown in the admin area. Having done some Googling it seems that the hook I need to use is theme_page_templates ... but this just does not run ...
1
vote
0answers
113 views

How to override p2 breathe theme plugin in content template file?

I'm experimenting with a theme, P2 Breathe, the first o2-enabled theme that adds functionality like front-end posting. One difficulty is that when the plugin is enabled, most of the changes that I ...
1
vote
0answers
36 views

A case for Hierarchical Custom Posts

So I have 3 Custom Posts created with the Types plugin (the plugin should be irrelevant, anyway): 'Hotels', 'Rooms' and 'Webcams'. These last two are hierarchical, with 'Hotels' as their parent, set ...
1
vote
1answer
242 views

Set Title from Custom Template

I'm building a site that uses a custom template to display a set of listings that are pulled from an external API. I need to set the title and meta description values using data from the API. I've ...
1
vote
0answers
576 views

if page is parent page redirect to first child with hook / polylang

I'm trying to check, before a page is rendered, if this page is a page with childs. If this is true, I would like to redirect to the first child page based on menu_order. I don't want to add the ...
1
vote
1answer
160 views

Switch to page template when using post permalink

I'm new to wordpress development so hopefully I'm asking this right. The company I work for recently bought a custom wordpress site from an agency, but before we were able to launch it, the agency ...
1
vote
0answers
48 views

Unable to display pagination links on custom category template

I'm trying to generate numbered pagination links on a custom category template. The template displays the current category's child categories. I've pasted the code I'm using below. At the moment there ...
1
vote
1answer
105 views

Custom taxonomy returns 404

I'm getting a 404 page when I visit my custom taxonomy page. Custom taxonomy is called 'manufacturer'. I also have a cpt called 'product'. EDIT 1: It has something to do with the cpt rewrite. If I ...