Questions tagged [template-tags]

Template tags are custom WordPress-specific functions for use in theme template files.

Filter by
Sorted by
Tagged with
0 votes
0 answers
17 views

What file is responsible with tags displaying on the post?

The tags are not diplayed on my blog post What file do I need to edit or how to fix this issue ? Update I found the page is post.php <?php /* translators: used between list items, ...
Crypto Coupons's user avatar
0 votes
1 answer
26 views

Code to check how many posts a tag has?

I would like to noindex any of my /tag/ pages that have less than three posts attributed to them. Any idea how I would go about doing that? I know is_tag() of course, but am not aware if there is any ...
Matt's user avatar
  • 163
0 votes
1 answer
60 views

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

How do I get the trackback count of a post in wordpress without writing an SQL query? I tried searching Brave Search and I couldn't find anything helpful. To fetch the amount of comments a post has, ...
desbest's user avatar
  • 101
0 votes
1 answer
28 views

How do I get tags linking to proper pages (/tag/sample-tag -> pages with that tag)

(Warning: WordPress newbie ahead...) I have a WP site with a bunch of posts, many of which have tags associated with them. However, clicks on links to such tags -- https://example.com/tag/sample-tag) ...
Jim Miller's user avatar
0 votes
1 answer
672 views

WP Method `get_theme_file_uri()` Doesn't Seem To Be Working Properly When Used In The Head Section Of A Site

I'm preloading a web font in the head section of a WP custom theme and when I use the full file path it doesn't throw an error and works OK. When I use the WP function get_theme_file_uri inside the ...
pjk_ok's user avatar
  • 898
0 votes
1 answer
60 views

How to add Text before my Custom Term and hide it when empty

This is my code: <?php $terms = get_the_terms( $post->ID , 'this_is_custom' ); $links = []; foreach ( $terms as $term ) { $term_link = get_term_link( $term, '...
Taufan's user avatar
  • 3
0 votes
1 answer
86 views

How to show 'tags' in 'Wordpress Pages' [not Posts]

I have found a way to have the ‘category’ the page is recorded against to display at the top of the ‘page’ (this is not a post but a WordPress ‘page’). I would also like to display the ‘tags’ that ...
Avocation's user avatar
0 votes
0 answers
136 views

Child theme overirde template-tags in a theme built on underscores in inc/template-tags

I've read this post and I don't think this question is a duplicate because I have a specific question that has not been answered. My parent theme is using the following to require a template tag php ...
Anders Kitson's user avatar
0 votes
1 answer
17 views

small problem in the article ()

WP 5.4 Theme masonic I try to show the numer of comments in each article it'as ok (see the picture) but on the next line, itshow () I don't know why !?!? the code in the file template-tags is: ...
pascalniv's user avatar
0 votes
3 answers
369 views

Get_header raises an 500 internal server error

I am working on custom development in wordpress, my problem is the following every time I create a new template. Code /* Template Name: Citas Rolex*/ get_header(); echo "<h1>loren ipsum</...
Luis Bernal's user avatar
1 vote
1 answer
884 views

Adding country tags automatically

I want to show country flags on post cards.My plan is showing flag icons with below code: <img src="/icons/<?php echo $tagName; ?>.png" /> However I dont know how can I add country tags ...
Faruk rıza's user avatar
1 vote
1 answer
65 views

Editing Category Pages

I want to allow Search engine Robots to index my category pages, But it seems noindex,follow tags is auto add by my theme functions I want category pages to allow indexing while keeping noindex,...
kalkun's user avatar
  • 23
0 votes
0 answers
37 views

Tag pages with regular editor

So, I am creating a website, review products and attach dozens of tags to them dependent on what the product entails. I have a custom review template for my products and based on what I tag the ...
MAXEV's user avatar
  • 1
0 votes
1 answer
1k views

How to display a custom taxonomy without a link?

I need to display the name of a custom taxonomy term in a page template, and I've tried with the following line: <h2><?php the_terms( 0, 'my_category'); ?></h2> This correctly ...
Sekhemty's user avatar
  • 141
1 vote
1 answer
1k views

Edit css for search results page

I have a search results page with a template call content-search.php. Basically what this file does is to display the results after a person searches something on the search bar, and i would like to ...
desh's user avatar
  • 137
1 vote
1 answer
47 views

WordPress menu link doesn't work properly

I am developing custom site. The header links work on home-page but when I go inside shop then the home-link becomes siteurl/shop how to solve this? <div id="content" class="site-content"> &...
xreonn's user avatar
  • 11
0 votes
1 answer
99 views

