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 |
|---|---|---|---|---|---|---|
199,427 | <p>Is there a way to create deep-level sub Panel in Theme Customizer(like roots of plants) ? My theme that I have been developing seem to be more complicated. I think that if we can create deep-level sub Panel, our Customizer Page won't look messy, our user will customize our theme easier and we will be able to make mu... | [
{
"answer_id": 226793,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 1,
"selected": false,
"text": "<p>At the moment it is simply not possible to have more than panels, sections and controls. Expanding this system w... | 2015/08/23 | [
"https://wordpress.stackexchange.com/questions/199427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76562/"
] | Is there a way to create deep-level sub Panel in Theme Customizer(like roots of plants) ? My theme that I have been developing seem to be more complicated. I think that if we can create deep-level sub Panel, our Customizer Page won't look messy, our user will customize our theme easier and we will be able to make much ... | For anyone that comes here looking for this, I was able to do it after battling with it for a few hours.
The code is a bit extensive so did not want to post here, (mods feel free to let me now if that would be better), instead I created a gist: <https://gist.github.com/OriginalEXE/9a6183e09f4cae2f30b006232bb154af>
Wh... |
199,469 | <p>How to get shortcode thumbnail size?</p>
<p>my code get shortcode thumbnail size in functions:</p>
<pre><code>function thumb_medium( $atts, $content = null ) {
return wp_get_attachment_url( get_post_thumbnail_id( $post_id, 'medium') );
//or wp_get_attachment_url( get_post_thumbnail_id( $post_id, 'large') );
//... | [
{
"answer_id": 199476,
"author": "Kory",
"author_id": 78199,
"author_profile": "https://wordpress.stackexchange.com/users/78199",
"pm_score": 3,
"selected": true,
"text": "<p>I think your code is very close, try to use <a href=\"https://codex.wordpress.org/Function_Reference/wp_get_attac... | 2015/08/24 | [
"https://wordpress.stackexchange.com/questions/199469",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65359/"
] | How to get shortcode thumbnail size?
my code get shortcode thumbnail size in functions:
```
function thumb_medium( $atts, $content = null ) {
return wp_get_attachment_url( get_post_thumbnail_id( $post_id, 'medium') );
//or wp_get_attachment_url( get_post_thumbnail_id( $post_id, 'large') );
//or wp_get_attachment_... | I think your code is very close, try to use [`wp_get_attachment_image_src()`](https://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src) instead:
```
function thumb_medium( $atts, $content = null ) {
// return wp_get_attachment_url( get_post_thumbnail_id( $post_id, 'medium') );
global $post;
... |
199,496 | <p>I want an extra sidebar added to this wordpress theme of mine. I want it right under my left sidebar and not next to it as it is currently showing: <a href="http://www.giftforgag.com" rel="nofollow">www.giftforgag.com</a>.</p>
<p>I have tried many things but nothing seems to be working. I have also tried making var... | [
{
"answer_id": 199513,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 1,
"selected": false,
"text": "<p><code>get_sidebar('left');</code> actually refers to a file, not the sidebar itself.</p>\n\n<ol>\n<li>Are... | 2015/08/24 | [
"https://wordpress.stackexchange.com/questions/199496",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78091/"
] | I want an extra sidebar added to this wordpress theme of mine. I want it right under my left sidebar and not next to it as it is currently showing: [www.giftforgag.com](http://www.giftforgag.com).
I have tried many things but nothing seems to be working. I have also tried making various changes to the css.
I had thou... | `get_sidebar('left');` actually refers to a file, not the sidebar itself.
1. Are you seeing the sidebar in the Admin section?
2. Are you trying to display it on the front end?
If the answer to both of these questions are "yes", then here's the solution:
Create a file called `sidebar-left.php`. In this file, you will... |
199,498 | <p>I'm trying to insert data from a wordpress post into a new table database table rather than <code>WP_postmeta</code>. My function is working, It'll insert the <code>$postid</code> no problem at all. The issues I'm having is I need to inser the latitude and longitude coordinates from Marty Spellerbergs 'Address Geoco... | [
{
"answer_id": 199503,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": true,
"text": "<p>Your syntax is slightly off in a few places. I'll try and let the code explain:</p>\n\n<pre><code>function ... | 2015/08/24 | [
"https://wordpress.stackexchange.com/questions/199498",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77395/"
] | I'm trying to insert data from a wordpress post into a new table database table rather than `WP_postmeta`. My function is working, It'll insert the `$postid` no problem at all. The issues I'm having is I need to inser the latitude and longitude coordinates from Marty Spellerbergs 'Address Geocoder' Plugin.
On the plug... | Your syntax is slightly off in a few places. I'll try and let the code explain:
```
function wpse_199498_meta_to_table( $post_id, $post ) {
// Use the second argument of our hook, which is the post object
if ( $post->post_type !== 'festival-event' )
return;
global $wpdb;
// Don't need to use ... |
199,521 | <p>I'm trying to get my posts to order by radius, and so far i'm struggling, I've been using the following tut by Steve MArks, <a href="http://biostall.com/performing-a-radial-search-with-wp_query-in-wordpress" rel="nofollow">http://biostall.com/performing-a-radial-search-with-wp_query-in-wordpress</a></p>
<p>Here's t... | [
{
"answer_id": 199503,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": true,
"text": "<p>Your syntax is slightly off in a few places. I'll try and let the code explain:</p>\n\n<pre><code>function ... | 2015/08/24 | [
"https://wordpress.stackexchange.com/questions/199521",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77395/"
] | I'm trying to get my posts to order by radius, and so far i'm struggling, I've been using the following tut by Steve MArks, <http://biostall.com/performing-a-radial-search-with-wp_query-in-wordpress>
Here's the code that produces the error the following error.
```
function location_posts_where( $where )
{
glo... | Your syntax is slightly off in a few places. I'll try and let the code explain:
```
function wpse_199498_meta_to_table( $post_id, $post ) {
// Use the second argument of our hook, which is the post object
if ( $post->post_type !== 'festival-event' )
return;
global $wpdb;
// Don't need to use ... |
199,539 | <p>On a specific page, I would like the search to be performed only against the terms from two custom taxonomies. Not the content or title. That is, the user is directly searching taxonomy terms.</p>
<p>What I'm trying to do is completely rewrite the query for searches, but it doesn't seem to work.</p>
<pre><code>fun... | [
{
"answer_id": 199571,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": 0,
"selected": false,
"text": "<p>I think, the problem is that you just put filtered query in <code>$query</code> variable but did not set it in... | 2015/08/24 | [
"https://wordpress.stackexchange.com/questions/199539",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4258/"
] | On a specific page, I would like the search to be performed only against the terms from two custom taxonomies. Not the content or title. That is, the user is directly searching taxonomy terms.
What I'm trying to do is completely rewrite the query for searches, but it doesn't seem to work.
```
function search_filter_g... | You did not return the new `$query`; that's why it's not working for you.
```
$query = new WP_Query( $taxquery );
return $query;
``` |
199,541 | <p>I'm trying to make a shortcut in navigation that will take user to one certain post.
So far I'm using </p>
<pre><code>add_action('admin_menu', 'add_custom_menu_position');
function add_custom_menu_position() {
add_menu_page('FeaturedJobs', 'Featured Jobs', 'edit_posts', 'edit.php?post=706&action=edit',18);
}... | [
{
"answer_id": 199571,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": 0,
"selected": false,
"text": "<p>I think, the problem is that you just put filtered query in <code>$query</code> variable but did not set it in... | 2015/08/24 | [
"https://wordpress.stackexchange.com/questions/199541",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33202/"
] | I'm trying to make a shortcut in navigation that will take user to one certain post.
So far I'm using
```
add_action('admin_menu', 'add_custom_menu_position');
function add_custom_menu_position() {
add_menu_page('FeaturedJobs', 'Featured Jobs', 'edit_posts', 'edit.php?post=706&action=edit',18);
}
```
The item do... | You did not return the new `$query`; that's why it's not working for you.
```
$query = new WP_Query( $taxquery );
return $query;
``` |
199,603 | <p>I'm looking to disable the 'media file' image link on mobile devices, so that when viewing a site on mobile devices we simply have the image being displayed with no link to anything.</p>
<p>I am looking to achieve this because in a responsive design my images are at 100% width on mobile devices anyway. Clicking on ... | [
{
"answer_id": 199606,
"author": "David Gallagher",
"author_id": 78289,
"author_profile": "https://wordpress.stackexchange.com/users/78289",
"pm_score": 0,
"selected": false,
"text": "<p>What you want to do isn't possible from <code>functions.php</code> or a plugin. The code you have pos... | 2015/08/25 | [
"https://wordpress.stackexchange.com/questions/199603",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78294/"
] | I'm looking to disable the 'media file' image link on mobile devices, so that when viewing a site on mobile devices we simply have the image being displayed with no link to anything.
I am looking to achieve this because in a responsive design my images are at 100% width on mobile devices anyway. Clicking on the image ... | You can easily do this using HTML and CSS. You can write 2 blocks of div for the same image and toogle display:none; properties in CSS using media queries as shown below. Note: I have remove the "a href" tag for mobile.
```
<!--HTML Start -->
<div class="image-grid desktop">
<a href="#"><img src="#" /></a>
<div>
... |
199,608 | <p>Many people has asked the same question, I have read those things and mine is different,</p>
<p>I am trying to insert some values inside the database from the form but it's not getting inserted</p>
<p>I have a table in the database having 6 columns wanted to insert some values inside only of 4 columns</p>
<p>Tabl... | [
{
"answer_id": 199614,
"author": "Mat",
"author_id": 10914,
"author_profile": "https://wordpress.stackexchange.com/users/10914",
"pm_score": 1,
"selected": false,
"text": "<p>It looks like you are trying to insert the data before the form is submitted. Your code above had two forms, one ... | 2015/08/25 | [
"https://wordpress.stackexchange.com/questions/199608",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78297/"
] | Many people has asked the same question, I have read those things and mine is different,
I am trying to insert some values inside the database from the form but it's not getting inserted
I have a table in the database having 6 columns wanted to insert some values inside only of 4 columns
Table Name: `wp_contactus`
... | [You're inserting raw POST data straight into an SQL query](https://i.stack.imgur.com/zF8QT.jpg) - sanitize, sanitize, sanitize! The code below should get you started, but I would advise you add some additional checks (is the email valid? are the strings too long? etc.):
```
<?php
$errors =
$values = array();
if ( i... |
199,668 | <p>What does it mean when (according to mySQL Workbench) 2 options have option_id = 0?</p>
<p>Just noticed this for unrelated plugin and theme holding very different options.</p>
<p><em>Update</em> Just noticed over 200 options had id 0 (<code>select * from wordpress.wp_options where option_id = 0</code>) on one test... | [
{
"answer_id": 212249,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>If we check how the <code>wp_options</code> table is created (in 4.4) from the <code>schema.php</code> file, ... | 2015/08/25 | [
"https://wordpress.stackexchange.com/questions/199668",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25767/"
] | What does it mean when (according to mySQL Workbench) 2 options have option\_id = 0?
Just noticed this for unrelated plugin and theme holding very different options.
*Update* Just noticed over 200 options had id 0 (`select * from wordpress.wp_options where option_id = 0`) on one test system. What causes this, and cou... | If we check how the `wp_options` table is created (in 4.4) from the `schema.php` file, we will find the following:
```
CREATE TABLE $wpdb->options (
option_id bigint(20) unsigned NOT NULL auto_increment,
option_name varchar(191) NOT NULL default '',
option_value longtext NOT NULL,
autoload varchar(20) NOT NULL... |
199,682 | <p>I am trying to write a get_posts() query to retrieve 7 posts per page. The retrieval of these posts are based on 3 different tags, "Featured","Highlighted", and "News". Now the "Featured" post take priority over all others, so if there are 7 Featured Posts then only those post should be displayed on the page. The "H... | [
{
"answer_id": 199698,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>tag__in is not listed as a valid orderby value in <a href=\"https://codex.wordpress.org/Class_Reference/WP_Q... | 2015/08/25 | [
"https://wordpress.stackexchange.com/questions/199682",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43155/"
] | I am trying to write a get\_posts() query to retrieve 7 posts per page. The retrieval of these posts are based on 3 different tags, "Featured","Highlighted", and "News". Now the "Featured" post take priority over all others, so if there are 7 Featured Posts then only those post should be displayed on the page. The "Hig... | It is quite easy to achieve this. Your answer is `usort()`
FEW NOTES:
----------
Before we code, just a few notes
* Requires PHP5.4+ due to the use of the short array syntax (`[]`). If you have an older version, you should really upgrade as older versions are a real security threat as all older versions prior to PHP... |
199,694 | <p>I have a multisite WordPress installation set up, and have a user who is set to an 'Administrator' role on both sites. However, the function <code>current_user_can('Administrator')</code> does not return true when logged in as them, which I expected it to.</p>
<p>My user account, however, is an 'Administrator' on b... | [
{
"answer_id": 199696,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 3,
"selected": true,
"text": "<p>I would agree that current_user_can('Administrator') should return true for the user. However, current_user_c... | 2015/08/25 | [
"https://wordpress.stackexchange.com/questions/199694",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78346/"
] | I have a multisite WordPress installation set up, and have a user who is set to an 'Administrator' role on both sites. However, the function `current_user_can('Administrator')` does not return true when logged in as them, which I expected it to.
My user account, however, is an 'Administrator' on both sites, and *also*... | I would agree that current\_user\_can('Administrator') should return true for the user. However, current\_user\_can is primarily intended to check for capabilities, which is generally a more robust check to be making.
I'd suggest something like this (untested):
```
if ( current_user_can( 'activate_plugins' ) && ! cur... |
199,709 | <p>I have set some extra profile fields set in buddypress (under users profile fields), and I want to make sure they are read only with the exception of site administrators.</p>
<p>How do I accomplish this?</p>
<p>Thank you.</p>
| [
{
"answer_id": 199722,
"author": "jim.duck",
"author_id": 78337,
"author_profile": "https://wordpress.stackexchange.com/users/78337",
"pm_score": 0,
"selected": false,
"text": "<p>Add this snippet to your child-theme functions.php or <a href=\"https://codex.buddypress.org/themes/bp-custo... | 2015/08/26 | [
"https://wordpress.stackexchange.com/questions/199709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68446/"
] | I have set some extra profile fields set in buddypress (under users profile fields), and I want to make sure they are read only with the exception of site administrators.
How do I accomplish this?
Thank you. | You can hide profile fields on the edit screen from everyone except site admins - therefore they can only be edited by site admins. They will still be visible on the public profile screen. You can get the field id by looking at the url in wp-admin when you edit that field, or just rolling over the edit button. Add this... |
199,725 | <p>Can you just trigger <code>wp-cron.php</code> using for example <code>$ php /path/to/wordpress/wp-cron.php</code> rather than going through the wget method using for example <code>wget -q -O - http://example.com/wp-cron.php>/dev/null 2>&1</code>?</p>
| [
{
"answer_id": 199728,
"author": "Mat",
"author_id": 10914,
"author_profile": "https://wordpress.stackexchange.com/users/10914",
"pm_score": 3,
"selected": false,
"text": "<p>Yes, it's possible to trigger cron runs with just <code>$ php /path/to/wordpress/wp-cron.php</code>.</p>\n\n<p>Al... | 2015/08/26 | [
"https://wordpress.stackexchange.com/questions/199725",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78360/"
] | Can you just trigger `wp-cron.php` using for example `$ php /path/to/wordpress/wp-cron.php` rather than going through the wget method using for example `wget -q -O - http://example.com/wp-cron.php>/dev/null 2>&1`? | Yes, it's possible to trigger cron runs with just `$ php /path/to/wordpress/wp-cron.php`.
Alternatively you can use `curl`:
```
*/10 * * * * curl http://example.com/wp-cron.php > /dev/null 2>&1
```
And you can add the following line to your `wp-config.php` to disable crons being run from HTTP requests:
```
define(... |
199,767 | <p>I've got a function that pulls the latest post from each category and arrange categories by latests posts. What I get from this is an array with category ids which I want to use to rearrange the get_categories array.</p>
<pre><code>/* Get all categories */
$categories = get_categories();
/* Create empty array */
$c... | [
{
"answer_id": 199728,
"author": "Mat",
"author_id": 10914,
"author_profile": "https://wordpress.stackexchange.com/users/10914",
"pm_score": 3,
"selected": false,
"text": "<p>Yes, it's possible to trigger cron runs with just <code>$ php /path/to/wordpress/wp-cron.php</code>.</p>\n\n<p>Al... | 2015/08/26 | [
"https://wordpress.stackexchange.com/questions/199767",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25900/"
] | I've got a function that pulls the latest post from each category and arrange categories by latests posts. What I get from this is an array with category ids which I want to use to rearrange the get\_categories array.
```
/* Get all categories */
$categories = get_categories();
/* Create empty array */
$categories_ord... | Yes, it's possible to trigger cron runs with just `$ php /path/to/wordpress/wp-cron.php`.
Alternatively you can use `curl`:
```
*/10 * * * * curl http://example.com/wp-cron.php > /dev/null 2>&1
```
And you can add the following line to your `wp-config.php` to disable crons being run from HTTP requests:
```
define(... |
199,795 | <p>I have created a custom admin page, which has a bunch of option fields available. One of them I use to enter some HTML code, and I was wondering if it was possible to also add php into that field, for it to be executed when that option is called in my template?</p>
<p>Thanks for any pointers.</p>
| [
{
"answer_id": 199728,
"author": "Mat",
"author_id": 10914,
"author_profile": "https://wordpress.stackexchange.com/users/10914",
"pm_score": 3,
"selected": false,
"text": "<p>Yes, it's possible to trigger cron runs with just <code>$ php /path/to/wordpress/wp-cron.php</code>.</p>\n\n<p>Al... | 2015/08/26 | [
"https://wordpress.stackexchange.com/questions/199795",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47334/"
] | I have created a custom admin page, which has a bunch of option fields available. One of them I use to enter some HTML code, and I was wondering if it was possible to also add php into that field, for it to be executed when that option is called in my template?
Thanks for any pointers. | Yes, it's possible to trigger cron runs with just `$ php /path/to/wordpress/wp-cron.php`.
Alternatively you can use `curl`:
```
*/10 * * * * curl http://example.com/wp-cron.php > /dev/null 2>&1
```
And you can add the following line to your `wp-config.php` to disable crons being run from HTTP requests:
```
define(... |
199,798 | <p>I've just disabled a plugin on my site and it's now giving me the dreaded white screen of death. I know the site will be fine if I reactivate the plugin.</p>
<p>Is there a way to manually activate a plugin through PHPMyAdmin or over FTP?</p>
| [
{
"answer_id": 199801,
"author": "Karolína Vyskočilová",
"author_id": 64771,
"author_profile": "https://wordpress.stackexchange.com/users/64771",
"pm_score": 2,
"selected": false,
"text": "<p>You can simply rename the plugin folder, for example:</p>\n\n<p><code>\"_aksimet\"</code> to dea... | 2015/08/26 | [
"https://wordpress.stackexchange.com/questions/199798",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4109/"
] | I've just disabled a plugin on my site and it's now giving me the dreaded white screen of death. I know the site will be fine if I reactivate the plugin.
Is there a way to manually activate a plugin through PHPMyAdmin or over FTP? | I fixed this by going through PHPMyAdmin to the table "Options" and then the row `active_plugins`.
I had the following stored there (formatted for readability):
```
a:10:{
i:0;s:49:"1and1-wordpress-wizard/1and1-wordpress-wizard.php";
i:1;s:29:"acf-repeater/acf-repeater.php";
i:2;s:30:"advanced-custom-fiel... |
199,813 | <p>Is it possible to change the labels for "Weak, Medium, Strong" etc... in the Password Indicator that's used in the user profile? I've been asked to change the word "Weak" to "OK" since this level of passwords is acceptable for our subscribers. Is there a filter I can hook into?</p>
| [
{
"answer_id": 199815,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 0,
"selected": false,
"text": "<p>You can do it right in your theme localization file. </p>\n\n<p>Open <code>*.pot</code> file and create the... | 2015/08/26 | [
"https://wordpress.stackexchange.com/questions/199813",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31345/"
] | Is it possible to change the labels for "Weak, Medium, Strong" etc... in the Password Indicator that's used in the user profile? I've been asked to change the word "Weak" to "OK" since this level of passwords is acceptable for our subscribers. Is there a filter I can hook into? | I was able to fix it with this method. Is this good/bad? It's working, but I'd be interested in feedback in case this could have unexpected consequences.
```
add_filter('gettext', 'translate_text');
add_filter('ngettext', 'translate_text');
function translate_text($translated) {
$translated = str_ireplace('Very Wea... |
199,840 | <p>I want to display the url's like this:</p>
<p>for Category:
/webshop/categories/hoodies/</p>
<p>for products:</p>
<p>/webshop/categories/hoodies/test-product</p>
<p>how is this possible without giving me 404 not found</p>
<p>thanks</p>
| [
{
"answer_id": 199815,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 0,
"selected": false,
"text": "<p>You can do it right in your theme localization file. </p>\n\n<p>Open <code>*.pot</code> file and create the... | 2015/08/26 | [
"https://wordpress.stackexchange.com/questions/199840",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52269/"
] | I want to display the url's like this:
for Category:
/webshop/categories/hoodies/
for products:
/webshop/categories/hoodies/test-product
how is this possible without giving me 404 not found
thanks | I was able to fix it with this method. Is this good/bad? It's working, but I'd be interested in feedback in case this could have unexpected consequences.
```
add_filter('gettext', 'translate_text');
add_filter('ngettext', 'translate_text');
function translate_text($translated) {
$translated = str_ireplace('Very Wea... |
199,844 | <p>Are there any example projects that do the same? </p>
<p>I want to be able to login and register for accounts on my site via the API.</p>
| [
{
"answer_id": 219446,
"author": "Joe Dooley",
"author_id": 81789,
"author_profile": "https://wordpress.stackexchange.com/users/81789",
"pm_score": 1,
"selected": false,
"text": "<p>There are a lot of examples of user registration using the WP REST API and the OAuth server implementation... | 2015/08/26 | [
"https://wordpress.stackexchange.com/questions/199844",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78405/"
] | Are there any example projects that do the same?
I want to be able to login and register for accounts on my site via the API. | I know it's a bit far fetched, but might help. For anyone looking for WP REST API implementation with JWT, here's our solution.
Add it to your function.php
```
add_action('rest_api_init', 'wp_rest_user_endpoints');
/**
* Register a new user
*
* @param WP_REST_Request $request Full details about the request.
* @... |
199,849 | <p>Im starting the biggest project I ever made, a online business directory in a certain niche.</p>
<p>Firstly, I thought to make two wordpress installs sharing the same database and specially the users table. Like website/blog.</p>
<p>I.e. niche-directory in the main domain and in a subdirectory a blog.</p>
<p>I wa... | [
{
"answer_id": 219446,
"author": "Joe Dooley",
"author_id": 81789,
"author_profile": "https://wordpress.stackexchange.com/users/81789",
"pm_score": 1,
"selected": false,
"text": "<p>There are a lot of examples of user registration using the WP REST API and the OAuth server implementation... | 2015/08/26 | [
"https://wordpress.stackexchange.com/questions/199849",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78409/"
] | Im starting the biggest project I ever made, a online business directory in a certain niche.
Firstly, I thought to make two wordpress installs sharing the same database and specially the users table. Like website/blog.
I.e. niche-directory in the main domain and in a subdirectory a blog.
I want to blog about that ni... | I know it's a bit far fetched, but might help. For anyone looking for WP REST API implementation with JWT, here's our solution.
Add it to your function.php
```
add_action('rest_api_init', 'wp_rest_user_endpoints');
/**
* Register a new user
*
* @param WP_REST_Request $request Full details about the request.
* @... |
199,860 | <p>I am trying to display authors comments on their profile page (author.php), however both codes I tried seem to display everyone's comments. Also the second code is suppose to link to the specific comment, but instead it does nothing. Also the comments id is already added to the comments output and it prints fine. An... | [
{
"answer_id": 200131,
"author": "Abhik",
"author_id": 26991,
"author_profile": "https://wordpress.stackexchange.com/users/26991",
"pm_score": 1,
"selected": false,
"text": "<p>First method, you are missing the second parameter for <code>get_the_author_meta</code>, which is the ID of the... | 2015/08/27 | [
"https://wordpress.stackexchange.com/questions/199860",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24067/"
] | I am trying to display authors comments on their profile page (author.php), however both codes I tried seem to display everyone's comments. Also the second code is suppose to link to the specific comment, but instead it does nothing. Also the comments id is already added to the comments output and it prints fine. Any h... | What you need to use here is the [WP\_Comment\_Query()](https://codex.wordpress.org/Class_Reference/WP_Comment_Query) function.
So on the `author.php` page, you can easily get the author info and ID as followed:
```
// get author info
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get... |
199,879 | <p>I am trying to create a couple of custom posts and set a custom taxonomy term to it on plugin activation. I am using the register plugin activation hook to do it. The posts are created properly, but I the post term is not being set. I am using <code>wp_set_object_terms</code> to do it. What could be the possible cau... | [
{
"answer_id": 199875,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 5,
"selected": true,
"text": "<p>It's the nature of the <a href=\"https://developer.wordpress.org/themes/basics/template-hierarchy/\">WordPr... | 2015/08/27 | [
"https://wordpress.stackexchange.com/questions/199879",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4740/"
] | I am trying to create a couple of custom posts and set a custom taxonomy term to it on plugin activation. I am using the register plugin activation hook to do it. The posts are created properly, but I the post term is not being set. I am using `wp_set_object_terms` to do it. What could be the possible cause?
My code r... | It's the nature of the [WordPress template hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/) - point being, if you *don't* have a `page.php`, it will use `singular.php`, same if you don't have `single.php`, it will *fallback* to a template lower in the hierarchy.
Ideal for themes that have ... |
199,887 | <p>I'm trying to use update_value filter hook of Advanced Custom Fields to write a function that when a user deletes an image from the field it will be deleted from the media library of WP as well. So far i haven't managed to make it work i get lots of errors. I need to check if the value of the field is empty then get... | [
{
"answer_id": 199907,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": true,
"text": "<p>You're close - couple of things:</p>\n\n<ol>\n<li><code>$field</code> is an array representation of the fie... | 2015/08/27 | [
"https://wordpress.stackexchange.com/questions/199887",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70428/"
] | I'm trying to use update\_value filter hook of Advanced Custom Fields to write a function that when a user deletes an image from the field it will be deleted from the media library of WP as well. So far i haven't managed to make it work i get lots of errors. I need to check if the value of the field is empty then get t... | You're close - couple of things:
1. `$field` is an array representation of the field, so you need to use `$field['name']` which is the *name* of the field.
2. `get_field` will format the value unless you set the third argument to false - we want the ID, not the post object/URL (or whatever setting you configured for y... |
199,898 | <p>I'm trying to develop a plugin which adds a single line to the .htaccess file generated by WordPress.</p>
<p>The problem is that one of the WP generated lines override my rule, and via the "insert_with_markers()" function, I have not found a way to specify a position so I could prepend my line instead of appending ... | [
{
"answer_id": 199907,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": true,
"text": "<p>You're close - couple of things:</p>\n\n<ol>\n<li><code>$field</code> is an array representation of the fie... | 2015/08/27 | [
"https://wordpress.stackexchange.com/questions/199898",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78187/"
] | I'm trying to develop a plugin which adds a single line to the .htaccess file generated by WordPress.
The problem is that one of the WP generated lines override my rule, and via the "insert\_with\_markers()" function, I have not found a way to specify a position so I could prepend my line instead of appending it as cu... | You're close - couple of things:
1. `$field` is an array representation of the field, so you need to use `$field['name']` which is the *name* of the field.
2. `get_field` will format the value unless you set the third argument to false - we want the ID, not the post object/URL (or whatever setting you configured for y... |
199,906 | <p>Following this <a href="https://wordpress.stackexchange.com/questions/9775/how-to-edit-a-user-profile-on-the-front-end">post</a>, I tried to add the code in the template of a genesis child theme to edit user's profile (change the password), using genesis actions (genesis_entry_content, genesis_loop,...), replacing t... | [
{
"answer_id": 199907,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": true,
"text": "<p>You're close - couple of things:</p>\n\n<ol>\n<li><code>$field</code> is an array representation of the fie... | 2015/08/27 | [
"https://wordpress.stackexchange.com/questions/199906",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75422/"
] | Following this [post](https://wordpress.stackexchange.com/questions/9775/how-to-edit-a-user-profile-on-the-front-end), I tried to add the code in the template of a genesis child theme to edit user's profile (change the password), using genesis actions (genesis\_entry\_content, genesis\_loop,...), replacing the genesis ... | You're close - couple of things:
1. `$field` is an array representation of the field, so you need to use `$field['name']` which is the *name* of the field.
2. `get_field` will format the value unless you set the third argument to false - we want the ID, not the post object/URL (or whatever setting you configured for y... |
199,912 | <p>I have plugin that has the same name as other plugin uploaded to wordpress.org<br>
How can i make it unique so it doesn't share "View Detais" link and auto-update with other plugin uploaded to wordpress.org? Considering that name of my plugin <strong>has to be exactly</strong> name it already has and <strong>cannot<... | [
{
"answer_id": 199907,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": true,
"text": "<p>You're close - couple of things:</p>\n\n<ol>\n<li><code>$field</code> is an array representation of the fie... | 2015/08/27 | [
"https://wordpress.stackexchange.com/questions/199912",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78437/"
] | I have plugin that has the same name as other plugin uploaded to wordpress.org
How can i make it unique so it doesn't share "View Detais" link and auto-update with other plugin uploaded to wordpress.org? Considering that name of my plugin **has to be exactly** name it already has and **cannot** be changed.
I've a... | You're close - couple of things:
1. `$field` is an array representation of the field, so you need to use `$field['name']` which is the *name* of the field.
2. `get_field` will format the value unless you set the third argument to false - we want the ID, not the post object/URL (or whatever setting you configured for y... |
199,999 | <p>I am using Bootstrap nav pills with drop-down items as WordPress menu, the menu without drop-down is looking good but when I add nested ul as drop-down the menu not working as expected..</p>
<p>HTML</p>
<pre><code><nav class="navbar navbar-default pull-right" role="navigation">
<div class="container-f... | [
{
"answer_id": 219027,
"author": "Gnana lingam",
"author_id": 89548,
"author_profile": "https://wordpress.stackexchange.com/users/89548",
"pm_score": 0,
"selected": false,
"text": "<pre><code><?php\n/**\n * Class Name: wp_bootstrap_navwalker\n * GitHub URI: https://github.com/twittem/... | 2015/08/28 | [
"https://wordpress.stackexchange.com/questions/199999",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78442/"
] | I am using Bootstrap nav pills with drop-down items as WordPress menu, the menu without drop-down is looking good but when I add nested ul as drop-down the menu not working as expected..
HTML
```
<nav class="navbar navbar-default pull-right" role="navigation">
<div class="container-fluid">
<div class="nav... | I ran into similar problem when I created a bootstrap navigation menu and dropdown links were all showing up at once.
I used the following steps to correct the issue:
1. download navwalker from github repo link: <https://github.com/wp-bootstrap/wp-bootstrap-navwalker>
2. put this file in the root folder of the theme ... |
200,049 | <p>There are many posts that seem to strike around this area, but I'm more and more confused by each one I read.</p>
<p>I have a page that shows the "Terms of Service" (id = 1086). I would like to display the content of that page inside a template (signup.php) on another page.</p>
<p>I'm running latest versi... | [
{
"answer_id": 200051,
"author": "terminator",
"author_id": 55034,
"author_profile": "https://wordpress.stackexchange.com/users/55034",
"pm_score": 1,
"selected": false,
"text": "<p>It should work</p>\n\n<pre><code><?php\n$my_postid = 1772;//This is page id or post id\n$content_post =... | 2015/08/28 | [
"https://wordpress.stackexchange.com/questions/200049",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/71680/"
] | There are many posts that seem to strike around this area, but I'm more and more confused by each one I read.
I have a page that shows the "Terms of Service" (id = 1086). I would like to display the content of that page inside a template (signup.php) on another page.
I'm running latest version (4.3). I'm confused by ... | The code that worked for me was the following:
```
<? $the_query = new WP_Query( 'page_id=1086' );
while ( $the_query->have_posts() ) :
$the_query->the_post();
the_title();
the_content();
endwhile;
wp_reset_postdata();
?>
```
I found this on a [thread here](https://wordpress.org/support/t... |
200,053 | <p>I migrated a WordPress 4.3 site from Register.com to MediaTemple today and found that the forced SSL is causing issues for the staging URL.</p>
<p>In order to try again I have (on the live Register.com site)</p>
<ul>
<li>Disabled plugin 'WordPress HTTPS'</li>
<li>Removed <code>define( 'FORCE_SSL_ADMIN', true );</c... | [
{
"answer_id": 200056,
"author": "jerrygarciuh",
"author_id": 12414,
"author_profile": "https://wordpress.stackexchange.com/users/12414",
"pm_score": 2,
"selected": true,
"text": "<p>In the active theme I found the redirection in header.php</p>\n\n<p>Once commented out the issue was reso... | 2015/08/28 | [
"https://wordpress.stackexchange.com/questions/200053",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12414/"
] | I migrated a WordPress 4.3 site from Register.com to MediaTemple today and found that the forced SSL is causing issues for the staging URL.
In order to try again I have (on the live Register.com site)
* Disabled plugin 'WordPress HTTPS'
* Removed `define( 'FORCE_SSL_ADMIN', true );` from wp-config
* In General Settin... | In the active theme I found the redirection in header.php
Once commented out the issue was resolved.
```
if($_SERVER["HTTPS"] != "on")
{
header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
exit();
}
``` |
200,082 | <p>I'm trying to load a stylesheet for a particular admin submenu page. The code below is what I came up with after looking up <code>admin_enqueue_scripts</code> in the codex:</p>
<pre><code>function my_function($hook) {
if ( 'themes.php?page=page-name' != $hook ) {
return;
}
wp_enqueue_style( 'cus... | [
{
"answer_id": 200086,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 0,
"selected": false,
"text": "<p>if you have declared the page with <code>add_theme_page(...</code>, you can add the stylesheet in the hook <code>... | 2015/08/29 | [
"https://wordpress.stackexchange.com/questions/200082",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18937/"
] | I'm trying to load a stylesheet for a particular admin submenu page. The code below is what I came up with after looking up `admin_enqueue_scripts` in the codex:
```
function my_function($hook) {
if ( 'themes.php?page=page-name' != $hook ) {
return;
}
wp_enqueue_style( 'custom-style', get_template_... | Ok, I figured it out: If it's a submenu page, the `$hook` looks like this: `appearance_page_page-name` instead of going by URL. So the complete code would be this:
```
function my_function($hook) {
if ( 'appearance_page_page-name' != $hook ) {
return;
}
wp_enqueue_style( 'custom-style', get_templat... |
200,093 | <p>I have a custom page template that looks like this:</p>
<pre><code><?php if( is_user_logged_in() ): ?>
<?php get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php thinkup_input_nav( 'nav-below' ); ?>
<?php thi... | [
{
"answer_id": 200117,
"author": "Jennifer M.",
"author_id": 78564,
"author_profile": "https://wordpress.stackexchange.com/users/78564",
"pm_score": 0,
"selected": false,
"text": "<p>Try logging in with an account that's NOT an admin account. I think that's just a quirk of an admin accou... | 2015/08/29 | [
"https://wordpress.stackexchange.com/questions/200093",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78546/"
] | I have a custom page template that looks like this:
```
<?php if( is_user_logged_in() ): ?>
<?php get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php thinkup_input_nav( 'nav-below' ); ?>
<?php thinkup_input_allowcomments(); ?>
<?php endwhil... | By removing the ADMIN SSL login in `wp-config.php`, I solved this.
So, remove this:
```
define('FORCE_SSL_ADMIN', true);
```
Read more about this feature [here](https://codex.wordpress.org/Administration_Over_SSL) |
200,096 | <p>Before to report this to wordpress I would like to know if it's just me or it's actually a bug. I noticed also another user that asked on the wordpress forum but he hadn't an answer for that: <a href="https://wordpress.org/support/topic/admin-left-menu-overlap" rel="nofollow noreferrer">https://wordpress.org/support... | [
{
"answer_id": 200117,
"author": "Jennifer M.",
"author_id": 78564,
"author_profile": "https://wordpress.stackexchange.com/users/78564",
"pm_score": 0,
"selected": false,
"text": "<p>Try logging in with an account that's NOT an admin account. I think that's just a quirk of an admin accou... | 2015/08/29 | [
"https://wordpress.stackexchange.com/questions/200096",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78388/"
] | Before to report this to wordpress I would like to know if it's just me or it's actually a bug. I noticed also another user that asked on the wordpress forum but he hadn't an answer for that: <https://wordpress.org/support/topic/admin-left-menu-overlap>
And the same is here:
[;
```
Read more about this feature [here](https://codex.wordpress.org/Administration_Over_SSL) |
200,108 | <p>I'm trying to give a more complete experience to my WordPress backend users and let them edit the custom image sizes I have added to my theme. </p>
<p>I added this to my <code>functions.php</code>:</p>
<pre><code>add_image_size( 'new_image_size', 500, 500, true );
</code></pre>
<p>I would like the new size to be ... | [
{
"answer_id": 207221,
"author": "user3392555",
"author_id": 82801,
"author_profile": "https://wordpress.stackexchange.com/users/82801",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think it is possible...\ni have been looking answer for this also...</p>\n\n<p>check this out...\... | 2015/08/29 | [
"https://wordpress.stackexchange.com/questions/200108",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78555/"
] | I'm trying to give a more complete experience to my WordPress backend users and let them edit the custom image sizes I have added to my theme.
I added this to my `functions.php`:
```
add_image_size( 'new_image_size', 500, 500, true );
```
I would like the new size to be available here:
[![Editing an image in Word... | As far as i know it is possible with `image_size_names_choose` hook (see <https://codex.wordpress.org/Plugin_API/Filter_Reference/image_size_names_choose>).
Example:
```
// add your custom size
function my_setup_image_sizes() {
add_image_size( 'wide-image', 900, 0);
}
add_action( 'after_setup_theme', 'my_setup_imag... |
200,113 | <p>We want to use wordpress to host image which we'll use in our email newsletter.</p>
<p>To that end, we can obviously upload the image via the Media panel in Admin and either right-click the image and get URL or enter <a href="http://www.wpbeginner.com/beginners-guide/how-to-get-the-url-of-images-you-upload-in-wordp... | [
{
"answer_id": 200140,
"author": "Ignat B.",
"author_id": 38121,
"author_profile": "https://wordpress.stackexchange.com/users/38121",
"pm_score": 2,
"selected": false,
"text": "<p>The fact that basic WP functionality wont provide you a panel to manage those sizes and retrieve media links... | 2015/08/29 | [
"https://wordpress.stackexchange.com/questions/200113",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48604/"
] | We want to use wordpress to host image which we'll use in our email newsletter.
To that end, we can obviously upload the image via the Media panel in Admin and either right-click the image and get URL or enter [Library and click the image](http://www.wpbeginner.com/beginners-guide/how-to-get-the-url-of-images-you-uplo... | This is a good idea. Thanks for suggesting it—going to use it. :)
You can add a column to the Media Library that outputs the paths. This will spit them all out. You could of course filter it to only show the sizes you actually want. Put in `functions.php` or similar.
```
// Adds a "Sizes" column
function sizes_colum... |
200,114 | <p>I Just want to know how can I update my Wordpress theme manually on live site. Actually I am using plugin called "WP Total Cache" My entire website styles is messed up when I try to update wordpress theme via ftp. </p>
<p>Any suggestions please ?</p>
| [
{
"answer_id": 200140,
"author": "Ignat B.",
"author_id": 38121,
"author_profile": "https://wordpress.stackexchange.com/users/38121",
"pm_score": 2,
"selected": false,
"text": "<p>The fact that basic WP functionality wont provide you a panel to manage those sizes and retrieve media links... | 2015/08/30 | [
"https://wordpress.stackexchange.com/questions/200114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78561/"
] | I Just want to know how can I update my Wordpress theme manually on live site. Actually I am using plugin called "WP Total Cache" My entire website styles is messed up when I try to update wordpress theme via ftp.
Any suggestions please ? | This is a good idea. Thanks for suggesting it—going to use it. :)
You can add a column to the Media Library that outputs the paths. This will spit them all out. You could of course filter it to only show the sizes you actually want. Put in `functions.php` or similar.
```
// Adds a "Sizes" column
function sizes_colum... |
200,120 | <p>I am trying to figure out how to echo 4 created fields from a plugin in my theme template for the comment form and customize the comments output as well. The plugin I am using lets me add custom fields to comment_form but I am unable to echo out even one of them in the comments.</p>
<p>The field I am trying to echo... | [
{
"answer_id": 200140,
"author": "Ignat B.",
"author_id": 38121,
"author_profile": "https://wordpress.stackexchange.com/users/38121",
"pm_score": 2,
"selected": false,
"text": "<p>The fact that basic WP functionality wont provide you a panel to manage those sizes and retrieve media links... | 2015/08/30 | [
"https://wordpress.stackexchange.com/questions/200120",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24067/"
] | I am trying to figure out how to echo 4 created fields from a plugin in my theme template for the comment form and customize the comments output as well. The plugin I am using lets me add custom fields to comment\_form but I am unable to echo out even one of them in the comments.
The field I am trying to echo in the c... | This is a good idea. Thanks for suggesting it—going to use it. :)
You can add a column to the Media Library that outputs the paths. This will spit them all out. You could of course filter it to only show the sizes you actually want. Put in `functions.php` or similar.
```
// Adds a "Sizes" column
function sizes_colum... |
200,129 | <p>I'd like to create the following structure for my WP installation:</p>
<ul>
<li>htdocs (base dir)
<ul>
<li>wp (WordPress dir)</li>
<li>themes (WordPress theme dir)</li>
<li>plugins (WordPress plugin dir)</li>
<li>upload</li>
<li>index.php</li>
<li>.htaccess</li>
</ul></li>
</ul>
<p>So far I've been able to change... | [
{
"answer_id": 200130,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>You can move the installation and also plugin and content folder. The follow source demonstrate this. </p>\n\n<pr... | 2015/08/30 | [
"https://wordpress.stackexchange.com/questions/200129",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78569/"
] | I'd like to create the following structure for my WP installation:
* htdocs (base dir)
+ wp (WordPress dir)
+ themes (WordPress theme dir)
+ plugins (WordPress plugin dir)
+ upload
+ index.php
+ .htaccess
So far I've been able to change the WordPress root directory [1] (which means that even though we're on «wp... | You can move the installation and also plugin and content folder. The follow source demonstrate this.
```
//*
// Custom content directory
define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/wp-content' );
define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wp-content' );
// Custom plugin directory
define(... |
200,144 | <p>I have written a custom plugin for wordpress.</p>
<p>Once I add a sub-menu to the plugin I get a double entry for the top level item:</p>
<p><a href="https://i.stack.imgur.com/WMhku.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WMhku.png" alt="enter image description here"></a></p>
<p>I would like to ... | [
{
"answer_id": 200145,
"author": "Rehman Ali",
"author_id": 78577,
"author_profile": "https://wordpress.stackexchange.com/users/78577",
"pm_score": -1,
"selected": false,
"text": "<p>You can easily handle via css.</p>\n\n<p>Like</p>\n\n<pre><code>.class_name{\ndisplay:none;\n}\n</code></... | 2015/08/30 | [
"https://wordpress.stackexchange.com/questions/200144",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15010/"
] | I have written a custom plugin for wordpress.
Once I add a sub-menu to the plugin I get a double entry for the top level item:
[](https://i.stack.imgur.com/WMhku.png)
I would like to disable the second "TopLevel" menu item so it would appear like so... | If you dont want 'TopLevel' menu to represent a custom page you can use:
```
add_menu_page( 'TopLevel', 'TopLevel', 'MENU_CAP_LVL', 'MENU_SLUG', 'MENU_CB' );
add_submenu_page( 'MENU_SLUG', 'SubMenu', 'SubMenu', 'MENU_CAP_LVL', 'SUB_MENU_SLUG', 'SUB_MENU_CB' );
add_submenu_page( 'MENU_SLUG', 'SubMenu-A', 'SubMenu... |
200,157 | <p>Initially the Product Category page is divided into</p>
<p>Content Area (70% width)
Side Bar Area (30% width)
I have removed the side bar area using function.php. However the content area is still in 70%.</p>
<p>I am looking for a code with the condition in php, "If the chosen URL has Product Category with two dep... | [
{
"answer_id": 200145,
"author": "Rehman Ali",
"author_id": 78577,
"author_profile": "https://wordpress.stackexchange.com/users/78577",
"pm_score": -1,
"selected": false,
"text": "<p>You can easily handle via css.</p>\n\n<p>Like</p>\n\n<pre><code>.class_name{\ndisplay:none;\n}\n</code></... | 2015/08/30 | [
"https://wordpress.stackexchange.com/questions/200157",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78218/"
] | Initially the Product Category page is divided into
Content Area (70% width)
Side Bar Area (30% width)
I have removed the side bar area using function.php. However the content area is still in 70%.
I am looking for a code with the condition in php, "If the chosen URL has Product Category with two depths, then ensure ... | If you dont want 'TopLevel' menu to represent a custom page you can use:
```
add_menu_page( 'TopLevel', 'TopLevel', 'MENU_CAP_LVL', 'MENU_SLUG', 'MENU_CB' );
add_submenu_page( 'MENU_SLUG', 'SubMenu', 'SubMenu', 'MENU_CAP_LVL', 'SUB_MENU_SLUG', 'SUB_MENU_CB' );
add_submenu_page( 'MENU_SLUG', 'SubMenu-A', 'SubMenu... |
200,158 | <p>I am trying to learn WP Theme development. And as I have understod it is important to use "post_class()" since plugins may need to use it. But what I not understand is where I should use it? </p>
<p>Should I use it for the post for the main loop. Or should I use it for my custom-post-type-loop. Or both?</p>
| [
{
"answer_id": 200163,
"author": "Will",
"author_id": 44795,
"author_profile": "https://wordpress.stackexchange.com/users/44795",
"pm_score": 3,
"selected": true,
"text": "<p>It's actually only important to use it if your theme's CSS or JS is reliant on something it outputs. It essential... | 2015/08/30 | [
"https://wordpress.stackexchange.com/questions/200158",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66256/"
] | I am trying to learn WP Theme development. And as I have understod it is important to use "post\_class()" since plugins may need to use it. But what I not understand is where I should use it?
Should I use it for the post for the main loop. Or should I use it for my custom-post-type-loop. Or both? | It's actually only important to use it if your theme's CSS or JS is reliant on something it outputs. It essentially stuffs relevant class names into the HTML tag you put it on based on the current post/category/blah/blah. So, on a single post template this:
```
<article <?php post_class(); ?>>
```
might output:
```... |
200,171 | <p>I've to add just a line when the user clicks on a category link or search for something, so I thought to do something like this inside the index.php instead of creating other template file like search.php and category.php:</p>
<pre><code><?php if(is_search()): ?>
<h1><?php the_search_query(); ?&g... | [
{
"answer_id": 200173,
"author": "Ruturaj",
"author_id": 43266,
"author_profile": "https://wordpress.stackexchange.com/users/43266",
"pm_score": 0,
"selected": false,
"text": "<p>For me, it's perfect to use that sort of IF logic statements in Index than writing new template files. In fac... | 2015/08/30 | [
"https://wordpress.stackexchange.com/questions/200171",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78388/"
] | I've to add just a line when the user clicks on a category link or search for something, so I thought to do something like this inside the index.php instead of creating other template file like search.php and category.php:
```
<?php if(is_search()): ?>
<h1><?php the_search_query(); ?></h1>
<?php endif; ?>
<?php i... | Before I start, it will be a good idea to check out [my answer](https://wordpress.stackexchange.com/a/199880/31545) to the following post
* [What is singular.php?](https://wordpress.stackexchange.com/questions/199873/what-is-singular-php/199880#199880)
It will give you some more insight
As I stated in the linked ans... |
200,190 | <p>I'm trying to figure out how can I display the amount of posts ever posted - not only the currently published, draft + pending etc ones, but even the deleted ones. </p>
<p>I assume that there has to be created some kind of a counter that every time a post is published gets increased by one.</p>
<p>Any ideas?</p>
... | [
{
"answer_id": 200192,
"author": "Will",
"author_id": 44795,
"author_profile": "https://wordpress.stackexchange.com/users/44795",
"pm_score": 0,
"selected": false,
"text": "<p>Presuming you don't empty the trash on deleted posts, you can do it with a simple <code>wp_query</code>.</p>\n\n... | 2015/08/30 | [
"https://wordpress.stackexchange.com/questions/200190",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69692/"
] | I'm trying to figure out how can I display the amount of posts ever posted - not only the currently published, draft + pending etc ones, but even the deleted ones.
I assume that there has to be created some kind of a counter that every time a post is published gets increased by one.
Any ideas?
P.S. I'm talking abou... | Depending on your needs, WP Query may not work for this since it won't include posts that have been deleted after the trash has been emptied. This should work (but hasn't been tested):
```
function wpse_custom_post_type_counter() {
$number = get_option( 'wpse_custom_counter' ) ? absint( get_option( 'wpse_custom_c... |
200,212 | <p>I have been thinking of managing a set of wordpress sites from a remote server.I would like to get information on plugins that has been installed on my wordpress sites.I would also like to install plugins to the corresponding wordpress sites from my remote server.I have searched and found that <code>XMLRPC</code> mi... | [
{
"answer_id": 200225,
"author": "Shuyinsama",
"author_id": 56771,
"author_profile": "https://wordpress.stackexchange.com/users/56771",
"pm_score": 0,
"selected": false,
"text": "<p>If you are not agains using and installing plugins on all of your servers.</p>\n\n<p>Then MainWP can be of... | 2015/08/31 | [
"https://wordpress.stackexchange.com/questions/200212",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78604/"
] | I have been thinking of managing a set of wordpress sites from a remote server.I would like to get information on plugins that has been installed on my wordpress sites.I would also like to install plugins to the corresponding wordpress sites from my remote server.I have searched and found that `XMLRPC` might help in re... | If you're only managing a few sites and you're comfortable with the command line, you might want to look into [wp-cli](http://wp-cli.org/). With a little bit of scripting you can SSH into a remote server and do all manner of stuff like:
Enable plugins:
`wp plugin activate acf-pro gravityforms wordpress-seo`
Check ... |
200,231 | <p>As of version 4.3. it should be possible to activate markdown for my posts and comments (<a href="http://news.softpedia.com/news/say-hello-to-wordpress-4-3-489688.shtml" rel="nofollow">http://news.softpedia.com/news/say-hello-to-wordpress-4-3-489688.shtml</a>).</p>
<p>I found a description on <a href="https://en.su... | [
{
"answer_id": 200237,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress 4.3 have <strong>no markdown implementation</strong>, it is only a short list of shortcuts.\nThe shortc... | 2015/08/31 | [
"https://wordpress.stackexchange.com/questions/200231",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63332/"
] | As of version 4.3. it should be possible to activate markdown for my posts and comments (<http://news.softpedia.com/news/say-hello-to-wordpress-4-3-489688.shtml>).
I found a description on <https://en.support.wordpress.com/markdown/> , but the settings mentioned are not visible in `settings -> writing` and `settings -... | WordPress 4.3 have **no markdown implementation**, it is only a short list of shortcuts.
The shortcuts active on default. It give no UI area to active/deactivated them.
As small hint for updates posts. I seen often, that works only on new posts, no old drafts. But I haven't debug this.
### Which Formatting Shortcuts
... |
200,243 | <p>I am using Mochhost.com as my Hosting. Recently I have downloaded a free wp theme from wordpress.org. I unzipped the theme and I uploaded to my site at <a href="http://thegoods.info" rel="nofollow">http://thegoods.info</a> into my root directory, that is, public_html with Filezilla. Now my question is, I am unable ... | [
{
"answer_id": 200237,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress 4.3 have <strong>no markdown implementation</strong>, it is only a short list of shortcuts.\nThe shortc... | 2015/08/31 | [
"https://wordpress.stackexchange.com/questions/200243",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78622/"
] | I am using Mochhost.com as my Hosting. Recently I have downloaded a free wp theme from wordpress.org. I unzipped the theme and I uploaded to my site at <http://thegoods.info> into my root directory, that is, public\_html with Filezilla. Now my question is, I am unable to see the wp-content directory both in the Filezil... | WordPress 4.3 have **no markdown implementation**, it is only a short list of shortcuts.
The shortcuts active on default. It give no UI area to active/deactivated them.
As small hint for updates posts. I seen often, that works only on new posts, no old drafts. But I haven't debug this.
### Which Formatting Shortcuts
... |
200,245 | <p>I have div structure</p>
<pre><code><div class = 'main-menu'>
<ul class = 'menu'>
<li class = 'item1'></li>
<li class = 'item2'></li>
</ul>
</div>
</code></pre>
<p>But I want add div to menu </p>
<pre><code><div class = 'main-menu'>
<ul class = 'menu... | [
{
"answer_id": 200237,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress 4.3 have <strong>no markdown implementation</strong>, it is only a short list of shortcuts.\nThe shortc... | 2015/08/31 | [
"https://wordpress.stackexchange.com/questions/200245",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78447/"
] | I have div structure
```
<div class = 'main-menu'>
<ul class = 'menu'>
<li class = 'item1'></li>
<li class = 'item2'></li>
</ul>
</div>
```
But I want add div to menu
```
<div class = 'main-menu'>
<ul class = 'menu'>
<li class = 'item1'></li>
<li class = 'item2'>
<div class="adv_categories" id="adv_c... | WordPress 4.3 have **no markdown implementation**, it is only a short list of shortcuts.
The shortcuts active on default. It give no UI area to active/deactivated them.
As small hint for updates posts. I seen often, that works only on new posts, no old drafts. But I haven't debug this.
### Which Formatting Shortcuts
... |
200,276 | <p>I want to know who added every user in all users menu in the back-end, I used 'get_the_author' but it must be within the 'loop' which cann't be in all users menu that the condnition willnot be verified, Could anyone help?</p>
| [
{
"answer_id": 200237,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress 4.3 have <strong>no markdown implementation</strong>, it is only a short list of shortcuts.\nThe shortc... | 2015/08/31 | [
"https://wordpress.stackexchange.com/questions/200276",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78311/"
] | I want to know who added every user in all users menu in the back-end, I used 'get\_the\_author' but it must be within the 'loop' which cann't be in all users menu that the condnition willnot be verified, Could anyone help? | WordPress 4.3 have **no markdown implementation**, it is only a short list of shortcuts.
The shortcuts active on default. It give no UI area to active/deactivated them.
As small hint for updates posts. I seen often, that works only on new posts, no old drafts. But I haven't debug this.
### Which Formatting Shortcuts
... |
200,294 | <p>I have a bit of content in a PHP file that is designed to live inside an iframe on another page. The PHP file is very simple-- here it is in its entirety right now:</p>
<pre><code><div class="content-tos">
<?php
// get the terms of service from other page
$getpage = get_page_by_path('/t... | [
{
"answer_id": 200299,
"author": "Will",
"author_id": 44795,
"author_profile": "https://wordpress.stackexchange.com/users/44795",
"pm_score": 0,
"selected": false,
"text": "<p>Think perhaps you're confusing <code>get_header()</code> with the file <code>wp-blog-header.php</code>. The firs... | 2015/08/31 | [
"https://wordpress.stackexchange.com/questions/200294",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13981/"
] | I have a bit of content in a PHP file that is designed to live inside an iframe on another page. The PHP file is very simple-- here it is in its entirety right now:
```
<div class="content-tos">
<?php
// get the terms of service from other page
$getpage = get_page_by_path('/terms-of-service');
... | If you don't want `get_header`, then don't call `get_header()`. It's a simple as that, the `get_header` function is not where all of the WP core is initialized. The simplest way to do this is using the template hierarchy to create a template for a specific page slug or id.
From the WP Admin, create a page at the URL y... |
200,296 | <p>WordPress 4.3 brought more updates to the customizer. It also added a new option at the top admin menu bar that says 'Cusomize' and has a paintbrush. How can I disable this menu from showing up? We don't use the customizer, and I would not like our users clicking on it either. </p>
<p>We currently do <code>$wp_admi... | [
{
"answer_id": 200304,
"author": "czerspalace",
"author_id": 47406,
"author_profile": "https://wordpress.stackexchange.com/users/47406",
"pm_score": 5,
"selected": true,
"text": "<p><code>customize</code> should work. I was able to remove the Customize link with the following code:</p>\n... | 2015/08/31 | [
"https://wordpress.stackexchange.com/questions/200296",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17423/"
] | WordPress 4.3 brought more updates to the customizer. It also added a new option at the top admin menu bar that says 'Cusomize' and has a paintbrush. How can I disable this menu from showing up? We don't use the customizer, and I would not like our users clicking on it either.
We currently do `$wp_admin_bar->remove_m... | `customize` should work. I was able to remove the Customize link with the following code:
```
add_action( 'wp_before_admin_bar_render', 'wpse200296_before_admin_bar_render' );
function wpse200296_before_admin_bar_render()
{
global $wp_admin_bar;
$wp_admin_bar->remove_menu('customize');
}
``` |
200,315 | <p>I am trying to learn WP theme development. And at the moment I got some problems when I try to enqueue my stylesheet (id does'nt load). It is named style.css and located in my theme folder.</p>
<p>I have put this code in my functions.php file:</p>
<pre><code>function my_theme_scripts() {
wp_register_style( 'style'... | [
{
"answer_id": 200316,
"author": "andreiudeiu",
"author_id": 74500,
"author_profile": "https://wordpress.stackexchange.com/users/74500",
"pm_score": 1,
"selected": false,
"text": "<p>try define the css url.</p>\n\n<p>for example this:</p>\n\n<p>wp_register_style('style', get_template_dir... | 2015/08/31 | [
"https://wordpress.stackexchange.com/questions/200315",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66256/"
] | I am trying to learn WP theme development. And at the moment I got some problems when I try to enqueue my stylesheet (id does'nt load). It is named style.css and located in my theme folder.
I have put this code in my functions.php file:
```
function my_theme_scripts() {
wp_register_style( 'style', get_stylesheet_uri(... | Please edit the path for the style sheet
And put the code in functions.php
```
function my_theme_scripts() {
wp_enqueue_style('style', get_stylesheet_directory_uri() . '/css/style.css',false,'all' );
}
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' );
``` |
200,338 | <p>How can I add a button to a posts -page. (In this case a custom post type).</p>
<p>I'd like to place it next to, or near, the "Add new" button, to import content from a web service.</p>
| [
{
"answer_id": 200340,
"author": "Marek",
"author_id": 54031,
"author_profile": "https://wordpress.stackexchange.com/users/54031",
"pm_score": 3,
"selected": false,
"text": "<p>Like this:</p>\n\n<pre><code>function custom_js_to_head() {\n ?>\n <script>\n jQuery(function... | 2015/09/01 | [
"https://wordpress.stackexchange.com/questions/200338",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78679/"
] | How can I add a button to a posts -page. (In this case a custom post type).
I'd like to place it next to, or near, the "Add new" button, to import content from a web service. | Like this:
```
function custom_js_to_head() {
?>
<script>
jQuery(function(){
jQuery("body.post-type-YOUR-CUSTOM-POST-TYPE .wrap h1").append('<a href="index.php?param=your-action" class="page-title-action">Import from ...</a>');
});
</script>
<?php
}
add_action('admin_head', 'custom_js_t... |
200,368 | <p>I'm trying to setup a cron to run every hour, it works fine on my local vagrant box, but it doesn't seem to schedule properly on aws(elastic beanstalk). Here's the code:</p>
<pre><code>register_activation_hook(__FILE__, 'my_activation');
add_action('my_hourly_event', 'do_this_hourly');
function my_activation() {
... | [
{
"answer_id": 215395,
"author": "Peyman Mohamadpour",
"author_id": 75020,
"author_profile": "https://wordpress.stackexchange.com/users/75020",
"pm_score": 0,
"selected": false,
"text": "<p>You may use these steps to get it to work:`\n<strong>1. Setup an schedule</strong></p>\n\n<pre><co... | 2015/09/01 | [
"https://wordpress.stackexchange.com/questions/200368",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/72925/"
] | I'm trying to setup a cron to run every hour, it works fine on my local vagrant box, but it doesn't seem to schedule properly on aws(elastic beanstalk). Here's the code:
```
register_activation_hook(__FILE__, 'my_activation');
add_action('my_hourly_event', 'do_this_hourly');
function my_activation() {
wp_schedule... | As a general principal, you shouldn't do anything that requires an 'add\_action' after the plugin activation hook. This is because WP loads and runs all plugins and THEN runs the new added one, and then does a re-direct. You have to set a DB option and hook into that. Here is the discussion from the CODEX:
<https://cod... |
200,373 | <p>I have a parent class, which contains the following:</p>
<pre><code>use app\My_Dashboard;
class My_Class {
public function __construct() {
add_action('admin_menu', array($this, 'setup_dashboard_page'));
}
public function setup_dashboard_page() {
My_Dashboard::add_dashboard_page();
... | [
{
"answer_id": 200379,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 3,
"selected": true,
"text": "<p>I hate OOP mixed in the functional structure of wordpress (here come the downvotes.....). If you use OOP j... | 2015/09/01 | [
"https://wordpress.stackexchange.com/questions/200373",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4740/"
] | I have a parent class, which contains the following:
```
use app\My_Dashboard;
class My_Class {
public function __construct() {
add_action('admin_menu', array($this, 'setup_dashboard_page'));
}
public function setup_dashboard_page() {
My_Dashboard::add_dashboard_page();
}
}
```
And... | I hate OOP mixed in the functional structure of wordpress (here come the downvotes.....). If you use OOP just for name spacing then just use the name spacing feature of PHP, putting function in a class is just a very small part of what OOP should be.
Anyway, your problems is that a there are only two way to refere to ... |
200,468 | <p>I am trying to learn WP theme development. And I just learned that WP already has a jQuery version included. Until now I have been using the jQuery from Google's CDN. </p>
<p>So I just now deleted the CDN link from my code. And of course all my jQuery code stopped working. </p>
<p>So I guess I am missing something... | [
{
"answer_id": 200470,
"author": "Ignat B.",
"author_id": 38121,
"author_profile": "https://wordpress.stackexchange.com/users/38121",
"pm_score": 1,
"selected": false,
"text": "<p>In order to enqueue jQuery from WP-installation you can:</p>\n\n<pre><code>function custom_enqueue_scripts()... | 2015/09/02 | [
"https://wordpress.stackexchange.com/questions/200468",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66256/"
] | I am trying to learn WP theme development. And I just learned that WP already has a jQuery version included. Until now I have been using the jQuery from Google's CDN.
So I just now deleted the CDN link from my code. And of course all my jQuery code stopped working.
So I guess I am missing something. What do I need ... | WP's jQuery is not mapped to `$` like you may expect, it is loaded in `noConflict` mode so you'll need to use `jQuery()` instead of `$()`, unless you map it yourself.
When you include your js file you'll want to make sure to set jQuery as a dependency as well:
```
wp_enqueue_script( 'your-script-handle', get_styleshe... |
200,469 | <p>After WordPress 4.3, the old method of disabling wpautop no longer works. Has anyone discovered a new method for removing this function?</p>
<pre><code>remove_filter( 'the_content', 'wpautop', 99 );
remove_filter( 'the_excerpt', 'wpautop', 99 );
</code></pre>
| [
{
"answer_id": 201896,
"author": "denis.stoyanov",
"author_id": 76287,
"author_profile": "https://wordpress.stackexchange.com/users/76287",
"pm_score": 3,
"selected": false,
"text": "<p>I guess you don't use it at all, so why don't you just remove the filter?</p>\n\n<pre><code>remove_fil... | 2015/09/02 | [
"https://wordpress.stackexchange.com/questions/200469",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78759/"
] | After WordPress 4.3, the old method of disabling wpautop no longer works. Has anyone discovered a new method for removing this function?
```
remove_filter( 'the_content', 'wpautop', 99 );
remove_filter( 'the_excerpt', 'wpautop', 99 );
``` | I guess you don't use it at all, so why don't you just remove the filter?
```
remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');
```
I've tested it a few minutes ago (on WP 4.3) and it works.
p.s. I just saw that you use the same function. Sorry for that. What version are you using? T... |
200,505 | <p>I am working on a custom query to show a few posts. I am able to output all the post ID's. I am trying to turn these ID's into an array so I can use 'post__in' => $myarray in my query. How can I do this?</p>
<pre><code> <?php
$allposts = $wpdb->get_results("SELECT `music_id` FROM ... | [
{
"answer_id": 200488,
"author": "Robert Rome",
"author_id": 78655,
"author_profile": "https://wordpress.stackexchange.com/users/78655",
"pm_score": 0,
"selected": false,
"text": "<p>You want to isolate what changes were made that caused the issue. If there is any way of narrowing down w... | 2015/09/02 | [
"https://wordpress.stackexchange.com/questions/200505",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49017/"
] | I am working on a custom query to show a few posts. I am able to output all the post ID's. I am trying to turn these ID's into an array so I can use 'post\_\_in' => $myarray in my query. How can I do this?
```
<?php
$allposts = $wpdb->get_results("SELECT `music_id` FROM `custom_table` ORDER BY id... | You are most probably using an outdated version of Advanced Custom Fields plugin. I had the same issue. Updating to latest version fixed the issue. |
200,510 | <p>Using the S2member plugin, a meta_key for the last-payment-time is automatically stored in WordPress DB under table wp_usermeta (custom field is called wp_meds2member_last_payment_time).</p>
<p>From wp_usermeta, the column called meta_key has a value 'wp_meds2member_last_payment_time'. But the content I'm trying to... | [
{
"answer_id": 205090,
"author": "Cristián Lávaque",
"author_id": 81709,
"author_profile": "https://wordpress.stackexchange.com/users/81709",
"pm_score": 0,
"selected": false,
"text": "<p>@Amine, the meta field's name is just <code>s2member_last_payment_time</code>, so try it without the... | 2015/09/02 | [
"https://wordpress.stackexchange.com/questions/200510",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78780/"
] | Using the S2member plugin, a meta\_key for the last-payment-time is automatically stored in WordPress DB under table wp\_usermeta (custom field is called wp\_meds2member\_last\_payment\_time).
From wp\_usermeta, the column called meta\_key has a value 'wp\_meds2member\_last\_payment\_time'. But the content I'm trying ... | @Cristián Lávaque Thank you for the hints ;)
Actually I managed to resolve the issue blocking this function (show the hidden comment above). In case this would help anyone here is the final working code:
```
function check_post_limit() {
if ( current_user_can( 'edit_posts' ) ) {
global $userdata;
... |
200,523 | <p>Say I have a bunch of posts, some of them have a meta key called "key1" and some of them have a meta key called "key2". But the posts do not have both.</p>
<p>I'd like to create a custom query which retrieves any post that has "key1" or "key2" as a meta key. (not a single post which has both).</p>
<p>After digging... | [
{
"answer_id": 200528,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 3,
"selected": true,
"text": "<p>An easy query like the following should work for you:</p>\n\n<pre><code><?php\n$_query = new WP_Quer... | 2015/09/03 | [
"https://wordpress.stackexchange.com/questions/200523",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35675/"
] | Say I have a bunch of posts, some of them have a meta key called "key1" and some of them have a meta key called "key2". But the posts do not have both.
I'd like to create a custom query which retrieves any post that has "key1" or "key2" as a meta key. (not a single post which has both).
After digging around, the clos... | An easy query like the following should work for you:
```
<?php
$_query = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => -1,
'post_status' => 'publish',
'meta_query' => array(
'relation' => 'OR',
array(
'key' ... |
200,580 | <p>I've created a new Wordpress site using the <a href="http://themient.com/themes/realistic" rel="nofollow noreferrer">Realistic theme</a>. I added a logo, and this was the resulting webpage (ignore the sidebar):</p>
<p><img src="https://i.imgur.com/Nyj4Zlh.png" alt="screenshot"></p>
<p>I want the website title to b... | [
{
"answer_id": 200590,
"author": "RooWM",
"author_id": 18563,
"author_profile": "https://wordpress.stackexchange.com/users/18563",
"pm_score": 0,
"selected": false,
"text": "<p>Are all of those style-sheets included from the parent theme?</p>\n\n<p>If so? Try <code>get_template_directory... | 2015/09/03 | [
"https://wordpress.stackexchange.com/questions/200580",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78824/"
] | I've created a new Wordpress site using the [Realistic theme](http://themient.com/themes/realistic). I added a logo, and this was the resulting webpage (ignore the sidebar):

I want the website title to be displayed next to the logo, for which I'd need to edit the header.... | I decided to work with the creator of the theme, and the problem has been fixed!
I did the following:
1. Remove all code from the child theme's function.php, leaving it empty.
2. Replaced the child theme's style.css with a copy of the parent theme's style.css, and replaced the commented bit with the child theme's com... |
200,586 | <p>I want to put the variable in the shortcode, but it is not working. What i have done wrong.</p>
<pre><code><?php $calendar = getCalendarTag();?>
<?php echo do_shortcode( '[ai1ec tag_name=".$calendar."]"]' ) ?>
</code></pre>
| [
{
"answer_id": 200594,
"author": "gdaniel",
"author_id": 30984,
"author_profile": "https://wordpress.stackexchange.com/users/30984",
"pm_score": 2,
"selected": false,
"text": "<p>Try changing your code to:</p>\n\n<pre><code><?php echo do_shortcode('[ai1ec tag_name=\"' . $calendar . '\... | 2015/09/03 | [
"https://wordpress.stackexchange.com/questions/200586",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78832/"
] | I want to put the variable in the shortcode, but it is not working. What i have done wrong.
```
<?php $calendar = getCalendarTag();?>
<?php echo do_shortcode( '[ai1ec tag_name=".$calendar."]"]' ) ?>
``` | Try changing your code to:
```
<?php echo do_shortcode('[ai1ec tag_name="' . $calendar . '"]'); ?>
``` |
200,622 | <p>Tried to find an or some hook to fire a function when theme is being delited, but didn't find any hook..</p>
<p>May be someone can tell if there's a way to fire my function on themes delete event?</p>
<p>I need it to delete options and drop tables on theme delete. ( for example )</p>
<p>Plugins do have <code>unin... | [
{
"answer_id": 230140,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 0,
"selected": false,
"text": "<p>As long as you don't delete your theme by ftp, but use the regular way of switching to another theme in the admi... | 2015/09/03 | [
"https://wordpress.stackexchange.com/questions/200622",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38034/"
] | Tried to find an or some hook to fire a function when theme is being delited, but didn't find any hook..
May be someone can tell if there's a way to fire my function on themes delete event?
I need it to delete options and drop tables on theme delete. ( for example )
Plugins do have `uninstall.php` or `register_unins... | Since 5.8.0 you can use the `deleted_theme` hook together with the stylesheet name:
```
add_action('deleted_theme', function($stylesheet, $deleted){
// do something
});
```
You will have to run this filter from outside the theme that you are trying to delete. In the OP case since it is for a plugin it should wo... |
201,638 | <p>Based on a few references I've built a function to output a list of custom taxonomy terms separated by comma. The code works as intended, where <code>food_tag</code> is the custom taxonomy I registered for a custom post_type.</p>
<p>Here's the function:</p>
<pre><code>function get_taxonomy_food_tags(){
$terms = g... | [
{
"answer_id": 201652,
"author": "Eduardo Sánchez Hidalgo Urías",
"author_id": 72745,
"author_profile": "https://wordpress.stackexchange.com/users/72745",
"pm_score": 1,
"selected": false,
"text": "<p>The problem is you are giving 0 as a value to $i, every time the foreach loop executes,... | 2015/09/04 | [
"https://wordpress.stackexchange.com/questions/201638",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45893/"
] | Based on a few references I've built a function to output a list of custom taxonomy terms separated by comma. The code works as intended, where `food_tag` is the custom taxonomy I registered for a custom post\_type.
Here's the function:
```
function get_taxonomy_food_tags(){
$terms = get_terms('food_tag');
foreach(... | You have a couple of flaws here:
* **ALWAYS** code in a way with a mindset of that your code **will** fail. This is very important. Most people code with a perfect world mindset. A perfect world will never happen. Always think of what will happen when your code fail.
As example, in your code, `$terms` return an objec... |
201,657 | <p>How can I get all the posts from a specific custom post type with WP REST API (either v1 or v2)? I'm very new to this and trying to understand how to do that.</p>
<p>I am currently using WP REST API v2 and managed to fetch a list of all the post types with this</p>
<pre><code>http://domain.com/wp-json/wp/v2/types
... | [
{
"answer_id": 201658,
"author": "dev",
"author_id": 79859,
"author_profile": "https://wordpress.stackexchange.com/users/79859",
"pm_score": -1,
"selected": false,
"text": "<p>You should use this:-</p>\n\n<pre><code>http://domain.com/wp-json/wp/v2/posts?job-type=your-post-type \n</code><... | 2015/09/04 | [
"https://wordpress.stackexchange.com/questions/201657",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74398/"
] | How can I get all the posts from a specific custom post type with WP REST API (either v1 or v2)? I'm very new to this and trying to understand how to do that.
I am currently using WP REST API v2 and managed to fetch a list of all the post types with this
```
http://domain.com/wp-json/wp/v2/types
```
and then manage... | Just add the next parmater into the function register\_post\_type, it can be before 'menu\_position'parameter. 'show\_in\_rest' => true
[](https://i.stack.imgur.com/fSCOE.png)
if you're using a plugin to register your posttype you can use the next co... |
201,670 | <p>If I scheduled a CPU-intensive job via a cron scheduled event, how do I go about stopping it or cancelling the job while it is currently running?</p>
| [
{
"answer_id": 201690,
"author": "matthew",
"author_id": 52429,
"author_profile": "https://wordpress.stackexchange.com/users/52429",
"pm_score": 2,
"selected": false,
"text": "<p>Removing / un-scheduling obsolete cron jobs can be achieved using this code snippet.</p>\n<pre><code>add_acti... | 2015/09/04 | [
"https://wordpress.stackexchange.com/questions/201670",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17642/"
] | If I scheduled a CPU-intensive job via a cron scheduled event, how do I go about stopping it or cancelling the job while it is currently running? | Removing / un-scheduling obsolete cron jobs can be achieved using this code snippet.
```
add_action("init", "remove_cron_job");
function remove_cron_job() {
wp_clear_scheduled_hook("my_schedule_hook");
}
```
Change the my\_schedule\_hook to cron’s hook name and add the code in your theme’s function.php file. |
201,676 | <p>hi i am new on WordPress can somebody tell me how can i upload multiple images using wp_handle_upload in a loop </p>
<pre><code>for($i=1;$i<count($_FILES['myfile']['name']);$i++){
$uploadedfile = $_FILES['myfile'].$i;
$upload_overrides = array( 'test_form'.$i => false );
$movefile = wp_handle_u... | [
{
"answer_id": 201686,
"author": "dev",
"author_id": 79859,
"author_profile": "https://wordpress.stackexchange.com/users/79859",
"pm_score": 0,
"selected": false,
"text": "<p>Hi here is code I used up in my plugin, hope you understand it and if any problem you can ask me:-</p>\n\n<pre><c... | 2015/09/04 | [
"https://wordpress.stackexchange.com/questions/201676",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/79858/"
] | hi i am new on WordPress can somebody tell me how can i upload multiple images using wp\_handle\_upload in a loop
```
for($i=1;$i<count($_FILES['myfile']['name']);$i++){
$uploadedfile = $_FILES['myfile'].$i;
$upload_overrides = array( 'test_form'.$i => false );
$movefile = wp_handle_upload( $uploadedfi... | here's my example of how to upload multiple images:
```
add_action( 'add_meta_boxes', 'my_test_metabox' );
function my_test_metabox() {
add_meta_box( 'my_test_metabox', 'File upload', 'my_test_metabox_out', 'post' );
}
add_action('post_edit_form_tag', 'update_edit_form' );
function update_edit_form() {
ech... |
201,684 | <p>I am using <a href="http://metabox.io" rel="nofollow">metabox's</a> advance file uploader to upload images.</p>
<pre><code><?php $images = rwmb_meta( 'tj_file_advanced', 'type=image&size=YOURSIZE');
foreach ( $images as $image ) { ?>
<div class="col-md-4">
<div class=... | [
{
"answer_id": 201687,
"author": "Maikal",
"author_id": 38034,
"author_profile": "https://wordpress.stackexchange.com/users/38034",
"pm_score": 0,
"selected": false,
"text": "<p>ok. so your <code>loadMore()</code> should do something like these:</p>\n\n<pre><code>function loadMore() {\n ... | 2015/09/04 | [
"https://wordpress.stackexchange.com/questions/201684",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75729/"
] | I am using [metabox's](http://metabox.io) advance file uploader to upload images.
```
<?php $images = rwmb_meta( 'tj_file_advanced', 'type=image&size=YOURSIZE');
foreach ( $images as $image ) { ?>
<div class="col-md-4">
<div class="boxe">
<?php echo "<img src='{$image['full_u... | It can be done just following regular way to use Ajax in WordPress.
<https://codex.wordpress.org/AJAX_in_Plugins>
First register a script file and also create an AJAX Call.
```
wp_enqueue_script( 'meta-ajaxscript', get_stylesheet_directory_uri() . '/js/ajax-init.js', array( 'jquery' ), '', true );
wp_localize_scrip... |
201,699 | <p>I recently noticed after performance errors and failure that the memory that a single request was consuming (either front or back) was increased rapidly. After hours of experiments and research I noticed that the option_value record of the "cron" row was 7MB!!!! containing a huge json with a loop of "reschedule" act... | [
{
"answer_id": 201740,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>You might be suffering from a bug introduced with WordPress 4.3, involving term splitting.</p>\n\n<p>There's... | 2015/09/04 | [
"https://wordpress.stackexchange.com/questions/201699",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78616/"
] | I recently noticed after performance errors and failure that the memory that a single request was consuming (either front or back) was increased rapidly. After hours of experiments and research I noticed that the option\_value record of the "cron" row was 7MB!!!! containing a huge json with a loop of "reschedule" actio... | This could be caused by many different things, as well as a result of a broken cron setup, where actions are being scheduled, but never run.
The best way forward is to try and understand what is actually being scheduled or rescheduled, what are the action names? If you can find the action names, you'll be able to pinp... |
201,709 | <p><strong>EDIT : I answered myself.</strong></p>
<p>Simple request for you. I am trying to develop a code that search for post for TODAY. If it returns nothing, then get the latest post before today.</p>
<p>For now, I have made a small algorithm to expose your my question.</p>
<pre><code><?php
// WP... | [
{
"answer_id": 201740,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>You might be suffering from a bug introduced with WordPress 4.3, involving term splitting.</p>\n\n<p>There's... | 2015/09/04 | [
"https://wordpress.stackexchange.com/questions/201709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32365/"
] | **EDIT : I answered myself.**
Simple request for you. I am trying to develop a code that search for post for TODAY. If it returns nothing, then get the latest post before today.
For now, I have made a small algorithm to expose your my question.
```
<?php
// WP_Query arguments
$args = array (... | This could be caused by many different things, as well as a result of a broken cron setup, where actions are being scheduled, but never run.
The best way forward is to try and understand what is actually being scheduled or rescheduled, what are the action names? If you can find the action names, you'll be able to pinp... |
201,715 | <p>I've made a woocommerce store and I am using a dropshipper - so every product has an price and a trade price for me - which I am importing and storing as a custom field 'trade_price' on the product.</p>
<p>I wanted to know if it would be possible to include some php on my single product template which would show me... | [
{
"answer_id": 201740,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>You might be suffering from a bug introduced with WordPress 4.3, involving term splitting.</p>\n\n<p>There's... | 2015/09/04 | [
"https://wordpress.stackexchange.com/questions/201715",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51830/"
] | I've made a woocommerce store and I am using a dropshipper - so every product has an price and a trade price for me - which I am importing and storing as a custom field 'trade\_price' on the product.
I wanted to know if it would be possible to include some php on my single product template which would show me 1) profi... | This could be caused by many different things, as well as a result of a broken cron setup, where actions are being scheduled, but never run.
The best way forward is to try and understand what is actually being scheduled or rescheduled, what are the action names? If you can find the action names, you'll be able to pinp... |
201,722 | <p>Is there a way to count and show the count of all author posts in a custom post type except the current logged in user? </p>
<p>I was hoping there's a way to do it with <code>count_many_users_posts</code> but it doesn't appear there is a way to exclude authors, only include them.</p>
<p>I've done multiple searches... | [
{
"answer_id": 201724,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>Inclusion and exclusion are often reversible. \"Not this\" (exclusive) is equal to \"All of that, skipping this\" (... | 2015/09/04 | [
"https://wordpress.stackexchange.com/questions/201722",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7662/"
] | Is there a way to count and show the count of all author posts in a custom post type except the current logged in user?
I was hoping there's a way to do it with `count_many_users_posts` but it doesn't appear there is a way to exclude authors, only include them.
I've done multiple searches but have found nothing to e... | I don't know why this works, but it does.
```
$authorid = get_current_user_id();
query_posts(array(
'post_type' => 'tasks',
'author' => -$authorid,
) );
$count = 0;
while (have_posts()) : the_post();
$count++;
endwh... |
201,728 | <p>We are experiencing very slow performance with queries that use <code>SQL_CALC_FOUND_ROWS</code> within the admin section of WordPress.</p>
<p>We currently have about 125,000 posts on our site and use Varnish to cache the front-end and are on WordPress version 4.2.3.</p>
<p>The problem arises when there are people... | [
{
"answer_id": 257665,
"author": "Younes Nesta",
"author_id": 114028,
"author_profile": "https://wordpress.stackexchange.com/users/114028",
"pm_score": -1,
"selected": false,
"text": "<p>$query->set('no_found_rows', true);</p>\n"
},
{
"answer_id": 271031,
"author": "Anastis",... | 2015/09/04 | [
"https://wordpress.stackexchange.com/questions/201728",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57849/"
] | We are experiencing very slow performance with queries that use `SQL_CALC_FOUND_ROWS` within the admin section of WordPress.
We currently have about 125,000 posts on our site and use Varnish to cache the front-end and are on WordPress version 4.2.3.
The problem arises when there are people using the admin section of ... | The use of `SQL_CALC_FOUND_ROWS` is not really a problem, although it incurs an overhead.
What happens is, WordPress uses `SQL_CALC_FOUND_ROWS` in order to determine the total posts that would have been returned, if no `LIMIT` clause was provided. This is necessary in order to calculate and provide you with correct pa... |
201,729 | <p>I added an extra registration field:</p>
<pre><code>function wooc_extra_register_fields() {
?><p class="form-row form-row-first">
<label for="billing_cpf"><?php _e( 'CPF', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" cla... | [
{
"answer_id": 257665,
"author": "Younes Nesta",
"author_id": 114028,
"author_profile": "https://wordpress.stackexchange.com/users/114028",
"pm_score": -1,
"selected": false,
"text": "<p>$query->set('no_found_rows', true);</p>\n"
},
{
"answer_id": 271031,
"author": "Anastis",... | 2015/09/04 | [
"https://wordpress.stackexchange.com/questions/201729",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/79900/"
] | I added an extra registration field:
```
function wooc_extra_register_fields() {
?><p class="form-row form-row-first">
<label for="billing_cpf"><?php _e( 'CPF', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="billing_cpf" id="billing_cpf" valu... | The use of `SQL_CALC_FOUND_ROWS` is not really a problem, although it incurs an overhead.
What happens is, WordPress uses `SQL_CALC_FOUND_ROWS` in order to determine the total posts that would have been returned, if no `LIMIT` clause was provided. This is necessary in order to calculate and provide you with correct pa... |
201,745 | <p>I have wordpress installed on my root (<code>/var/www/html</code>) and I have a sub-directory in the root as <code>/var/www/html/manage</code> Both directories have it's own <code>.htaccess</code> files. Content of the <code>.htaccess</code> are as follows.</p>
<h2>/var/www/html/.htaccess (root)</h2>
<pre><code># ... | [
{
"answer_id": 257665,
"author": "Younes Nesta",
"author_id": 114028,
"author_profile": "https://wordpress.stackexchange.com/users/114028",
"pm_score": -1,
"selected": false,
"text": "<p>$query->set('no_found_rows', true);</p>\n"
},
{
"answer_id": 271031,
"author": "Anastis",... | 2015/09/05 | [
"https://wordpress.stackexchange.com/questions/201745",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/79907/"
] | I have wordpress installed on my root (`/var/www/html`) and I have a sub-directory in the root as `/var/www/html/manage` Both directories have it's own `.htaccess` files. Content of the `.htaccess` are as follows.
/var/www/html/.htaccess (root)
------------------------------
```
# BEGIN WordPress
<IfModule mod_rewri... | The use of `SQL_CALC_FOUND_ROWS` is not really a problem, although it incurs an overhead.
What happens is, WordPress uses `SQL_CALC_FOUND_ROWS` in order to determine the total posts that would have been returned, if no `LIMIT` clause was provided. This is necessary in order to calculate and provide you with correct pa... |
201,756 | <p>On the multisite main page (<a href="http://example.com/" rel="nofollow">http://example.com/</a>) I have a login-form where users can login to their multisite like so:</p>
<pre><code><?php
$args = array(
'redirect' => get_active_blog_for_user(),
);
wp_login_form( $args );
?>
</code></pre>
<p>After lo... | [
{
"answer_id": 202493,
"author": "Johan Ndiyo Linnarsson",
"author_id": 64332,
"author_profile": "https://wordpress.stackexchange.com/users/64332",
"pm_score": 2,
"selected": true,
"text": "<p>I solved this and I only use:</p>\n\n<pre><code>wp_login_form();\n</code></pre>\n\n<p>Since I d... | 2015/09/05 | [
"https://wordpress.stackexchange.com/questions/201756",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64332/"
] | On the multisite main page (<http://example.com/>) I have a login-form where users can login to their multisite like so:
```
<?php
$args = array(
'redirect' => get_active_blog_for_user(),
);
wp_login_form( $args );
?>
```
After logging in they will be redirected to their dashboard (http:// example.com/userblog/... | I solved this and I only use:
```
wp_login_form();
```
Since I don't want users to get access to the wp-admin area at all I use the following code:
```
// Restrict users from accessing the admin-area
function restrict_admin()
{
if ( ! current_user_can( 'manage_sites' ) ) {
wp_redirect( site_url() );
... |
201,772 | <p>I used a theme that had a great function for popup windows - a pop could be created by adding "#iframe" to any urllink ie</p>
<pre><code><a href="http://yahoo.com#iframe">click for popup</a>
</code></pre>
<p>Is there a function I can add to achieve this in any theme?</p>
<p>Second - is there an easy ... | [
{
"answer_id": 202493,
"author": "Johan Ndiyo Linnarsson",
"author_id": 64332,
"author_profile": "https://wordpress.stackexchange.com/users/64332",
"pm_score": 2,
"selected": true,
"text": "<p>I solved this and I only use:</p>\n\n<pre><code>wp_login_form();\n</code></pre>\n\n<p>Since I d... | 2015/09/05 | [
"https://wordpress.stackexchange.com/questions/201772",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66990/"
] | I used a theme that had a great function for popup windows - a pop could be created by adding "#iframe" to any urllink ie
```
<a href="http://yahoo.com#iframe">click for popup</a>
```
Is there a function I can add to achieve this in any theme?
Second - is there an easy way to do popups containing html instead of a ... | I solved this and I only use:
```
wp_login_form();
```
Since I don't want users to get access to the wp-admin area at all I use the following code:
```
// Restrict users from accessing the admin-area
function restrict_admin()
{
if ( ! current_user_can( 'manage_sites' ) ) {
wp_redirect( site_url() );
... |
201,786 | <p>I need to add a php code in a wordpress widget called PHP Code Widget which only asks for proper enclosing:</p>
<p>All PHP code must be enclosed in the standard php opening and closing tags ( <code><?php</code> and <code>?></code> ) for it to be recognized and executed.</p>
<p>The code must use the current p... | [
{
"answer_id": 202493,
"author": "Johan Ndiyo Linnarsson",
"author_id": 64332,
"author_profile": "https://wordpress.stackexchange.com/users/64332",
"pm_score": 2,
"selected": true,
"text": "<p>I solved this and I only use:</p>\n\n<pre><code>wp_login_form();\n</code></pre>\n\n<p>Since I d... | 2015/09/05 | [
"https://wordpress.stackexchange.com/questions/201786",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/79929/"
] | I need to add a php code in a wordpress widget called PHP Code Widget which only asks for proper enclosing:
All PHP code must be enclosed in the standard php opening and closing tags ( `<?php` and `?>` ) for it to be recognized and executed.
The code must use the current page title slug (i will use PAGES not posts) t... | I solved this and I only use:
```
wp_login_form();
```
Since I don't want users to get access to the wp-admin area at all I use the following code:
```
// Restrict users from accessing the admin-area
function restrict_admin()
{
if ( ! current_user_can( 'manage_sites' ) ) {
wp_redirect( site_url() );
... |
201,791 | <p>I am trying to learn WP Theme development. And I am wondering what's the proper way to load api's? For example Google Maps:</p>
<p><code><script src="http://maps.googleapis.com/maps/api/js"></script></code></p>
<p>Should I enqueue the API url, or how should I do? I am a bit confused since this api for ... | [
{
"answer_id": 202493,
"author": "Johan Ndiyo Linnarsson",
"author_id": 64332,
"author_profile": "https://wordpress.stackexchange.com/users/64332",
"pm_score": 2,
"selected": true,
"text": "<p>I solved this and I only use:</p>\n\n<pre><code>wp_login_form();\n</code></pre>\n\n<p>Since I d... | 2015/09/05 | [
"https://wordpress.stackexchange.com/questions/201791",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66256/"
] | I am trying to learn WP Theme development. And I am wondering what's the proper way to load api's? For example Google Maps:
`<script src="http://maps.googleapis.com/maps/api/js"></script>`
Should I enqueue the API url, or how should I do? I am a bit confused since this api for example reffers to a /js folder and not ... | I solved this and I only use:
```
wp_login_form();
```
Since I don't want users to get access to the wp-admin area at all I use the following code:
```
// Restrict users from accessing the admin-area
function restrict_admin()
{
if ( ! current_user_can( 'manage_sites' ) ) {
wp_redirect( site_url() );
... |
201,793 | <p>I need to get the post author profile picture link.</p>
<p>I know I can use <code>get_avatar();</code> but it displays whole image markup</p>
<pre><code><img src="http://.../img.png" class="avatar img-responsive" alt="image">
</code></pre>
<p>But need only the <code>src</code> of the author profile pic.</p>... | [
{
"answer_id": 201799,
"author": "Jentan Bernardus",
"author_id": 34502,
"author_profile": "https://wordpress.stackexchange.com/users/34502",
"pm_score": 0,
"selected": false,
"text": "<p>Beside using <code>get_avatar_url</code>, you can still use <code>get_avatar</code>. If I'm not wron... | 2015/09/05 | [
"https://wordpress.stackexchange.com/questions/201793",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65568/"
] | I need to get the post author profile picture link.
I know I can use `get_avatar();` but it displays whole image markup
```
<img src="http://.../img.png" class="avatar img-responsive" alt="image">
```
But need only the `src` of the author profile pic.
How can I got that ? Maybe we can use some `php` or `js` to tak... | Putting the following inside loop should fulfill your needs:
```
<?php
$get_author_id = get_the_author_meta('ID');
$get_author_gravatar = get_avatar_url($get_author_id, array('size' => 450));
if(has_post_thumbnail()){
the_post_thumbnail();
} else {
echo '<img src="'.$get_author_gravatar.'" alt="'.get_the_titl... |
201,814 | <p>I would like to change jetpack default blank.jpg atribute on og:image.
I readed some artcile in this subject, but not realy helped me.
Here some trys:</p>
<pre><code>/**
* Override the default OpenGraph tags
*/
add_filter( 'jetpack_open_graph_tags', function( $tags ) {
$tags['twitter:site'] = '@ourhandle';
... | [
{
"answer_id": 201825,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 1,
"selected": false,
"text": "<p>You made that <em>way</em> more complicated than it needs to be.</p>\n\n<pre><code>add_filter( 'jetpack_open_graph... | 2015/09/06 | [
"https://wordpress.stackexchange.com/questions/201814",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/79944/"
] | I would like to change jetpack default blank.jpg atribute on og:image.
I readed some artcile in this subject, but not realy helped me.
Here some trys:
```
/**
* Override the default OpenGraph tags
*/
add_filter( 'jetpack_open_graph_tags', function( $tags ) {
$tags['twitter:site'] = '@ourhandle';
$tags['twitt... | You made that *way* more complicated than it needs to be.
```
add_filter( 'jetpack_open_graph_image_default', 'example_change_default_image' );
function example_change_default_image( $image ) {
return 'https://s0.wp.com/i/blank.jpg';
}
```
Just edit the function to return whatever URL you want. |
201,815 | <p>I'm trying to add a <a href="https://trinket.io/" rel="nofollow">trinket.io</a> widget to my blog post in order to do some interactive things but I'm not having any success.</p>
<p>If i try to just use the embed code given to me by the trinket.io page:</p>
<pre><code><iframe src="https://trinket.io/embed/python... | [
{
"answer_id": 201825,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 1,
"selected": false,
"text": "<p>You made that <em>way</em> more complicated than it needs to be.</p>\n\n<pre><code>add_filter( 'jetpack_open_graph... | 2015/09/06 | [
"https://wordpress.stackexchange.com/questions/201815",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/79946/"
] | I'm trying to add a [trinket.io](https://trinket.io/) widget to my blog post in order to do some interactive things but I'm not having any success.
If i try to just use the embed code given to me by the trinket.io page:
```
<iframe src="https://trinket.io/embed/python/73f4d9630f" width="100%"
height="356" frameborde... | You made that *way* more complicated than it needs to be.
```
add_filter( 'jetpack_open_graph_image_default', 'example_change_default_image' );
function example_change_default_image( $image ) {
return 'https://s0.wp.com/i/blank.jpg';
}
```
Just edit the function to return whatever URL you want. |
201,824 | <p>I trying to understand what is happening with the Wordpress theme that I am using. The menu is found on the right hand side of the page and when the window size is made smaller it changes to a single drop down from the middle (for smaller devices). On inspection I can see that there are various classes that seem to ... | [
{
"answer_id": 201827,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>This is called responsive design and has nothing to do with Wordpress, it is an extension rule to media ... | 2015/09/06 | [
"https://wordpress.stackexchange.com/questions/201824",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38223/"
] | I trying to understand what is happening with the Wordpress theme that I am using. The menu is found on the right hand side of the page and when the window size is made smaller it changes to a single drop down from the middle (for smaller devices). On inspection I can see that there are various classes that seem to han... | This is called responsive design and has nothing to do with Wordpress, it is an extension rule to media queries (*`@media`*) in CSS3. CSS is a browser/client side language which can determine window sizes and browser types, this is what is used to determine how a website should look at a specific window size or browser... |
201,844 | <p>i try show the_date with link to same date!</p>
<pre><code> <?php the_date('l j F Y', '<tr>
<th colspan="3"><a href="<?php the_date('Y/m/d'); ?>" rel="bookmark">', '</th>
</tr>'); ?>
</code></pre>
| [
{
"answer_id": 201847,
"author": "Erfo",
"author_id": 41537,
"author_profile": "https://wordpress.stackexchange.com/users/41537",
"pm_score": 2,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code><?php \n$archive_year = get_the_time('Y'); \n$archive_month = get_the_time('m');... | 2015/09/06 | [
"https://wordpress.stackexchange.com/questions/201844",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78599/"
] | i try show the\_date with link to same date!
```
<?php the_date('l j F Y', '<tr>
<th colspan="3"><a href="<?php the_date('Y/m/d'); ?>" rel="bookmark">', '</th>
</tr>'); ?>
``` | Try this:
```
<?php
$archive_year = get_the_time('Y');
$archive_month = get_the_time('m');
$archive_day = get_the_time('d');
?>
<a href="<?php echo get_day_link( $archive_year, $archive_month, $archive_day); ?>"><?php the_date('Y/m/d'); ?></a>
```
HTML result:
```
<a href="http://example.com/2015/09/07">2015... |
201,849 | <p>I'm using the MyStile theme for a new site. I'm trying to create a child theme so I can modify the theme and not have my changes overwritten, however once I activate my child theme, the whole styling seems to go from the website all together.<br>
I'm guessing the issue here lies somewhere when it's calling the paren... | [
{
"answer_id": 201850,
"author": "d79",
"author_id": 69071,
"author_profile": "https://wordpress.stackexchange.com/users/69071",
"pm_score": 4,
"selected": true,
"text": "<p>Take a look at <a href=\"https://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme\" rel=\"noreferrer\"... | 2015/09/06 | [
"https://wordpress.stackexchange.com/questions/201849",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77340/"
] | I'm using the MyStile theme for a new site. I'm trying to create a child theme so I can modify the theme and not have my changes overwritten, however once I activate my child theme, the whole styling seems to go from the website all together.
I'm guessing the issue here lies somewhere when it's calling the parent *s... | Take a look at [How to create a Child Theme](https://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme) and you'll see that:
>
> the previous method to enqueue the parent stylesheet was to import the parent theme stylesheet using @import: this is no longer best practice. The correct method of enqueuing the... |
201,871 | <p>On a project I require to keep only 10 latest posts on website and auto delete all other posts. So I came up with this function which triggers on post publish/update and I used <code>offset</code> parameter to exclude latest 10 items.</p>
<pre><code>function wpse_auto_delete_posts( $post_ID ) {
global $post;
$... | [
{
"answer_id": 201882,
"author": "Ignat B.",
"author_id": 38121,
"author_profile": "https://wordpress.stackexchange.com/users/38121",
"pm_score": 0,
"selected": false,
"text": "<p>The fact that <code>'nopaging' => true</code> and <code>'posts_per_page' => -1</code> behaves the same... | 2015/09/07 | [
"https://wordpress.stackexchange.com/questions/201871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22461/"
] | On a project I require to keep only 10 latest posts on website and auto delete all other posts. So I came up with this function which triggers on post publish/update and I used `offset` parameter to exclude latest 10 items.
```
function wpse_auto_delete_posts( $post_ID ) {
global $post;
$delete_posts = get_posts(... | The `offset` parameter is ignored with `posts_per_page` set to `-1` in `WP_Query`. If you look at the source code in the `WP_Query` class, `posts_per_page=-1` sets `nopaging` to true.
```
if ( !isset($q['nopaging']) ) {
if ( $q['posts_per_page'] == -1 ) {
$q['nopaging'] = true;
} else {
$q['nop... |
201,877 | <p>I want my POST pagination to show the numbers from 1 to 9 like this:
01 02 03 04 05 06 07 08 09 10 11... and NOT like > 1, 2, 3, 4...</p>
<p>Actualy i have this code:</p>
<pre><code><?php wp_link_pages( array( 'before' => '
<div class="page-links clr">', 'after' => '</div>
', 'link_before' =&... | [
{
"answer_id": 201894,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": true,
"text": "<p><a href=\"https://codex.wordpress.org/Function_Reference/wp_link_pages\" rel=\"nofollow\"><code>wp_l... | 2015/09/07 | [
"https://wordpress.stackexchange.com/questions/201877",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/79974/"
] | I want my POST pagination to show the numbers from 1 to 9 like this:
01 02 03 04 05 06 07 08 09 10 11... and NOT like > 1, 2, 3, 4...
Actualy i have this code:
```
<?php wp_link_pages( array( 'before' => '
<div class="page-links clr">', 'after' => '</div>
', 'link_before' => '<span>', 'link_after' => '</span>' ) );?... | [`wp_link_pages()`](https://codex.wordpress.org/Function_Reference/wp_link_pages) does not have a parameter for what you want. So I'm thinking you can make use of the filter hook [`wp_link_pages_link`](https://developer.wordpress.org/reference/hooks/wp_link_pages_link/), which has two - `$link` and `$i` - parameters, w... |
201,888 | <p>This is what happens in a Wordpress (Woocommerce) site I've been asked to investigate.</p>
<p>1) I make a modification to .htaccess and save it.</p>
<p>Here's output of the ls -command</p>
<pre><code>% ls -l
ll
-r--r--r-- 1 user group 248 Sep 7 11:31 .htaccess
</code></pre>
<p>2) Just a moment later</p>
<pr... | [
{
"answer_id": 201894,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": true,
"text": "<p><a href=\"https://codex.wordpress.org/Function_Reference/wp_link_pages\" rel=\"nofollow\"><code>wp_l... | 2015/09/07 | [
"https://wordpress.stackexchange.com/questions/201888",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/79979/"
] | This is what happens in a Wordpress (Woocommerce) site I've been asked to investigate.
1) I make a modification to .htaccess and save it.
Here's output of the ls -command
```
% ls -l
ll
-r--r--r-- 1 user group 248 Sep 7 11:31 .htaccess
```
2) Just a moment later
```
% ls -l
-r--r--r-- 1 user group 235 Jul ... | [`wp_link_pages()`](https://codex.wordpress.org/Function_Reference/wp_link_pages) does not have a parameter for what you want. So I'm thinking you can make use of the filter hook [`wp_link_pages_link`](https://developer.wordpress.org/reference/hooks/wp_link_pages_link/), which has two - `$link` and `$i` - parameters, w... |
201,922 | <p>I've been using this code:</p>
<pre><code>function remove_first_image ($content) {
if (!is_page() && !is_feed() && !is_feed()) {
$content = preg_replace("/<img[^>]+\>/i", "", $content, 1);
} return $content;
}
add_filter('the_content', 'remove_first_image');
</code></pre>
<p>for a few year... | [
{
"answer_id": 202082,
"author": "totels",
"author_id": 23446,
"author_profile": "https://wordpress.stackexchange.com/users/23446",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know of any plugin specifically for this, there's nothing in WP that will do this but it's not too dif... | 2015/09/07 | [
"https://wordpress.stackexchange.com/questions/201922",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80001/"
] | I've been using this code:
```
function remove_first_image ($content) {
if (!is_page() && !is_feed() && !is_feed()) {
$content = preg_replace("/<img[^>]+\>/i", "", $content, 1);
} return $content;
}
add_filter('the_content', 'remove_first_image');
```
for a few years now on my site that has almost 20,000 posts with ... | I don't know of any plugin specifically for this, there's nothing in WP that will do this but it's not too difficult to implement with a little php, even 20k posts shouldn't be too extreme. Depending on your server settings you may need to do some workarounds to make sure the connection stays alive but the basic idea w... |
201,963 | <p>I have a form that I created using a plugin which upon clicking the Submit button, it's redirecting to a URL that I selected in the form's settings. But the problem is that any other form that I create, it gets directed to the same URL that I selected on my original form. I need to trace the Submit action to see w... | [
{
"answer_id": 201984,
"author": "dev",
"author_id": 79859,
"author_profile": "https://wordpress.stackexchange.com/users/79859",
"pm_score": 1,
"selected": false,
"text": "<p>yes you can use jquery, like</p>\n\n<pre><code>$('form').attr('action');\n</code></pre>\n"
},
{
"answer_i... | 2015/09/07 | [
"https://wordpress.stackexchange.com/questions/201963",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58774/"
] | I have a form that I created using a plugin which upon clicking the Submit button, it's redirecting to a URL that I selected in the form's settings. But the problem is that any other form that I create, it gets directed to the same URL that I selected on my original form. I need to trace the Submit action to see where ... | Still using jQuery, you can do this:
```
$('form').submit(function() {
// Use this to echo in JS console.
console.log( $(this).attr('action') );
// Use this to display a popup.
alert( $(this).attr('action') );
});
```
This will track **every** form being submitted.
Place this between `<script>` tags... |
201,968 | <p>My question is: Is it ok, or even preferable, to use html instead of php when possible? </p>
<p>Why I ask:
Wordpress seems to use php even for simple tasks, where old good html would do the job. Php code is <strong>not</strong> famous for its simplicity or readability. Besides this, I guess that all the unnecessary... | [
{
"answer_id": 201969,
"author": "Maikal",
"author_id": 38034,
"author_profile": "https://wordpress.stackexchange.com/users/38034",
"pm_score": -1,
"selected": false,
"text": "<p>Well.. it is faster to use strict html, becouse server takes some time to make php functions/actions/code.. b... | 2015/09/07 | [
"https://wordpress.stackexchange.com/questions/201968",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80031/"
] | My question is: Is it ok, or even preferable, to use html instead of php when possible?
Why I ask:
Wordpress seems to use php even for simple tasks, where old good html would do the job. Php code is **not** famous for its simplicity or readability. Besides this, I guess that all the unnecessary database requests make... | Quite strange that the core developers would decide to make an URL translatable, it is actually a case here of over-doing something. But anyways, lets get to the main question
PHP vs HTML
-----------
Although there are many reasons I can think of why one would prefer PHP above HTML, and that goes for the core develop... |
201,976 | <p>I am trying to get a list of a custom post type's IDs using WP_Query, but it is returning undesired result, which is a memory leak and stuck browser.</p>
<p>Here is the code I use:</p>
<pre><code> $the_query = new WP_Query("post_type=post&posts_per_page=-1&field=ids");
if ($the_query->have_po... | [
{
"answer_id": 201978,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>You are missing the <code>the_post()</code> function call in the loop. Just add</p>\n\n<pre><code>$the_q... | 2015/09/08 | [
"https://wordpress.stackexchange.com/questions/201976",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32989/"
] | I am trying to get a list of a custom post type's IDs using WP\_Query, but it is returning undesired result, which is a memory leak and stuck browser.
Here is the code I use:
```
$the_query = new WP_Query("post_type=post&posts_per_page=-1&field=ids");
if ($the_query->have_posts()) {
while ($the_quer... | You are missing the `the_post()` function call in the loop. Just add
```
$the_query->the_post();
```
in your loop. Apart from that, your loop should work
EDIT
----
You should also not forget to reset your postdata after the query is done |
201,977 | <p>I have a shortcode that (among other things) echoes out a menu using <code>wp_nav_menu</code> like so</p>
<pre><code>if ( ! function_exists( 'foundationPress_main_nav' ) ) {
function foundationPress_main_nav() {
wp_nav_menu(array(
'container' => false, // remove... | [
{
"answer_id": 248806,
"author": "FellowTraveler",
"author_id": 108673,
"author_profile": "https://wordpress.stackexchange.com/users/108673",
"pm_score": 2,
"selected": false,
"text": "<p><code>'echo' => true</code> needs to be <code>'echo' => false</code> in your <code>wp_nav_menu... | 2015/09/08 | [
"https://wordpress.stackexchange.com/questions/201977",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18228/"
] | I have a shortcode that (among other things) echoes out a menu using `wp_nav_menu` like so
```
if ( ! function_exists( 'foundationPress_main_nav' ) ) {
function foundationPress_main_nav() {
wp_nav_menu(array(
'container' => false, // remove nav container
'... | `'echo' => true` needs to be `'echo' => false` in your `wp_nav_menu` array for it to nest. From the [docs](https://developer.wordpress.org/reference/functions/wp_nav_menu/) you'll find
>
> 'echo' (bool) Whether to echo the menu or return it. Default true.
>
>
>
so what's happening is the wp\_nav\_menu isn't being... |
202,009 | <p>Im trying to figure out how can I change names to cookies that wordpress is setting for example on login.</p>
<pre><code>wordpress_test_cookie = sitename_test_cookie
</code></pre>
<p>or/ and</p>
<pre><code> wordpress_logged_in = sitename_test_cookie
</code></pre>
| [
{
"answer_id": 202019,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": false,
"text": "<p>Check out the <a href=\"https://developer.wordpress.org/reference/functions/wp_cookie_constants/\" rel=\"nore... | 2015/09/08 | [
"https://wordpress.stackexchange.com/questions/202009",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80053/"
] | Im trying to figure out how can I change names to cookies that wordpress is setting for example on login.
```
wordpress_test_cookie = sitename_test_cookie
```
or/ and
```
wordpress_logged_in = sitename_test_cookie
``` | Check out the [`wp_cookie_constants()`](https://developer.wordpress.org/reference/functions/wp_cookie_constants/) and [`ms_cookie_constants()`](https://developer.wordpress.org/reference/functions/ms_cookie_constants/) functions, to see available cookies.
We can try this in the `wp-config.php` file:
```
// Here we jus... |
202,021 | <p>There are multiple users who have to post their own post on respective post types (like news, reports etc) with feature image upload, extra file (pdf, txt, excel) upload button from the front end which is approve by the admin from backend.</p>
<p>I have solve for feature image but hanging my mind for file upload fr... | [
{
"answer_id": 202056,
"author": "grlwondr",
"author_id": 78669,
"author_profile": "https://wordpress.stackexchange.com/users/78669",
"pm_score": 0,
"selected": false,
"text": "<p>Would this plugin possibly provide what you need? <a href=\"https://wordpress.org/plugins/frontend-uploader/... | 2015/09/08 | [
"https://wordpress.stackexchange.com/questions/202021",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65450/"
] | There are multiple users who have to post their own post on respective post types (like news, reports etc) with feature image upload, extra file (pdf, txt, excel) upload button from the front end which is approve by the admin from backend.
I have solve for feature image but hanging my mind for file upload from front e... | Use [`wp_handle_upload`](https://codex.wordpress.org/Function_Reference/wp_handle_upload) in a custom function
```
if ( $_FILES ) {
upload_user_file($_FILES['test_upload']);
}
if ( ! function_exists( 'upload_user_file' ) ) :
function upload_user_file( $file = array(), $title = false ) {
require_once ABSP... |
202,022 | <p>Im looking for a way to add a custom class to the add-to-cart button on the single-product.php page in Woocommerce. I have tried the following without any result:</p>
<ol>
<li>Copy whole woocommerce-folder from the folder "plugins" to "themes/MY-THEME/woocommerce".</li>
<li>Modifying the file "add-to-cart.php" in "... | [
{
"answer_id": 202055,
"author": "grlwondr",
"author_id": 78669,
"author_profile": "https://wordpress.stackexchange.com/users/78669",
"pm_score": 0,
"selected": false,
"text": "<p>Are you using a child theme? If not, I would suggest that. Then you can custom style the button in the child... | 2015/09/08 | [
"https://wordpress.stackexchange.com/questions/202022",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40381/"
] | Im looking for a way to add a custom class to the add-to-cart button on the single-product.php page in Woocommerce. I have tried the following without any result:
1. Copy whole woocommerce-folder from the folder "plugins" to "themes/MY-THEME/woocommerce".
2. Modifying the file "add-to-cart.php" in "themes/MY-THEME/woo... | As explained in [their documentation](http://docs.woothemes.com/document/template-structure/) WooCommerce provides a templating structure. Copying WC in your theme won't get you anywhere.
1. Create a `woocommerce` folder in your theme.
2. Copy any template inside the `templates` folder of WC inside your `woocommerce`... |
202,076 | <p>I'm using the <a href="https://wordpress.org/plugins/redirection/" rel="noreferrer">Redirection plugin</a>. It enables a 'Redirection' submenu under "Tools" menu in Admin panel. As an Administrator I can access the plugin. But I want to avail it for my 'editor' accounts too.</p>
<p>I've searched a lot, but found so... | [
{
"answer_id": 202077,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 5,
"selected": true,
"text": "<h1>Update 2020</h1>\n<p>The original answer was of 2015, and the author has no affiliation with the plugi... | 2015/09/08 | [
"https://wordpress.stackexchange.com/questions/202076",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | I'm using the [Redirection plugin](https://wordpress.org/plugins/redirection/). It enables a 'Redirection' submenu under "Tools" menu in Admin panel. As an Administrator I can access the plugin. But I want to avail it for my 'editor' accounts too.
I've searched a lot, but found solution like [this](http://develop.seri... | Update 2020
===========
The original answer was of 2015, and the author has no affiliation with the plugin, so not aware of any changes to the plugin at all. You are requested to follow any updated helpful answer that might help you on this issue.
Original Answer
===============
Good news is, from version 2.3.7 of R... |
202,083 | <p>I'd like to replace all <code>{POST_NAME}</code> 's from my text-widgets on <code>single.php</code> sidebar. I'm thinking of something like this</p>
<pre><code>global $post;
$POST_NAME= $post->post_name;
$sidebar = preg_replace('/\{(POST_NAME)\}/e', "$$1", $sidebar);
</code></pre>
<p>How can I get sidebar HTML ... | [
{
"answer_id": 202089,
"author": "totels",
"author_id": 23446,
"author_profile": "https://wordpress.stackexchange.com/users/23446",
"pm_score": 2,
"selected": false,
"text": "<p>I don't think there's a particularly good way to do this universally. You can use the <a href=\"https://develo... | 2015/09/08 | [
"https://wordpress.stackexchange.com/questions/202083",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78799/"
] | I'd like to replace all `{POST_NAME}` 's from my text-widgets on `single.php` sidebar. I'm thinking of something like this
```
global $post;
$POST_NAME= $post->post_name;
$sidebar = preg_replace('/\{(POST_NAME)\}/e', "$$1", $sidebar);
```
How can I get sidebar HTML into `\$sidebar` | Your code looks well and considerations are correct. In order to achieve your goal, I'd collect HTML and wrap it up like this:
Instead of calling `<?php dynamic_sidebar($sidebar_id); ?>` use `<?php dynamic_sidebar_replaced($sidebar_id); ?>` with a function (add it to functions.php) below:
```
function dynamic_sidebar... |
202,097 | <p><strong>{This question is marked as duplicate but i think my question and answer to it is much simpler then the original one}</strong></p>
<p>Hi i have this following code that is showing before the widget title. For what i understand from my research is that i have to use return, but its not working. Please help.<... | [
{
"answer_id": 202098,
"author": "Jorge Y. C. Rodriguez",
"author_id": 35073,
"author_profile": "https://wordpress.stackexchange.com/users/35073",
"pm_score": 0,
"selected": false,
"text": "<p>shortcut should return a value, if you echo it, this will place it before anything else. try th... | 2015/09/08 | [
"https://wordpress.stackexchange.com/questions/202097",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78475/"
] | **{This question is marked as duplicate but i think my question and answer to it is much simpler then the original one}**
Hi i have this following code that is showing before the widget title. For what i understand from my research is that i have to use return, but its not working. Please help.
```
<?php ... | Some of the calls in your function will echo rather than return.
Instead of [the\_author\_meta](https://codex.wordpress.org/Function_Reference/the_author_meta), use [get\_the\_author\_meta](https://codex.wordpress.org/Function_Reference/get_the_author_meta).
Instead of [the\_excerpt](https://codex.wordpress.org/Functi... |
202,107 | <p>Is it possible to change the background color of every post based on its category? </p>
<p>I have tried -</p>
<pre><code>body.term-adb {
background-color: #000;
</code></pre>
<p>but this only changes the category page, not the individual posts backgrounds tagged with that category.</p>
<p>Where am I going wrong?... | [
{
"answer_id": 202108,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>Sure that is possible. Take a look at the output of </p>\n\n<pre><code><body <?php body_class( $additional_c... | 2015/09/08 | [
"https://wordpress.stackexchange.com/questions/202107",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48140/"
] | Is it possible to change the background color of every post based on its category?
I have tried -
```
body.term-adb {
background-color: #000;
```
but this only changes the category page, not the individual posts backgrounds tagged with that category.
Where am I going wrong?
Here is the [page](http://tinyurl.com/... | The body\_class() is what controls those classes, and does not include the category in single posts. That is why the CSS doesn't work once you click through to a post.
I did find a function that may help, though. Try placing this in your functions.php. This will add the current post's category back to the body class. ... |
202,113 | <p>I have problem with sort posts according to date:</p>
<p>My code now:</p>
<pre><code><?php
global $switched;
$original_blog_id = get_current_blog_id(); // get current blog
$blog_ids = array(4,1);
foreach( $blog_ids as $blog_id ){
switch_to_blog( $blog_id );
$args = array( 'posts_per_page' => 10, 'orderby' ... | [
{
"answer_id": 202148,
"author": "Dips Kakadiya",
"author_id": 57167,
"author_profile": "https://wordpress.stackexchange.com/users/57167",
"pm_score": 0,
"selected": false,
"text": "<p>You can add argument as below for <code>get_posts</code> method</p>\n\n<pre><code>'orderby' =&... | 2015/09/08 | [
"https://wordpress.stackexchange.com/questions/202113",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78540/"
] | I have problem with sort posts according to date:
My code now:
```
<?php
global $switched;
$original_blog_id = get_current_blog_id(); // get current blog
$blog_ids = array(4,1);
foreach( $blog_ids as $blog_id ){
switch_to_blog( $blog_id );
$args = array( 'posts_per_page' => 10, 'orderby' => 'date', 'order' => 'DESC... | Here's how I'd attack your problem (in fact I think I've written code like this in the past, but I can't find it at the moment):
```
$blogs = array( 4, 1 );
$all_posts = array();
foreach( $blogs as $blog ) {
switch_to_blog( $blog );
$args = array( 'posts_per_page' => 10, 'orderby' => 'date', 'order' => 'DESC')... |