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

learn more… | top users | synonyms

6
votes
1answer
1k views

How do I display a tag cloud under my post that only shows tags from that post?

I've be looking to add a tag cloud under my post that only shows tags pertaining to the post. The tags shown should be in a tag cloud format; the post tags that have more post tagged with it will be ...
4
votes
1answer
4k views

why doesn't the_content() work in this {single-custom_post_type.php} page?

This code is from my page single-publication.php. It outputs the relevant custom fields etc (here wrapped in template tags), but the_content() won't output the post content. I've resorted to using ...
3
votes
4answers
594 views

How to show the real post date in a draft

When looking at a draft post, get_the_date() only seems to return today's date, not the post date, even if I have selected another date on the post edit screen. Is there a way to show the "actual" ...
3
votes
2answers
808 views

How to get the clean permalink in a draft?

When I use the_permalink or get_the_permalink in a draft or scheduled post, the URL provided is not the "final" permalink—it is the unpretty ?p=xxxxx version. How can I get the final, "clean" ...
3
votes
1answer
3k views

Echo author ID in author.php

This is probably a super simple question. But how do I echo the ID of a user on author.php? I've tried the_author_meta('ID') But it didn't seem to want to work. I want to echo it at the end of a ...
3
votes
2answers
2k views

Remove line breaks in wp_list_categories()?

I am trying to output a list of categories per an article. I am using the following code, <?php wp_list_categories('child_of=270&style=none'); ?> (string) Style to display the categories ...
3
votes
2answers
854 views

Making a Shortcode [NEXT] and [PREVIOUS] to place into specific posts for post navigation

I really need some help, I dont know where else to turn with this request. I'd like to add a shortcode to one of my posts. The template tags get_next_post() and get_previous will not work for me since ...
3
votes
1answer
62 views

When to use which plugin output method?

I'm a Drupal dev, getting into Wordpress. So far as I can tell there are a few different methods by which a plugin can output content on to a Wordpress site: Shortcode Rewrite API Widget API ...
2
votes
2answers
2k views

Manually set global $post vars with an ID, in order to use template tags

I have a function retrieving ID's of posts by very specific means. I need to be able to set the global $post in order to use functions like the_content(), which does not allow an ID as a parameter. ...
2
votes
1answer
86 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
5answers
4k views

On the category page, get the category object

Right, hopefully a nice and simple one... I'm on a category page with the id of 4, I want to get the category object back so I can interogate a few values. I've had a good old look in the WP codex ...
1
vote
2answers
148 views

How can I link a CSS file only on single posts?

If I understand is_single() correctly, it's only supposed to return true when the current "post" (in a generic sense) is a literal post (i.e., it has a post_type of post), and that it will return ...
1
vote
2answers
962 views

Minor css-change based on topmenu - how?

I want to make minor css-changes based on the choice of the top (root) menu. What's the proper way to handle this in WP? //edit// It's a website (pages), no blog, and basically, the colors of some ...
1
vote
2answers
150 views

How to check if I am inside the WP Theme Customizer preview?

I have some elements showing on the home page that I do not want to display in the Theme Customizer preview window. Is there a simple check in PHP that I can use for that ? For example: <img ...
1
vote
1answer
179 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 ...
1
vote
1answer
313 views

How do I reset this wp_list_categories query?

How do I reset a query that generates a list of categories with wp_list_categories? The query below builds a two column list of categories that is then displayed with the second code chunk. I'm ...
1
vote
1answer
30 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
vote
1answer
791 views

Check if password protected post is visible

Is there anyway of checking if a password protected post is visible / not visible? I want some thing that says this; If the post is password protected (that parts fine) and the correct password ...
1
vote
2answers
1k views

Getting tagid from tagname

