0
votes
1answer
41 views

Change the template when the user is not logged in using page_template filter (it does not work)

I want to print other template when the user is not logged in. I use this code: function restrict_access_to_unlogged_users($template) { global $post, $pagename; $new_template = ...
0
votes
1answer
60 views

Add filter multiple times using only one master function

Is it possible to use add_filter with lets say an array of different values? to achieve something like the following: foreach($templates as $name) { add_filter( 'single_template', function ( ...
0
votes
1answer
73 views

Add Element as a Filter to the_content

Can I and How would I add a filter in the function.php that would add a HTML element around the content when the_content is used? This would be similar to what you can do with the_title. i.e: ...
1
vote
2answers
434 views

Custom Post Templates

The Issue: I am looking for custom single post templates, to add or remove individual elements as a function of a normal single post. There are a lot of ways to create custom post templates for ...
0
votes
2answers
86 views

Shortcode / plugin with custom (flexible) output

Following scenario: I'm building a theme framework which I want to reuse in various themes of mine. In this framework there is a collection of many shortcodes. For exemplary illustration of my ...
0
votes
1answer
102 views

Extending body classes in front- and backend

I want to extend both body classes for the front-end as well as for the admin area. I have seen some snippets floating around, which led me to the following ...
0
votes
1answer
256 views

What filter or action hook to use in order to load some code before the template begins printing in BuddyPress? [closed]

I would like to load some code before the template begins printing in BuddyPress. What filter or action hook should I use? I tried a number of them (such as bp_head, bp_include, bp_init), but none of ...
0
votes
1answer
372 views

Replace single_template filter with what for default posts?

I was going through a tutorial on Justin Tadlock's blog but it uses the single_template filter, which was removed in 3.4. The codex says to use {$type}_template but if I use "post_template" with the ...
2
votes
2answers
296 views

Load different template file when condition met?

If I visit a page on my WordPress site, WP goes and determines what template file it should use based on the template hierarchy. If I'm doing some logic checking in the hook init and say my ...
1
vote
1answer
653 views

Problem getting single_template filter to work - I want to serve a different single.php file for posts in a certain category

I am trying to customize the behavior of my blog to serve a specific single post template based on the category the post is assigned to. I came across this filter in my parent theme which is what ...
12
votes
5answers
5k views

single-{$post_type}-{slug}.php for custom post types

My favorite part of the Wordpress template hierarchy is the ability to quickly create template files for pages by slug, without having to edit the page in Wordpress to select a template. We can ...
0
votes
1answer
121 views

output custom Posts on a Page

I'm trying to write a function that will output a set of posts on a page. Because I want to display more than just the post titles, wp_get_archives() won't do (I think). The function to add the post ...
-1
votes
1answer
114 views

if i put the code in my theme's function.php file can it work?

$gr_preview_theme = $_GET['preview_theme']; $gr_preview_css = $_GET['preview_css']; if (! $gr_preview_css ) $gr_preview_css = $gr_preview_theme; if($gr_preview_theme && ...
3
votes
3answers
2k views

Loading template files from a subfolder in my theme?

I am working on a site that will have up to 30 templates in it. I don't want to have all those templates at the root of my theme folder cluttering up everything. I know how I can modify the ...