Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [theme-development]

Themes create the public (front-end) interface for a WordPress site.

102
votes
4answers
94k 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 ...
86
votes
6answers
14k 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 ...
69
votes
27answers
11k 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 ...
69
votes
3answers
22k 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 ...
68
votes
4answers
31k 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 ...
63
votes
3answers
41k 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 ...
48
votes
6answers
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 ...
38
votes
4answers
104k views

How do I get the theme URL in PHP?

I need to get the URL of my theme directory to reference an image in the theme's image/headers directory. How is this done in PHP?
37
votes
10answers
13k views

What process do you use for WordPress development? [closed]

I'm interested in how other people develop themes and plugins for WordPress. To me, the in-browser editor in the admin panel just doesn't cut it. Currently, I'm just using an IDE with a PHP plugin (...
34
votes
5answers
42k views

Get the blog page URL set in Options

I have set the blog to be a different page other than the home page. I want to have a link from single.php to this blog page. Is there any function that pulls out URL for the blog ?
32
votes
2answers
22k views

What is the constant WP_USE_THEMES for?

Regarding the WP_USE_THEMES constant, the Codex states: If you are using The Loop inside your own design (and your own design is not a template), set WP_USE_THEMES to false. But what is the ...
31
votes
10answers
40k views

How to create .pot files with POedit?

I've spent hours today on what seemed like something really simple, which is to create a .pot file for a Wordpress theme that I'm creating. I've read the Smashing Magazine article, the Tutsplus ...
31
votes
6answers
23k views

How to detect mobile devices and present them a specific theme?

I would like to create a new modified version of my theme (check my profile if needed) to present to visitors if I detect that they are visiting the site from a hand-held device, like iPhone, Android, ...
31
votes
5answers
12k views

How Do I Protect My Premium WordPress App Theme from Copying?

They say WordPress is GPL, and therefore all plugins and themes made with it are supposed to be GPL. Fine, but if I spent three months coding an extremely complex app theme with the intent on selling ...
31
votes
1answer
6k 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 ...
28
votes
1answer
44k views

How to add posts to custom menus?

I'm just beginning to work the "Custom Menu" functionality that was introduced in 3.0 into my theme. I like everything about this new capability and API, with one exception: Why no posts? I can ...
27
votes
5answers
7k 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 ...
26
votes
2answers
61k views

How to get the path to the current theme?

This code is used to get the directory of the current plugin: plugin_dir_url( __FILE__ ). What should I use to get the directory of the current theme?
25
votes
2answers
65k views

ajaxurl not defined on front end

I am trying to create a ajaxform on the front side. I am using the code jQuery.ajax( { type: "post", dataType: "json", url: ajaxurl, data: ...
24
votes
5answers
2k 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 ...
23
votes
4answers
11k 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?
23
votes
2answers
5k 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 ...
23
votes
2answers
13k 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 ...
22
votes
2answers
49k views

WordPress Theme Preview Image

I'm developing a custom WordPress theme. When I go to select themes in the Appearance menu, my theme does not have a preview image. Is there something I need to do to get a preview image to show up? I ...
19
votes
4answers
16k views

Why when I submit a form in wordpress it loads a 404 page though URL is correct

I am just creating a simple contact form, but I notice that it seems to post to an invalid page. The url in the browser is correct but the title of the page is "Page not found" on the top of the page ...
19
votes
3answers
3k views

How important is it to enqueue a theme's stylesheet?

I have trawled the net looking for an answer to this, but for some reason all I can find are actual examples, but without that particular explanation, which is clear say in the case of scripts. Can ...
19
votes
1answer
5k 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.
17
votes
4answers
13k views

How to add CSS class to custom logo?

I enabled custom-logo for my theme and have it printed with <?php the_custom_logo(); ?> into the header. Is there any chance to simply add some more classes to this image directly? Per default ...
17
votes
2answers
11k views

When to use _e and __ for the translation?

What is difference between _e() and __() functions for the translation? In what cases e() and __ ()should be used?
17
votes
1answer
25k views

What is a Theme textdomain?

I've found that any WordPress theme uses this functions, but I don't understand what is the purpose of it and what is it, in this case 'themify'? Here are some examples in Themify functions.php: 1). ...
17
votes
8answers
1k views

Where can I learn to create my own theme?

I want to learn how to create a theme for WordPress. Where can I find information and resources on how to do it?
16
votes
3answers
6k views

Is wp_is_mobile() effective?

I'm going to test the user agent to load a mobile template instead of the desktop theme. There are many mobile detection scripts out there. Does wp_is_mobile() function work well? What is your ...
16
votes
1answer
15k views

What is the difference between front-page.php and home.php? [duplicate]

When developing a theme wordpress grant us to use front-page and home page templates, so what is the major difference between these two templates as they seems like identical. I also want to know what ...
16
votes
2answers
15k views

Making update notification functionality for my themes

the question is simple :) I am making a theme that i will use in lots of sites. So, i don't want to go all the site and ftp the files every time i fix a bug or do a theme upgrade. Is there any way i ...
15
votes
6answers
10k 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 ...
15
votes
4answers
60k views