Show the section only if custom taxonomy was chosen

So I have a code where all items of my custom taxonomy ('colour') are displayed. I broke my head trying to show the section ("colour__chart") only if one of taxonomy items was chosen. In simple words, ...
Jamdev's user avatar
  • 117
1 vote
1 answer
1k views

'is' functions and 'get_query_var' not working

Why does is functions not work inside an Ajax function? Except for is_user_logged_in? I also tried using get_query_var and it did not work. jQuery: jQuery('.post-modal').live('click', function(e) { ...
Alex's user avatar
  • 15
1 vote
1 answer
16 views

Please help me to figure out how to display my tags

desperately looking for help. Have a Wordpress theme which does not display post tags on a single page and I badly need to have them there. Developers only named a file which needs to be modified. It'...
Vytautas Ravinskas's user avatar
0 votes
0 answers
77 views

Pagination doesn't work in query post in tag template

In tag template I use the following query post: global $query_string; // required $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; ...
Giulio's user avatar
  • 51
0 votes
1 answer
251 views

using themename_the_custom_logo() in template-tags?

I am trying to learn how to create a theme for wordpress so i looked at the default theme 'twenty sixteen'. I was crawling around it and searching everything that i find strange then i saw this code ...
Khesht's user avatar
  • 1
0 votes
1 answer
170 views

Limit Tag Links in Post Content

I am trying to Limit Maximum Numbers of Tag Links to appear within post content. Below is my code. I don't know how to fix it up. function link_words( $text ) { $replace_times=3; $replace = ...
Godwin Alex Ogbonda's user avatar
0 votes
1 answer
41 views

Show author image at home page latestest posts plugin

On my home page, I'm showing the last 3 blog posts with their respective titles, texts and their featured images. I need to change the featured image at homepage to each blog to the image of the ...
marcdecline's user avatar
0 votes
0 answers
522 views

method to fetch entire tag list on archive.php

What I have Tried → <?php $taginto = get_the_tag_list(); if ( ! empty( $taginto ) ) { echo '<a class="categum" href="' . esc_url( get_tag_link( $taginto[0]->term_id ) ) . '">' ...
WordCent's user avatar
  • 1,827
1 vote
2 answers
1k views

Disable Woocommerce product tags display by alphabetical order

I have a Woocommerce e-shop where each product has at least five tags. The problem is each product's tags are displayed alphabetically on the single product page. I would like to know if it's ...
Maxime Lafarie's user avatar
1 vote
1 answer
47 views

Sort list of page templates a-z?

In the code below, it possible to sort the results alphabetically - and if so what changes do I need? <?php $templates = get_page_templates(); foreach ( $templates as $template_name => $...
glvr's user avatar
  • 851
5 votes
1 answer
4k views

get_parent_theme_file_path vs. get_template_directory

I've been reading about the new functions for referencing theme location added in v4.7. I read through the trac ticket. I understand why they created these functions and the benefit of ...
Sirmontegu's user avatar
0 votes
0 answers
35 views

Template tags not working in the customizer preview

I have a small code to inject some CSS to the single post. And it has an option in the Customizer to enable/disable the CSS. My code is similar to this: add_action( 'wp_head', function() { if ( ! ...
Anh Tran's user avatar
  • 4,072
0 votes
2 answers
262 views

php within html within php

I use an extension called Custom Field Suite to import info from a csv in order to batch create posts. In order to display the form fields I use <?php echo CFS()->get('image_location'); ?> ...
Thomas Martin's user avatar
1 vote
3 answers
97 views

different tag different stylesheet

i have tags, and for some tags i want to load a different stylesheet But i don't know how i have.... function customstyles() { if ( is_tag( 'circulair' ) ) { //Register and enqueue the ...
bets's user avatar
  • 11
0 votes
2 answers
47 views

Template Tag Does Not Work in Page Template

I've created a page template and used this code to call a post which contains a shortcode: $post_id = 129; if( get_post_status( $post_id ) == 'publish' ) { the_content(); } The problem is that ...
L-HAZAM's user avatar
0 votes
1 answer
167 views

How do I str_replace with template tag?

I have a template tag of: <?php echo the_post_thumbnail( 'full' ); ?> It outputs: <img src="/graphics/magazine/802/1.jpg" class=" wp-post-image" alt="" /> I want to remove 'class=" wp-...
gulliver's user avatar
  • 123
-1 votes
1 answer
44 views

Misleading information in the Codex, how do they get away with it? [closed]

I'm new to WordPress Development but I've programmed in PHP for a couple of years. My understanding is that the Codex pages are as close to authoritative information on WordPress that you're going to ...
Larry Lawless's user avatar
3 votes
1 answer
941 views

setup_postdata is not returning any values

I am using ACF to create a custom field called facilities. Within that field is a repeater field called facility. So each store has 'facilities', which contains a number of 'facility'. What I am ...
ravravrav's user avatar
1 vote
1 answer
193 views

Changing Image Size In The Content tag

I am developing a WordPress theme locally and I can't figure out how to get an image to display in a normal size in the_content(). At the moment, the images are displaying the same size as my featured ...
Clinton1000's user avatar
0 votes
1 answer
45 views

showing tag beside catagory

thanks for your guidance, here is one last but not least thing for me to learn, i am using Today news wordpress theme, since with your help i have moved my process from category to tag based ...
Rohan Zakie's user avatar
0 votes
1 answer
168 views

Wordpress tag or archive php file customization

I am not that pro with php but i have good concept and can find my way in cleverly, this forum have always put me ahead of the game due to people like you who share as the care, I have a site that ...
Rohan Zakie's user avatar
0 votes
0 answers
1k views

Hide Certain Tags on Single Post Page

I'm trying to hide certain tags from single posts pages. I've googled and found 2 codes but both are hiding the whole post page. I'm using a theme that needs using 2 tags ticker and slider to show ...
Zaher's user avatar
  • 19
0 votes
1 answer
257 views

How do I get shortcode, widget and template tag CSS to load in the head only as required? [duplicate]

I have a shortcode, widget and template tag that need to load CSS. I am registering in init, and enqueueing as required. The only problem is, it is adding the CSS loader at the bottom of the page, ...
Chris Howard's user avatar
0 votes
1 answer
2k views

Calling the first & last post by category in custom post type

I have custom post type for comics, called “comic” and have written a basic comic navigation. First —previous — (current) title — next — and last comic. In functions.php, this code calls for the ...
Hoa's user avatar
  • 3
0 votes
0 answers
162 views

edit_post_link returns blank

I'm using edit_post_link in The Loop and the function keeps returning the $before and $after arguments with blank content. <?php edit_post_link('edit', '<p>', '</p>'); ?> returns &...
b3asts's user avatar
  • 11
0 votes
0 answers
476 views

'Post_tag' taxonomy tags don't link to existing posts in CMS

I'm using this bit of code to retrieve the object data for post_tag taxonomy. <?php $tax = 'post_tag'; $tax_terms = get_terms($tax); if ($tax_terms) { foreach ($tax_terms as $...
sledgeweight's user avatar
0 votes
0 answers
141 views

Get list of body classes for X page?

Is there a way to grab the list of body classes for X page? I tried: <?php get_body_class('home'); ?> but got a console error for function not defined.
Desi's user avatar
  • 1,199
0 votes
1 answer
3k views

Getting custom post type author and date published

In underscores I can get my custom post type just fine with pre get posts along regular blog posts. However the date published and author does not display. How can I modify my template tag (...
cristovaov's user avatar
1 vote
1 answer
376 views

Is there a way to display a menu using the ol tag instead of the default ul tag?

I'm trying to display a menu using wp_nav_menu(). The default markup that the function generates is a menu parented by a <ul> tag like so: <ul> <li><a>Menu 1</a></...
Abel Melquiades Callejo's user avatar
0 votes
1 answer
72 views

Custom Fields Question

I'm new to wordpress and I am trying to understand these custom fields. I read the wordpress codex page refering to custom fields but I have some questions. I take for example my site. I created a ...
Alin Tanase's user avatar
0 votes
1 answer
3k views

the_category() tag not styling HTML or CSS

I am having problems getting my the_category() template tag to style accordingly with the rest of my theme. I believe this is because the HTML isn't output the same way as the the_author() and ...
Travis Patron's user avatar
0 votes
2 answers
78 views

comments_number fails to print

I want to display the number of comments on a post using the template tag <?php comments_number( $zero, $one, $more ); ?> However, for some reason this tag does nothing and it is ...
Travis Patron's user avatar
0 votes
1 answer
198 views

How to modify template tags function?

By default, get_user_meta returns an array, a single value or false. I want to change the return value somehow. How to do that? I want to modify the return type of a template tag get_user_meta inside ...
manojadams's user avatar
3 votes
1 answer
7k views

Wordpress function/template tag to get first n words of the content

OK, this might be a duplicate, I was just unable to put my idea in proper search terms, sorry for that! Is there a built-in function or template tag to get the first n words of the content? I mean ...
Jaromír the Greenhorn's user avatar