All Questions
99,319
questions
37
votes
7answers
18k views
Sending multipart (text/html) emails via wp_mail() will likely get your domain banned
Summary
Because of a bug in WP Core, sending multipart emails (html/text) with wp_mail() (to reduce chance of emails ending up in spam folders) will ironically result with your domain being blocked ...
36
votes
7answers
42k views
Most efficient way to get posts with postmeta
I need to get a bunch of posts with their metadata. Of course you can't get metadata with a standard posts query, so you generally have to do a get_post_custom() for each post.
I'm trying with one ...
36
votes
6answers
67k views
Template Hierarchy: confused with index.php, front-page.php, home.php
I'm really confused with index.php, home.php and front-page.php. In many cases even though I had an index.php, I overwrite it with front-page.php. But recently, I became aware about home.php.
What's ...
36
votes
7answers
68k views
How can I show posts only if meta_value is not empty
Three people have already tried to solve this, and we're coming up nil. I want to show only posts that have a value in the meta_key 'featured_image'.
So... if 'featured_image' is not empty, show the ...
36
votes
6answers
88k views
how to get page id of a page using page slug
Im pretty new to wordpress and I was wondering if I could get a page id with it's slug. Is it possible please let me know.
36
votes
1answer
37k views
How can I fix fatal RevSlider error in dashboard after upgrading to PHP 7? [closed]
I can access the public side of the site. But the dashboard comes up blank.
The log shows an error pointing to the RevSlider plugin:
PHP Fatal error: Uncaught Error: [] operator not supported for ...
36
votes
3answers
132k views
36
votes
6answers
7k views
Using OOP in themes
I see a lot of plugins making use of object-oriented coding when there isn't really necessary.
But what's even worse is that theme developers are starting to do the same thing. Commercial themes and ...
36
votes
4answers
18k views
Editor can create any new user except administrator
I have set up a WordPress site for a client. The client has the Editor role, however I have installed the Members plugin and given the client the capability to add new users to the WP admin. This is ...
36
votes
3answers
59k views
What security concerns should I have when setting FS_METHOD to “direct” in wp-config?
I have recently had an issue where I have been unable to install the WP Smush Pro plugin because I don't have the Manual Install or One-Click Installation options available.
I came across this post ...
36
votes
2answers
39k views
Customizing Only a Specific Menu using the “wp_nav_menu_items” Hook?
Thanks to some help on here, I've managed to add a custom search box to my main menu... by adding this to my theme's functions.php
add_filter('wp_nav_menu_items','search_box_function');
function ...
36
votes
7answers
40k views
Best way to overide plugin CSS?
Currently, I use CSS specificity to override plugin styles. I prefer this for editing the plugin as it makes less headaches when you update.
It would be nice if my style sheet loaded after the ...
36
votes
4answers
12k views
Database synchronization between dev/staging and production
I have a problem with WordPress database synchronization between development and production and I am wondering how other people solving it. I am aware about this question but it doesn't really cover ...
35
votes
8answers
94k views
Can I assign a template to a custom post type?
Can I assign a template file to a custom post type?
I have created a custom post type called items, and I would like to assign templates to the items like you can do with pages.
35
votes
3answers
125k views
How to get an array of post data from wp_query result?
When run a query with WP_Query method, I got an object. I understand that I can then do the loop to display stuffs. But, my goal is not to display anything, instead, I want to get some post data by ...
35
votes
2answers
57k views
get_template_directory_uri pointing to parent theme not child theme
The problem I am having is that the get_template_directory_uri is pointing to the parent theme like site/wp-content/themes/twentythirteen/myGallery/gallery_functions_include.php
but I want it to ...
35
votes
7answers
38k views
How do I get the size of an attachment file?
I'm using the following template code to display attachment links:
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => ...
35
votes
8answers
92k views
Cannot access non-wordpress subdirectories as wordpress overrides them with a 404 error
I refer to this question previously asked and not suitably answered:
Wordpress overriding actual subdirectories
and also
Non "Wordpress" pages/code getting 404 error
I have the same problem ...
35
votes
4answers
8k views
Best practice for versioning wp-config.php?
Is there a best practice for including your wp-config.php file in your version control repository?
I'm considering creating a new site with this type of configuration, (similar to Alex King and Mark ...
35
votes
6answers
34k views
wp enqueue inline script due to dependancies
Is there a way to use wp_enqueue_script() for inline scripts?
I'm doing this because my inline script depends on another script and i would like the flexibility of inserting it after it's loaded.
...
35
votes
3answers
38k views
How do you properly prepare a %LIKE% SQL statement?
I'd like to use a LIKE %text% statement while still using the WordPress $wpdb class to sanitize and prepare input.
SELECT column_1 from `prefix_my_table` WHERE column_2 LIKE '%something%';
I've ...
35
votes
4answers
61k views
How to override JavaScript files in child theme?
I'm loading some JavaScript files in the parent theme. The path in the parent theme is:
scripts > custom.js
In the child theme, I'm creating the same path (scripts > custom.js) and changing ...
35
votes
9answers
10k views
Why do I get comment spam even with Akismet and Captcha?
I'm a bit perplexed why I keep getting so many spam comments ...
Even though I use both the Akismet and WP-reCAPTCHA plugins on my WordPress blog!
WP-reCAPTCHA should stop machine entered spam, but ...
35
votes
4answers
26k views
Filter to remove image dimension attributes?
I'm working on a site based on a fluid width css template which sets a max-width on images to the width of the column containing them, and I need to remove the inline width and height dimension ...
35
votes
2answers
23k 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 ...
34
votes
10answers
43k 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 ...
34
votes
10answers
46k views
How to show a hierarchical terms list?
I have a hierarchical taxonomy called 'geographical locations'. It contains continents on a first level, and then the countries for each one. Example :
Europe
- Ireland
- Spain
- Sweden
Asia
- Laos
- ...
34
votes
9answers
73k views
How to change a user's role?
I have custom roles in my setup and I want to be able to automatically change a user's role thru a function. Say user A has a SUBSCRIBER role, how do I change it to EDITOR? When adding a role we just: ...
34
votes
1answer
8k views
Testing hooks callback
I'm developing a plugin using TDD and one thing that i completely fail to test are... hooks.
I mean OK, i can test hook callback, but how could I test if a hook actually trigger (both custom hooks ...
34
votes
2answers
58k views
How to add a shortcode button to the TinyMCE editor?
How to make any plugin icon in wordpress post? The code I want to insert in plugin code and will appear in post bar [wp-admin/post.php].
Like this image:
Output: If I click the icon it automatically ...
34
votes
5answers
92k views
Translate a plugin using .po .mo files
I want to translate this plugin.
The plugin has already been translated into other languages and it has .pot files for adding new languages (as far as I understood from description).
How do I create ...
34
votes
4answers
7k views
Where do I put the code snippets I found here or somewhere else on the web?
Many posts here or somewhere else contain code, but they do not say where to put it.
Example:
I have found this post: How do I turn off 301 redirecting posts (not canonical)?
I'm a newbie with PHP. ...
34
votes
6answers
23k views
Extending the search context in the admin list post screen
I have created a custom post type and have attached some custom fields to it. Now I would like to the search that authors can perform on the custom post list screen (in the admin backend) to also be ...
34
votes
1answer
24k views
The Difference Between Hierarchical and Non-Hierarchical Taxonomies?
The question is "What is the Difference Between Hierarchical and Non-Hierarchical Taxonomies?" This question really stumped me at first so I figured it would be a good idea to show the difference to ...
34
votes
1answer
3k views
Is there a plugin that provides a stackoverflow style editor for wordpress? [closed]
I am tired of the tinymce editor in wordpress and I really love the stackoverflow editor which allows me to write with markdown grammar. So I want to write blog with markdown in wordpress.
Now I am ...
34
votes
3answers
8k views
How well does WordPress scale?
With the new WordPress and it's new features, it seems like WordPress is capable of much more than a simple blog engine. But how well does WordPress scale being used by say 10k -> 100k users per day?
...
34
votes
4answers
7k views
Add a menu item to Wordpress 3.5 Media Manager
How can add a new menu item underneath the "insert From URL" on the left sidebar in the new Wordpress 3.5 Media Manager?
I've been looking at the backbone js and tried my hand at hooking into it with ...
34
votes
3answers
20k views
What are the differences between WPINC and ABSPATH?
It's common for plugin developers to protect their plugins from direct access. I saw two ways to do that:
if ( ! defined( 'WPINC' ) ) die;
and
if ( ! defined( 'ABSPATH' ) ) exit;
What are the ...
33
votes
6answers
91k views
After server migration only the homepage works
I have recently changed hosting of my WordPress site to VPS.net. I have moved all of my files and imported the database. Everything appeared to be fine until I clicked a link and noticed that all of ...
33
votes
2answers
50k views
Adding a Custom Post Type into the menu screen
I need a way of adding custom post types to the "Appearance-->Menus" option in Wordpress. i have created a custom post type with:
register_post_type('produksjoner',$args);
All examples I find just ...
33
votes
9answers
89k views
Check if current page is the Blog Page
I'm new to WordPress. I am looking for a way to check if current page is the blog page in the code of the header file.
I've checked but I can't find a way. Help me, Pls.
33
votes
10answers
68k views
remove empty paragraphs from the_content?
Hey guys,
I simply want to prevent the creation of empty paragraphs in my wordpress post. That happens quite often when trying to manually space content.
I don't know why this doesn't take effect?
/*...
33
votes
6answers
45k views
Sending the reset password link programatically
I have this manually created page:
$user_login = sanitize_text_field( $_GET['user_login'] );
if ( username_exists( $user_login ) || email_exists($user_login) ) { ?>
<!--Everything has been ...
33
votes
2answers
43k views
Remove JSON API links in header html
Does anyone know how to remove the WordPress JSON API links in the header tag?
<head>
...
<link rel='https://api.w.org/' href='http://example.com/wp-json/' />
<link rel="alternate" ...
33
votes
10answers
27k views
Stop Wordpress Wrapping Images In A “P” Tag
I have searched high and low for a simple solution to this, but to no avail. Wordpress keeps on wrapping my images in p tags and because of the eccentric nature of the layout for a site I am working ...
33
votes
6answers
43k views
Include custom taxonomy term in search
I have two custom taxonomies applied to two custom post types. the terms list on the sidebar just fine and will list all posts associated with it. However, if you search one of the terms in specific, ...
33
votes
3answers
50k views
Adding 'menu order' column to custom post type admin screen
I want to use the menu order attribute to control ordering for a custom post type that's going to be used for a specific purpose.
It's easy enough to add this to the CPT via supports => array('...
33
votes
9answers
27k views
Can I Prevent Enumeration of Usernames?
Can I prevent enumeration of usernames on my wordpress site? I can see users at the moment using the WPScan tool.
33
votes
6answers
68k views
How do I get image url only on the_post_thumbnail
I want to know how to get image url on the_post_thumbnail()
Default the_post_thumbnail()
<img width="800" height="533" src="http://domain.com/wp-content/uploads/2011/02/book06.jpg" class="...
33
votes
6answers
13k views
Change the default-view of Media Library in 3.5?
When inserting media into a post, is there a way to change the default-view of the Media-Library from "All media items" to "Uploaded to this post"?
There is another thread where this question was ...