qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
213,986
<p>I know this is a big ask for you guys, but i can't seem to figure this out.</p> <p>I found this page : <a href="http://www.bobz.co/ajax-filter-posts-tag/#comment-28112" rel="nofollow">http://www.bobz.co/ajax-filter-posts-tag/#comment-28112</a></p> <p>it shows how to make a dynamic filter for post tags. </p> <p>I...
[ { "answer_id": 237485, "author": "Daniel Griffiths", "author_id": 101849, "author_profile": "https://wordpress.stackexchange.com/users/101849", "pm_score": 3, "selected": true, "text": "<p>Not sure if you've solved this or not but I was looking for a way to embed this within a page and f...
2016/01/07
[ "https://wordpress.stackexchange.com/questions/213986", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77767/" ]
I know this is a big ask for you guys, but i can't seem to figure this out. I found this page : <http://www.bobz.co/ajax-filter-posts-tag/#comment-28112> it shows how to make a dynamic filter for post tags. I wanted to change it to post categories, but i can't seem to get it working. I placed this code in my funct...
Not sure if you've solved this or not but I was looking for a way to embed this within a page and filter posts by category. I got this working so it displays all categories and the posts related. Put that in `functions.php` ``` function ajax_filter_posts_scripts() { // Enqueue script wp_register_script('afp_scri...
213,987
<p>I saw <a href="https://wordpress.stackexchange.com/questions/3029/how-to-retrieve-image-from-url-and-set-as-featured-image-post-thumbnail?rq=1">this code</a> as how to set a featured image for a post: </p> <pre><code>// required libraries for media_sideload_image require_once(ABSPATH . 'wp-admin/includes/file.php')...
[ { "answer_id": 237485, "author": "Daniel Griffiths", "author_id": 101849, "author_profile": "https://wordpress.stackexchange.com/users/101849", "pm_score": 3, "selected": true, "text": "<p>Not sure if you've solved this or not but I was looking for a way to embed this within a page and f...
2016/01/07
[ "https://wordpress.stackexchange.com/questions/213987", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29247/" ]
I saw [this code](https://wordpress.stackexchange.com/questions/3029/how-to-retrieve-image-from-url-and-set-as-featured-image-post-thumbnail?rq=1) as how to set a featured image for a post: ``` // required libraries for media_sideload_image require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . ...
Not sure if you've solved this or not but I was looking for a way to embed this within a page and filter posts by category. I got this working so it displays all categories and the posts related. Put that in `functions.php` ``` function ajax_filter_posts_scripts() { // Enqueue script wp_register_script('afp_scri...
214,052
<p>I have recently redone a site that was originally created in 2011. Of course there were a few big development issues and one of them is the usage of an old audio shortcode:</p> <p>[audio:<a href="http://localhost:8888/lusa/audio/1310seg02.mp3]" rel="nofollow">http://localhost:8888/lusa/audio/1310seg02.mp3]</a></p> ...
[ { "answer_id": 237485, "author": "Daniel Griffiths", "author_id": 101849, "author_profile": "https://wordpress.stackexchange.com/users/101849", "pm_score": 3, "selected": true, "text": "<p>Not sure if you've solved this or not but I was looking for a way to embed this within a page and f...
2016/01/08
[ "https://wordpress.stackexchange.com/questions/214052", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60029/" ]
I have recently redone a site that was originally created in 2011. Of course there were a few big development issues and one of them is the usage of an old audio shortcode: [audio:<http://localhost:8888/lusa/audio/1310seg02.mp3]> I have not seen any documentation of the native Wordpress audio shortcode ever using a c...
Not sure if you've solved this or not but I was looking for a way to embed this within a page and filter posts by category. I got this working so it displays all categories and the posts related. Put that in `functions.php` ``` function ajax_filter_posts_scripts() { // Enqueue script wp_register_script('afp_scri...
214,066
<p>The WordPress 4.4 adds multiple image sizes with <code>srcset</code> when using <code>the_post_thumbnail</code> function. Is it possible to get only one image size without srcset ?</p> <p>I understand that it is possible to add a filter to disable <code>srcset</code> from all images, but I want to disable the <code...
[ { "answer_id": 214071, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": false, "text": "<blockquote>\n <p>I want to disable the srcset only when calling a specific thumbnail\n size (for example only...
2016/01/08
[ "https://wordpress.stackexchange.com/questions/214066", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86476/" ]
The WordPress 4.4 adds multiple image sizes with `srcset` when using `the_post_thumbnail` function. Is it possible to get only one image size without srcset ? I understand that it is possible to add a filter to disable `srcset` from all images, but I want to disable the `srcset` only when calling a specific thumbnail ...
> > I want to disable the srcset only when calling a specific thumbnail > size (for example only when calling full image size). > > > Here are two ideas (if I understand you correctly): Approach #1 ----------- Let's check the size from the `post_thumbnail_size` filter. If it matches a corresponding size (e.g. `...
214,084
<p>I have a taxonomy archive page where I display everything under the term 'techno' I want to be able to limit this to 20 posts to a page until it paginates. At the moment it displays 10 on one page and then 10 on another. This works fine on my main page where I give the posts per page limit to 20. Can anyone see why?...
[ { "answer_id": 214096, "author": "Charles", "author_id": 15605, "author_profile": "https://wordpress.stackexchange.com/users/15605", "pm_score": 3, "selected": true, "text": "<p>Maybe a very quick and (simplified)dirty way I show here, but would this function not solve it without the nee...
2016/01/08
[ "https://wordpress.stackexchange.com/questions/214084", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64115/" ]
I have a taxonomy archive page where I display everything under the term 'techno' I want to be able to limit this to 20 posts to a page until it paginates. At the moment it displays 10 on one page and then 10 on another. This works fine on my main page where I give the posts per page limit to 20. Can anyone see why? He...
Maybe a very quick and (simplified)dirty way I show here, but would this function not solve it without the need to make changes for/in the templates? *(Yes I know I also make queries in my templates but wanted to help out before leaving office)* ``` function wpse214084_max_post_queries( $query ) { if(is_tax('ge...
214,098
<p>How can i create an custom post template for an specific post category in Wordpress?</p>
[ { "answer_id": 214096, "author": "Charles", "author_id": 15605, "author_profile": "https://wordpress.stackexchange.com/users/15605", "pm_score": 3, "selected": true, "text": "<p>Maybe a very quick and (simplified)dirty way I show here, but would this function not solve it without the nee...
2016/01/08
[ "https://wordpress.stackexchange.com/questions/214098", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86490/" ]
How can i create an custom post template for an specific post category in Wordpress?
Maybe a very quick and (simplified)dirty way I show here, but would this function not solve it without the need to make changes for/in the templates? *(Yes I know I also make queries in my templates but wanted to help out before leaving office)* ``` function wpse214084_max_post_queries( $query ) { if(is_tax('ge...
214,109
<p>I'm querying a custom field of users based on a city they are in. I am able to display their profile photo and display name, however I can't seem to get the link to their actual author url to work.</p> <p>It just keeps linking to the same page it's currently on. Any help would be greatly appreciated.</p> <pre><c...
[ { "answer_id": 214111, "author": "terminator", "author_id": 55034, "author_profile": "https://wordpress.stackexchange.com/users/55034", "pm_score": 2, "selected": false, "text": "<p>I am not sure too much about the code but i think you forgot to <code>echo</code> $user->url</p>\n\n<p>So...
2016/01/08
[ "https://wordpress.stackexchange.com/questions/214109", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86499/" ]
I'm querying a custom field of users based on a city they are in. I am able to display their profile photo and display name, however I can't seem to get the link to their actual author url to work. It just keeps linking to the same page it's currently on. Any help would be greatly appreciated. ``` <?php $lond...
I am not sure too much about the code but i think you forgot to `echo` $user->url So just replace all `$user->url` with `echo $user->url`
214,134
<p>I know there is many solutions how to rename attachment while upload files to postid. I got correct solutions that really works fine is: <a href="https://wordpress.stackexchange.com/a/30767/86517">https://wordpress.stackexchange.com/a/30767/86517</a> <strong><em>(I'm new and I can't comments there. So I ask this que...
[ { "answer_id": 214111, "author": "terminator", "author_id": 55034, "author_profile": "https://wordpress.stackexchange.com/users/55034", "pm_score": 2, "selected": false, "text": "<p>I am not sure too much about the code but i think you forgot to <code>echo</code> $user->url</p>\n\n<p>So...
2016/01/09
[ "https://wordpress.stackexchange.com/questions/214134", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86517/" ]
I know there is many solutions how to rename attachment while upload files to postid. I got correct solutions that really works fine is: <https://wordpress.stackexchange.com/a/30767/86517> ***(I'm new and I can't comments there. So I ask this question.)*** **The code is:** ``` add_action('add_attachment', 'rename_at...
I am not sure too much about the code but i think you forgot to `echo` $user->url So just replace all `$user->url` with `echo $user->url`
214,206
<p>I've a website currently running in CI and it has a user table. I'm making a WordPress website and need it to use the user table of the CI database for users to login in WordPress. How can I use only that table of different database? Both DBs are on same server. Also I have to differentiate between admin and normal ...
[ { "answer_id": 214207, "author": "Lionel Ritchie the Manatee", "author_id": 94990, "author_profile": "https://wordpress.stackexchange.com/users/94990", "pm_score": 0, "selected": false, "text": "<p>You don't need a plugin to make multiple db connections in CI. Just do this:</p>\n\n<h3>Co...
2015/12/29
[ "https://wordpress.stackexchange.com/questions/214206", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I've a website currently running in CI and it has a user table. I'm making a WordPress website and need it to use the user table of the CI database for users to login in WordPress. How can I use only that table of different database? Both DBs are on same server. Also I have to differentiate between admin and normal use...
It might work to use a view as essentially a table alias, by doing the something like the following with the WordPress instance mysql database ``` DROP TABLE wp_users CREATE VIEW wp_users AS SELECT * FROM CI.users; ``` However * will probably need to tweak the view creation to map the columns * the password encod...
214,210
<p>My WordPress site currently displays users' identifying information by their FIRSTNAME + LASTNAME.</p> <p>The vast majority prefer to be known by their usernames. I've instructed how to change their "Display Name Publicly As" manually (i.e. via their User settings) but this is less than ideal.</p> <p>I would like ...
[ { "answer_id": 214214, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 2, "selected": false, "text": "<p>If you want this for all future users then hook into the <a href=\"https://codex.wordpress.org/Plugin_API/Acti...
2016/01/10
[ "https://wordpress.stackexchange.com/questions/214210", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86585/" ]
My WordPress site currently displays users' identifying information by their FIRSTNAME + LASTNAME. The vast majority prefer to be known by their usernames. I've instructed how to change their "Display Name Publicly As" manually (i.e. via their User settings) but this is less than ideal. I would like new users to be s...
If you want this for all future users then hook into the [`user_register`](https://codex.wordpress.org/Plugin_API/Action_Reference/user_register) event and update it there. Pull the [`WP_User`](https://codex.wordpress.org/Class_Reference/WP_User) using [`get_userdata`](https://codex.wordpress.org/Function_Reference/ge...
214,224
<p>I have Radio with programs and they are associated to day of the weak.</p> <p><em>Example:</em></p> <p>1-Program Disco Nights plays at Monday and Friday</p> <p>2-Pragram Crazy weekends play only at Sunday</p> <p>3-etc</p> <p>4-etc</p> <p><strong>Objective:</strong> List All the programs without repeating the o...
[ { "answer_id": 214214, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 2, "selected": false, "text": "<p>If you want this for all future users then hook into the <a href=\"https://codex.wordpress.org/Plugin_API/Acti...
2016/01/11
[ "https://wordpress.stackexchange.com/questions/214224", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86598/" ]
I have Radio with programs and they are associated to day of the weak. *Example:* 1-Program Disco Nights plays at Monday and Friday 2-Pragram Crazy weekends play only at Sunday 3-etc 4-etc **Objective:** List All the programs without repeating the ones are associated to multiple days based on current day and the ...
If you want this for all future users then hook into the [`user_register`](https://codex.wordpress.org/Plugin_API/Action_Reference/user_register) event and update it there. Pull the [`WP_User`](https://codex.wordpress.org/Class_Reference/WP_User) using [`get_userdata`](https://codex.wordpress.org/Function_Reference/ge...
214,250
<p>I have developed on theme which have integrated framework for theme options, visual composer and slider, it make the theme size nearly 11mb after compressed(zip) but while i want to upload the theme by wp-admin area it provides the upload error but if upload using ftp(live site) it works. How can i make the upload f...
[ { "answer_id": 214214, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 2, "selected": false, "text": "<p>If you want this for all future users then hook into the <a href=\"https://codex.wordpress.org/Plugin_API/Acti...
2016/01/11
[ "https://wordpress.stackexchange.com/questions/214250", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65450/" ]
I have developed on theme which have integrated framework for theme options, visual composer and slider, it make the theme size nearly 11mb after compressed(zip) but while i want to upload the theme by wp-admin area it provides the upload error but if upload using ftp(live site) it works. How can i make the upload from...
If you want this for all future users then hook into the [`user_register`](https://codex.wordpress.org/Plugin_API/Action_Reference/user_register) event and update it there. Pull the [`WP_User`](https://codex.wordpress.org/Class_Reference/WP_User) using [`get_userdata`](https://codex.wordpress.org/Function_Reference/ge...
214,254
<p>I can select posts via my custom taxonomy as explained <a href="https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters" rel="nofollow">in the codex</a>. But I am not sure, how I have to set up the tax_query if I want to get only posts which have no relation in the custom taxonomy at all. Any sugges...
[ { "answer_id": 214255, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": false, "text": "<p>The only way is to get all the terms and exclude posts which belongs to those terms</p>\n\n<pre><code>$...
2016/01/11
[ "https://wordpress.stackexchange.com/questions/214254", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34176/" ]
I can select posts via my custom taxonomy as explained [in the codex](https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters). But I am not sure, how I have to set up the tax\_query if I want to get only posts which have no relation in the custom taxonomy at all. Any suggestion?
I have found an answer by myself, for those landing here by google: ``` $taxq = array( array( 'taxonomy' => 'story_lng', 'field' => 'id', 'operator' => 'NOT EXISTS', ) ); ``` That results in ``` AND (NOT EXISTS( SELECT 1 FROM wp_term_relationships ...
214,285
<p>So I am trying to display a working version of the default wordpress login form on one of my pages. There is code in the functions.php file that creates the shortcode and as far as I know it works successfully, however after submitting the form, it simply refreshes the page and doesn't redirect to the url I am speci...
[ { "answer_id": 214255, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": false, "text": "<p>The only way is to get all the terms and exclude posts which belongs to those terms</p>\n\n<pre><code>$...
2016/01/11
[ "https://wordpress.stackexchange.com/questions/214285", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84655/" ]
So I am trying to display a working version of the default wordpress login form on one of my pages. There is code in the functions.php file that creates the shortcode and as far as I know it works successfully, however after submitting the form, it simply refreshes the page and doesn't redirect to the url I am specifyi...
I have found an answer by myself, for those landing here by google: ``` $taxq = array( array( 'taxonomy' => 'story_lng', 'field' => 'id', 'operator' => 'NOT EXISTS', ) ); ``` That results in ``` AND (NOT EXISTS( SELECT 1 FROM wp_term_relationships ...
214,291
<p>All theme dev who follows the wp guidelines properly, now uses ability of default wp customizer to customize their themes, instead of making a different theme option section the admin panel.</p> <p>But what I was unable to figure out is that how to use shortcode within that wp customizer.</p> <p>For example: In on...
[ { "answer_id": 214301, "author": "setterGetter", "author_id": 8756, "author_profile": "https://wordpress.stackexchange.com/users/8756", "pm_score": 2, "selected": false, "text": "<p>wrap whatever you are outputting the shortcode in around <code>do_shortcode()</code></p>\n" }, { "...
2016/01/11
[ "https://wordpress.stackexchange.com/questions/214291", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50584/" ]
All theme dev who follows the wp guidelines properly, now uses ability of default wp customizer to customize their themes, instead of making a different theme option section the admin panel. But what I was unable to figure out is that how to use shortcode within that wp customizer. For example: In one of the theme I ...
wrap whatever you are outputting the shortcode in around `do_shortcode()`
214,302
<p>I recently had to script the adding of a number of roles to a selection of the users in my database. In order to do so I put together a script like this:</p> <pre><code>error_reporting(E_ALL); require("../../wp-load.php"); $source_file = 'role_source'; if(($source_handle = fopen($source_file, "r")) !== false) { ...
[ { "answer_id": 214501, "author": "Saikat", "author_id": 28168, "author_profile": "https://wordpress.stackexchange.com/users/28168", "pm_score": 1, "selected": false, "text": "<p>I am not sure why you have written codes this way to add user role. And <code>wp_usermeta</code> table does no...
2016/01/12
[ "https://wordpress.stackexchange.com/questions/214302", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54988/" ]
I recently had to script the adding of a number of roles to a selection of the users in my database. In order to do so I put together a script like this: ``` error_reporting(E_ALL); require("../../wp-load.php"); $source_file = 'role_source'; if(($source_handle = fopen($source_file, "r")) !== false) { while(($row...
This would be best as a comment, but no reputation :) In the [codex](https://codex.wordpress.org/Function_Reference/add_role) they say "If you are defining a custom role, and adding capabilities to the role using add\_role(), be aware that modifying the capabilities array and re-executing add\_role() will not necess...
214,333
<p>I'm developing a plugin that relies pretty heavily on AJAX calls. It works well in a single-install version of WordPress, but when I ported it into a Network WP my AJAX functions stopped working (always return 0).</p> <p>Simplified, my plugin setup looks like this:</p> <pre><code>// plugin.php /* Plugin Name: My p...
[ { "answer_id": 283066, "author": "mj_azani", "author_id": 98670, "author_profile": "https://wordpress.stackexchange.com/users/98670", "pm_score": 1, "selected": false, "text": "<p>Instead of using <code>get_admin_ajax_path()</code> use <code>self_admin_url( 'admin-ajax.php' )</code> whic...
2016/01/12
[ "https://wordpress.stackexchange.com/questions/214333", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31367/" ]
I'm developing a plugin that relies pretty heavily on AJAX calls. It works well in a single-install version of WordPress, but when I ported it into a Network WP my AJAX functions stopped working (always return 0). Simplified, my plugin setup looks like this: ``` // plugin.php /* Plugin Name: My plugin */ defined( 'AB...
Instead of using `get_admin_ajax_path()` use `self_admin_url( 'admin-ajax.php' )` which retrieves the URL to the ajax address for either the current site or the network.
214,351
<p>I am developing a custom theme with custom post types involved. Custom post types have been defined via plugin 'Pods' (<a href="http://pods.io" rel="nofollow">http://pods.io</a>).</p> <p>When writing a category.php, I realized, that the standard loop does not retrieve custom post types (CPT) posts which belong to a...
[ { "answer_id": 214398, "author": "terminator", "author_id": 55034, "author_profile": "https://wordpress.stackexchange.com/users/55034", "pm_score": 0, "selected": false, "text": "<p>You need to use <code>taxonomy.php</code> instead of category.php </p>\n\n<p>Give little reading to templ...
2016/01/12
[ "https://wordpress.stackexchange.com/questions/214351", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63707/" ]
I am developing a custom theme with custom post types involved. Custom post types have been defined via plugin 'Pods' (<http://pods.io>). When writing a category.php, I realized, that the standard loop does not retrieve custom post types (CPT) posts which belong to a certain category. Is that right? If not, are there ...
Custom post types are by default excluded from the main query except on taxonomy pages and custom post type archives. You can simply use `pre_get_posts` to correctly alter the main query (*alter the query variables before the SQL query is build and executed*) to your needs. Just a few notes on `pre_get_posts` * `pr...
214,370
<p>The append result is 0, instead of a list with the title ass a link. If I check this locally (<a href="http://localhost/wordpress/wp-admin/admin-ajax.php?action=lateral_fluid" rel="nofollow">http://localhost/wordpress/wp-admin/admin-ajax.php?action=lateral_fluid</a>), I get the titles ass a link. I don't know why I ...
[ { "answer_id": 214376, "author": "urka_mazurka", "author_id": 51568, "author_profile": "https://wordpress.stackexchange.com/users/51568", "pm_score": 1, "selected": false, "text": "<p>The codex says here <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action)\"...
2016/01/12
[ "https://wordpress.stackexchange.com/questions/214370", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84865/" ]
The append result is 0, instead of a list with the title ass a link. If I check this locally (<http://localhost/wordpress/wp-admin/admin-ajax.php?action=lateral_fluid>), I get the titles ass a link. I don't know why I get the appended 0. What am I missing? FUNCTIONS.PHP ``` // Your actual AJAX script wp_enqueue_scrip...
The codex says here [that](https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action)) The wp\_ajax\_ hook follows the format "wp\_ajax\_$youraction", where $youraction is your AJAX request's 'action' property. I suppose in your js file you should go for: ``` data: { action: 'lateral_fluid',...
214,384
<p>I'm trying to include my parents themes functions.php include into my child theme functions.php.</p> <p>I have a standard setup for a functions.php in my parent.</p> <p>This is what i have in my child themes functions.php</p> <pre><code>&lt;?php /** * Base functions and definitions. * * @link https://developer...
[ { "answer_id": 240445, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 2, "selected": false, "text": "<p>As per @toscho's comments, the parent theme is always loaded after the child theme's. In this way, if you want t...
2016/01/12
[ "https://wordpress.stackexchange.com/questions/214384", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54516/" ]
I'm trying to include my parents themes functions.php include into my child theme functions.php. I have a standard setup for a functions.php in my parent. This is what i have in my child themes functions.php ``` <?php /** * Base functions and definitions. * * @link https://developer.wordpress.org/themes/basics/th...
As per @toscho's comments, the parent theme is always loaded after the child theme's. In this way, if you want to override a parent theme's function you can rewrite it and the original will be ignored, whereas any functions you didn't rewrite are loaded and available. There is no need to do it the other way around. If...
214,388
<p>I am trying to produce a list of posts and display a report which shows both some meta_values for each post, but also a list of all categories to which each post is attached. </p> <p>I am using the nifty Exports and Reports module to format the results of my query, and the data I am trying to pull out is a list of ...
[ { "answer_id": 215176, "author": "Sterling Hamilton", "author_id": 10075, "author_profile": "https://wordpress.stackexchange.com/users/10075", "pm_score": 2, "selected": false, "text": "<p><strong>cracks knuckles</strong></p>\n\n<p>Alright -- so first thing is first.</p>\n\n<h1>Working w...
2016/01/12
[ "https://wordpress.stackexchange.com/questions/214388", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37897/" ]
I am trying to produce a list of posts and display a report which shows both some meta\_values for each post, but also a list of all categories to which each post is attached. I am using the nifty Exports and Reports module to format the results of my query, and the data I am trying to pull out is a list of Woocommer...
SQL-wise, you only need to join to the wp\_posts table once. Joining to the terms stuff will give you multiple rows, so it's probably easiest to group these and then use GROUP\_CONCAT() to flatten the terms into a comma-separated string (**updated to use LEFT joins**): ``` global $wpdb; $sql = $wpdb->prepare( 'SEL...
214,395
<p>I'm trying to tailor an RSS feed so that it can be used to generate a newsletter via Digesto/Marketo. I've tried adding a custom RSS template to the site's theme - and it worked - but I can't seem to lose the site link that is added below each post. The post links are really all we need.</p> <p>The link is being in...
[ { "answer_id": 214397, "author": "terminator", "author_id": 55034, "author_profile": "https://wordpress.stackexchange.com/users/55034", "pm_score": 0, "selected": false, "text": "<p>you can use the filter to edit the output of the_excerpt_rss()</p>\n\n<p>May be the following code will h...
2016/01/13
[ "https://wordpress.stackexchange.com/questions/214395", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57514/" ]
I'm trying to tailor an RSS feed so that it can be used to generate a newsletter via Digesto/Marketo. I've tried adding a custom RSS template to the site's theme - and it worked - but I can't seem to lose the site link that is added below each post. The post links are really all we need. The link is being inserting ju...
After doing a search of all folders in the site for "the\_excerpt\_rss", I found a Yoast plugin file that was adding the link to each post item. In the end it was as simple as accessing a field via the dashboard > SEO > advanced and clicking the RSS tab. I emptied the field "Content to put after each post in the feed",...
214,443
<p>I followed the common advise to use wp_head() in header.php and wp_enqueue_scripts() instead of hard linking css and js files in header.php.</p> <p>However, I realized that wp_head() outputs lots of stuff I'm not sure if I really want it to be there. E.g. there is some CSS stylesheet stuff dealing with emotiis and ...
[ { "answer_id": 214446, "author": "panos", "author_id": 33435, "author_profile": "https://wordpress.stackexchange.com/users/33435", "pm_score": 0, "selected": false, "text": "<p>The wp_head hook is simply a hook.</p>\n\n<p>Themes and plugins use this hook to add stuff they need in the hea...
2016/01/13
[ "https://wordpress.stackexchange.com/questions/214443", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63707/" ]
I followed the common advise to use wp\_head() in header.php and wp\_enqueue\_scripts() instead of hard linking css and js files in header.php. However, I realized that wp\_head() outputs lots of stuff I'm not sure if I really want it to be there. E.g. there is some CSS stylesheet stuff dealing with emotiis and smiley...
[Here](https://github.com/WordPress/WordPress/blob/9fb5c540bb7888faec05670bd70a93e0593dcfb1/wp-includes/default-filters.php#L224) is the current list of actions that is currently hooked by default to `wp_head` Reposted here to avoid unnecessary opening multiple browser windows ``` add_action( 'wp_head', '...
214,450
<h1>Disabling Password Resets</h1> <p>I've come across numerous security hardening articles relating to various measures for disabling password resets (i.e. lost password retrieval).</p> <p><a href="https://www.google.com/search?q=wordpress+disable+lost+password" rel="nofollow">https://www.google.com/search?q=wordpre...
[ { "answer_id": 214446, "author": "panos", "author_id": 33435, "author_profile": "https://wordpress.stackexchange.com/users/33435", "pm_score": 0, "selected": false, "text": "<p>The wp_head hook is simply a hook.</p>\n\n<p>Themes and plugins use this hook to add stuff they need in the hea...
2016/01/13
[ "https://wordpress.stackexchange.com/questions/214450", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41545/" ]
Disabling Password Resets ========================= I've come across numerous security hardening articles relating to various measures for disabling password resets (i.e. lost password retrieval). <https://www.google.com/search?q=wordpress+disable+lost+password> SQL Injection ============= I've read that SQL inject...
[Here](https://github.com/WordPress/WordPress/blob/9fb5c540bb7888faec05670bd70a93e0593dcfb1/wp-includes/default-filters.php#L224) is the current list of actions that is currently hooked by default to `wp_head` Reposted here to avoid unnecessary opening multiple browser windows ``` add_action( 'wp_head', '...
214,455
<p>I added some actions to <code>wp_enqueue_scripts</code> to load my custom css and js files in the header section by using <code>wp_head();</code> right before the closing <code>&lt;/head&gt;</code> tag.</p> <pre><code>function mytheme_scripts(){ // Load our main stylesheet wp_enqueue_style( 'mytheme-css', g...
[ { "answer_id": 254889, "author": "Diego Betto", "author_id": 96955, "author_profile": "https://wordpress.stackexchange.com/users/96955", "pm_score": -1, "selected": false, "text": "<p>You can change the hook to <code>get_footer</code> so files are inserted in the footer</p>\n\n<p>try cha...
2016/01/13
[ "https://wordpress.stackexchange.com/questions/214455", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63707/" ]
I added some actions to `wp_enqueue_scripts` to load my custom css and js files in the header section by using `wp_head();` right before the closing `</head>` tag. ``` function mytheme_scripts(){ // Load our main stylesheet wp_enqueue_style( 'mytheme-css', get_template_directory_uri() . '/css/styles.min.css', ...
hook into init action on your initial plugin function ``` add_action('init', array(__CLASS__, 'your_function_within_class')); ``` and add the function ``` public static function your_function_within_class() { wp_register_style('myfirstplugin-admin-css', '/wp-content/plugins/myfirstplugin/assets/style.css', fal...
214,456
<p>While configuring Ctags to recognize WordPress functions, I came across the <a href="https://core.trac.wordpress.org/browser/tags/4.4.1/src/wp-admin/includes/noop.php" rel="nofollow noreferrer">noop.php</a> file. Here is an excerpt:</p> <pre><code>/** * @ignore */ function add_action() {} /** * @ignore */ func...
[ { "answer_id": 214457, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 4, "selected": true, "text": "<p>The description on top of the page you have linked gives an explanation:</p>\n\n<blockquote>\n <p>C...
2016/01/13
[ "https://wordpress.stackexchange.com/questions/214456", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34330/" ]
While configuring Ctags to recognize WordPress functions, I came across the [noop.php](https://core.trac.wordpress.org/browser/tags/4.4.1/src/wp-admin/includes/noop.php) file. Here is an excerpt: ``` /** * @ignore */ function add_action() {} /** * @ignore */ function did_action() {} /** * @ignore */ function d...
The description on top of the page you have linked gives an explanation: > > Create a new file, `wp-admin/includes/noop.php`, which loads all of the noop functions for `load-script|styles.php` and is only loaded by those files. DRYs in the process. See [#33813](https://core.trac.wordpress.org/ticket/33813). > > > ...
214,498
<p>When is <code>wp_loaded</code> initiated?</p> <p>Im trying to add function that downloads a big file for the plugin DB, and I need it to be executed whenever user/admin/unknown user get in the frontend, after the site is fully loaded, so that it would not be any delay with the site speed, and user experience.</p> ...
[ { "answer_id": 214499, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 4, "selected": true, "text": "<p><a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/wp_loaded\" rel=\"nofollow noreferrer\"><code...
2016/01/14
[ "https://wordpress.stackexchange.com/questions/214498", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41168/" ]
When is `wp_loaded` initiated? Im trying to add function that downloads a big file for the plugin DB, and I need it to be executed whenever user/admin/unknown user get in the frontend, after the site is fully loaded, so that it would not be any delay with the site speed, and user experience. I use this script: ``` /...
[`wp_loaded`](https://codex.wordpress.org/Plugin_API/Action_Reference/wp_loaded) fires for both the front-end and admin section of the site. > > This action hook is fired once WordPress, all plugins, and the theme are fully loaded and instantiated. > > > Since you're checking for plugin updates, it might be best ...
214,503
<p>I'm using <code>wp_dropdown_categories()</code> with <code>multiple="multiple"</code> <a href="https://wordpress.stackexchange.com/q/183292/22728">in this way</a>, bypassing WordPress core. Till now (WP 4.4.1) doesn't support <code>multiple</code> on that select field. <sup>(<a href="https://core.trac.wordpress.org/...
[ { "answer_id": 214505, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 1, "selected": false, "text": "<p>As the core tickets (for example <a href=\"https://core.trac.wordpress.org/ticket/16734\" rel=\"nofollow\...
2016/01/14
[ "https://wordpress.stackexchange.com/questions/214503", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22728/" ]
I'm using `wp_dropdown_categories()` with `multiple="multiple"` [in this way](https://wordpress.stackexchange.com/q/183292/22728), bypassing WordPress core. Till now (WP 4.4.1) doesn't support `multiple` on that select field. ([Core Ticket](https://core.trac.wordpress.org/ticket/31909)) I'm struggling with the `select...
Thanks @markkaplun. I solved it writing my own: ``` <?php /** * Dropdown for 'my_tax' * @since 1.0.0 Using wp_dropdown_categories(). * @since 2.0.3 Custom code, as wp_dropdown_categories() doesn't provide * 'selected' field for multiple="multiple" */ $my_tax_terms = get_terms( 'my_tax', array('hid...
214,540
<p>I have created a shortcode for a custom post type query but when I add meta_query values to it, it throws an error:</p> <pre><code>Notice: Undefined variable: my in E:\xampp\htdocs\test\wp-content\themes\test-theme\functions.php on line 182 </code></pre> <p>Here is the shortcode code:</p> <pre><code>function list...
[ { "answer_id": 214541, "author": "Nefro", "author_id": 86801, "author_profile": "https://wordpress.stackexchange.com/users/86801", "pm_score": -1, "selected": false, "text": "<p>try change </p>\n\n<pre><code>return $my;\n</code></pre>\n\n<p>to</p>\n\n<pre><code>if (isset($my)) return $my...
2016/01/14
[ "https://wordpress.stackexchange.com/questions/214540", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58787/" ]
I have created a shortcode for a custom post type query but when I add meta\_query values to it, it throws an error: ``` Notice: Undefined variable: my in E:\xampp\htdocs\test\wp-content\themes\test-theme\functions.php on line 182 ``` Here is the shortcode code: ``` function list_unit( $atts ) { $args = array( ...
As the error states, your $my variable is not defined. The reason behind it is that you only defines $my when $the\_query->have\_posts(). Adding ``` $my = 'No results found'; ``` right after ``` $the_query = new WP_Query( $args ); ``` would solve your problem. $my would then be redefined if results are found.
214,580
<p>I receive this error while debug mode is enabled:</p> <blockquote> <p>Notice: load_plugin_textdomain was called with an argument that is deprecated since version 2.7 with no alternative available. in /home/xyz/public_html/wp-includes/functions.php on line 3739</p> </blockquote> <p>I found that is related to ...
[ { "answer_id": 214633, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": true, "text": "<p>The plugin calling <code>load_plugin_textdomain()</code> <a href=\"https://wordpress.stackexchange.com/a/97928/73\">th...
2016/01/14
[ "https://wordpress.stackexchange.com/questions/214580", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62437/" ]
I receive this error while debug mode is enabled: > > Notice: load\_plugin\_textdomain was called with an argument that is > deprecated since version 2.7 with no alternative available. in > /home/xyz/public\_html/wp-includes/functions.php on line 3739 > > > I found that is related to this plugin: <https://wordp...
The plugin calling `load_plugin_textdomain()` [the wrong way](https://wordpress.stackexchange.com/a/97928/73): ``` load_plugin_textdomain( 'custom_smilies', PLUGINDIR . '/' . dirname(plugin_basename(__FILE__)) . '/lang' ); ``` You have to change the code to: ``` load_plugin_textdomain( 'custom_smilies'...
214,587
<p>I found 2 ways to block direct access to php files (although it's not always necessary, see <a href="https://wordpress.stackexchange.com/a/63004/60539">https://wordpress.stackexchange.com/a/63004/60539</a>) The first one is:</p> <pre><code>defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); </code></pre> <...
[ { "answer_id": 214598, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 1, "selected": false, "text": "<p>The logic of the first one is based on wordpress setting <code>ABSPATH</code> as part of the initializati...
2016/01/15
[ "https://wordpress.stackexchange.com/questions/214587", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60539/" ]
I found 2 ways to block direct access to php files (although it's not always necessary, see <https://wordpress.stackexchange.com/a/63004/60539>) The first one is: ``` defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); ``` And the other: ``` if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && basename( __FILE__ ...
In my opinion, the **only** way to do this (within the context of WordPress) is: ``` if ( ! defined( 'ABSPATH' ) ) // Or some other WordPress constant exit; ``` The second technique is vague and does give the same level of checking (it only checks that the filename of the main PHP file matches itself, not wheth...
214,588
<p>This is pretty much an exact duplicate of: <a href="https://wordpress.stackexchange.com/q/158525/9802">How to make Wordpress and TinyMCE accept &lt;a&gt; tags wrapping block-level elements as allowed in HTML5?</a> and <a href="https://wordpress.stackexchange.com/q/96725/9802">HTML5, WordPress and Tiny MCE issue - wr...
[ { "answer_id": 214591, "author": "Bryan Willis", "author_id": 38123, "author_profile": "https://wordpress.stackexchange.com/users/38123", "pm_score": 5, "selected": true, "text": "<p>Regardless of what you have configured as valid children, WordPress handles p tags as well as line breaks...
2016/01/15
[ "https://wordpress.stackexchange.com/questions/214588", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9802/" ]
This is pretty much an exact duplicate of: [How to make Wordpress and TinyMCE accept <a> tags wrapping block-level elements as allowed in HTML5?](https://wordpress.stackexchange.com/q/158525/9802) and [HTML5, WordPress and Tiny MCE issue - wrapping anchor tag around div results in funky output](https://wordpress.stacke...
Regardless of what you have configured as valid children, WordPress handles p tags as well as line breaks in a very unique way. You'll probably notice eventually, if you haven't already, that when switching from the text editor to the visual editor and back that your `<p>` tags get stripped, similar to what occurs on t...
214,627
<p>I have to add a row that (containing the content of post) below the post thumbnail on clicking thumbnail. I have done it by using this but it affects the adjacent post thumbnail.I want that a complete row to be add below every post without affecting other posts. Thumbnail of each post should be remain same.</p> <p...
[ { "answer_id": 214591, "author": "Bryan Willis", "author_id": 38123, "author_profile": "https://wordpress.stackexchange.com/users/38123", "pm_score": 5, "selected": true, "text": "<p>Regardless of what you have configured as valid children, WordPress handles p tags as well as line breaks...
2016/01/15
[ "https://wordpress.stackexchange.com/questions/214627", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86863/" ]
I have to add a row that (containing the content of post) below the post thumbnail on clicking thumbnail. I have done it by using this but it affects the adjacent post thumbnail.I want that a complete row to be add below every post without affecting other posts. Thumbnail of each post should be remain same. ``` <?php ...
Regardless of what you have configured as valid children, WordPress handles p tags as well as line breaks in a very unique way. You'll probably notice eventually, if you haven't already, that when switching from the text editor to the visual editor and back that your `<p>` tags get stripped, similar to what occurs on t...
214,640
<p>Basically in the <code>wp-admin</code> section I have a page where I attempt to export some records from a grid. I have an Export link which leads to something like <code>admin.php?page=download&amp;selected_ids=1,2,4</code>. But when I click it I get the following error:</p> <blockquote> <p>You do not have suffi...
[ { "answer_id": 214650, "author": "C C", "author_id": 83299, "author_profile": "https://wordpress.stackexchange.com/users/83299", "pm_score": 1, "selected": false, "text": "<p>I believe you will need to add it via <code>add_menu_page</code> - but in the callback function you register that...
2016/01/15
[ "https://wordpress.stackexchange.com/questions/214640", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/55042/" ]
Basically in the `wp-admin` section I have a page where I attempt to export some records from a grid. I have an Export link which leads to something like `admin.php?page=download&selected_ids=1,2,4`. But when I click it I get the following error: > > You do not have sufficient permissions to access this page. > > >...
You can use `admin.php?action=my_action` and WordPress will fire the equivalent action hook: ``` // How to get the URL $url = admin_url( "admin.php?action=wpse_21460_export&any_other_arguments" ); // How to handle the URL function wpse_21460_export() { // Do your export and exit } add_action( 'admin_action_wpse_2...
214,641
<p>Assuming a website where page header and footer elements remain constant in every view: Due to WP's template hierarchy system, I could hard-code the general website layout in index.php. Then, I could use conditional tags in index.php to determine which inner content templates to render.</p> <p>On the other hand, I ...
[ { "answer_id": 214643, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 2, "selected": false, "text": "<p>Short and painless, I would recommend going with Option 2. </p>\n\n<p>Why? Because that is what th...
2016/01/15
[ "https://wordpress.stackexchange.com/questions/214641", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63707/" ]
Assuming a website where page header and footer elements remain constant in every view: Due to WP's template hierarchy system, I could hard-code the general website layout in index.php. Then, I could use conditional tags in index.php to determine which inner content templates to render. On the other hand, I could writ...
Option 2 is the best option. To know why, one needs to look at the [template loader](https://core.trac.wordpress.org/browser/tags/4.4/src/wp-includes/template-loader.php#L58). (*The [template hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/) means nothing, if you do not know how it really w...
214,652
<p>I am trying to create dynamic listbox values but getting this error in console: Uncaught TypeError: Cannot assign to read only property 'active' of [</p> <p>Here's my code( pasting only the code for listbox ):</p> <pre><code> body: [ { type: 'listbox', name: ...
[ { "answer_id": 215570, "author": "Jeroen", "author_id": 83390, "author_profile": "https://wordpress.stackexchange.com/users/83390", "pm_score": 0, "selected": false, "text": "<p>If you make a reference to another function in Javascript I don't think you need the () after get_author_list....
2016/01/15
[ "https://wordpress.stackexchange.com/questions/214652", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43572/" ]
I am trying to create dynamic listbox values but getting this error in console: Uncaught TypeError: Cannot assign to read only property 'active' of [ Here's my code( pasting only the code for listbox ): ``` body: [ { type: 'listbox', name: 'type', ...
So the problem with the values helper was that it will only take array of objects and i was passing a string...I have corrected the code by passing an array of objects..Below is the corrected code.. ``` body: [ { type: 'listbox', name: 'type', label: 'Panel Type', ...
214,673
<p>I have a new install of WordPress on my Mac mini server. The site uses SSL and has a valid up to date certificate from StartCom. </p> <p>The site loads, but with no CSS or theme.</p> <p>Mainly, I can't get into wp-admin (or wp-login.php) as it redirects with two 301 redirects and then multiple 302 redirects. I us...
[ { "answer_id": 215570, "author": "Jeroen", "author_id": 83390, "author_profile": "https://wordpress.stackexchange.com/users/83390", "pm_score": 0, "selected": false, "text": "<p>If you make a reference to another function in Javascript I don't think you need the () after get_author_list....
2016/01/15
[ "https://wordpress.stackexchange.com/questions/214673", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86889/" ]
I have a new install of WordPress on my Mac mini server. The site uses SSL and has a valid up to date certificate from StartCom. The site loads, but with no CSS or theme. Mainly, I can't get into wp-admin (or wp-login.php) as it redirects with two 301 redirects and then multiple 302 redirects. I used <http://redirec...
So the problem with the values helper was that it will only take array of objects and i was passing a string...I have corrected the code by passing an array of objects..Below is the corrected code.. ``` body: [ { type: 'listbox', name: 'type', label: 'Panel Type', ...
214,674
<h3>The scenario</h3> <p>I'm developing a plugin, and part of it requires lots of text content (help descriptions) that I would prefer to keep as separate text files (in a subdirectory within the plugin) for organisational and version control purposes. The obvious candidate would be <code>file_get_contents()</code>, bu...
[ { "answer_id": 214675, "author": "Jim Maguire", "author_id": 63669, "author_profile": "https://wordpress.stackexchange.com/users/63669", "pm_score": -1, "selected": false, "text": "<p>Put this in your plugin file:</p>\n\n<pre><code>add_action('init', 'captureFileToVariable');\n\nfunction...
2016/01/15
[ "https://wordpress.stackexchange.com/questions/214674", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60767/" ]
### The scenario I'm developing a plugin, and part of it requires lots of text content (help descriptions) that I would prefer to keep as separate text files (in a subdirectory within the plugin) for organisational and version control purposes. The obvious candidate would be `file_get_contents()`, but its usage with W...
I had to dig pretty deep for this too, and eventually figured out some way to do this. in my solution I used the following: ``` WP_Filesystem(); global $wp_filesystem; $wp_filesystem->exists( '/path/to/file' ); //use any other functions available in the Filesystem API: @see https://developer.wordpress.org/reference/...
214,686
<p>I'm trying to obtain all orders for particular day/time and then order products using SQL (MySQL) as seen in the query below:</p> <pre><code>select p.ID as order_id, p.post_date, i.order_item_name, max( CASE WHEN im.meta_key = '_product_id' and p.ID = im.order_item_id THEN im.meta_value END ) as Pr...
[ { "answer_id": 214675, "author": "Jim Maguire", "author_id": 63669, "author_profile": "https://wordpress.stackexchange.com/users/63669", "pm_score": -1, "selected": false, "text": "<p>Put this in your plugin file:</p>\n\n<pre><code>add_action('init', 'captureFileToVariable');\n\nfunction...
2016/01/15
[ "https://wordpress.stackexchange.com/questions/214686", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28491/" ]
I'm trying to obtain all orders for particular day/time and then order products using SQL (MySQL) as seen in the query below: ``` select p.ID as order_id, p.post_date, i.order_item_name, max( CASE WHEN im.meta_key = '_product_id' and p.ID = im.order_item_id THEN im.meta_value END ) as Prod_ID from ...
I had to dig pretty deep for this too, and eventually figured out some way to do this. in my solution I used the following: ``` WP_Filesystem(); global $wp_filesystem; $wp_filesystem->exists( '/path/to/file' ); //use any other functions available in the Filesystem API: @see https://developer.wordpress.org/reference/...
214,687
<p>I'm making a category archive template that works for <em>all</em> my categories. I need to dynamically set the <code>'category'</code> parameter of <code>WP_Query</code> inside of this template to make it work. </p> <p>How do I dynamically get a string of the current category page name to feed into the WP_Query? A...
[ { "answer_id": 214691, "author": "serraosays", "author_id": 59627, "author_profile": "https://wordpress.stackexchange.com/users/59627", "pm_score": 2, "selected": false, "text": "<p>This is the only option I have found:</p>\n\n<pre><code>$current_category = single_cat_title(\"\", false);...
2016/01/15
[ "https://wordpress.stackexchange.com/questions/214687", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59627/" ]
I'm making a category archive template that works for *all* my categories. I need to dynamically set the `'category'` parameter of `WP_Query` inside of this template to make it work. How do I dynamically get a string of the current category page name to feed into the WP\_Query? All the methods I've seen presupposed t...
This is the only option I have found: ``` $current_category = single_cat_title("", false); ```
214,688
<p>I have to add <code>itemprop="url"</code> to the links of the links in the navbar of <a href="http://www.anahatatantra.com/" rel="nofollow">this site</a>.</p> <p>In the settings I found the function <code>wp_nav_menu()</code>. Even after reading the WP codex, I am not able to make the necessary changes by myself.<...
[ { "answer_id": 214693, "author": "Pikk", "author_id": 41456, "author_profile": "https://wordpress.stackexchange.com/users/41456", "pm_score": 0, "selected": false, "text": "<p>The change to be done is to change:</p>\n\n<pre><code>$item_output .= '&lt;a'. $attributes .'&gt;';\n</code></pr...
2016/01/15
[ "https://wordpress.stackexchange.com/questions/214688", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41456/" ]
I have to add `itemprop="url"` to the links of the links in the navbar of [this site](http://www.anahatatantra.com/). In the settings I found the function `wp_nav_menu()`. Even after reading the WP codex, I am not able to make the necessary changes by myself. Here is the code: ``` <!-- BEGIN MAIN NAVIGATION --> <nav...
To add a new attribute to your anchor link for the nav items concatenate $attribute variable with your required attribute. You have commended code just uncomment the code and use those ``` $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_atta( $item->attr_title ) .'"' : ''; $attributes .= ! em...
214,699
<p>I have a WP_Query loop that gets posts of a certain type. These posts have custom post meta so I need to be able to get the ID of the post without echoing it so I can display that post's meta. How can I get the ID of the post without echoing it? This is my code:</p> <pre><code>$menu_id = get_the_id(); $c...
[ { "answer_id": 214718, "author": "N00b", "author_id": 80903, "author_profile": "https://wordpress.stackexchange.com/users/80903", "pm_score": 5, "selected": false, "text": "<p><code>get_the_ID()</code> can <em>(only)</em> be used within the loop. </p>\n\n<p>This retrieves the <code>ID</c...
2016/01/15
[ "https://wordpress.stackexchange.com/questions/214699", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86835/" ]
I have a WP\_Query loop that gets posts of a certain type. These posts have custom post meta so I need to be able to get the ID of the post without echoing it so I can display that post's meta. How can I get the ID of the post without echoing it? This is my code: ``` $menu_id = get_the_id(); $category_args = a...
`get_the_ID()` can *(only)* be used within the loop. This retrieves the `ID` of the current post handled by the loop. --- You can use it on it's own if you need it only once: ``` $dish_meta = get_post_meta( get_the_ID(), 'dish_meta', true ); ``` You can also store it as a variable if you need it more than once: ...
214,700
<p>I just imported a Blogger site to Wordpress, and it put the category "Uncategorized" on all posts. I ended up converting all of the tags (which did come over from Blogger) to categories, but now I still have "Uncategorized" also set for all of my posts.</p> <p>I'm trying to find out how to remove the "Uncategorized...
[ { "answer_id": 214711, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": false, "text": "<p>You can make use of <a href=\"https://codex.wordpress.org/Function_Reference/wp_remove_object_terms\" r...
2016/01/16
[ "https://wordpress.stackexchange.com/questions/214700", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75134/" ]
I just imported a Blogger site to Wordpress, and it put the category "Uncategorized" on all posts. I ended up converting all of the tags (which did come over from Blogger) to categories, but now I still have "Uncategorized" also set for all of my posts. I'm trying to find out how to remove the "Uncategorized" category...
You can make use of [`wp_remove_object_terms()`](https://codex.wordpress.org/Function_Reference/wp_remove_object_terms) to remove the desired category from a post. What we will do is, run a custom query to get all the post with the associated category, and then loop through the posts and use `wp_remove_object_terms()...
214,719
<p>I'm not very good with computers/codes etc. I use a plugin that makes a registration form thingy and in that form I added country, age group, gender and so on. I click the option that will add the registerer into the wordpress user thingy. But when I try it, only the username and email show on the Users section on t...
[ { "answer_id": 214723, "author": "Arpita Hunka", "author_id": 86864, "author_profile": "https://wordpress.stackexchange.com/users/86864", "pm_score": 7, "selected": false, "text": "<p>You need to use the <code>show_user_profile</code>, <code>edit_user_profile</code>, <code>personal_optio...
2016/01/16
[ "https://wordpress.stackexchange.com/questions/214719", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86910/" ]
I'm not very good with computers/codes etc. I use a plugin that makes a registration form thingy and in that form I added country, age group, gender and so on. I click the option that will add the registerer into the wordpress user thingy. But when I try it, only the username and email show on the Users section on the ...
You need to use the `show_user_profile`, `edit_user_profile`, `personal_options_update`, and `edit_user_profile_update` hooks. You can use the following code for adding additional fields in User section **Code for adding extra fields in Edit User Section:** ``` add_action( 'show_user_profile', 'extra_user_profile_fi...
214,727
<p>I have a wordpress website that i have added custom meta boxes to the post.</p> <p>Custom meta boxes have an editor using wp_editor(), but the editor is refusing to show the visual/text tabs on the editor panel. </p> <p>I have deactivating all plugins on my development, and the issue persisted.</p> <p>Anyone can ...
[ { "answer_id": 236180, "author": "Peter Jan Michael Porras", "author_id": 101149, "author_profile": "https://wordpress.stackexchange.com/users/101149", "pm_score": 0, "selected": false, "text": "<p>You should assign a <strong>textarea_name</strong> and your editor ID should not contain o...
2016/01/16
[ "https://wordpress.stackexchange.com/questions/214727", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86918/" ]
I have a wordpress website that i have added custom meta boxes to the post. Custom meta boxes have an editor using wp\_editor(), but the editor is refusing to show the visual/text tabs on the editor panel. I have deactivating all plugins on my development, and the issue persisted. Anyone can help me ?
Without seeing your code I can't say whats wrong but here is a working (tested) example of a metabox with an editor inside that has the visual/text tabs. ``` add_action( 'add_meta_boxes', function() { add_meta_box('html_myid_61_section', 'Meta Box Title', 'my_custom_meta_function'); }); function my_custom_meta_...
214,847
<p>I have the searchform.php set up to search a custom post type and a category. So far so good. However, a savvy user could edit the URL to remove "post_type=film" and search all pages and posts.</p> <p>I don't want it to do this! I'd essentially like the search hardcoded to only search the specific CPT regardless of...
[ { "answer_id": 214848, "author": "Jeroen", "author_id": 83390, "author_profile": "https://wordpress.stackexchange.com/users/83390", "pm_score": 0, "selected": false, "text": "<p>You can do this by editing the <code>Search.php</code> file in your theme.</p>\n\n<p>This file will contain so...
2016/01/18
[ "https://wordpress.stackexchange.com/questions/214847", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60291/" ]
I have the searchform.php set up to search a custom post type and a category. So far so good. However, a savvy user could edit the URL to remove "post\_type=film" and search all pages and posts. I don't want it to do this! I'd essentially like the search hardcoded to only search the specific CPT regardless of what is ...
I guess you mean overriding the post type of the main search query on the front-end. You could try: ``` add_action( 'pre_get_posts', function ( WP_Query $q ) { if ( ! is_admin() && $q->is_main_query() && $q->is_search() ) $q->set( 'post_type', 'film' ); } ); ``` This...
214,867
<p>I've been using Bedrock (<a href="https://roots.io/bedrock/" rel="nofollow">https://roots.io/bedrock/</a>) for a while to deploy WordPress websites, but have encountered some issues when deploying to a Siteground.com shared server.</p> <p>The issue is with composer. I can run composer globaly with no problem, but w...
[ { "answer_id": 217513, "author": "solosik", "author_id": 45301, "author_profile": "https://wordpress.stackexchange.com/users/45301", "pm_score": 0, "selected": false, "text": "<p>You can try to use something like <strong>Codeship</strong> instead. </p>\n\n<p>Unfortunately I didn't try it...
2016/01/18
[ "https://wordpress.stackexchange.com/questions/214867", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82491/" ]
I've been using Bedrock (<https://roots.io/bedrock/>) for a while to deploy WordPress websites, but have encountered some issues when deploying to a Siteground.com shared server. The issue is with composer. I can run composer globaly with no problem, but when I run it using Capistrano, it executes the command, but not...
The solution was pretty simple, actually. I just needed to specify the path of the php-cli that I wanted to use and where the composer.phar file was located. So I added the following to my depoly.rb script for Capistrano: ``` SSHKit.config.command_map[:composer] = "/usr/local/php56/bin/php-cli ~/composer.phar" ```
214,868
<p>I'm developing an order management system that hooks into <a href="https://docs.woothemes.com/documentation/plugins/woocommerce/" rel="noreferrer">WooCommerce</a> but the <a href="https://docs.woothemes.com/document/webhooks/" rel="noreferrer">Webhook</a> behaves irregularly. The <a href="https://docs.woothemes.com/...
[ { "answer_id": 215482, "author": "Alex Seif", "author_id": 62682, "author_profile": "https://wordpress.stackexchange.com/users/62682", "pm_score": 4, "selected": true, "text": "<p>Apparently a WooCommerce Webhook will automatically disable due to delivery failure. \n<a href=\"https://doc...
2016/01/18
[ "https://wordpress.stackexchange.com/questions/214868", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62682/" ]
I'm developing an order management system that hooks into [WooCommerce](https://docs.woothemes.com/documentation/plugins/woocommerce/) but the [Webhook](https://docs.woothemes.com/document/webhooks/) behaves irregularly. The [Webhook](https://docs.woothemes.com/document/webhooks/) gets disabled on its own. I've invest...
Apparently a WooCommerce Webhook will automatically disable due to delivery failure. <https://docs.woothemes.com/document/webhooks/#section-3> > > “Disabled” (does not deliver due delivery failures). > > >
214,910
<p>In the <strong>thankyou.php</strong> template there is an action showing the section marked in red in the image. The problem is the caption/title "<strong>Our Bank Detals</strong>" should be above the description not beneath.</p> <p><img src="https://i.stack.imgur.com/Ll936.jpg" alt="screen-dump"></p> <p>The code ...
[ { "answer_id": 214981, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 2, "selected": false, "text": "<p>Unfortunately there is no hook available to remove that \"Our Bank Details\" text. But, you can hide th...
2016/01/18
[ "https://wordpress.stackexchange.com/questions/214910", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87041/" ]
In the **thankyou.php** template there is an action showing the section marked in red in the image. The problem is the caption/title "**Our Bank Detals**" should be above the description not beneath. ![screen-dump](https://i.stack.imgur.com/Ll936.jpg) The code in **thankyou.php** that create this section is: ``` <?p...
I ended up inserting the payment description. (the one you specify in the woocommerce settings in the Wordpress backend) The "native" build-in woocommerce payment-text is static and doesn't relates to the actual selected payment method. :-( I did this by modifying the woocommerce template file: 1: Copy this templ...
214,911
<p>The problem I'm having is that <code>the_excerpt()</code> isn't returning the content from the post's "Excerpt" field. Instead, it's returning the first 55 words of the post, as though the "Excerpt" field is empty.</p> <p>My code is very simple - inside the loop, I have:</p> <pre><code>if( has_excerpt() ) { th...
[ { "answer_id": 214981, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 2, "selected": false, "text": "<p>Unfortunately there is no hook available to remove that \"Our Bank Details\" text. But, you can hide th...
2016/01/18
[ "https://wordpress.stackexchange.com/questions/214911", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76191/" ]
The problem I'm having is that `the_excerpt()` isn't returning the content from the post's "Excerpt" field. Instead, it's returning the first 55 words of the post, as though the "Excerpt" field is empty. My code is very simple - inside the loop, I have: ``` if( has_excerpt() ) { the_excerpt(); } else { the_co...
I ended up inserting the payment description. (the one you specify in the woocommerce settings in the Wordpress backend) The "native" build-in woocommerce payment-text is static and doesn't relates to the actual selected payment method. :-( I did this by modifying the woocommerce template file: 1: Copy this templ...
214,927
<p>I have the following snippet that allows me to auto generate the post title. I'd like to change the <code>$post_type</code> of the <code>'post_title' =&gt; $post_type . ' Job #' . $post_id</code> line to some other post property like <code>post_date</code> and <code>post_author</code>.</p> <pre><code>function save_...
[ { "answer_id": 214929, "author": "Linnea Huxford", "author_id": 86210, "author_profile": "https://wordpress.stackexchange.com/users/86210", "pm_score": 0, "selected": false, "text": "<p>Use the function <a href=\"https://developer.wordpress.org/reference/functions/get_post_meta/\" rel=\"...
2016/01/19
[ "https://wordpress.stackexchange.com/questions/214927", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37346/" ]
I have the following snippet that allows me to auto generate the post title. I'd like to change the `$post_type` of the `'post_title' => $post_type . ' Job #' . $post_id` line to some other post property like `post_date` and `post_author`. ``` function save_post_func_2134( $post_id ) { $post_type = 'post'; //...
The post object is passed by reference as the second parameter of the [`save_post` action (*`do_action ( 'save_post', int $post_ID, WP_Post $post, bool $update )`*](https://developer.wordpress.org/reference/hooks/save_post/). You can use this post object to get the post date and author from. You can try the following:...
214,977
<p>I would like to receive datas from an external client to a Wordpress website. Example: I send an email to someone and I would like to send a copy (to archive it) to the website/smtp server. </p> <p>Is there an easy solution in?</p> <p>Email send to <code>example@example.com</code> copy to <code>website@wordpress.c...
[ { "answer_id": 214979, "author": "Jenis Patel", "author_id": 65707, "author_profile": "https://wordpress.stackexchange.com/users/65707", "pm_score": -1, "selected": false, "text": "<p>Hope the below mentioned plugin will help you : </p>\n\n<p><a href=\"https://wordpress.org/plugins/easy-...
2016/01/19
[ "https://wordpress.stackexchange.com/questions/214977", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87076/" ]
I would like to receive datas from an external client to a Wordpress website. Example: I send an email to someone and I would like to send a copy (to archive it) to the website/smtp server. Is there an easy solution in? Email send to `example@example.com` copy to `website@wordpress.com`
By default, WordPress is not equipped to be an email server. It can ***send*** email but does not ***receive*** email. If you want to ***send*** mail to multiple recipients then [`wp_mail`](https://codex.wordpress.org/Function_Reference/wp_mail) will allow you to specify multiple addresses. ``` <?php $multiple_recip...
214,986
<p>I am listing custom taxonomy names. The list is displaying and the table structure is:</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;Name 1&lt;/td&gt; &lt;td&gt;Name 2&lt;/td&gt; &lt;td&gt;Name 3&lt;/td&gt; &lt;td&gt;Name 4&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; ......
[ { "answer_id": 214979, "author": "Jenis Patel", "author_id": 65707, "author_profile": "https://wordpress.stackexchange.com/users/65707", "pm_score": -1, "selected": false, "text": "<p>Hope the below mentioned plugin will help you : </p>\n\n<p><a href=\"https://wordpress.org/plugins/easy-...
2016/01/19
[ "https://wordpress.stackexchange.com/questions/214986", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37320/" ]
I am listing custom taxonomy names. The list is displaying and the table structure is: ``` <table> <tr> <td>Name 1</td> <td>Name 2</td> <td>Name 3</td> <td>Name 4</td> </tr> <tr> ..... </table> ``` The fourth name doesn't display, skipping to to the 5th. If I don't ...
By default, WordPress is not equipped to be an email server. It can ***send*** email but does not ***receive*** email. If you want to ***send*** mail to multiple recipients then [`wp_mail`](https://codex.wordpress.org/Function_Reference/wp_mail) will allow you to specify multiple addresses. ``` <?php $multiple_recip...
215,032
<p>I'm upgrading my website and it's using WordPress. I'm using sub-domain <code>cdn</code> for CDN and it needs to be cookieless.</p> <p>Currently my website is a multi-network of multisites (both are subdirectory installs), with the subdomain <code>www</code> hosting my main music project, and subdomain <code>photo<...
[ { "answer_id": 215108, "author": "David", "author_id": 31323, "author_profile": "https://wordpress.stackexchange.com/users/31323", "pm_score": 4, "selected": true, "text": "<p>As <code>cdn.mydomain.com</code> is not part of your WordPress network, it wont be affected by your settings. </...
2016/01/19
[ "https://wordpress.stackexchange.com/questions/215032", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67721/" ]
I'm upgrading my website and it's using WordPress. I'm using sub-domain `cdn` for CDN and it needs to be cookieless. Currently my website is a multi-network of multisites (both are subdirectory installs), with the subdomain `www` hosting my main music project, and subdomain `photo` hosting my photography project. The...
As `cdn.mydomain.com` is not part of your WordPress network, it wont be affected by your settings. The `COOKIE_DOMAIN` constant should only be used if you want to serve cookies from a single domain *for all your sites in the network*. If you omit the constant or set it to an empty value, cookies will belong to the do...
215,041
<p>I am building a single author blog that will include multiple categories. One main category is "Movie Reviews."</p> <p>The author will leave a short review every time they watch a movie - even if they've seen the movie in the past and reviewed it on their site in the past.</p> <p>For the "Movie Reviews" category (...
[ { "answer_id": 215794, "author": "тнє Sufi", "author_id": 28744, "author_profile": "https://wordpress.stackexchange.com/users/28744", "pm_score": 3, "selected": false, "text": "<p>I am not sure if this is the best solution or not, but it works:</p>\n\n<pre><code>function movie_review_per...
2016/01/19
[ "https://wordpress.stackexchange.com/questions/215041", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14558/" ]
I am building a single author blog that will include multiple categories. One main category is "Movie Reviews." The author will leave a short review every time they watch a movie - even if they've seen the movie in the past and reviewed it on their site in the past. For the "Movie Reviews" category (only this categor...
I am not sure if this is the best solution or not, but it works: ``` function movie_review_permalink( $url, $post, $leavename ) { $category = get_the_category($post->ID); if ( !empty($category) && $category[0]->slug == "test" ) { //change 'test' to your category slug $date=date_create($post->post_dat...
215,053
<p>I cannot load <code>admin-ajax.php</code> and I keep getting this error message:</p> <blockquote> <p>XMLHttpRequest cannot load ..../wp-admin/admin-ajax.php.,. No 'Access-Control-Allow-Origin' header is present on...</p> </blockquote> <p>On local WAMP it worked just to add this:</p> <pre><code>header("Access-...
[ { "answer_id": 248729, "author": "ben", "author_id": 108609, "author_profile": "https://wordpress.stackexchange.com/users/108609", "pm_score": 4, "selected": true, "text": "<p>There are filters for <code>allowed_http_origins</code> and <code>add_allowed_origins</code>.\nYou can use them ...
2016/01/19
[ "https://wordpress.stackexchange.com/questions/215053", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38848/" ]
I cannot load `admin-ajax.php` and I keep getting this error message: > > XMLHttpRequest cannot load ..../wp-admin/admin-ajax.php.,. No > 'Access-Control-Allow-Origin' header is present on... > > > On local WAMP it worked just to add this: ``` header("Access-Control-Allow-Origin: *"); ``` (Even if this seems...
There are filters for `allowed_http_origins` and `add_allowed_origins`. You can use them to set the proper Access-Control-Allow-Origin header in the response to your AJAX call. Add this to your theme's `functions.php` file: ``` add_filter('allowed_http_origins', 'add_allowed_origins'); function add_allowed_origins($...
215,063
<p>I am using the following filter to run a function that generates a CSS file after a plugin gets updated. Currently the CSS gets generated when any plugin gets updated. Is there a simple way to limit this running to a particular plugin?</p> <pre><code>add_filter('upgrader_post_install', 'generate_my_css', 100, 0); ...
[ { "answer_id": 215097, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 2, "selected": true, "text": "<p><a href=\"https://developer.wordpress.org/reference/hooks/upgrader_post_install/\" rel=\"nofollow\">...
2016/01/20
[ "https://wordpress.stackexchange.com/questions/215063", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81133/" ]
I am using the following filter to run a function that generates a CSS file after a plugin gets updated. Currently the CSS gets generated when any plugin gets updated. Is there a simple way to limit this running to a particular plugin? ``` add_filter('upgrader_post_install', 'generate_my_css', 100, 0); function gener...
[`upgrader_post_install`](https://developer.wordpress.org/reference/hooks/upgrader_post_install/) has three parameters `$response`, `$hook_extra` and `$result` which give you extra information. At the moment I can't take a look myself, but I'm assuming that especially the `$result` variable should give you additional i...
215,119
<p>The <code>is_page()</code> with post id, post slug isn't working. Below is the code i have been using in divi child theme at the end of the <code>functions.php</code> file.</p> <pre><code>function addingcattocatlist($cat_list){ if ( is_page('blog') ) { $cat_list = 'blog: '. '' .$cat_list; ...
[ { "answer_id": 215122, "author": "Lorraine", "author_id": 87158, "author_profile": "https://wordpress.stackexchange.com/users/87158", "pm_score": 2, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>if ( is_front_page() &amp;&amp; is_home() ) {\n // Default homepage\n} elseif (...
2016/01/20
[ "https://wordpress.stackexchange.com/questions/215119", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87172/" ]
The `is_page()` with post id, post slug isn't working. Below is the code i have been using in divi child theme at the end of the `functions.php` file. ``` function addingcattocatlist($cat_list){ if ( is_page('blog') ) { $cat_list = 'blog: '. '' .$cat_list; } return $cat_list; } ...
Try this: ``` if ( is_front_page() && is_home() ) { // Default homepage } elseif ( is_front_page() ) { // static homepage } elseif ( is_home() ) { // blog page } else { //everything else } ``` Source: <http://codex.wordpress.org/Conditional_Tags>
215,124
<p>I'd like to remove the link from the Woocommerce product listings. I don't need the user to see the product detail pages, we are going to use Quick View instead. Anywho, I have been searching and everything I've found is outdated. This is the current <code>content-product.php</code> file: <a href="https://github.com...
[ { "answer_id": 215127, "author": "MrFox", "author_id": 69240, "author_profile": "https://wordpress.stackexchange.com/users/69240", "pm_score": 1, "selected": true, "text": "<p>The way I've done this was to take a copy of content-product.php and paste it into the root of your theme folder...
2016/01/20
[ "https://wordpress.stackexchange.com/questions/215124", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73662/" ]
I'd like to remove the link from the Woocommerce product listings. I don't need the user to see the product detail pages, we are going to use Quick View instead. Anywho, I have been searching and everything I've found is outdated. This is the current `content-product.php` file: <https://github.com/woothemes/woocommerce...
The way I've done this was to take a copy of content-product.php and paste it into the root of your theme folder. Comment out `do_action( 'woocommerce_before_shop_loop_item_title' );` and `do_action( 'woocommerce_after_shop_loop_item' );` Quick and dirty, but it worked for me.
215,128
<p>I've shut down password resets for all users.</p> <p>I now need to prevent <code>/wp-login.php?action=lostpassword</code> from doing anything should anyone manually input the URL into their browser.</p> <p>i.e. I don't want the password reset form to show.</p> <p>Can I disable the action that's being passed by th...
[ { "answer_id": 215136, "author": "jas", "author_id": 80247, "author_profile": "https://wordpress.stackexchange.com/users/80247", "pm_score": 4, "selected": true, "text": "<p>Hi Please try to use this in your functions.php it will redirect user to login form when user try to access lost p...
2016/01/20
[ "https://wordpress.stackexchange.com/questions/215128", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41545/" ]
I've shut down password resets for all users. I now need to prevent `/wp-login.php?action=lostpassword` from doing anything should anyone manually input the URL into their browser. i.e. I don't want the password reset form to show. Can I disable the action that's being passed by the URL or can I redirect `/wp-login....
Hi Please try to use this in your functions.php it will redirect user to login form when user try to access lost password page: ``` add_action('init','possibly_redirect'); function possibly_redirect(){ if (isset( $_GET['action'] )){ if ( in_array( $_GET['action'], array('lostpassword', 'retrievepassword') ...
215,150
<p>I'm trying to remove the Category URI from the WordPress URL and have a custom pagination rewrite. I'll explain exactly what's happening below:</p> <p>So I have a blog.</p> <p>We have two (main) categories: "bar-talk" and "tutorials". I'll use "Bar Talk" for the example.</p> <p>I've found with WordPress, I can ac...
[ { "answer_id": 215155, "author": "DrizzlyOwl", "author_id": 31627, "author_profile": "https://wordpress.stackexchange.com/users/31627", "pm_score": 2, "selected": false, "text": "<p>Hm. Have you thought about doing some URL rewrites in .htaccess?\n<code>\nRewriteRule ^category/bar-talk/p...
2016/01/20
[ "https://wordpress.stackexchange.com/questions/215150", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38881/" ]
I'm trying to remove the Category URI from the WordPress URL and have a custom pagination rewrite. I'll explain exactly what's happening below: So I have a blog. We have two (main) categories: "bar-talk" and "tutorials". I'll use "Bar Talk" for the example. I've found with WordPress, I can actually visit both of the...
Hm. Have you thought about doing some URL rewrites in .htaccess? `RewriteRule ^category/bar-talk/page/([0-9]+)$ /bar-talk/drink-number/$1 [L,R=301] RewriteRule ^bar-talk/drink-number/([0-9]+)$ /index.php?category_name=bar-talk&page=$1 [L]` // @drizzlyowl
215,157
<p>Here's the code we're using to set an image file as an option for the site's logo via WordPress' theme customizer:</p> <pre><code>/* Logo &gt; Image -------------------------------------------------- */ $wp_customize-&gt;add_setting( 'themeslug_logo' ); $wp_customize-&gt;add_control( new WP_Customize_Image_Co...
[ { "answer_id": 215161, "author": "Ryan Dorn", "author_id": 47880, "author_profile": "https://wordpress.stackexchange.com/users/47880", "pm_score": 1, "selected": false, "text": "<p>OK, well, we found a quick and perhaps a bit dirty solution using PHP's <a href=\"http://php.net/manual/en/...
2016/01/20
[ "https://wordpress.stackexchange.com/questions/215157", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47880/" ]
Here's the code we're using to set an image file as an option for the site's logo via WordPress' theme customizer: ``` /* Logo > Image -------------------------------------------------- */ $wp_customize->add_setting( 'themeslug_logo' ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_cus...
Modern answer to this question: We have `WP_Customize_Media_Control` control in WP since **4.2** that gives you the attachment id. This answer was posted on I [similar question](https://wordpress.stackexchange.com/a/259845/54025). You can see the documentation for `WP_Customize_Media_Control` [here](https://developer...
215,164
<p>I have the following in a child theme's functions.php file:</p> <pre><code>&lt;?php function theme_child_add_scripts() { wp_register_script( 'script', get_stylesheet_directory_uri() . '/js/script.js', array( 'jquery' ), null, false ); wp_enqueue_script( 'script' ...
[ { "answer_id": 215351, "author": "twsmith", "author_id": 87192, "author_profile": "https://wordpress.stackexchange.com/users/87192", "pm_score": 2, "selected": true, "text": "<p>Our problem was that our style.css file was in a css folder inside the child theme directory, not at the root ...
2016/01/20
[ "https://wordpress.stackexchange.com/questions/215164", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87192/" ]
I have the following in a child theme's functions.php file: ``` <?php function theme_child_add_scripts() { wp_register_script( 'script', get_stylesheet_directory_uri() . '/js/script.js', array( 'jquery' ), null, false ); wp_enqueue_script( 'script' ) } add_action('w...
Our problem was that our style.css file was in a css folder inside the child theme directory, not at the root of the child theme. When we placed a style.css file at the root and included the comment block with theme name and template it picked up the functions.php file as expected.
215,181
<p>So I've set up my site to use static pages for the front page and the posts page. Now I'm creating my posts page template. I wanted to grab some content from the actual page I made for the posts page (even though it's no longer really considered a page) and I figured out how to do it...sort of.</p> <pre><code>$post...
[ { "answer_id": 215351, "author": "twsmith", "author_id": 87192, "author_profile": "https://wordpress.stackexchange.com/users/87192", "pm_score": 2, "selected": true, "text": "<p>Our problem was that our style.css file was in a css folder inside the child theme directory, not at the root ...
2016/01/21
[ "https://wordpress.stackexchange.com/questions/215181", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87200/" ]
So I've set up my site to use static pages for the front page and the posts page. Now I'm creating my posts page template. I wanted to grab some content from the actual page I made for the posts page (even though it's no longer really considered a page) and I figured out how to do it...sort of. ``` $posts_page = get_o...
Our problem was that our style.css file was in a css folder inside the child theme directory, not at the root of the child theme. When we placed a style.css file at the root and included the comment block with theme name and template it picked up the functions.php file as expected.
215,193
<p>I'm using URL parameters as actions links within a custom WP_List_Table for users like so:</p> <pre><code>http://domain.com/wp-admin/users.php?page=account-expiration-status&amp;do_action_xyz&amp;email=email%40domain.com&amp;_wpnonce=xyz </code></pre> <p>Within the parent class, I'm checking for the existence of</...
[ { "answer_id": 215201, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 1, "selected": false, "text": "<p>You should consider the POST request method for your action.</p>\n\n<p>Otherwise you might try to hijack the ...
2016/01/21
[ "https://wordpress.stackexchange.com/questions/215193", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73917/" ]
I'm using URL parameters as actions links within a custom WP\_List\_Table for users like so: ``` http://domain.com/wp-admin/users.php?page=account-expiration-status&do_action_xyz&email=email%40domain.com&_wpnonce=xyz ``` Within the parent class, I'm checking for the existence of ``` array_key_exists( 'do_action_xyz...
You should consider the POST request method for your action. Otherwise you might try to hijack the `set_url_scheme` filter with: ``` add_filter( 'set_url_scheme', 'wpse_remove_arg' ); function wpse_remove_arg( $url ) { return remove_query_arg( 'do_action_xyz', $url ); } ``` Then you could try to narrow the ...
215,199
<p>I am writing my custom theme from scratch and I have a custom post type 'my_frontpage' and want to declare one of it's posts as front-page. I want to do this via admin, hence simply add my cpt to the <em>Front Page</em> select box in <em>Appearance >> Customize >> Static Front Page</em>. </p> <p>This issue has been...
[ { "answer_id": 215445, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": true, "text": "<p>I had time to look at your issue and the <a href=\"https://github.com/WordPress/WordPress/blob/master/wp...
2016/01/21
[ "https://wordpress.stackexchange.com/questions/215199", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63707/" ]
I am writing my custom theme from scratch and I have a custom post type 'my\_frontpage' and want to declare one of it's posts as front-page. I want to do this via admin, hence simply add my cpt to the *Front Page* select box in *Appearance >> Customize >> Static Front Page*. This issue has been discussed quite a few ...
I had time to look at your issue and the [*options-reading.php*](https://github.com/WordPress/WordPress/blob/master/wp-admin/options-reading.php) page which is the template used to render the reading settings page in backend. There are unfortunately no filters to filter or add custom posts as sticky posts in a selecta...
215,219
<p>currently i add a custom billing field in woocommerce by </p> <pre><code>function custom_override_checkout_fields( $fields ) { $fields['billing']['billing_phone_new'] = array( 'label' =&gt; __('Phone 2', 'woocommerce'), 'placeholder' =&gt; _x('Phone 2', 'placeholder', 'woocommerce'), 'requ...
[ { "answer_id": 215447, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 6, "selected": true, "text": "<p>The code you have provided is incomplete. Not sure if that is the only code you are using to achieve wha...
2016/01/21
[ "https://wordpress.stackexchange.com/questions/215219", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86219/" ]
currently i add a custom billing field in woocommerce by ``` function custom_override_checkout_fields( $fields ) { $fields['billing']['billing_phone_new'] = array( 'label' => __('Phone 2', 'woocommerce'), 'placeholder' => _x('Phone 2', 'placeholder', 'woocommerce'), 'required' => false, ...
The code you have provided is incomplete. Not sure if that is the only code you are using to achieve what you want. So, besides first code block which you have provided, bellow I am adding all rest of the code which is required to show the new field on backend in 'Order Details' box and make it editable through custom ...
215,239
<p>I'm trying to make a menu that automatically populates from a custom post type I have and I'm having some trouble getting it right If someone could point me in the right direction I would greatly appreciate it. Here is the code. The PHP in the <code>&lt;img src&gt;</code> is pulling the right info and sticking it...
[ { "answer_id": 215241, "author": "ScheRas", "author_id": 87069, "author_profile": "https://wordpress.stackexchange.com/users/87069", "pm_score": 4, "selected": true, "text": "<p><code>the_permalink()</code> <strong>prints</strong> url immediately and returns nothing, you should use <code...
2016/01/21
[ "https://wordpress.stackexchange.com/questions/215239", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84703/" ]
I'm trying to make a menu that automatically populates from a custom post type I have and I'm having some trouble getting it right If someone could point me in the right direction I would greatly appreciate it. Here is the code. The PHP in the `<img src>` is pulling the right info and sticking it in the right spot, `th...
`the_permalink()` **prints** url immediately and returns nothing, you should use `get_the_permalink()` function, which **returns** current post url.
215,289
<p>I want to wrap <code>&lt;strong&gt;&lt;/strong&gt;</code> around the words "logged out":</p> <pre><code>add_filter( 'gettext', 'wpse17709_gettext', 10, 2 ); function wpse17709_gettext( $custom_translation, $login_texts ) { // Messages if ( 'You are now logged out.' == $login_texts ) { return ''; } // Log o...
[ { "answer_id": 215294, "author": "Clarus Dignus", "author_id": 41545, "author_profile": "https://wordpress.stackexchange.com/users/41545", "pm_score": 1, "selected": false, "text": "<p>Based on Sven's recommended solution and Tom J Nowell's warning about <code>gettext()</code> (see comme...
2016/01/22
[ "https://wordpress.stackexchange.com/questions/215289", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41545/" ]
I want to wrap `<strong></strong>` around the words "logged out": ``` add_filter( 'gettext', 'wpse17709_gettext', 10, 2 ); function wpse17709_gettext( $custom_translation, $login_texts ) { // Messages if ( 'You are now logged out.' == $login_texts ) { return ''; } // Log out message return $translation }...
This allows for the message to be overwritten specifically for the `loggedout` message while leaving all other messages alone. [Here is more documentation on the filter](https://developer.wordpress.org/reference/hooks/wp_login_errors/). ``` add_filter( 'wp_login_errors', 'my_logout_message' ); function my_logout_mess...
215,297
<p><a href="https://wordpress.org/plugins/tabulate/" rel="nofollow">A plugin</a> I maintain uses Twig templates to produce HTML (and some other outputs). I've tried using <code>__()</code> within these (first adding the i18n functions with <code>$twig-&gt;addFunction()</code>) but it doesn't work. The strings are outpu...
[ { "answer_id": 215294, "author": "Clarus Dignus", "author_id": 41545, "author_profile": "https://wordpress.stackexchange.com/users/41545", "pm_score": 1, "selected": false, "text": "<p>Based on Sven's recommended solution and Tom J Nowell's warning about <code>gettext()</code> (see comme...
2016/01/22
[ "https://wordpress.stackexchange.com/questions/215297", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58142/" ]
[A plugin](https://wordpress.org/plugins/tabulate/) I maintain uses Twig templates to produce HTML (and some other outputs). I've tried using `__()` within these (first adding the i18n functions with `$twig->addFunction()`) but it doesn't work. The strings are output correctly, but not picked up for inclusion in the `....
This allows for the message to be overwritten specifically for the `loggedout` message while leaving all other messages alone. [Here is more documentation on the filter](https://developer.wordpress.org/reference/hooks/wp_login_errors/). ``` add_filter( 'wp_login_errors', 'my_logout_message' ); function my_logout_mess...
215,321
<p>I have a custom php page and i need to override the global posts variables, but i cant get it to work. When going through the main loop im able to override the global posts, but i cant override whatever have_posts() is using to obtain the count. Im obtaining data from a 3rd party API so i need to build the WP object...
[ { "answer_id": 215329, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 1, "selected": false, "text": "<p>It is quite hard to understand what you need to do here, but you need to look at the following</p>\n\n<...
2016/01/22
[ "https://wordpress.stackexchange.com/questions/215321", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/190834/" ]
I have a custom php page and i need to override the global posts variables, but i cant get it to work. When going through the main loop im able to override the global posts, but i cant override whatever have\_posts() is using to obtain the count. Im obtaining data from a 3rd party API so i need to build the WP object o...
I found the solution to this was in the $wp\_query variable. By getting the global variable for this and overriding the values within it i was able to have full control over what displayed on the page. This allowed me to generate a WP post object that came from a database outside of wordpress, but didnt have to do anyt...
215,343
<p>I have running a wordpress site on - lets say - "site.com" and another site "input.com" hosted in completely different locations. As the name suggests, "input.com" should be used as a input site with a very simple form (for example: title and content). The entered information should then be sent to "site.com" and po...
[ { "answer_id": 215347, "author": "jdm2112", "author_id": 45202, "author_profile": "https://wordpress.stackexchange.com/users/45202", "pm_score": 0, "selected": false, "text": "<p>Setup a script on site.com to receive the data from input.com and use <code>wp_insert_post()</code> to create...
2016/01/22
[ "https://wordpress.stackexchange.com/questions/215343", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87300/" ]
I have running a wordpress site on - lets say - "site.com" and another site "input.com" hosted in completely different locations. As the name suggests, "input.com" should be used as a input site with a very simple form (for example: title and content). The entered information should then be sent to "site.com" and poste...
I finally managed to accomplish the task using XML-RPC as suggested by denis.stoyanov. If xmlrpc is installed on your Server simply use the [wpPostXMLRPC function](https://stackoverflow.com/questions/24264761/how-to-add-posts-in-wordpress-without-admin-login-using-xml-rpc-and-curl) from stackoverflow. But keep in mind ...
215,375
<p>I'm using some private posts for intern purposes. When an editor changes something on these posts, its status turns to pending "review" and I have to publish it again as a private post.</p> <p>When an editor changes something on a normal page/post - that has already been published for public - the status doesn't ch...
[ { "answer_id": 216389, "author": "jhcorsair", "author_id": 73025, "author_profile": "https://wordpress.stackexchange.com/users/73025", "pm_score": -1, "selected": false, "text": "<p>I would check that your users have the same capability. It sounds like this is happening: </p>\n\n<p>\"Int...
2016/01/22
[ "https://wordpress.stackexchange.com/questions/215375", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87321/" ]
I'm using some private posts for intern purposes. When an editor changes something on these posts, its status turns to pending "review" and I have to publish it again as a private post. When an editor changes something on a normal page/post - that has already been published for public - the status doesn't change, so I...
As it doesn't look as though the OP is coming back, I'm adding their answer as an answer rather than leaving it in the question: > > For everyone dealing with the same problem: I was able to fix it with > a code snippet of another thread: > <https://wordpress.stackexchange.com/a/172556/87321> > > > Just had to ad...
215,386
<p>I'm registering my javascript files for Wordpress in my functions file as so:</p> <pre><code>if( !function_exists( "theme_js" ) ) { function theme_js(){ wp_register_script('wpbs-scripts', get_template_directory_uri() . '/library/js/min/scripts.min.js', array('jquery'), '1.4...
[ { "answer_id": 215388, "author": "mrmadhat", "author_id": 68703, "author_profile": "https://wordpress.stackexchange.com/users/68703", "pm_score": 0, "selected": false, "text": "<p>Don't you need to be using wp_enqueue_script instead of wp_register_script? What I get from the <a href=\"ht...
2016/01/22
[ "https://wordpress.stackexchange.com/questions/215386", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64789/" ]
I'm registering my javascript files for Wordpress in my functions file as so: ``` if( !function_exists( "theme_js" ) ) { function theme_js(){ wp_register_script('wpbs-scripts', get_template_directory_uri() . '/library/js/min/scripts.min.js', array('jquery'), '1.43', ...
I have not directly an answer to solve your issue as it *(please take a look at the **edit** part I add)*, but this codesnippet (`function`) could maybe help you to solve the version issues for .js as well for .css files. ``` /** * Remove query (output)string from .js / .css * Using filters */ function wpse21538...
215,403
<p>I created a shortcode that will list the categories in my custom taxonomy and will return a list of all the categories that have at least 1 post (not empty).</p> <p>The result is that when someone clicks on my links it takes them to an archive page of that category.</p> <p>My question is if it's possible that when...
[ { "answer_id": 215388, "author": "mrmadhat", "author_id": 68703, "author_profile": "https://wordpress.stackexchange.com/users/68703", "pm_score": 0, "selected": false, "text": "<p>Don't you need to be using wp_enqueue_script instead of wp_register_script? What I get from the <a href=\"ht...
2016/01/23
[ "https://wordpress.stackexchange.com/questions/215403", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77767/" ]
I created a shortcode that will list the categories in my custom taxonomy and will return a list of all the categories that have at least 1 post (not empty). The result is that when someone clicks on my links it takes them to an archive page of that category. My question is if it's possible that when there is only on...
I have not directly an answer to solve your issue as it *(please take a look at the **edit** part I add)*, but this codesnippet (`function`) could maybe help you to solve the version issues for .js as well for .css files. ``` /** * Remove query (output)string from .js / .css * Using filters */ function wpse21538...
215,407
<p>I downloaded a WordPress website that I am modifying for a friend. He gave me access to cPanel, where I downloaded the SQL and changed it on <a href="https://www.apachefriends.org/" rel="nofollow">XAMPP</a>.</p> <p>Now when I open <code>&gt;localhost/wp</code> it opens the website but without the control panel.</p...
[ { "answer_id": 215410, "author": "SeanJ", "author_id": 71456, "author_profile": "https://wordpress.stackexchange.com/users/71456", "pm_score": 0, "selected": false, "text": "<p>When you say downloaded, do you mean exported (using the all in one migration plugin or similar). </p>\n\n<p>If...
2016/01/23
[ "https://wordpress.stackexchange.com/questions/215407", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87347/" ]
I downloaded a WordPress website that I am modifying for a friend. He gave me access to cPanel, where I downloaded the SQL and changed it on [XAMPP](https://www.apachefriends.org/). Now when I open `>localhost/wp` it opens the website but without the control panel. I think to modify I need to access `>localhost/wp/w...
As long as you know the `username` you can have WP automatically log you in. You might need to ask your *friend* what that is. Check to see if you're [logged in](https://codex.wordpress.org/Function_Reference/is_user_logged_in) and if not, [get user by login](https://codex.wordpress.org/Function_Reference/get_user_by)...
215,423
<p>I had installed a Wordpress theme on my localhost on my ubuntu 14.04.</p> <p>Now, I have forgot my admin password and I am not able to login.</p> <p>What's the way to login, as I am not able to get the email confirmation link in the email via <em>lost password</em>.</p>
[ { "answer_id": 215425, "author": "Devendra Sharma", "author_id": 70571, "author_profile": "https://wordpress.stackexchange.com/users/70571", "pm_score": 3, "selected": true, "text": "<p>If you have database access,of course you have because it is localhost.\nYou can update password(MD5) ...
2016/01/23
[ "https://wordpress.stackexchange.com/questions/215423", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87051/" ]
I had installed a Wordpress theme on my localhost on my ubuntu 14.04. Now, I have forgot my admin password and I am not able to login. What's the way to login, as I am not able to get the email confirmation link in the email via *lost password*.
If you have database access,of course you have because it is localhost. You can update password(MD5) in database. Or if you have not access.You can try code in function.php only one time. ``` <?php $user_id = 1; $password = 'HelloWorld'; wp_set_password( $password, $user_id ); ?> ```
215,434
<p>i have a posts tag with 'php'.....i am using this code to show all posts tag with 'php' but it not work</p> <pre><code>&lt;?php query_posts('tag=$tag'); if ( have_posts() ) : while ( have_posts() ) : the_post(); the_content() endwhile; endif ; ?&gt; </code></pre>
[ { "answer_id": 215437, "author": "Sumit", "author_id": 32475, "author_profile": "https://wordpress.stackexchange.com/users/32475", "pm_score": 2, "selected": false, "text": "<p>It is not recommended to use <code>query_posts</code>. But this is not the problem, Problem is you are using PH...
2016/01/23
[ "https://wordpress.stackexchange.com/questions/215434", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85875/" ]
i have a posts tag with 'php'.....i am using this code to show all posts tag with 'php' but it not work ``` <?php query_posts('tag=$tag'); if ( have_posts() ) : while ( have_posts() ) : the_post(); the_content() endwhile; endif ; ?> ```
It is not recommended to use `query_posts`. But this is not the problem, Problem is you are using PHP variable in single quotes. `'tag=$tag'` Consider these examples: ``` query_posts('tag=php'); //OR query_posts("tag=$tag"); //$tag should output: php ``` *Using `WP_query //Recommended`* ``` $query = new WP_Query(...
215,459
<p>Let's assume that there is a plugin that displays 20 related posts (for each post) with a very complex query. And then using data from this query, it builds complex HTML layout. Also, should be noted that the plugin is public, and can be installed on any server with any configuration.</p> <p>Something like:</p> <p...
[ { "answer_id": 215608, "author": "kovshenin", "author_id": 1316, "author_profile": "https://wordpress.stackexchange.com/users/1316", "pm_score": 5, "selected": true, "text": "<blockquote>\n <p>Should I use Transient API at all here?</p>\n</blockquote>\n\n<p>No.</p>\n\n<p>In a stock Word...
2016/01/23
[ "https://wordpress.stackexchange.com/questions/215459", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8331/" ]
Let's assume that there is a plugin that displays 20 related posts (for each post) with a very complex query. And then using data from this query, it builds complex HTML layout. Also, should be noted that the plugin is public, and can be installed on any server with any configuration. Something like: ``` /* complex a...
> > Should I use Transient API at all here? > > > No. In a stock WordPress install transients are stored in the wp\_options table, and only cleaned up during core upgrades. Suppose you have 50,000 posts, that's 50,000 additional rows in the options table. Obviously they're set to autoload=no, so it's not going to...
215,463
<p>Before I had the following code in the function.php</p> <pre><code>add_filter('widget_text','execute_php',100); function execute_php($html){ if(strpos($html,"&lt;"."?php")!==false){ ob_start(); eval("?"."&gt;".$html); $html=ob_get_contents(); ob_end_clean(); } ...
[ { "answer_id": 215470, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 3, "selected": true, "text": "<p>Better to write your own widget that does precisely what you need instead of something like this.</p>\n\n<p>However...
2016/01/23
[ "https://wordpress.stackexchange.com/questions/215463", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86337/" ]
Before I had the following code in the function.php ``` add_filter('widget_text','execute_php',100); function execute_php($html){ if(strpos($html,"<"."?php")!==false){ ob_start(); eval("?".">".$html); $html=ob_get_contents(); ob_end_clean(); } return $html; } ```...
Better to write your own widget that does precisely what you need instead of something like this. However, if you really want to execute arbitrary PHP in a widget, use a plugin specifically designed for that task: <https://wordpress.org/plugins/php-code-widget/> I maintain this plugin specifically so that people don'...
215,468
<p>I have a section in my dashboard called "services".</p> <ul> <li>I have 4 services</li> <li>I have 2 categories for these services: residential and commercial</li> <li>2 of the 4 services have the category "residential", and the other 2 "commercial"</li> </ul> <p>As it is now my services page is pulling up all 4 s...
[ { "answer_id": 215479, "author": "Greg Robertson", "author_id": 87373, "author_profile": "https://wordpress.stackexchange.com/users/87373", "pm_score": 0, "selected": false, "text": "<p>From the above Codex page, I used this:</p>\n\n<p><code>'tax_query' =&gt; array(\n array(\n ...
2016/01/23
[ "https://wordpress.stackexchange.com/questions/215468", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87373/" ]
I have a section in my dashboard called "services". * I have 4 services * I have 2 categories for these services: residential and commercial * 2 of the 4 services have the category "residential", and the other 2 "commercial" As it is now my services page is pulling up all 4 services. Question: What code do I add, to...
Add this to your args: ``` 'taxonomies' => array( 'category' ) ``` Should look like this- ``` $args = array( 'post_type' => 'service', 'posts_per_page' => 8, 'paged' => $paged, 'taxonomies' => array( 'category' ), ); ```
215,476
<p>I would like to take steps to limit the damage a compromised Wordpress install can cause on the rest of my system. What system calls does Wordpress need? What can I put in the <code>disable_functions</code> configuration?</p> <p>Documentation: <a href="http://php.net/manual/en/ini.core.php#ini.disable-functions" re...
[ { "answer_id": 215479, "author": "Greg Robertson", "author_id": 87373, "author_profile": "https://wordpress.stackexchange.com/users/87373", "pm_score": 0, "selected": false, "text": "<p>From the above Codex page, I used this:</p>\n\n<p><code>'tax_query' =&gt; array(\n array(\n ...
2016/01/23
[ "https://wordpress.stackexchange.com/questions/215476", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16825/" ]
I would like to take steps to limit the damage a compromised Wordpress install can cause on the rest of my system. What system calls does Wordpress need? What can I put in the `disable_functions` configuration? Documentation: <http://php.net/manual/en/ini.core.php#ini.disable-functions>
Add this to your args: ``` 'taxonomies' => array( 'category' ) ``` Should look like this- ``` $args = array( 'post_type' => 'service', 'posts_per_page' => 8, 'paged' => $paged, 'taxonomies' => array( 'category' ), ); ```
215,481
<p>I'm working on my first plugin and I have made a nice settings page which saves and works. </p> <p>But I have split it to few files and now I can't determine if field is checked.. I have also tried declaring a <code>global</code> variable but I can't get it to work :\</p> <p><strong>Plugin</strong></p> <p>This is...
[ { "answer_id": 215493, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 1, "selected": false, "text": "<p>Save yourself a headache and make a class. The static variable can be accessed like a global once it's loaded....
2016/01/23
[ "https://wordpress.stackexchange.com/questions/215481", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87380/" ]
I'm working on my first plugin and I have made a nice settings page which saves and works. But I have split it to few files and now I can't determine if field is checked.. I have also tried declaring a `global` variable but I can't get it to work :\ **Plugin** This is how my plugin starts: ``` global $if_autoload;...
Save yourself a headache and make a class. The static variable can be accessed like a global once it's loaded. Just be sure the class exists before you try to use it! ``` if ( ! class_exists( 'WPSE_20150123_Plugin' ) ) { class WPSE_20150123_Plugin { // our variable that will be set and read back later ...
215,511
<p>I have a query for to display some posts . </p> <pre><code>$args = array( 'post_type' =&gt;'products' 'posts_per_page'=&gt; 12, 'orderby' =&gt; 'meta_value_num', 'meta_key' =&gt; '_price', 'order' =&gt; 'asc', ); $loop=new WP_Query($args); while($loop-&gt;have_posts()) : $loop-&gt;the_po...
[ { "answer_id": 215526, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>We could do that with two queries:</p>\n\n<p>First we fetch the post ids we need with the first query and the...
2016/01/24
[ "https://wordpress.stackexchange.com/questions/215511", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86219/" ]
I have a query for to display some posts . ``` $args = array( 'post_type' =>'products' 'posts_per_page'=> 12, 'orderby' => 'meta_value_num', 'meta_key' => '_price', 'order' => 'asc', ); $loop=new WP_Query($args); while($loop->have_posts()) : $loop->the_post(); the_content(); endwhile; ...
If you need to: * page the query * retain 12 posts per page instead of "sticking" the desired posts on top of the required 12 * only need to show those posts on the first page you can try the following ``` $ids_args = [ 'post_type' => 'products' 'posts_per_page' => -1, 'orderby' => 'meta_valu...
215,513
<p>I'm using a theme that has it's own home page layout but I want to use a normal page instead. I can't find a way to change it because in Settings> Reading, the home page is already set to 'Home' (a page which already exists for my mobile theme). It seems like the desktop theme home page is just overriding this setti...
[ { "answer_id": 215526, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>We could do that with two queries:</p>\n\n<p>First we fetch the post ids we need with the first query and the...
2016/01/24
[ "https://wordpress.stackexchange.com/questions/215513", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62300/" ]
I'm using a theme that has it's own home page layout but I want to use a normal page instead. I can't find a way to change it because in Settings> Reading, the home page is already set to 'Home' (a page which already exists for my mobile theme). It seems like the desktop theme home page is just overriding this setting.
If you need to: * page the query * retain 12 posts per page instead of "sticking" the desired posts on top of the required 12 * only need to show those posts on the first page you can try the following ``` $ids_args = [ 'post_type' => 'products' 'posts_per_page' => -1, 'orderby' => 'meta_valu...
215,520
<p>Is this the right way to use get_row with a select *?</p> <pre><code>$_crds = $wpdb-&gt;get_row($wpdb-&gt;prepare(" SELECT * FROM `mailers` WHERE `id` = %d", $_GET['caId'] )); $_zipcodes = $_crds-&gt;zipcodes; $_maildate = $_crds-&gt;maildate; </code></pre> <p>Is that the right way to pull the values from the dat...
[ { "answer_id": 215526, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>We could do that with two queries:</p>\n\n<p>First we fetch the post ids we need with the first query and the...
2016/01/24
[ "https://wordpress.stackexchange.com/questions/215520", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87377/" ]
Is this the right way to use get\_row with a select \*? ``` $_crds = $wpdb->get_row($wpdb->prepare(" SELECT * FROM `mailers` WHERE `id` = %d", $_GET['caId'] )); $_zipcodes = $_crds->zipcodes; $_maildate = $_crds->maildate; ``` Is that the right way to pull the values from the database? I have a lot of records in th...
If you need to: * page the query * retain 12 posts per page instead of "sticking" the desired posts on top of the required 12 * only need to show those posts on the first page you can try the following ``` $ids_args = [ 'post_type' => 'products' 'posts_per_page' => -1, 'orderby' => 'meta_valu...
215,554
<p>I am trying to comment out unwanted CSS and JS files to prevent them from firing in the HTML by creating a simple function in my functions.php. So far I have:</p> <pre><code>function commentStuff() { $stylesheet = "&lt;link rel=stylesheet --unwanted CSS file-- /&gt;"; $CommentedStyle = '&lt;!-- ' . $stylesheet . ' ...
[ { "answer_id": 215526, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>We could do that with two queries:</p>\n\n<p>First we fetch the post ids we need with the first query and the...
2016/01/25
[ "https://wordpress.stackexchange.com/questions/215554", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87430/" ]
I am trying to comment out unwanted CSS and JS files to prevent them from firing in the HTML by creating a simple function in my functions.php. So far I have: ``` function commentStuff() { $stylesheet = "<link rel=stylesheet --unwanted CSS file-- />"; $CommentedStyle = '<!-- ' . $stylesheet . ' -->'; return $Commente...
If you need to: * page the query * retain 12 posts per page instead of "sticking" the desired posts on top of the required 12 * only need to show those posts on the first page you can try the following ``` $ids_args = [ 'post_type' => 'products' 'posts_per_page' => -1, 'orderby' => 'meta_valu...
215,569
<p>For starters, I'm aware of the concerns generally brought up by many when someone looks for a way to skip duplicate e-mail checks for creating new user accounts.</p> <p>However, In my case, I believe the reason for needing this is justified if I can explain it.</p> <p>I'm building an extensive vendor directory on ...
[ { "answer_id": 215578, "author": "fischi", "author_id": 15680, "author_profile": "https://wordpress.stackexchange.com/users/15680", "pm_score": 0, "selected": false, "text": "<p>That is not possible in an easy way, as WordPress always checks if the Emailadress is already used.</p>\n\n<pr...
2016/01/25
[ "https://wordpress.stackexchange.com/questions/215569", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87434/" ]
For starters, I'm aware of the concerns generally brought up by many when someone looks for a way to skip duplicate e-mail checks for creating new user accounts. However, In my case, I believe the reason for needing this is justified if I can explain it. I'm building an extensive vendor directory on my site using a m...
Here is another approach in which we can answer the question, here is a small Plugin that adds a Submenupage for "Users", containing a small form where you can enter a username to create the new user with no emailadress. Additional Error handling allows you to see if the current user already exists, as usernames have ...
215,577
<p>I have a paid plugin that creates a custom type categories and posts in this categories. I want to get URLs like <em><code>site_name/category_name/post_name</code></em>. This plugin forms links like this: </p> <ul> <li>List item</li> </ul> <p>for categories - <em><code>site_name/category_name</code></em></p> <ul>...
[ { "answer_id": 215578, "author": "fischi", "author_id": 15680, "author_profile": "https://wordpress.stackexchange.com/users/15680", "pm_score": 0, "selected": false, "text": "<p>That is not possible in an easy way, as WordPress always checks if the Emailadress is already used.</p>\n\n<pr...
2016/01/25
[ "https://wordpress.stackexchange.com/questions/215577", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86327/" ]
I have a paid plugin that creates a custom type categories and posts in this categories. I want to get URLs like *`site_name/category_name/post_name`*. This plugin forms links like this: * List item for categories - *`site_name/category_name`* * List item for posts - *`site_name/category_name`* I have installed pl...
Here is another approach in which we can answer the question, here is a small Plugin that adds a Submenupage for "Users", containing a small form where you can enter a username to create the new user with no emailadress. Additional Error handling allows you to see if the current user already exists, as usernames have ...
215,628
<p>I'm attempting to upload an audio file via AJAX form.</p> <p>Here is my HTML in the profile-edit template.</p> <pre><code>&lt;form method="post" id="my_upload_form" action="" enctype="multipart/form-data"&gt; &lt;input type="file" name="file" id="my_file_input" accept="audio/*"&gt; ...
[ { "answer_id": 215809, "author": "Jeffrey Ponsen", "author_id": 80453, "author_profile": "https://wordpress.stackexchange.com/users/80453", "pm_score": 3, "selected": false, "text": "<p>Try using <code>preventDefault()</code>, it's a jQuery function for preventing default actions called ...
2016/01/25
[ "https://wordpress.stackexchange.com/questions/215628", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85662/" ]
I'm attempting to upload an audio file via AJAX form. Here is my HTML in the profile-edit template. ``` <form method="post" id="my_upload_form" action="" enctype="multipart/form-data"> <input type="file" name="file" id="my_file_input" accept="audio/*"> <input type="submit" cl...
I was missing a crucial line in my AJAX query. Without this option, the call fails, and the pages refreshes. ``` processData: false, ```
215,638
<p>My general question is: how to display product price in woocommerce of a product in a loop, not the price of the product which page it is? In other words I would like to display few related products in a grid on a single product page, but when I use this code :</p> <pre><code>&lt;?php $product = new WC_Product(...
[ { "answer_id": 216339, "author": "yennefer", "author_id": 87470, "author_profile": "https://wordpress.stackexchange.com/users/87470", "pm_score": 3, "selected": true, "text": "<p>I sorted this out, <code>$post</code> should be <code>$p</code> in:</p>\n\n<pre class=\"lang-php prettyprint-...
2016/01/25
[ "https://wordpress.stackexchange.com/questions/215638", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87470/" ]
My general question is: how to display product price in woocommerce of a product in a loop, not the price of the product which page it is? In other words I would like to display few related products in a grid on a single product page, but when I use this code : ``` <?php $product = new WC_Product(get_the_ID()); ...
I sorted this out, `$post` should be `$p` in: ```php global $post; $product = new WC_Product( $post->ID ); ```
215,640
<p>I can't get the published post ID, i'm using a front end custom form. When the submit button is clicked site is re directed to a different page. Now, i can't get the just published post ID using:</p> <p><code>wp_insert_post($post)</code></p> <p>Because it returns the ID of redirected page instead of the published ...
[ { "answer_id": 215662, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 1, "selected": false, "text": "<p><code>wp_insert_post()</code> returns either one of three things</p>\n\n<ul>\n<li><p>the newly created ...
2016/01/25
[ "https://wordpress.stackexchange.com/questions/215640", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84237/" ]
I can't get the published post ID, i'm using a front end custom form. When the submit button is clicked site is re directed to a different page. Now, i can't get the just published post ID using: `wp_insert_post($post)` Because it returns the ID of redirected page instead of the published post. How can i get it? I'm ...
`wp_insert_post()` returns either one of three things * the newly created post's ID * a `WP_Error` object if `$wp_error` is set to true if an error occured during post insertion in which case the post is not inserted * `0` if `$wp_error` is set to false (*default*) if an error occured during post insertion in which ca...
215,677
<p>I've been struggling with this for a few days now. What i want to do, it to limit the Postcode/zip fields to 4 numbers. So, to add a <b>maxlength</b> and a <b>type="number"</b> to those fields.</p> <p>Things i've tried so far:</p> <p>1 - (functions.php)</p> <pre><code>add_filter( 'woocommerce_checkout_fields' , '...
[ { "answer_id": 216231, "author": "certainstrings", "author_id": 75979, "author_profile": "https://wordpress.stackexchange.com/users/75979", "pm_score": 2, "selected": false, "text": "<p>By the time <code>woocommerce_checkout_fields</code> filter is run, the arrays for billing and shippin...
2016/01/26
[ "https://wordpress.stackexchange.com/questions/215677", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76984/" ]
I've been struggling with this for a few days now. What i want to do, it to limit the Postcode/zip fields to 4 numbers. So, to add a **maxlength** and a **type="number"** to those fields. Things i've tried so far: 1 - (functions.php) ``` add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' )...
By the time `woocommerce_checkout_fields` filter is run, the arrays for billing and shipping have already been created. You can see that here: <https://docs.woothemes.com/wc-apidocs/source-class-WC_Checkout.html#101> If you want to effect the default fields, use this hook. ``` function wpse215677_checkout_field...
215,688
<p>I'm using the plugin <a href="https://wordpress.org/plugins/custom-css-js/" rel="noreferrer">Custom CSS JS</a> which registers it's own post type but the capability is assigned to <code>"post"</code>. </p> <p>I want to change it to <code>"manage_options"</code>.</p> <p>Is there a correct way without altering the p...
[ { "answer_id": 215692, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": false, "text": "<p>WordPress 4.4 finally saw the introduction of the <a href=\"https://developer.wordpress.org/reference/h...
2016/01/26
[ "https://wordpress.stackexchange.com/questions/215688", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64771/" ]
I'm using the plugin [Custom CSS JS](https://wordpress.org/plugins/custom-css-js/) which registers it's own post type but the capability is assigned to `"post"`. I want to change it to `"manage_options"`. Is there a correct way without altering the plugin to do that? Calling a hook, a function or whatever? ``` pub...
@PieterGoosen is cool, and still awake like me and answering like boss. To simplify his code and make it work to this specifically without a bunch of junk on your page: ``` /** * Pieter Goosen writes awesome code */ add_filter( 'register_post_type_args', 'change_capabilities_of_the_custom_css_js_posttype' , 10, 2 )...
215,707
<p>Maybe you guys know if it's possible to create an account when a new user creates a ticket. At this point there are 2 options. </p> <ol> <li>Let user create a ticket based on e-mail address</li> <li>Let user create an account first</li> </ol> <p>It would be nice if people don't need to create an account manually...
[ { "answer_id": 215710, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p><code>wp_create_user</code> is your friend!</p>\n\n<p>It takes a username, password, and email:</p>\n\n<pre>...
2016/01/26
[ "https://wordpress.stackexchange.com/questions/215707", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85557/" ]
Maybe you guys know if it's possible to create an account when a new user creates a ticket. At this point there are 2 options. 1. Let user create a ticket based on e-mail address 2. Let user create an account first It would be nice if people don't need to create an account manually. So if they fill in all the fie...
`wp_create_user` is your friend! It takes a username, password, and email: ``` wp_create_user( $username, $password, $email ); ``` And here's an example: ``` $user_id = username_exists( $user_name ); if ( !$user_id and email_exists($user_email) == false ) { $random_password = wp_generate_password( $length=12, ...
215,722
<p>My site has custom post type 'Portfolio'. If a user has at least one Portfolio, how can I disable the option to delete that user?</p> <p>I found the action/hook <code>delete_user</code>, but it doesn't seem right for this issue.</p>
[ { "answer_id": 215710, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p><code>wp_create_user</code> is your friend!</p>\n\n<p>It takes a username, password, and email:</p>\n\n<pre>...
2016/01/26
[ "https://wordpress.stackexchange.com/questions/215722", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87518/" ]
My site has custom post type 'Portfolio'. If a user has at least one Portfolio, how can I disable the option to delete that user? I found the action/hook `delete_user`, but it doesn't seem right for this issue.
`wp_create_user` is your friend! It takes a username, password, and email: ``` wp_create_user( $username, $password, $email ); ``` And here's an example: ``` $user_id = username_exists( $user_name ); if ( !$user_id and email_exists($user_email) == false ) { $random_password = wp_generate_password( $length=12, ...
215,732
<p>I want to show <code>adsense ads</code> below the <strong>4th</strong> and <strong>20th</strong> paragraph of every blog post, ONLY if there is a <strong>20th</strong> paragraph.</p> <p>I managed to insert an ad below the <strong>4th</strong> ad by placing the following code in my <code>functions.php</code> file, h...
[ { "answer_id": 215710, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p><code>wp_create_user</code> is your friend!</p>\n\n<p>It takes a username, password, and email:</p>\n\n<pre>...
2016/01/26
[ "https://wordpress.stackexchange.com/questions/215732", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87528/" ]
I want to show `adsense ads` below the **4th** and **20th** paragraph of every blog post, ONLY if there is a **20th** paragraph. I managed to insert an ad below the **4th** ad by placing the following code in my `functions.php` file, however I don't know how to add an additional ad after the **20th**. ``` // Insert a...
`wp_create_user` is your friend! It takes a username, password, and email: ``` wp_create_user( $username, $password, $email ); ``` And here's an example: ``` $user_id = username_exists( $user_name ); if ( !$user_id and email_exists($user_email) == false ) { $random_password = wp_generate_password( $length=12, ...
215,744
<p>Is there a way to limit the dimensions of the full size uploaded image (made normally through the Media library)?</p> <p>I have clients that upload huge images files with resolutions sometimes greater than 5000 x 5000. They don't quite understand why Wordpress/websites have a hard time with these images.</p> <p>Li...
[ { "answer_id": 215748, "author": "Stephen", "author_id": 85776, "author_profile": "https://wordpress.stackexchange.com/users/85776", "pm_score": 2, "selected": false, "text": "<p>So I've found this <a href=\"https://codex.wordpress.org/Class_Reference/WP_Image_Editor\" rel=\"nofollow\">W...
2016/01/26
[ "https://wordpress.stackexchange.com/questions/215744", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4109/" ]
Is there a way to limit the dimensions of the full size uploaded image (made normally through the Media library)? I have clients that upload huge images files with resolutions sometimes greater than 5000 x 5000. They don't quite understand why Wordpress/websites have a hard time with these images. Limiting "Full" siz...
So I've found this [WP\_Image\_Editor](https://codex.wordpress.org/Class_Reference/WP_Image_Editor) in the CodeX. Basically by adding the code below it should automatically resize an image :) Code: ``` $image = wp_get_image_editor( 'cool_image.jpg' ); // Return an implementation that extends WP_Image_Editor if ( ! i...
215,745
<p>I'm building a custom theme for in-house use only. I started by putting a lot of the core functions in plugins, but then that seemed silly since they don't require any user interaction.</p> <p>Next, I put all of my classes in different php files in my theme folder and <code>include</code> them all in functions.php....
[ { "answer_id": 215764, "author": "Geoff", "author_id": 26452, "author_profile": "https://wordpress.stackexchange.com/users/26452", "pm_score": 0, "selected": false, "text": "<p>I store core functions in a parent theme, then load site-specific functions to a child theme.</p>\n\n<p>Benefit...
2016/01/26
[ "https://wordpress.stackexchange.com/questions/215745", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87536/" ]
I'm building a custom theme for in-house use only. I started by putting a lot of the core functions in plugins, but then that seemed silly since they don't require any user interaction. Next, I put all of my classes in different php files in my theme folder and `include` them all in functions.php. Is there a better ...
> > As @toscho mentioned in his comment, your best bet is probably an > [autoloader](https://codex.wordpress.org/Function_Reference/plugin_dir_path#Examples) > of some sort... > > > ``` foreach ( glob( plugin_dir_path( __FILE__ ) . "subfolder/*.php" ) as $file ) { include_once $file; } ``` There are plugin...
215,766
<p>When you insert the "More" link into a post using the "Insert More Break" toolbar icon, the url that is generated is appended with "#more-". Thus when you click that link, you get the full post (via single.php), but the browser then scrolls to where the 'more' was inserted.</p> <p>Is there a filter I can use to re...
[ { "answer_id": 215768, "author": "Dejo Dekic", "author_id": 20941, "author_profile": "https://wordpress.stackexchange.com/users/20941", "pm_score": 3, "selected": true, "text": "<p>There you go this will prevent scroll (add to functions.php)</p>\n\n<pre><code>function remove_more_link_sc...
2016/01/26
[ "https://wordpress.stackexchange.com/questions/215766", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76191/" ]
When you insert the "More" link into a post using the "Insert More Break" toolbar icon, the url that is generated is appended with "#more-". Thus when you click that link, you get the full post (via single.php), but the browser then scrolls to where the 'more' was inserted. Is there a filter I can use to remove the "#...
There you go this will prevent scroll (add to functions.php) ``` function remove_more_link_scroll( $link ) { $link = preg_replace( '|#more-[0-9]+|', '', $link ); return $link; } add_filter( 'the_content_more_link', 'remove_more_link_scroll' ); ``` Explained in depth [Here](https://codex.wordpress.org/Customizing_the...