Questions tagged [theme-development]
Themes create the public (front-end) interface for a WordPress site.
4,454
questions
111
votes
4
answers
112k
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
...
99
votes
7
answers
18k
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 ...
95
votes
3
answers
43k
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 ...
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
56k
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 ...
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 ...
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 ...
54
votes
5
answers
80k
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 ?
52
votes
11
answers
74k
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 ...
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 ...
41
votes
4
answers
135k
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?
41
votes
2
answers
119k
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?
40
votes
5
answers
153k
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: ...
39
votes
2
answers
33k
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 ...
37
votes
5
answers
30k
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
...
37
votes
3
answers
209k
views
Meaning of "if ( is_home() && ! is_front_page() )" snippet?
I see the following code a lot in index.php files. I understand that is_front_page() returns true when viewing the Site Front Page (whether displaying the blog posts index or a static page), while ...
37
votes
10
answers
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 (...
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 ...
34
votes
5
answers
15k
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 ...
34
votes
6
answers
26k
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, ...
32
votes
3
answers
37k
views
Using wp_add_inline_style without a stylesheet
I need to add custom inline styles to the header of a custom theme I'm creating. I've come across the wp_add_inline_style() function, which works but doesn't really suit me as it depends of a specific ...
32
votes
3
answers
21k
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?
30
votes
2
answers
69k
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 ...
29
votes
1
answer
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 ...
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
1
answer
20k
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 ...
28
votes
5
answers
11k
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 ...
27
votes
2
answers
143k
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 ...
25
votes
1
answer
21k
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?
24
votes
4
answers
84k
views
How can I get page slug
How can I get the slug of a page or post?
24
votes
12
answers
95k
views
CSS not updating in browser when I change it
I am working on the CSS of my wordpress site. When I make changes and refresh the page the changes are not reflected. When I clear the browser history and cache the changes are still reflected. When I ...
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 ...
24
votes
1
answer
40k
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).
...
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.
23
votes
4
answers
60k
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
...
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 ...
22
votes
6
answers
29k
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 ...
21
votes
10
answers
168k
views
How to add custom css file in theme?
Some themes ask you not to edit the style.css file, instead use custom.css file. If you write code on custom.css, it will overwrite the same element style in style.css. I think this is done in order ...
21
votes
2
answers
51k
views
Display Search Result Count
Until now I have been using below code to get the number of results when someone searches and to display that count.
<?php /* Search Count */ $allsearch =& new WP_Query("s=$s&showposts=-1")...
20
votes
2
answers
48k
views
Custom post type - order field
In a custom post type, is there a way to include the "order" field that is available for pages?
Is there any built-in logic that prevents duplicate values in the "order" field?
The idea is to be ...
20
votes
3
answers
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
5
answers
88k
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 ...
19
votes
8
answers
2k
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?
18
votes
8
answers
65k
views
How to remove dashicons.min.css from frontend?
Is there any way to remove the dashicons.min.css file from the frontend? I know that they are used by the admin panel, but my theme doesn't use them so it's an unnecessary request.
18
votes
3
answers
33k
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>
&...
17
votes
6
answers
72k
views
theme path in javascript file
I need to include the path to my theme file within a javascript file. How would I go about this? I have already tried:
var templateUrl = "<?php get_stylesheet_directory_uri(); ?>";
function ...
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?
17
votes
4
answers
11k
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 ...
17
votes
4
answers
12k
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 ...
17
votes
4
answers
9k
views
Issues with title-tag and document_title_parts
Wordpress version 4.5.1
I'm trying to dynamically update page titles on a particular template. After lots of digging and learning about the wp_title() changes, I'm attempting to use ...