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
1 answer
44 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, ...
user avatar
  • 101
0 votes
1 answer
25 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) ...
user avatar
0 votes
1 answer
257 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 ...
user avatar
  • 838
0 votes
1 answer
41 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, '...
user avatar
  • 3
0 votes
1 answer
52 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 ...
user avatar
0 votes
0 answers
80 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 ...
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: ...
user avatar
0 votes
3 answers
267 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</...
user avatar
1 vote
1 answer
723 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 ...
user avatar
1 vote
1 answer
51 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,...
user avatar
  • 23
0 votes
0 answers
31 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 ...
user avatar
  • 1
0 votes
1 answer
706 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 ...
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 ...
user avatar
  • 137
1 vote
1 answer
36 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"> &...
user avatar
  • 11
0 votes
1 answer
89 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, ...
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) { ...
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'...
user avatar
0 votes
0 answers
76 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; ...
user avatar
  • 51
0 votes
1 answer
224 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 ...
user avatar
  • 1
0 votes
1 answer
165 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 = ...
user avatar
0 votes
1 answer
30 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 ...
user avatar
0 votes
0 answers
431 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 ) ) . '">' ...
user avatar
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 ...
user avatar
1 vote
1 answer
31 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 => $...
user avatar
  • 811
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 ...
user avatar
0 votes
0 answers
34 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 ( ! ...
user avatar
  • 3,946
0 votes
2 answers
257 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'); ?> ...
user avatar
1 vote
3 answers
93 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 ...
user avatar
  • 11
0 votes
2 answers
43 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 ...
user avatar
0 votes
1 answer
163 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-...
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 ...
user avatar
3 votes
1 answer
826 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 ...
user avatar
1 vote
1 answer
186 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 ...
user avatar
0 votes
1 answer
44 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 ...
user avatar
0 votes
1 answer
150 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 ...
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 ...
user avatar
  • 19
0 votes
1 answer
234 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, ...
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 ...
user avatar
  • 3
0 votes
0 answers
153 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 &...
user avatar
  • 11
0 votes
0 answers
429 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 $...
user avatar
0 votes
0 answers
138 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.
user avatar
  • 1,159
0 votes
1 answer
2k 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 (...
user avatar
1 vote
1 answer
367 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></...
user avatar
0 votes
1 answer
68 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 ...
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 ...
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 ...
user avatar
0 votes
1 answer
163 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 ...
user avatar
2 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 ...
user avatar
0 votes
0 answers
81 views

Own Custom Tags/Category page ( posts)

I want to make a page where on each tags : My page should look alike : http://www.missmalini.com/aamir-khan-2/ Above page is coming from http://www.missmalini.com/celebrity-fan-pages/ this are ...
user avatar
-2 votes
1 answer
2k views

Adding more information to a Content Product Category

The template content_product_cat is responsible for showing the product categories images and its name. I want to display more information below the name of a category e.g a Category called 'Books', I ...
user avatar
  • 484