Currently I am working on a rating plugin. You can see the code I got so far below: <?php if (function_exists('get_highest_rated')): ?> <ul> <?php get_highest_rated_tag(12, 'both', 0, ...
1
vote
2answers
2k views

Displaying page content in category archive (archive.php)

I'm new to template editing in wordpress and I'm trying to get a page description to show up on my site but it is not appearing. The URL I'm trying to get to display the description is here: ...
1
vote
2answers
712 views

tag.php pagination and query_posts()

Having some issues on the tag.php page. Right now it just give me a "nothing to show" If I have no query it shows posts, but I want to change the number of posts per page. Changing the reading ...
1
vote
1answer
579 views

Exclude a category from the_category in the single post page

I want to include something like the the_category function in a WordPress post, which by default echoes a list of links to all categories the post is attached separated by comma, but I want to exclude ...
1
vote
1answer
474 views

Multiple templates for single custom post type

Does anybody know of a way to modify the wordpress template process so that a single custom post type can be displayed on two separate templates based on the value of a custom field. For example I ...
1
vote
0answers
45 views

Checking if a specific date archive is being displayed

The is_month(), is_year() or is_week functions don't accept arguments. Are there any other functions available that I'm able to use to determine if I'm viewing specific month/year/week archive ? Or do ...
0
votes
3answers
721 views

How to support letting users add their OWN logo to a custom theme?

I am a rookie theme developer (3 months in) and I am trying to figure out how to implement the following functionality: The theme I am building has a logo which I would like for users to be able to ...
0
votes
3answers
2k views

Multisite get_home_url(); - Getting URL for current site

What would be the replacement for get_home_url() when using a multisite? For example, if I have one theme installed across several sites, and within the theme there are links that need to be specific ...
0
votes
2answers
543 views

<!--more--> help

I have a custom post type called "Blog", in my templates I looping over the blog type and doing the following, <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> ...
0
votes
2answers
421 views

Is it possible to add a child post into the parent page?

Is it possible to add a child post into the parent page? Basically I have a 1 parent page and it has 2 child page that has a simple content , and I want the child page content to put also in the ...
0
votes
2answers
336 views

Return function only on certain pages

I'd like this function to only return on certain pages. How might i do that? // Retreats Accordion function retreats_accordion() { ?> <!-- accordion root --> <div id="accordion"> ...
0
votes
2answers
191 views

Template tags vs get_template_part() vs functions.php

When to use template tags and when to use get_template_part() and when to use function.php? I am confused at them. For example, if I want to show related portfolios under single portfolio, I can ...
0
votes
1answer
88 views

navigation link based on custom field

I'm looking for a method to order posts by a custom field so that the navigational links on a single post template would point to the next or previous post in the sequence defined by a number in a ...
0
votes
2answers
1k views

Displaying list of subcategories and not parent category

I have a blog which has three top level categories. Each top level category has a list of sub categories. I am displaying only certain top level category posts in certain sections of the website. ...
0
votes
1answer
326 views

What is the p parameter in a get_posts() parameter array?

I've seen code that looks like this: get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment')); What is the definition of the p parameter and is it documented anywhere? I can't find ...
0
votes
2answers
1k views

How to change a custom query into a standard loop?

I'm trying to modify how results are displayed in a post list that's currently controlled by the code below. However, it's not built in the WP_Query while ( $the_query->have_posts() ) : ...
0
votes
1answer
4k views

Get permalink and title by post name?

In the theme there is a custom post type called faq I just want to get certain post by its name (NOT by id cause no id exist). <?php query_posts('post_type=faq') ?> how to get the_tile() and ...
0
votes
1answer
983 views

How to query details of images in gallery that is attached to a post

I have several images attached to each post. I need to generate a gallery, but because it's heavily customized I don't want to use a gallery plugin, nor the gallery short code. It's also situated in a ...
0
votes
1answer
23 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 ...
0
votes
1answer
26 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 ...
0
votes
1answer
1k views

Setting selected term_id with wp_dropdown_categories?

I'm using this code to get the term_id of a custom taxonomy. The drop down does list the terms of the taxonomy Type. When I print the $terms variable I see the term ID of the post i'm editing on the ...
0
votes
1answer
1k views

page.php – is_front_page NOT WORKING

I'm trying to target my landing page with is_front_page or is_home in my page.php file but it's not working. I have set the settings > reading to a static page. However, if I create a page-home.php ...
0
votes
2answers
556 views

Conditional template tag for buddypress pages

I'm trying to assign a special template only to buddypress pages (activity, members, profile...). All other posts / pages use a different template. Problem is: I just can't find a good way to tell if ...
0
votes
1answer
125 views

is_front_page use in sidebar.php

I want to introduce some code into sidebar.php dependant on whether the site was on the front page or not. ( I have a static front page and am using the front-page.php file ). To cut a long story ...
0
votes
1answer
688 views

Show the current post's category, without displaying parent category

I have a series of posts that all reside within a 'Main' parent category. Various posts are assigned to sub-categories. What I need to do is display the direct parent category for the currently ...
0
votes
1answer
728 views

Why does this search.php not work?

This search.php shows all the results from a said search however, doesn't include the title, The Search Results For...... and search query amount; or even the no searches found and prints the ...
0
votes
1answer
46 views

odd behaviours from template tags

Some of my template tags are playing up, and they have left me confused. On one site, that has been live for over a year without any of these issues, on all the pages that have custom query loops, ...
0
votes
1answer
802 views

how to limit and display tag?

Hi i need to show random 3 tags for a post. all my posts have been tagged with more than 10 tags, i need to display any 3 tags randomly. for eg: A sample post <a href="/tag1">Tag1</a> ...
0
votes
1answer
489 views

Second Level Menu

I'm trying to figure out how to do, Second Level Menu as a template function, that persistent when visiting any level, whether its a top level page, or a grand children Page. Any Ideas?
0
votes
2answers
287 views

How can I detemine the parameters needed by the_widget()?

I'm working with an old (now unmaintained) widget, which only allows one instance. Since I want to have a different sidebar on the homepage and I want this widget on both sidebars, I figure I need to ...
0
votes
1answer
96 views

how to add # before tags?

Like Lifehacker and several other sites, would like to know how to add # before tags displayed on the site. for e.g. instead of a tag like "abc", how about "#abc". - is there a way to automatically ...
0
votes
1answer
34 views

Is there a template tag I can use to link to the archive page corresponding to the month that a post was published on?

For example, if the post was published on may 5th 2011, then clicking on "May 5th, 2011" would show all posts published in May 2011. How can that be done?