Articles of template tags

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 using two of these queries (with different category include strings) in a jQuery tab to display different lists of categories. Problem […]

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 the_permalink() by its name?

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 create a template tag named show_related_portfolios(). In contrast, I can create a file named content-related-portfolios.php, and use it like get_template_part( ‘content’, […]

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 hasn’t been entered, then show ‘XXX’, else show ‘ZZZ’.

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 class=”background” src=”<?php echo $background ?>” <?php if(is_wpThemeCustomizer()) echo ‘style=”display:none”‘ ?>/> I could do it in javascript […]

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 false when the current “post” is a page, attachment, etc. This is what the Codex says: is_single() returns true if […]

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 to the current site. On my single install, using get_home_url(); would give me, which was great, and if I moved […]

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 the_content(). Thanks!

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 links and some images should depend of the choosen top-menu-item. Example, page-structure: * Start * Products * Prod.categ. […]

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 for a post type other than ‘post’ The result of this is that is_home() is […]