Questions tagged [theme-development]
Themes create the public (front-end) interface for a WordPress site.
333
questions
99
votes
7
answers
17k
views
Where to put my code: plugin or functions.php?
Is there an easy to understand scheme to decide what kind of code belongs to a plugin or the theme’s functions.php?
There are many cases and many debates about that topic, mostly because there are ...
111
votes
4
answers
111k
views
Menu items description? Custom Walker for wp_nav_menu()
Normal Wordpress Menu looks like:
Home | Blog | About us | Contact
But I've seen many pages with descriptions under these links:
Home Page | Our Blogs | About us
| Contact
...
94
votes
3
answers
42k
views
Between functions.php (theme), widgets, and plugins, which is loaded first?
Customer asks if a specific carousel plugin he uses can be widgetized. That means I should create a widget inside functions.php which calls the plugin's function. That means that the plugin's code has ...
73
votes
4
answers
33k
views
What is the preferred way to add custom javascript files to the site?
I've already added my scripts, but I wanted to know the preferred way.
I just put a <script> tag directly in the header.php of my template.
Is there a preferred method of inserting external or ...
16
votes
6
answers
12k
views
How to include jQuery and JavaScript files correctly?
I'm doing it right now with the following code:
function uw_load_scripts() {
// De-register the built in jQuery
wp_deregister_script('jquery');
// Register the CDN version
...
36
votes
1
answer
8k
views
Worthwhile to restrict direct access of theme files?
I've run across the following snippet in themes from time to time:
if ( ! defined('ABSPATH')) exit('restricted access');
It's at the beginning of some (all?) PHP files in a theme and it's supposed ...
24
votes
2
answers
6k
views
Does the functions.php file ever get called during an AJAX call? Debug AJAX
Trying to figure out an issue a fellow programmer is having. I was wondering if the functions.php file get called at all when you do admin side AJAX? I know that when you do an AJAX call a part of ...
75
votes
27
answers
12k
views
Software for WordPress Theme and Plugin Development? [closed]
What software do you use for your WordPress related needs?
Please state your OS.
On windows XP I use:
filezilla (FTP)
notepad++ (for reading of PHP / CSS files)
firebug (a firefox extension to ...
14
votes
5
answers
14k
views
Theme Activate Hook
I would like to write a function to email me the URL of the website when my theme is activated.
What is the hook initiated when the theme is activated?
13
votes
2
answers
4k
views
How can I add a URL field to the attachments window?
For example...
add_action('init', 'reg_tax');
function reg_tax() {
register_taxonomy_for_object_type('category', 'attachment');
}
Adds a "Category" input field to the media manager and ...
24
votes
1
answer
6k
views
What is the advantage of using wp_mail?
What is the advantage of using wp_mail() over mail(). Codex says they're similar, but they seem to be very similar.
6
votes
2
answers
20k
views
Proper use of Output Buffer
I'm attempting to use actions to override function calls I currently have throughout a template (to make updating certain replicated sections easier). For example, in archives.php I have the following:...
52
votes
6
answers
9k
views
framework for plugin/theme options panel? [closed]
I found that the longest part of a plugin or theme development is creating the options panel, at least in my case.
So i like to know what's your take on that.
Do you use a ready made framework or ...
4
votes
2
answers
7k
views
How to use logout function on custom menu link?
All
I am using wordpress custom menu, and there is one menu as Logout.
I know wordpress Logout function <?php echo wp_logout_url(); ?>
But how can i use it in custom menu ?
1
vote
1
answer
1k
views
What's the difference between hooks, filters and actions? [duplicate]
It seems like the terms hooks, filters and actions are used interchangeably. What's the difference between them? What do they do? How do I use them?
83
votes
3
answers
28k
views
Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
Has anyone used autoloading and/or PHP namespaces within a plugin or theme?
Thoughts on using them? Any harm? Pitfalls?
Note: namespaces are PHP 5.3+ only. Assume, for this question, that you know ...
76
votes
3
answers
55k
views
When to use is_home() vs is_front_page()?
I've found that is_front_page appears to return true when I'm viewing the home page and have a single sticky post assigned there.
It also returns true when I've assigned a page as the static front ...
23
votes
2
answers
17k
views
How to show a custom meta box on the "Quick Edit" screen?
I've used add_meta_box() to add a custom meta box to the WordPress edit window on both pages and posts.
How can I make this meta box also show on the "Quick Edit" screen?
Ideally, I'd like it to ...
17
votes
4
answers
11k
views
Should Plugin Folders Include a Blank index.php File?
WordPress itself, in the wp-content folder, includes an empty PHP file which looks like this.
<?php
// Silence is golden.
?>
Should plugins include an empty file like this as well to stop ...
10
votes
1
answer
6k
views
Enqueue a stylesheet for login page and make it appear in head element
I try to style the login page in my theme. Very simple:
add_action( 'login_enqueue_scripts', function()
{
wp_enqueue_style( 'TEST', get_template_directory_uri() . '/css/login.css' );
});
...
4
votes
4
answers
5k
views
Automatic Updates For Private And Commercial Themes?
Is there any way to get wordpress to check for, download private theme updates?
I found this plugin for private plugin updates....
http://w-shadow.com/blog/2010/09/02/automatic-updates-for-any-...
2
votes
2
answers
554
views
Guidance with The Loop for CMS
Maybe I'm going about this the wrong way but this is my scenario... I would like to use WordPress as a CMS rather than a blogging platform. I have a website that will have somewhere between 25-50 ...
32
votes
3
answers
20k
views
Why does WordPress use outdated jQuery v1.12.4?
While checking the source code, I saw that WordPress uses jQuery v1.12.4. Why does WordPress use this outdated version of jQuery?
17
votes
6
answers
22k
views
How do I remove a pre-existing customizer setting?
My theme doesn't use the tag line, how can I remove it from the customizer?
15
votes
3
answers
22k
views
How to Link External jQuery/Javascript files with WordPress
So I'm using Starkers to base my next WP theme on and I've run into a small issue, I was including my own version of jQuery in the header.php file but when inspecting my site using Firebug I noticed ...
12
votes
6
answers
38k
views
Get the first image from post content (eg.: hotlinked images)
I am using this code directly from the codex.
function echo_first_image ($postID)
{
$args = array(
'numberposts' => 1,
'order'=> 'ASC',
'post_mime_type' =>...
11
votes
2
answers
12k
views
How to store widget fields data as an array?
I am creating a widget, it needs to store about 10 IDs. Right now I'm using following field method to store each of the ID in a separate field. It stores data of each field in a separately in the ...
9
votes
1
answer
2k
views
Is it ok to use a function to output the text domain name in a wordpress theme
I am working on a theme and I want to make it available for translating. I have not been including a text domain on translated text because I don't know what the text domain is going to be yet. I ...
7
votes
1
answer
3k
views
Enqueue Stylesheets After Theme's "rtl.css"
I am currently developing a theme with internationalization support, and would like to load stylesheets after my theme's rtl.css (an alternative style.css loaded for languages with a right-to-left ...
4
votes
3
answers
13k
views
How to export/import theme customizer settings?
I am wondering if it is possible to export theme customizer settings(theme_mods) to be imported into another install of the same theme. I know that the settings are saved into the database so I am ...
4
votes
2
answers
1k
views
Adding items to page template dropdown on Page Edit Screen
I am developing a WP theme with MVC approach. It only have index.php, functions.php and styles.css on the parent directory. So, I do not want to place page templates on it rather then I want to ...
28
votes
5
answers
3k
views
Why have <?php and ?> on every line
I've seen this convention pretty much everywhere, and, at times, it comes close to driving me nuts:
<?php //The loop ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php ...
28
votes
5
answers
10k
views
How To extend WP_Customize_Control
I'm looking for a way to add a new kind of control to the customize live preview panel. I have seen how to add new sections to the panel using
add_action( 'customize_register'...
The control I want ...
16
votes
2
answers
24k
views
Why ignore_sticky_posts argument is in sticky post query?
We all know that ignore_sticky_posts is used to exclude sticky post from your custom query.
But why on WordPress Theme Development documentation, they use ignore_sticky_posts in querying sticky posts?
...
12
votes
2
answers
3k
views
How to move page template files like page-{slug}.php to a sub-directory?
I want to move page template files like page-{slug}.php to a sub-directory within my theme, in a way that WordPress will recognize them automatically. If the page templates of the said form doesn't ...
11
votes
4
answers
6k
views
Do I actually need to link my theme's style.css in the theme files
So I am developing a wordpress theme using a series of LESS files for the CSS. These compile using codekit to a combined and minifed stylesheet that I use for the theme's styling.
I understand a ...
9
votes
2
answers
31k
views
Form to Add Posts to Custom Post Type
Basically I want to display a form on my blog (on a certain page) that will allow anyone to fill it out and it will create a post in a custom post type.
I saw the answer once before but I can't find ...
8
votes
1
answer
19k
views
How do I cleanly override a plugin's CSS with a child theme?
I have taken it upon myself to adhere to WordPress conventions so I can have a clean, sexy child theme. However, I am unsure how to proceed on a certain issue.
I would like to override the CSS for ...
7
votes
2
answers
5k
views
How to add a checkbox element to attachments editor with example
The code below adds a custom input field to the attachments editor. How can I convert the text input to a checkbox and get/set the value of the checkbox on load and save?
Note: "input" => "...
6
votes
3
answers
12k
views
How to move page templates to custom folder?
I created page templates that use the page slug, for example, page-contact.php, page-gallery.php etc. or page id, for example, page-2.php, page-11.php etc.
How can I move these templates to a ...
6
votes
3
answers
2k
views
Call dynamic_sidebar but include/exclude named widgets?
Is it possible to include or exclude specific named widgets that are assigned to a named dynamic_sidebar call?
For example, if I've registered a sidebar named "my_sidebar" and the user had placed a "...
5
votes
2
answers
8k
views
Theme Customizer : how to create multiple-level panel
Is there a way to create deep-level sub Panel in Theme Customizer(like roots of plants) ? My theme that I have been developing seem to be more complicated. I think that if we can create deep-level sub ...
5
votes
2
answers
402
views
Best practice for including plugins as part of a theme?
I'm working on a theme that includes some functionality I've developed as separate plugins (as I'm hoping to release them independently).
I'd like to include these plugins as part of the theme core ...
5
votes
3
answers
13k
views
How to get Images included in Post
is possible to get images added to a post programmatically? I am working on custom template (my first) and I need to display Images added to a post in specific way.(first image as title image and the ...
4
votes
2
answers
6k
views
Custom attribute for the title tag with wp_title()
Can i add the itemprop to the title element and still use wp_head() and add_theme_support( "title-tag" )?
I want to create a theme and get it approved on wordpres.org which uses microdata.
The ...
1
vote
1
answer
3k
views
Creating Page Based on Category
I'm using WordPress 4.0, and the Hemingway theme.
I've created a custom page template which currently pull blog posts based on the category I give it. However I'm currently using
query_posts('...
1
vote
1
answer
149
views
Questions about WordPress.org theme review
I have created one theme. The theme was denied today for the following reasons:
Theme Review:
Themes should be reviewed using define('WP_DEBUG', true); in wp-config.php
Themes should be ...
0
votes
1
answer
3k
views
How to check if post has any tag?
I am displaying post tags like this:
<div class="tags"><?php the_tags('<span>Tags</span>' , ' '); ?> </div>
It works fine, but if the post does not have any tag, then ...
0
votes
1
answer
201
views
Trouble with conditional tags
I've got some code I want to run on every page other than the blog page and the archive page.
If I use
<?php if ( !is_home() ) { ?>
The code correctly doesn't show on the blog page.
If I ...
0
votes
2
answers
21
views
Not Able to Access Terms Under Custom Taxonomy Archive
Having a Custom Taxonomy called movie-genres
'rewrite' => array('slug' => 'movie-genres', 'with_front' => true) );
register_taxonomy( 'movie-genres', array( 'movies' ), $args );
And I have ...