wp_nav_menu(), how to change <li> class?

I'm building a menu for my website. The static is looking like this: <nav> <ul id="menu"> <li class="item_1"><a href="#">Item 1</a></li> <li ...
15
votes
3answers
26k views

Display Menu Name using wp_nav_menu

I have a custom menu that I can call just fine using wp_nav_menu. Is there a way to have the menu name displayed inside an h3 tag before the menu? Ex. <h3>My Menu Name</h3> <nav> &...
15
votes
3answers
14k views

What's the difference between home.php and index.php?

If I create a home.php file, it seems that WP will use that instead of index.php, so index.php is never used? What are the differences between these two template files (located in the theme folder)? ...
15
votes
2answers
77k views

How to display value of custom fields in page

I have a custom post type called 'software', contained within are various custom fields such as subtitle, price, screenshots, download link, etc. I created a function to allow use of the tinyMCE edit ...
15
votes
3answers
20k 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 ...
15
votes
6answers
665 views

What questions do you ask when asked to give an estimate on theme development?

I just recieved an email that asked the following question: "How much will cost to code a WordPress theme?" I cannot answer this question without know the answer to a plethora of other questions. I ...
14
votes
4answers
43k views

How can I get page slug

How can I get the slug of a page or post?
14
votes
4answers
40k views

Custom post type single-{custom}.php not working

I made a custom post type with the machine name special_media_post and wordpress is simply not seeing the single-special_media_post.php. I am at a complete lose. It keeps defaulting to the index.php ...
14
votes
5answers
13k 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?
14
votes
2answers
9k views

Minimum Template Files for Theme Development

WordPress has minimum theme template files as style.css index.php and also some other files as listed here. If the theme developer wants to build theme with less bells and whistles, what are some ...
14
votes
4answers
7k 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 ...
14
votes
1answer
20k views

Can I create my own “Recent Posts” widget or customize the existing one?

I'd like to enable the Recent posts widget with the ability to show a "View All" link when there are more posts than I've currently got the widget set to show. I'd also like to be able to exclude ...
14
votes
3answers
3k views

get_template_part vs action hooks in themes

It seems to me both of these afford the opportunity for the end user to modify a theme without actually editing the themes files (via child themes). My question is, is one method preferred over the ...
14
votes
2answers
4k views

pass object/JSON to wp_localize_script

I've got a working piece of javascript that contains an object literal. But I need to localize it, and I'm ytrying to figure out how to rewrite it so that I can get wp_localize_script() to accet it, ...
14
votes
5answers
9k views

Solutions for generating dynamic javascript / CSS

Let's say you need to generate javascript or CSS code that depends on the current context. For example you have a form on the homepage that fires an ajax request on submit, and a different form on ...