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 |
|---|---|---|---|---|---|---|
196,471 | <p>I removed/unregistered the theme (BirdTIPS) header images, but the default header image is still displayed. How to remove it programmatically (not css or editing header.php)?</p>
<p>My code:</p>
<pre><code>add_action( 'after_setup_theme', 'remove_default_headers', 11 );
function remove_default_headers() {
rem... | [
{
"answer_id": 196473,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>When I started out with Wordpress I was anti-plugin. I wanted to add everything in my theme's <code>fun... | 2015/08/03 | [
"https://wordpress.stackexchange.com/questions/196471",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | I removed/unregistered the theme (BirdTIPS) header images, but the default header image is still displayed. How to remove it programmatically (not css or editing header.php)?
My code:
```
add_action( 'after_setup_theme', 'remove_default_headers', 11 );
function remove_default_headers() {
remove_theme_support( 'c... | When I started out with Wordpress I was anti-plugin. I wanted to add everything in my theme's `functions.php`. When I looked at the bigger picture it began making sense having and leaving some functionalities inside a plugin.
There are many write-ups on the subject of what should go into a plugin and what should go i... |
196,502 | <p>I am trying to retrieve some custom post type from their specific parent category.</p>
<pre><code> <div class="tab-content">
<?php
$cat_menu = get_categories('taxonomy=menu_categorie&type=menus');
foreach($cat_menu as $menu) {
echo '<div role="tabpanel" class="tab-pane active fade" id="'.$m... | [
{
"answer_id": 196506,
"author": "terminator",
"author_id": 55034,
"author_profile": "https://wordpress.stackexchange.com/users/55034",
"pm_score": 2,
"selected": false,
"text": "<p>From what u have written so far it seems <code>menu_categorie</code> is the custom taxonomy. Make sure it ... | 2015/08/03 | [
"https://wordpress.stackexchange.com/questions/196502",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66181/"
] | I am trying to retrieve some custom post type from their specific parent category.
```
<div class="tab-content">
<?php
$cat_menu = get_categories('taxonomy=menu_categorie&type=menus');
foreach($cat_menu as $menu) {
echo '<div role="tabpanel" class="tab-pane active fade" id="'.$menu->slug.'">';
$id = (int... | From what u have written so far it seems `menu_categorie` is the custom taxonomy. Make sure it is this only. I get a feeling that you have misses "s" from the end of `menu_categorie`
Anyways
The argument `'cat' => $id` you were using is used for default taxonomy i.e `category`.
But in your case you have custom taxo... |
196,508 | <p>I have googled this a few different ways, but cannot find the answer I'm looking for. I want to be able to count the number of posts each author has within a custom post type. Any suggestions would be really appreciated</p>
| [
{
"answer_id": 196510,
"author": "terminator",
"author_id": 55034,
"author_profile": "https://wordpress.stackexchange.com/users/55034",
"pm_score": 1,
"selected": true,
"text": "<p>i found this code wordpress.org . This code would work in author template.</p>\n\n<pre><code><?php\nglob... | 2015/08/03 | [
"https://wordpress.stackexchange.com/questions/196508",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77226/"
] | I have googled this a few different ways, but cannot find the answer I'm looking for. I want to be able to count the number of posts each author has within a custom post type. Any suggestions would be really appreciated | i found this code wordpress.org . This code would work in author template.
```
<?php
global $wp_query;
$curauth = $wp_query->get_queried_object();
$post_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '" . $curauth->ID . "' AND post_type = 'post' AND post_status = 'publish'");
?>
<h2>Post... |
196,521 | <p>I want to run a PHP script that iterates over WordPress sites found in a certain folder and read the plugins info per each site using get_plugin function</p>
<p>In the code below, I try to require API functions inside the WP folder and use it to retrieve data. However, the problem is the multiple "require".</p>
<p... | [
{
"answer_id": 196510,
"author": "terminator",
"author_id": 55034,
"author_profile": "https://wordpress.stackexchange.com/users/55034",
"pm_score": 1,
"selected": true,
"text": "<p>i found this code wordpress.org . This code would work in author template.</p>\n\n<pre><code><?php\nglob... | 2015/08/03 | [
"https://wordpress.stackexchange.com/questions/196521",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73742/"
] | I want to run a PHP script that iterates over WordPress sites found in a certain folder and read the plugins info per each site using get\_plugin function
In the code below, I try to require API functions inside the WP folder and use it to retrieve data. However, the problem is the multiple "require".
Sample code:
`... | i found this code wordpress.org . This code would work in author template.
```
<?php
global $wp_query;
$curauth = $wp_query->get_queried_object();
$post_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '" . $curauth->ID . "' AND post_type = 'post' AND post_status = 'publish'");
?>
<h2>Post... |
196,552 | <p>I am new to wordpress and i am learning a lot. But i am making this intranet site and i need to make a form just like Facebook's update status where my logged in users will need to update their status or upload some images with a description on it. Then underneath that, i will need to have a comment section and like... | [
{
"answer_id": 196510,
"author": "terminator",
"author_id": 55034,
"author_profile": "https://wordpress.stackexchange.com/users/55034",
"pm_score": 1,
"selected": true,
"text": "<p>i found this code wordpress.org . This code would work in author template.</p>\n\n<pre><code><?php\nglob... | 2015/08/04 | [
"https://wordpress.stackexchange.com/questions/196552",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76635/"
] | I am new to wordpress and i am learning a lot. But i am making this intranet site and i need to make a form just like Facebook's update status where my logged in users will need to update their status or upload some images with a description on it. Then underneath that, i will need to have a comment section and like bu... | i found this code wordpress.org . This code would work in author template.
```
<?php
global $wp_query;
$curauth = $wp_query->get_queried_object();
$post_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '" . $curauth->ID . "' AND post_type = 'post' AND post_status = 'publish'");
?>
<h2>Post... |
196,565 | <p>I am trying to create a page that shows all users with a selection of details. One of those details is the user role it has. For each role I want to display a different string. In order to achieve this is have the following code:</p>
<pre><code>function smoelenboek_func(){
$users = get_users('orderby=nicename')... | [
{
"answer_id": 196566,
"author": "Webloper",
"author_id": 29035,
"author_profile": "https://wordpress.stackexchange.com/users/29035",
"pm_score": 1,
"selected": true,
"text": "<p>You missed break statement</p>\n\n<p>This is how switch case works</p>\n\n<pre><code>switch ($i) {\n case ... | 2015/08/04 | [
"https://wordpress.stackexchange.com/questions/196565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74864/"
] | I am trying to create a page that shows all users with a selection of details. One of those details is the user role it has. For each role I want to display a different string. In order to achieve this is have the following code:
```
function smoelenboek_func(){
$users = get_users('orderby=nicename');
foreach ... | You missed break statement
This is how switch case works
```
switch ($i) {
case "apple":
echo "i is apple";
break;
case "bar":
echo "i is bar";
break;
case "cake":
echo "i is cake";
break;
}
``` |
196,567 | <p>I have written a function in <code>functions.php</code> that gets variables from a contact form and sends the inputs (and some other info like IP and location..) to my email. </p>
<p>I am starting to work on my first plugin and I want to store the parameters in a new table on the database. </p>
<p>How do I get the... | [
{
"answer_id": 196568,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 1,
"selected": false,
"text": "<p>Basic PHP:</p>\n\n<p><strong>functions.php</strong>:</p>\n\n<pre><code>function my_func() {\n //doin... | 2015/08/04 | [
"https://wordpress.stackexchange.com/questions/196567",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75062/"
] | I have written a function in `functions.php` that gets variables from a contact form and sends the inputs (and some other info like IP and location..) to my email.
I am starting to work on my first plugin and I want to store the parameters in a new table on the database.
How do I get the parameters from `function.p... | There is three way to use `function.php` file variable into plugin file.
1. Using [global](https://codex.wordpress.org/Global_Variables). Make sure you globalize it first.
`global $my_variable;
echo $my_variable;`
2. I recommend is using WordPress built-in filter mechanism [add\_filter](https://developer.wordpress.or... |
196,577 | <p>I was working on my MacOS System with everything well configured and working. Now I try to migrate all of my work to Windows using the same software as in MacOS MAMP to run Wordpress on localhost. So I set up MAMP on my Windows System and copied all files from GitHub to my workstation on Windows.</p>
<p>The problem... | [
{
"answer_id": 196568,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 1,
"selected": false,
"text": "<p>Basic PHP:</p>\n\n<p><strong>functions.php</strong>:</p>\n\n<pre><code>function my_func() {\n //doin... | 2015/08/04 | [
"https://wordpress.stackexchange.com/questions/196577",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77261/"
] | I was working on my MacOS System with everything well configured and working. Now I try to migrate all of my work to Windows using the same software as in MacOS MAMP to run Wordpress on localhost. So I set up MAMP on my Windows System and copied all files from GitHub to my workstation on Windows.
The problem is, when ... | There is three way to use `function.php` file variable into plugin file.
1. Using [global](https://codex.wordpress.org/Global_Variables). Make sure you globalize it first.
`global $my_variable;
echo $my_variable;`
2. I recommend is using WordPress built-in filter mechanism [add\_filter](https://developer.wordpress.or... |
196,586 | <p>I'm trying to get into wordpress theme development. I currently work at agency which uses Roots framework and piklist. </p>
<p>I created a custom post type into which i wanted to add an icon from font-awesome.
I wanted a more userfriendly approach in the select box inside the metabox container.</p>
<p>i was sugges... | [
{
"answer_id": 196568,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 1,
"selected": false,
"text": "<p>Basic PHP:</p>\n\n<p><strong>functions.php</strong>:</p>\n\n<pre><code>function my_func() {\n //doin... | 2015/08/04 | [
"https://wordpress.stackexchange.com/questions/196586",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76716/"
] | I'm trying to get into wordpress theme development. I currently work at agency which uses Roots framework and piklist.
I created a custom post type into which i wanted to add an icon from font-awesome.
I wanted a more userfriendly approach in the select box inside the metabox container.
i was suggested this: <https:... | There is three way to use `function.php` file variable into plugin file.
1. Using [global](https://codex.wordpress.org/Global_Variables). Make sure you globalize it first.
`global $my_variable;
echo $my_variable;`
2. I recommend is using WordPress built-in filter mechanism [add\_filter](https://developer.wordpress.or... |
196,594 | <p>I want to know the best use of adding custom <code>JS/CSS</code> to a theme.</p>
<p>I have built a small plugin which has a section to allow users to add <code>CSS/JS</code> to their theme. Now I am trying to figure out is which is the best way to do this:</p>
<blockquote>
<ol>
<li><p>Save all of the code insi... | [
{
"answer_id": 196597,
"author": "AddWeb Solution Pvt Ltd",
"author_id": 73643,
"author_profile": "https://wordpress.stackexchange.com/users/73643",
"pm_score": -1,
"selected": false,
"text": "<p>You've probably came across several different methods for including JavaScript and CSS.</p>\... | 2015/08/04 | [
"https://wordpress.stackexchange.com/questions/196594",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47687/"
] | I want to know the best use of adding custom `JS/CSS` to a theme.
I have built a small plugin which has a section to allow users to add `CSS/JS` to their theme. Now I am trying to figure out is which is the best way to do this:
>
> 1. Save all of the code inside an custom DB and load this as plain code inside the he... | I actually ran into a similar issue yesterday. A theme I was working with was adding 500+ lines of internal styles to the header which absolutely drives me nuts! I ended up finding a clever solution online to work around this which you could use for CSS. The JavaScript side I'll explain toward the bottom.
**--- :: CSS... |
196,600 | <p>I thought I read that when you send in a post via email you can add the category tag with a short code. So I try this with something like </p>
<pre><code>[my-category-name]
</code></pre>
<p>But all that does is print the literal with brackets. </p>
<p>I must be missing something obvious. </p>
<p>Anyone know, off... | [
{
"answer_id": 196597,
"author": "AddWeb Solution Pvt Ltd",
"author_id": 73643,
"author_profile": "https://wordpress.stackexchange.com/users/73643",
"pm_score": -1,
"selected": false,
"text": "<p>You've probably came across several different methods for including JavaScript and CSS.</p>\... | 2015/08/04 | [
"https://wordpress.stackexchange.com/questions/196600",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77268/"
] | I thought I read that when you send in a post via email you can add the category tag with a short code. So I try this with something like
```
[my-category-name]
```
But all that does is print the literal with brackets.
I must be missing something obvious.
Anyone know, offhand? | I actually ran into a similar issue yesterday. A theme I was working with was adding 500+ lines of internal styles to the header which absolutely drives me nuts! I ended up finding a clever solution online to work around this which you could use for CSS. The JavaScript side I'll explain toward the bottom.
**--- :: CSS... |
196,614 | <p>Hoping someone can assist with Wordpress table prefix for an already established site.</p>
<p>What is the best approach in changing the existing table prefix within both DB and wp-config file to reflect new table prefix.</p>
<p>Actually, it's more the backend DB changes required.</p>
<p>Is there a decent plugin o... | [
{
"answer_id": 196619,
"author": "Matt van Andel",
"author_id": 15324,
"author_profile": "https://wordpress.stackexchange.com/users/15324",
"pm_score": 1,
"selected": false,
"text": "<p>This is pretty straightforward. You can use <a href=\"https://stackoverflow.com/questions/23960321/how... | 2015/08/04 | [
"https://wordpress.stackexchange.com/questions/196614",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1053/"
] | Hoping someone can assist with Wordpress table prefix for an already established site.
What is the best approach in changing the existing table prefix within both DB and wp-config file to reflect new table prefix.
Actually, it's more the backend DB changes required.
Is there a decent plugin or can someone pls point ... | This is pretty straightforward. You can use [phpMyAdmin](https://stackoverflow.com/questions/23960321/how-to-change-table-prefixes-in-phpmyadmin) or [MySQL Workbench](https://stackoverflow.com/questions/26888738/mysql-workbench-add-prefix-to-all-tabels) to change the prefix on all the tables at once, or you can do it o... |
196,649 | <p>I'm setting up a series of questions and based on the answers, I am trying to redirect to a specific page. For one example, the questions have to be answer correctly, they need to be male and 65 or older. For the other, correct questions, they need to be female and 55 or older. Here is the code I am using below. I a... | [
{
"answer_id": 196747,
"author": "jdm2112",
"author_id": 45202,
"author_profile": "https://wordpress.stackexchange.com/users/45202",
"pm_score": 0,
"selected": false,
"text": "<p>Without testing your code, I believe the problem lies in the structure of the data you are expecting from the... | 2015/08/04 | [
"https://wordpress.stackexchange.com/questions/196649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77297/"
] | I'm setting up a series of questions and based on the answers, I am trying to redirect to a specific page. For one example, the questions have to be answer correctly, they need to be male and 65 or older. For the other, correct questions, they need to be female and 55 or older. Here is the code I am using below. I am a... | If anyone runs into this problem, the answer lies in the fact that gform\_confirmation is fired after gform\_after\_submission. The logic is correct, however, the 5th session variable was not being stored before the confirmation was sent. Therefore, no variable ever equaled 'No' and it failed every time.
The solution ... |
196,666 | <p>I mean the speed of query records from database, not the way we render the content gained.
More specifically, I just want to query the posts' IDs, my site contains more than 4000 posts (they are custom post type) and I just want to have all their ID.</p>
| [
{
"answer_id": 196668,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, custom SQL queries are in essence faster than a custom instance of <code>WP_Query</code>. The disad... | 2015/08/05 | [
"https://wordpress.stackexchange.com/questions/196666",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70868/"
] | I mean the speed of query records from database, not the way we render the content gained.
More specifically, I just want to query the posts' IDs, my site contains more than 4000 posts (they are custom post type) and I just want to have all their ID. | Yes, custom SQL queries are in essence faster than a custom instance of `WP_Query`. The disadvantage of a custom SQL query is that you are loosing a lot, like object cache, filters and actions, etc, etc, and it is also discouraged to use custom SQL if Wordpress already offers that specific functionality.
`WP_Query` do... |
196,673 | <p>I was trying to add category images for custom taxonomy I am using this plugin <a href="https://wordpress.org/plugins/taxonomy-images/" rel="nofollow">taxonomy-images</a> but I don't know how to get that custom taxonomy image</p>
<p>I tried to keep print <code>apply_filters( 'taxonomy-images-queried-term-image', '... | [
{
"answer_id": 196668,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, custom SQL queries are in essence faster than a custom instance of <code>WP_Query</code>. The disad... | 2015/08/05 | [
"https://wordpress.stackexchange.com/questions/196673",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76780/"
] | I was trying to add category images for custom taxonomy I am using this plugin [taxonomy-images](https://wordpress.org/plugins/taxonomy-images/) but I don't know how to get that custom taxonomy image
I tried to keep print `apply_filters( 'taxonomy-images-queried-term-image', '' );`
but not getting image in taxonomy p... | Yes, custom SQL queries are in essence faster than a custom instance of `WP_Query`. The disadvantage of a custom SQL query is that you are loosing a lot, like object cache, filters and actions, etc, etc, and it is also discouraged to use custom SQL if Wordpress already offers that specific functionality.
`WP_Query` do... |
196,683 | <p>I have one template file for the main page, after creating home page I have added text to check if it reflect changes on my home page or not and it was successfully displaying text. But when I try to add image by clicking on add media option then image is uploaded but not displaying on my page. What piece of code sh... | [
{
"answer_id": 196668,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, custom SQL queries are in essence faster than a custom instance of <code>WP_Query</code>. The disad... | 2015/08/05 | [
"https://wordpress.stackexchange.com/questions/196683",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76941/"
] | I have one template file for the main page, after creating home page I have added text to check if it reflect changes on my home page or not and it was successfully displaying text. But when I try to add image by clicking on add media option then image is uploaded but not displaying on my page. What piece of code shoul... | Yes, custom SQL queries are in essence faster than a custom instance of `WP_Query`. The disadvantage of a custom SQL query is that you are loosing a lot, like object cache, filters and actions, etc, etc, and it is also discouraged to use custom SQL if Wordpress already offers that specific functionality.
`WP_Query` do... |
196,714 | <p>I'm looking to retrieve a specific meta value for users from the Wordpress types plugin. I know the value is stored in a wpcf-team-experience-member-type. This is a checkbox option and I'd like to retrieve a list of all selected values.</p>
<p>Right off the bat if I do something like:</p>
<pre><code>var_dump(get_u... | [
{
"answer_id": 196668,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, custom SQL queries are in essence faster than a custom instance of <code>WP_Query</code>. The disad... | 2015/08/05 | [
"https://wordpress.stackexchange.com/questions/196714",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/72946/"
] | I'm looking to retrieve a specific meta value for users from the Wordpress types plugin. I know the value is stored in a wpcf-team-experience-member-type. This is a checkbox option and I'd like to retrieve a list of all selected values.
Right off the bat if I do something like:
```
var_dump(get_user_meta($user->ID, '... | Yes, custom SQL queries are in essence faster than a custom instance of `WP_Query`. The disadvantage of a custom SQL query is that you are loosing a lot, like object cache, filters and actions, etc, etc, and it is also discouraged to use custom SQL if Wordpress already offers that specific functionality.
`WP_Query` do... |
196,731 | <p>As per the title, what I want to do is run a custom query that (using WP-Cron) will run once a day to check for users who registered exactly 360 days before the current date (don't need time, just date) and gather their <code>ID</code>. I have this:</p>
<pre><code>global $wpdb;
$sql = $wpdb->prepare(
"SELECT... | [
{
"answer_id": 196743,
"author": "Trang",
"author_id": 70868,
"author_profile": "https://wordpress.stackexchange.com/users/70868",
"pm_score": 0,
"selected": false,
"text": "<p>Use</p>\n\n<pre><code>$wpdb->get_results(\"SELECT *, (DATEDIFF(NOW(),user_registered)) AS daydiff FROM {$wpd... | 2015/08/05 | [
"https://wordpress.stackexchange.com/questions/196731",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35299/"
] | As per the title, what I want to do is run a custom query that (using WP-Cron) will run once a day to check for users who registered exactly 360 days before the current date (don't need time, just date) and gather their `ID`. I have this:
```
global $wpdb;
$sql = $wpdb->prepare(
"SELECT * FROM {$wpdb->users}
... | I [peeked](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/user.php#L794) into the `WP_User_Query` class and it supports a `WP_Date_Query` query on the user registration date.
So we could use:
```
$query = new WP_User_Query( $args );
```
or simply:
```
$users = get_users( $args );
```
where:
... |
196,739 | <p>I'm having difficulty returning a list of posts. This file is contained in a plugin folder (ultimately I want to have a cron job just run the script here to delete posts with invalid urls in the given meta value). </p>
<p>I've tried using get_posts to return posts with no success. So I tried working and reworking a... | [
{
"answer_id": 196743,
"author": "Trang",
"author_id": 70868,
"author_profile": "https://wordpress.stackexchange.com/users/70868",
"pm_score": 0,
"selected": false,
"text": "<p>Use</p>\n\n<pre><code>$wpdb->get_results(\"SELECT *, (DATEDIFF(NOW(),user_registered)) AS daydiff FROM {$wpd... | 2015/08/05 | [
"https://wordpress.stackexchange.com/questions/196739",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73442/"
] | I'm having difficulty returning a list of posts. This file is contained in a plugin folder (ultimately I want to have a cron job just run the script here to delete posts with invalid urls in the given meta value).
I've tried using get\_posts to return posts with no success. So I tried working and reworking a wp\_quer... | I [peeked](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/user.php#L794) into the `WP_User_Query` class and it supports a `WP_Date_Query` query on the user registration date.
So we could use:
```
$query = new WP_User_Query( $args );
```
or simply:
```
$users = get_users( $args );
```
where:
... |
196,750 | <p>I need, somehow, to enable that when you logout, that <em>'My Account'</em> item is getting hidden from the navbar, and instead it displays a <em>'Log in'</em> link. The item <em>'My Account'</em> also have submenus with the items <em>'Log out'</em> and <em>'Track your order'</em>. This should be hidden as well <em>... | [
{
"answer_id": 196908,
"author": "somebodysomewhere",
"author_id": 44937,
"author_profile": "https://wordpress.stackexchange.com/users/44937",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the WordPress function <code>is_user_logged_in()</code> to check that, and create some ... | 2015/08/05 | [
"https://wordpress.stackexchange.com/questions/196750",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77322/"
] | I need, somehow, to enable that when you logout, that *'My Account'* item is getting hidden from the navbar, and instead it displays a *'Log in'* link. The item *'My Account'* also have submenus with the items *'Log out'* and *'Track your order'*. This should be hidden as well *(I guess it gets hidden when you hide the... | It seems that the OP have managed to solve his/her problem by doing this, which can be found at [Different menus for logged-in users](https://codex.wordpress.org/Function_Reference/wp_nav_menu#Different_menus_for_logged-in_users).
```
if ( is_user_logged_in() ) {
wp_nav_menu( array( 'theme_location' => 'logged-in... |
196,811 | <p>I am currently listing posts based on user role, with the following query:</p>
<pre><code>$ids = get_users( array('role' => 'author' ,'fields' => 'ID') );
$args = array(
'author' => implode(',', $ids),
'orderby' => 'date',
'order' => 'ASC',
);
</code></pre>
<p>Would i... | [
{
"answer_id": 196801,
"author": "Rene Korss",
"author_id": 69908,
"author_profile": "https://wordpress.stackexchange.com/users/69908",
"pm_score": 0,
"selected": false,
"text": "<p>Add <code>.htaccess</code> file to root folder in arkansaspicker.com.</p>\n\n<p><strong>.htaccess</strong>... | 2015/08/06 | [
"https://wordpress.stackexchange.com/questions/196811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58166/"
] | I am currently listing posts based on user role, with the following query:
```
$ids = get_users( array('role' => 'author' ,'fields' => 'ID') );
$args = array(
'author' => implode(',', $ids),
'orderby' => 'date',
'order' => 'ASC',
);
```
Would it be possible to also limit the posts bas... | The simplest way is to use WordPress plugins. For example:
1. 301 SEO Redirection
2. 301 Redirects
Or use `.htaccess` file |
196,812 | <p>I am using latest wordpres. I have created child theme. </p>
<p>I am trying to overwride the .box style of parent theme but it is not overriding it. If i do this in parent themes <code>style.css</code> it works.</p>
<pre><code>//This is style.css of child theme
/*
Theme Name: Custom Theme
Description: Child Theme
... | [
{
"answer_id": 196817,
"author": "Ernedar",
"author_id": 74019,
"author_profile": "https://wordpress.stackexchange.com/users/74019",
"pm_score": 1,
"selected": false,
"text": "<p>Is this: <strong>/</strong> just overwritten or is it a mistake in your code? <code>max-width: 75%;/</code> ... | 2015/08/06 | [
"https://wordpress.stackexchange.com/questions/196812",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67596/"
] | I am using latest wordpres. I have created child theme.
I am trying to overwride the .box style of parent theme but it is not overriding it. If i do this in parent themes `style.css` it works.
```
//This is style.css of child theme
/*
Theme Name: Custom Theme
Description: Child Theme
Author: Shahrukh
Template: baset... | Is this: **/** just overwritten or is it a mistake in your code? `max-width: 75%;/`
It might cause to not work properly. Otherwise i will try a bit shady way, try to make your parent attributes `!important`. |
196,830 | <p>I've got myself into a little pickle, and while I'm so close, my understanding of PHP is letting me down.</p>
<p>I want to display the image associated with each category in the menu - working from the answer <a href="https://stackoverflow.com/questions/26079190/add-featured-image-to-wp-nav-menu-items">over here</a... | [
{
"answer_id": 196833,
"author": "markmoxx",
"author_id": 70674,
"author_profile": "https://wordpress.stackexchange.com/users/70674",
"pm_score": 2,
"selected": true,
"text": "<p>Not sure why your object is returning the non-object notice, but you can set the output of <code>get_term_by<... | 2015/08/06 | [
"https://wordpress.stackexchange.com/questions/196830",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77390/"
] | I've got myself into a little pickle, and while I'm so close, my understanding of PHP is letting me down.
I want to display the image associated with each category in the menu - working from the answer [over here](https://stackoverflow.com/questions/26079190/add-featured-image-to-wp-nav-menu-items) I needed to make th... | Not sure why your object is returning the non-object notice, but you can set the output of `get_term_by` to `OBJECT`, `ARRAY_A`, or `ARRAY_N` - You'll want to use `ARRAY_A` and then access the term ID via `$term['term_id']`. |
196,847 | <p>I've created some custom columns to display my custom post types more attractively in the admin section - the columns are mostly custom fields. Mostly, this works absolutely fine, and I can sort by the custom field columns as expected.</p>
<p>However, one of the custom fields points to the post ID of a different po... | [
{
"answer_id": 196848,
"author": "phil",
"author_id": 21347,
"author_profile": "https://wordpress.stackexchange.com/users/21347",
"pm_score": 1,
"selected": false,
"text": "<p>(I was going to add this as a comment as it's not a full answer, but I can't yet...)</p>\n\n<p>I think you will ... | 2015/08/06 | [
"https://wordpress.stackexchange.com/questions/196847",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63673/"
] | I've created some custom columns to display my custom post types more attractively in the admin section - the columns are mostly custom fields. Mostly, this works absolutely fine, and I can sort by the custom field columns as expected.
However, one of the custom fields points to the post ID of a different post type. W... | Building on Phil's answer:
Made the following change to the switch:
```
case 'extranet_sort_document_case':
add_filter('posts_join', 'extranet_clientdocument_case_join');
add_filter('posts_fields', 'extranet_clientdocument_case_fields');
add_filter('posts_orderby', 'extranet_clientdocument_case_order');
break;
```... |
196,855 | <p>I want to know if a user with a specific user id has logged in on my wordpress site.How can I achieve this accurately.</p>
| [
{
"answer_id": 196865,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 0,
"selected": false,
"text": "<p>try this code, it is in user-edit.php :<br>\n<code>$sessions = WP_Session_Tokens::get_instance( $profileuser->... | 2015/08/06 | [
"https://wordpress.stackexchange.com/questions/196855",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77400/"
] | I want to know if a user with a specific user id has logged in on my wordpress site.How can I achieve this accurately. | You could always try using the `wp_login` action hook:
```
function custom_check_for_user($user_login, $user) {
if($user->ID == 123) { // Where 123 is the particular user's ID
// Do something here, eg. PHP mail() function
}
}
add_action('wp_login', 'custom_check_for_user', 10, 2);
```
Further reading... |
196,868 | <p>I'm trying to load a template via ajax if the user clicks on a button. This is the code I'm using:</p>
<p>On <code>functions.php</code>:</p>
<pre><code>function phantom_scripts() {
global $child_dir;
/* Ajax Requests */
wp_enqueue_script( 'ajax-stuff', get_stylesheet_directory_uri() . '/js/ajax.js', array( ... | [
{
"answer_id": 196891,
"author": "Dougal Campbell",
"author_id": 65,
"author_profile": "https://wordpress.stackexchange.com/users/65",
"pm_score": 2,
"selected": true,
"text": "<p>So, you're using <code>wp_localize_script</code> to inject the ajax url. But you didn't use the localized va... | 2015/08/06 | [
"https://wordpress.stackexchange.com/questions/196868",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22933/"
] | I'm trying to load a template via ajax if the user clicks on a button. This is the code I'm using:
On `functions.php`:
```
function phantom_scripts() {
global $child_dir;
/* Ajax Requests */
wp_enqueue_script( 'ajax-stuff', get_stylesheet_directory_uri() . '/js/ajax.js', array( 'jquery' ), true );
}
add_acti... | So, you're using `wp_localize_script` to inject the ajax url. But you didn't use the localized var handle to access that value. Try this:
```
/* ... */
$.ajax({
url: ajaxStuff.ajaxurl, // NOTE use of 'ajaxStuff' object
/* ... */
``` |
196,879 | <p>I am trying to integrate a ‘subscribe to newsletter’ feature on my wordpress blog</p>
<p>Users just need to enter their name and email address, hit subscribe. This is then supposed to send me an email and I add them to the mailing list.</p>
<p>I activated the WP SMTP Mail plugin and entered in the relevant email s... | [
{
"answer_id": 196891,
"author": "Dougal Campbell",
"author_id": 65,
"author_profile": "https://wordpress.stackexchange.com/users/65",
"pm_score": 2,
"selected": true,
"text": "<p>So, you're using <code>wp_localize_script</code> to inject the ajax url. But you didn't use the localized va... | 2015/08/06 | [
"https://wordpress.stackexchange.com/questions/196879",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77410/"
] | I am trying to integrate a ‘subscribe to newsletter’ feature on my wordpress blog
Users just need to enter their name and email address, hit subscribe. This is then supposed to send me an email and I add them to the mailing list.
I activated the WP SMTP Mail plugin and entered in the relevant email server information... | So, you're using `wp_localize_script` to inject the ajax url. But you didn't use the localized var handle to access that value. Try this:
```
/* ... */
$.ajax({
url: ajaxStuff.ajaxurl, // NOTE use of 'ajaxStuff' object
/* ... */
``` |
196,881 | <p>I want to capture the click event on the "<strong>Save all changes</strong>" button? </p>
<p>Is there any callback method like there is when you click (<strong>window.send_to_editor</strong>) the "<strong>Insert into Post</strong>" button</p>
<p><a href="https://i.stack.imgur.com/CiEBa.jpg"><img src="https://i.sta... | [
{
"answer_id": 196891,
"author": "Dougal Campbell",
"author_id": 65,
"author_profile": "https://wordpress.stackexchange.com/users/65",
"pm_score": 2,
"selected": true,
"text": "<p>So, you're using <code>wp_localize_script</code> to inject the ajax url. But you didn't use the localized va... | 2015/08/06 | [
"https://wordpress.stackexchange.com/questions/196881",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77411/"
] | I want to capture the click event on the "**Save all changes**" button?
Is there any callback method like there is when you click (**window.send\_to\_editor**) the "**Insert into Post**" button
[](https://i.stack.imgur.com/CiEBa.jpg) | So, you're using `wp_localize_script` to inject the ajax url. But you didn't use the localized var handle to access that value. Try this:
```
/* ... */
$.ajax({
url: ajaxStuff.ajaxurl, // NOTE use of 'ajaxStuff' object
/* ... */
``` |
196,929 | <p>I am new in buddypress. </p>
<p>My problem is: I have create a template for get member list based on role Like:</p>
<pre><code><?php if ( bp_has_members( bp_ajax_querystring( 'members' ). '&per_page=25&role=author' ) ) : ?>
<ul id="members-list" class="item-list row kleo-isotope masonry">
... | [
{
"answer_id": 196931,
"author": "AddWeb Solution Pvt Ltd",
"author_id": 73643,
"author_profile": "https://wordpress.stackexchange.com/users/73643",
"pm_score": 0,
"selected": false,
"text": "<p>If you use this code directly below <code>while ( bp_members() ) : bp_the_member();</code> in... | 2015/08/07 | [
"https://wordpress.stackexchange.com/questions/196929",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59532/"
] | I am new in buddypress.
My problem is: I have create a template for get member list based on role Like:
```
<?php if ( bp_has_members( bp_ajax_querystring( 'members' ). '&per_page=25&role=author' ) ) : ?>
<ul id="members-list" class="item-list row kleo-isotope masonry">
<?php while ( bp_members() ) : bp_... | To preserve pagination, try:
```
<?php
$authors = get_users( array( 'fields' => 'ID', 'role' => 'author' ) );
$authors = implode(',', $authors);
?>
<?php if ( bp_has_members( bp_ajax_querystring( 'members' ). '&per_page=25&include=' . $authors) ) : ?>
//etc
``` |
196,952 | <p>I am trying to display my menu, while menu is displaying perectly, it does have open within nav, which hide everything behind it, as navbar-fixed has come style. what should i be doing to fix the issue?</p>
<pre><code> <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="con... | [
{
"answer_id": 196953,
"author": "AddWeb Solution Pvt Ltd",
"author_id": 73643,
"author_profile": "https://wordpress.stackexchange.com/users/73643",
"pm_score": 3,
"selected": true,
"text": "<p><strong>Source: <a href=\"http://chrislema.com/high-performance-wordpress-membership-site/\" r... | 2015/08/07 | [
"https://wordpress.stackexchange.com/questions/196952",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33028/"
] | I am trying to display my menu, while menu is displaying perectly, it does have open within nav, which hide everything behind it, as navbar-fixed has come style. what should i be doing to fix the issue?
```
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class... | **Source: [Chris Lima - Managing a High Performance WordPress Membership Site](http://chrislema.com/high-performance-wordpress-membership-site/)**
---
I should look at caching plugins because it makes things faster, better and worked for you. The problem with that answer is that most caching plugins don’t do much for... |
196,960 | <p>We know that we can check if the particular post has a term by using this code: </p>
<pre><code>has_term('term', 'taxonomy', $post->ID )) {
</code></pre>
<p>I was wondering if there is a code to check if a particular post does not have a particular term.
Thanks. </p>
| [
{
"answer_id": 196964,
"author": "Brad Dalton",
"author_id": 9884,
"author_profile": "https://wordpress.stackexchange.com/users/9884",
"pm_score": 4,
"selected": true,
"text": "<pre><code>if ( !has_term('term', 'taxonomy', $post->ID )) {\n</code></pre>\n\n<p>Use the NOT (<code>!</code... | 2015/08/07 | [
"https://wordpress.stackexchange.com/questions/196960",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13058/"
] | We know that we can check if the particular post has a term by using this code:
```
has_term('term', 'taxonomy', $post->ID )) {
```
I was wondering if there is a code to check if a particular post does not have a particular term.
Thanks. | ```
if ( !has_term('term', 'taxonomy', $post->ID )) {
```
Use the NOT (`!`) operator |
196,990 | <p>I am working on dailysuit.de, which features 8 related articles below the content in every post, defined by some tags.</p>
<p>Now I wanted to reduce the number of "posts per page" from 8 to 4. Of course, I can easily achieve that by changing the functions.php, but as soon as the theme gets an update, the figure is ... | [
{
"answer_id": 196992,
"author": "Pooja Mistry",
"author_id": 71675,
"author_profile": "https://wordpress.stackexchange.com/users/71675",
"pm_score": 0,
"selected": false,
"text": "<p>The above code looks okay. I think the reason why you are getting 8 posts instead of 4 is that, you stil... | 2015/08/07 | [
"https://wordpress.stackexchange.com/questions/196990",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50311/"
] | I am working on dailysuit.de, which features 8 related articles below the content in every post, defined by some tags.
Now I wanted to reduce the number of "posts per page" from 8 to 4. Of course, I can easily achieve that by changing the functions.php, but as soon as the theme gets an update, the figure is back to 8.... | I have gone through your code and found that the function `longform_the_related_posts` displays 8 related posts. This function is defined in functions.php of parent theme and called in single.php.
Thus, to override the function, follow below steps -
1. Create another function that displays 4 related posts in func... |
196,995 | <p>I am developing a WP theme with MVC approach. It only have <code>index.php</code>, <code>functions.php</code> and <code>styles.css</code> on the parent directory. So, I do not want to place page templates on it rather then I want to programmatically provide them from View classes while functionality from edit screen... | [
{
"answer_id": 197041,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 1,
"selected": false,
"text": "<p>Got around with a ugly hack :-/. I will update the answer If I go with jQuery later on. The solution still requir... | 2015/08/07 | [
"https://wordpress.stackexchange.com/questions/196995",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3094/"
] | I am developing a WP theme with MVC approach. It only have `index.php`, `functions.php` and `styles.css` on the parent directory. So, I do not want to place page templates on it rather then I want to programmatically provide them from View classes while functionality from edit screen stays the same.
Users need to hav... | I thought I would provide you with another approach. It is also a bit hackish, but it is general purpose and allows you to simply register the filename and label that you want to use, like so:
```
if ( class_exists( 'WPSE_196995_Page_Templates' ) ) {
WPSE_196995_Page_Templates::register_page_template(
'... |
197,001 | <p>I've got a True/False value added to posts (Exclusive versus Curated) that was added via Advanced Custom Fields. How do I get that value to show up as a column on the Post list (/wp-admin/edit.php) to allow editors to quickly sort via that field?</p>
<p>I found this example (<a href="http://code.tutsplus.com/articl... | [
{
"answer_id": 198528,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": false,
"text": "<p>You've got your action/filter names slightly off:</p>\n\n<pre><code>// For registering the column\nadd_fil... | 2015/08/07 | [
"https://wordpress.stackexchange.com/questions/197001",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10692/"
] | I've got a True/False value added to posts (Exclusive versus Curated) that was added via Advanced Custom Fields. How do I get that value to show up as a column on the Post list (/wp-admin/edit.php) to allow editors to quickly sort via that field?
I found this example (<http://code.tutsplus.com/articles/add-a-custom-co... | You've got your action/filter names slightly off:
```
// For registering the column
add_filter( 'manage_posts_columns', 'custom_posts_table_head' );
// For rendering the column
add_action( 'manage_posts_custom_column', 'custom_posts_table_content', 10, 2 );
``` |
197,011 | <p>I'm attempting to <a href="https://wordpress.stackexchange.com/questions/87017/pulling-featured-images-in-to-a-wordpress-menu">add thumbnails to navigation items as per this question</a>. However, after adding the sample code to the top of my functions.php file nothing happens. I've whittled the code down in an atte... | [
{
"answer_id": 198528,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": false,
"text": "<p>You've got your action/filter names slightly off:</p>\n\n<pre><code>// For registering the column\nadd_fil... | 2015/08/07 | [
"https://wordpress.stackexchange.com/questions/197011",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43552/"
] | I'm attempting to [add thumbnails to navigation items as per this question](https://wordpress.stackexchange.com/questions/87017/pulling-featured-images-in-to-a-wordpress-menu). However, after adding the sample code to the top of my functions.php file nothing happens. I've whittled the code down in an attempt to get any... | You've got your action/filter names slightly off:
```
// For registering the column
add_filter( 'manage_posts_columns', 'custom_posts_table_head' );
// For rendering the column
add_action( 'manage_posts_custom_column', 'custom_posts_table_content', 10, 2 );
``` |
197,019 | <p>I have searched Stack and the codex but can't find a simple solution for limiting the number of posts returned to one using the following:</p>
<pre><code><?php query_posts('cat=24'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_field('alert'); ?>
<?php endwhile;?>
... | [
{
"answer_id": 197022,
"author": "Dejo Dekic",
"author_id": 20941,
"author_profile": "https://wordpress.stackexchange.com/users/20941",
"pm_score": 2,
"selected": true,
"text": "<pre><code><?php query_posts('cat=24&posts_per_page=1'); ?>\n</code></pre>\n\n<p>But using query_pos... | 2015/08/07 | [
"https://wordpress.stackexchange.com/questions/197019",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48611/"
] | I have searched Stack and the codex but can't find a simple solution for limiting the number of posts returned to one using the following:
```
<?php query_posts('cat=24'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_field('alert'); ?>
<?php endwhile;?>
``` | ```
<?php query_posts('cat=24&posts_per_page=1'); ?>
```
But using query\_posts is a **[very bad idea](https://codex.wordpress.org/Function_Reference/query_posts)**.
This is straigt from the Codex:
For general post queries, use [WP\_Query](https://codex.wordpress.org/Class_Reference/WP_Query) or [get\_posts](https:... |
197,036 | <p>i want code that show display some category and sort by acf field.</p>
<p>for example show all post from category 122,123,124 and sort all of them by acf (for example : lastname ). please write code for me. </p>
<p>my code is : </p>
<pre><code><?php
query_posts('cat=1,2&post_status=publish&posts_per_p... | [
{
"answer_id": 197022,
"author": "Dejo Dekic",
"author_id": 20941,
"author_profile": "https://wordpress.stackexchange.com/users/20941",
"pm_score": 2,
"selected": true,
"text": "<pre><code><?php query_posts('cat=24&posts_per_page=1'); ?>\n</code></pre>\n\n<p>But using query_pos... | 2015/08/08 | [
"https://wordpress.stackexchange.com/questions/197036",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77475/"
] | i want code that show display some category and sort by acf field.
for example show all post from category 122,123,124 and sort all of them by acf (for example : lastname ). please write code for me.
my code is :
```
<?php
query_posts('cat=1,2&post_status=publish&posts_per_page=1');
if ( have_posts() ) : while (... | ```
<?php query_posts('cat=24&posts_per_page=1'); ?>
```
But using query\_posts is a **[very bad idea](https://codex.wordpress.org/Function_Reference/query_posts)**.
This is straigt from the Codex:
For general post queries, use [WP\_Query](https://codex.wordpress.org/Class_Reference/WP_Query) or [get\_posts](https:... |
197,053 | <p>how i can get posts via MYSQL from posts where language is 'en' and 'ru'</p>
<p>I have this query</p>
<pre><code>$sql = "SELECT p1.*, wm2.meta_value
FROM wp_posts p1
LEFT JOIN wp_postmeta wm1 ON ( wm1.post_id = p1.ID
AND wm1.meta_value IS NOT NULL
AND wm1.meta_key = '_thumbnail_id' )
LEFT JOIN wp_po... | [
{
"answer_id": 197055,
"author": "Valeriy Donika",
"author_id": 57628,
"author_profile": "https://wordpress.stackexchange.com/users/57628",
"pm_score": 0,
"selected": false,
"text": "<pre><code>$sql = \"SELECT p1.*, wm2.meta_value \n FROM wp_posts p1 \n ... | 2015/08/08 | [
"https://wordpress.stackexchange.com/questions/197053",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57628/"
] | how i can get posts via MYSQL from posts where language is 'en' and 'ru'
I have this query
```
$sql = "SELECT p1.*, wm2.meta_value
FROM wp_posts p1
LEFT JOIN wp_postmeta wm1 ON ( wm1.post_id = p1.ID
AND wm1.meta_value IS NOT NULL
AND wm1.meta_key = '_thumbnail_id' )
LEFT JOIN wp_postmeta wm2 ON ( wm1.m... | I resolved creating SQL query:
```
SELECT posts.post_title, posts.post_content, trans.element_type,
trans.language_code
FROM wp_posts AS posts
INNER JOIN wp_icl_translations AS trans
ON posts.ID = trans.element_id
INNER JOIN wp_postmeta AS meta
ON posts.ID = meta.post_id
WHERE trans.element_type = 'post_product'
AN... |
198,075 | <p>I have a plugin that prepends an upvote box to <code>the_content</code> of a single post, sends data via AJAX back to the main plugin PHP file and calls a function to update a database value on success.</p>
<p>Here is the PHP callback from the AJAX:</p>
<pre><code>function update_parlay_points() {
//Update Par... | [
{
"answer_id": 198104,
"author": "Lasse M. Tvedt",
"author_id": 40819,
"author_profile": "https://wordpress.stackexchange.com/users/40819",
"pm_score": 0,
"selected": false,
"text": "<p>What about sending the post id of the single post trough ajax as well? So if you create a hidden input... | 2015/08/08 | [
"https://wordpress.stackexchange.com/questions/198075",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77501/"
] | I have a plugin that prepends an upvote box to `the_content` of a single post, sends data via AJAX back to the main plugin PHP file and calls a function to update a database value on success.
Here is the PHP callback from the AJAX:
```
function update_parlay_points() {
//Update Parlay Points field on database wit... | >
> As you can see, I tried declaring the $post variable as global to account for failures due to being outside of the Loop.
>
>
>
The problem is **not** that the post is *"outside of the loop"*, problem is that AJAX request is a completely separate HTTP request.
When you do an AJAX request, is just like you are... |
198,114 | <p>I'm overriding WooCommerce's default search query to include searching by SKU as well.</p>
<pre class="lang-php prettyprint-override"><code>// default search query
$query_default_search = new WP_Query(
array(
"post_type" => "product",
"s" => $search_query
)
);
// SKU query
$query_sear... | [
{
"answer_id": 198104,
"author": "Lasse M. Tvedt",
"author_id": 40819,
"author_profile": "https://wordpress.stackexchange.com/users/40819",
"pm_score": 0,
"selected": false,
"text": "<p>What about sending the post id of the single post trough ajax as well? So if you create a hidden input... | 2015/08/09 | [
"https://wordpress.stackexchange.com/questions/198114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77533/"
] | I'm overriding WooCommerce's default search query to include searching by SKU as well.
```php
// default search query
$query_default_search = new WP_Query(
array(
"post_type" => "product",
"s" => $search_query
)
);
// SKU query
$query_search_by_sku = new WP_Query(
array(
"post_type... | >
> As you can see, I tried declaring the $post variable as global to account for failures due to being outside of the Loop.
>
>
>
The problem is **not** that the post is *"outside of the loop"*, problem is that AJAX request is a completely separate HTTP request.
When you do an AJAX request, is just like you are... |
198,135 | <p>I have been working with a front end upload and post creation script. For some reason calling the media_handle_upload function from my project-save.php file is returning as an undefined function. Is there something I a missing? Permissions, additional files, coffee?</p>
<p>Here is my function in functions.php</p... | [
{
"answer_id": 198136,
"author": "Derek",
"author_id": 20663,
"author_profile": "https://wordpress.stackexchange.com/users/20663",
"pm_score": 2,
"selected": false,
"text": "<p>So I dont know if its the best way but my problem was the if statement surrounding the require_once on the nece... | 2015/08/09 | [
"https://wordpress.stackexchange.com/questions/198135",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20663/"
] | I have been working with a front end upload and post creation script. For some reason calling the media\_handle\_upload function from my project-save.php file is returning as an undefined function. Is there something I a missing? Permissions, additional files, coffee?
Here is my function in functions.php
```
function... | So I dont know if its the best way but my problem was the if statement surrounding the require\_once on the necessary files that contain the function. Commented out the IF statement and it did the trick. I'll go have that coffee now ;)
```
//if (!function_exists('wp_generate_attachment_metadata')){
require_o... |
198,143 | <p>I'm looking for a way to get the list of all plugins listed in the <a href="https://wordpress.org/plugins/" rel="noreferrer">WordPress.org Plugin Directory</a>.</p>
<p>There is one other post I've <a href="https://wordpress.stackexchange.com/questions/95836/list-of-all-existing-wordpress-plugins">found on StackOver... | [
{
"answer_id": 204266,
"author": "Burgi",
"author_id": 62753,
"author_profile": "https://wordpress.stackexchange.com/users/62753",
"pm_score": 2,
"selected": false,
"text": "<p>Without seeing some code or results it is difficult to advise beyond linking you to other tutorials on the web.... | 2015/08/10 | [
"https://wordpress.stackexchange.com/questions/198143",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43881/"
] | I'm looking for a way to get the list of all plugins listed in the [WordPress.org Plugin Directory](https://wordpress.org/plugins/).
There is one other post I've [found on StackOverflow](https://wordpress.stackexchange.com/questions/95836/list-of-all-existing-wordpress-plugins) regarding this which recommends [using t... | You can start with something like this:
```
https://api.wordpress.org/plugins/info/1.2/?action=query_plugins&request[page]=1&request[per_page]=400
```
I think it's self-explanatory. |
198,171 | <p>My application has >10 <code>user_roles</code>, each able to perform completely different tasks, provided with an custom backend and no access to <code>wp-admin</code>. </p>
<p>The extra functionality each <code>user_role</code> gets to use is handled via multiple plugins. Each <code>user_role</code> interacts on t... | [
{
"answer_id": 198175,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>Sounds like you are trying hard to shot yourself and you will likely succeed. Every framework has its own... | 2015/08/10 | [
"https://wordpress.stackexchange.com/questions/198171",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68858/"
] | My application has >10 `user_roles`, each able to perform completely different tasks, provided with an custom backend and no access to `wp-admin`.
The extra functionality each `user_role` gets to use is handled via multiple plugins. Each `user_role` interacts on the same data (posts, taxonomies etc.)
The idea I had ... | Sounds like you are trying hard to shot yourself and you will likely succeed. Every framework has its own assumptions and limitation so if the assumptions of wordpress do not fit your needs then just don't use wordpress for the project.
If you (ok, probably the client) have decided that for reasons of cost, delivery ... |
198,185 | <p>During the vanilla WP core load the current user is being set up in <code>$wp-init()</code> which is after theme load and before <code>init</code> hook. This is in line with good practice of functionality getting hooked to <code>init</code> or later.</p>
<p>However it is also common practice to call related functio... | [
{
"answer_id": 198190,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>The only prerequisite for <code>current_user_can()</code> is an existing <code>wp_get_current_user()</code>. The latt... | 2015/08/10 | [
"https://wordpress.stackexchange.com/questions/198185",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/847/"
] | During the vanilla WP core load the current user is being set up in `$wp-init()` which is after theme load and before `init` hook. This is in line with good practice of functionality getting hooked to `init` or later.
However it is also common practice to call related functions, such as `current_user_can()` *earlier* ... | The only prerequisite for `current_user_can()` is an existing `wp_get_current_user()`. The latter is defined in `pluggable.php`, so you can use it after `plugins_loaded`.
The `_doing_it_wrong()` call you are citing in your question is wrong for itself. My guess is that you took that from BuddyPress or bbPress. Both ar... |
198,217 | <p>I need to display the total number of votes that have been made for a specific custom post type. Here's an example of how the <code>wp_postmeta</code> table looks for these keys/values:</p>
<pre><code>meta_id post_id meta_key meta_value
22 4 vote 4
26 6 vote 0
27 7 vote 1
32 10 vote 10
</code></pre>
<p>Suppose the... | [
{
"answer_id": 198221,
"author": "Abhik",
"author_id": 26991,
"author_profile": "https://wordpress.stackexchange.com/users/26991",
"pm_score": 2,
"selected": false,
"text": "<p>Try this, should get you started.. (not tested though) </p>\n\n<pre><code>function count_total_vote() {\n $... | 2015/08/10 | [
"https://wordpress.stackexchange.com/questions/198217",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1462/"
] | I need to display the total number of votes that have been made for a specific custom post type. Here's an example of how the `wp_postmeta` table looks for these keys/values:
```
meta_id post_id meta_key meta_value
22 4 vote 4
26 6 vote 0
27 7 vote 1
32 10 vote 10
```
Suppose the first and last rows are `wp_postmeta... | There may not be a need for a custom query, but I'd recommend it rather than hitting the database:
- once for the WP\_Query
- once more for each post entry
And then manually working out the math in PHP. Do it all at once with one MySQL statement.
```
select sum(PM.meta_value) from wp_postmeta PM
join wp_posts P on ... |
198,233 | <p>firstly i know i have to add some code explaining what i have done before.</p>
<p>But honestly i had tried more than ten tutorial concerning wordpress post slider based on flexslider or bxslider or other trics with jquery but seriously guys I don't where is the problem, i can't show slider the best thingi show is a... | [
{
"answer_id": 198221,
"author": "Abhik",
"author_id": 26991,
"author_profile": "https://wordpress.stackexchange.com/users/26991",
"pm_score": 2,
"selected": false,
"text": "<p>Try this, should get you started.. (not tested though) </p>\n\n<pre><code>function count_total_vote() {\n $... | 2015/08/10 | [
"https://wordpress.stackexchange.com/questions/198233",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69413/"
] | firstly i know i have to add some code explaining what i have done before.
But honestly i had tried more than ten tutorial concerning wordpress post slider based on flexslider or bxslider or other trics with jquery but seriously guys I don't where is the problem, i can't show slider the best thingi show is a list of p... | There may not be a need for a custom query, but I'd recommend it rather than hitting the database:
- once for the WP\_Query
- once more for each post entry
And then manually working out the math in PHP. Do it all at once with one MySQL statement.
```
select sum(PM.meta_value) from wp_postmeta PM
join wp_posts P on ... |
198,256 | <p>I have done this so many times but facing problems with meta boxes and wp_editor these days, lot of notices, errors and strange behaviour.</p>
<p>I have been able to solve problem with meta boxes notices and save . The main problem was nonce. The nonce i was using was for plugin usage. But my code is inside the the... | [
{
"answer_id": 198258,
"author": "Marek",
"author_id": 54031,
"author_profile": "https://wordpress.stackexchange.com/users/54031",
"pm_score": 1,
"selected": false,
"text": "<p>In your <code>wpt_save_performer_meta()</code> function you are iterating through <code>$performer_meta</code> ... | 2015/08/11 | [
"https://wordpress.stackexchange.com/questions/198256",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55034/"
] | I have done this so many times but facing problems with meta boxes and wp\_editor these days, lot of notices, errors and strange behaviour.
I have been able to solve problem with meta boxes notices and save . The main problem was nonce. The nonce i was using was for plugin usage. But my code is inside the theme so now... | You forgot to declare the variable `$main_detail`. Since it's a meta field you need to retrieve it first before you add it.
```
$main_detail = get_post_meta($post->ID, '_main_detail', true);
```
Also, I can see that some errors in your code.
```
echo '<label >';?><?php _e( 'short description:' );?></label>
```
... |
198,266 | <p>I have a situation where i have about 5000 imported records in a custom post type (travel) with a taxonomy category (country). Since i import from several different locations and each source seems to use a different description for some countries i want to update the term reference of that post to a uniform descript... | [
{
"answer_id": 198946,
"author": "webtoure",
"author_id": 72992,
"author_profile": "https://wordpress.stackexchange.com/users/72992",
"pm_score": 1,
"selected": false,
"text": "<p>There are quite a few steps involved here and also, with that 5000 posts figure you are mentioning, this wil... | 2015/08/11 | [
"https://wordpress.stackexchange.com/questions/198266",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77252/"
] | I have a situation where i have about 5000 imported records in a custom post type (travel) with a taxonomy category (country). Since i import from several different locations and each source seems to use a different description for some countries i want to update the term reference of that post to a uniform description... | Unfortunately webtoure's solution didn't work so i decided to dive into Wordpress's database structure and came up with the following working code:
```
global $wpdb;
$taxonomy = 'country';
$environment = 0;
function _get_term_taxonomy_id($term_id){
global $wpdb;
$results = $wpdb->get_results("
SELECT... |
198,283 | <p>I am using a custom post type that uses two taxonomies "colour" and "style". I have a script (<a href="https://stackoverflow.com/questions/31672345/sorting-custom-taxonomy-term-page-in-wordpress/">from this thread</a>) which groups them together so when you are on a colour taxonomy page they are grouped by style lik... | [
{
"answer_id": 198348,
"author": "caffeinehigh",
"author_id": 77625,
"author_profile": "https://wordpress.stackexchange.com/users/77625",
"pm_score": 0,
"selected": false,
"text": "<p>Ok, I think I have found a way of doing this. Although I must say I haven't tested it out yet and it's p... | 2015/08/11 | [
"https://wordpress.stackexchange.com/questions/198283",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77625/"
] | I am using a custom post type that uses two taxonomies "colour" and "style". I have a script ([from this thread](https://stackoverflow.com/questions/31672345/sorting-custom-taxonomy-term-page-in-wordpress/)) which groups them together so when you are on a colour taxonomy page they are grouped by style like this:
Blue ... | As I have stated in comments, this will take some work. In short, you will need the following:
* Get all the terms from the `style` taxonomy. Here we would only want the term ids
* Get the current `tax_query` from the `colour` taxonomy. Use each term from the `style` taxonomy and create a new `tax_query` to get posts ... |
198,343 | <p>For each post, I want to send an email once it has been published. The email address is stored in a custom field.</p>
<p>I have added a custom field . I have got <code>your_email</code> for the 'name'and the value is my email address (as a test).</p>
<p>I have got the following code in functions.php :</p>
<pre>... | [
{
"answer_id": 198346,
"author": "Emetrop",
"author_id": 64623,
"author_profile": "https://wordpress.stackexchange.com/users/64623",
"pm_score": 0,
"selected": false,
"text": "<p>Your code looks good. I'd bet with you that it's a problem with configuration of email sending server. Maybe ... | 2015/08/11 | [
"https://wordpress.stackexchange.com/questions/198343",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | For each post, I want to send an email once it has been published. The email address is stored in a custom field.
I have added a custom field . I have got `your_email` for the 'name'and the value is my email address (as a test).
I have got the following code in functions.php :
```
function ik_send_email($post_id){
... | Try logging out of the site and going to /wp-admin (to get to the login screen). Click on the Forgot Password link and enter your username. Did you get an email with password reset instructions? If not, that means that the email configuration (as Emetrop has suggested) may not be correct for the server. |
198,362 | <p>I've got my custom post type 'event'. I got tne next code in single-event.php:</p>
<pre><code>get_header();
the_post();
echo '<pre>';
echo "$post->ID\n";
var_dump(get_post_meta($post->ID));
echo '</pre>';
</code></pre>
<p>When I open my event page by normal URI /event/slug/, I got this:</p>
<pre... | [
{
"answer_id": 198346,
"author": "Emetrop",
"author_id": 64623,
"author_profile": "https://wordpress.stackexchange.com/users/64623",
"pm_score": 0,
"selected": false,
"text": "<p>Your code looks good. I'd bet with you that it's a problem with configuration of email sending server. Maybe ... | 2015/08/11 | [
"https://wordpress.stackexchange.com/questions/198362",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56959/"
] | I've got my custom post type 'event'. I got tne next code in single-event.php:
```
get_header();
the_post();
echo '<pre>';
echo "$post->ID\n";
var_dump(get_post_meta($post->ID));
echo '</pre>';
```
When I open my event page by normal URI /event/slug/, I got this:
```
22681
array(17) {
["_edit_lock"]=>
array(1) ... | Try logging out of the site and going to /wp-admin (to get to the login screen). Click on the Forgot Password link and enter your username. Did you get an email with password reset instructions? If not, that means that the email configuration (as Emetrop has suggested) may not be correct for the server. |
198,422 | <p>If I am on a product archive page then how can I get current product category ID in product archive page. I am using this but no result:</p>
<pre><code>global $wp_query;
$category_name = $wp_query->query_vars['product_cat'];
$category_object = get_term_by('name', $category_name, 'product_cat');
$category_id = $c... | [
{
"answer_id": 198425,
"author": "Exclutips",
"author_id": 74748,
"author_profile": "https://wordpress.stackexchange.com/users/74748",
"pm_score": 5,
"selected": false,
"text": "<p>I solve This To get the current category ID.</p>\n\n<pre><code>$cate = get_queried_object();\n$cateID = $ca... | 2015/08/12 | [
"https://wordpress.stackexchange.com/questions/198422",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74748/"
] | If I am on a product archive page then how can I get current product category ID in product archive page. I am using this but no result:
```
global $wp_query;
$category_name = $wp_query->query_vars['product_cat'];
$category_object = get_term_by('name', $category_name, 'product_cat');
$category_id = $category_object->t... | I solve This To get the current category ID.
```
$cate = get_queried_object();
$cateID = $cate->term_id;
echo $cateID;
```
and it works like a charm. |
198,435 | <p>I need to use PHP's <code>DateTime()</code>. It's currently displaying GMT time instead of the time that's set for the timezone setting (EST) in the WordPress Admin.</p>
<p>How can this be converted to show the the time base</p>
<pre><code>$time = new DateTime();
echo $time->format("Y-m-d h:i:s");
// 2015-08-1... | [
{
"answer_id": 198438,
"author": "EliasNS",
"author_id": 40743,
"author_profile": "https://wordpress.stackexchange.com/users/40743",
"pm_score": -1,
"selected": false,
"text": "<p><code>DateTime</code> aceppts a <code>DateTimeZone</code> parameter, that you can get from WordPress options... | 2015/08/12 | [
"https://wordpress.stackexchange.com/questions/198435",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1462/"
] | I need to use PHP's `DateTime()`. It's currently displaying GMT time instead of the time that's set for the timezone setting (EST) in the WordPress Admin.
How can this be converted to show the the time base
```
$time = new DateTime();
echo $time->format("Y-m-d h:i:s");
// 2015-08-12 04:35:34 (gmt)
// 2015-08-12 12:3... | I'm not sure why EliasNS' answer is marked correct, as far as I'm aware (and from the [documentation](http://es1.php.net/manual/en/datetime.construct.php)), the second parameter of `DateTime::__construct()`, if provided, should be a `DateTimeZone` instance.
The problem then becomes, how we do we create a `DateTimeZone... |
198,447 | <p>Within the WooCommerce template file "content-product.php", I'm trying to overwrite the following action hook:</p>
<pre><code>/**
* woocommerce_shop_loop_item_title hook
*
* @hooked woocommerce_template_loop_product_title - 10
*/
do_action( 'woocommerce_shop_loop_item_title' );
</code></pre>
<p>To overwrite this h... | [
{
"answer_id": 198449,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 0,
"selected": false,
"text": "<p>in WordPress, you cannot just \"overwrite\" a hook (that's works only for pluggable functions)</p>\n\n<p>but, you... | 2015/08/12 | [
"https://wordpress.stackexchange.com/questions/198447",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37548/"
] | Within the WooCommerce template file "content-product.php", I'm trying to overwrite the following action hook:
```
/**
* woocommerce_shop_loop_item_title hook
*
* @hooked woocommerce_template_loop_product_title - 10
*/
do_action( 'woocommerce_shop_loop_item_title' );
```
To overwrite this hook, I have added the foll... | It's actually pretty simple to change the title in content-product.php, but you won't be able to do it with a hook. Near the top of the file, you should see this line:
```
Override this template by copying it to yourtheme/woocommerce/content-product.php
```
All you have to do is copy the file to the above directory,... |
198,461 | <p>I created a WordPress plugin using OOP. If the plugin hasn't been activated and a method is called in a theme file, it throws the PHP fatal error "call to undefined function".</p>
<p>What is the correct way of doing this in the event the plugin hasn't been enabled?</p>
<p>Should a check be made in every file where... | [
{
"answer_id": 198449,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 0,
"selected": false,
"text": "<p>in WordPress, you cannot just \"overwrite\" a hook (that's works only for pluggable functions)</p>\n\n<p>but, you... | 2015/08/12 | [
"https://wordpress.stackexchange.com/questions/198461",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1462/"
] | I created a WordPress plugin using OOP. If the plugin hasn't been activated and a method is called in a theme file, it throws the PHP fatal error "call to undefined function".
What is the correct way of doing this in the event the plugin hasn't been enabled?
Should a check be made in every file where it's used within... | It's actually pretty simple to change the title in content-product.php, but you won't be able to do it with a hook. Near the top of the file, you should see this line:
```
Override this template by copying it to yourtheme/woocommerce/content-product.php
```
All you have to do is copy the file to the above directory,... |
198,500 | <p>I've been trying around a lot to get this working, however every method I tried just didn't want to do as I wanted it to. So here I am.</p>
<p>I have a login-Mask that's only visible if the user is not logged in but it's permanently visible and covers some important areas. So here's my idea: hide it via toggle.</p>... | [
{
"answer_id": 198595,
"author": "junkrig",
"author_id": 54989,
"author_profile": "https://wordpress.stackexchange.com/users/54989",
"pm_score": 0,
"selected": false,
"text": "<p>I think you are pretty much there. In your JavaScript you are referencing log_forms as a class, but in your H... | 2015/08/13 | [
"https://wordpress.stackexchange.com/questions/198500",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63130/"
] | I've been trying around a lot to get this working, however every method I tried just didn't want to do as I wanted it to. So here I am.
I have a login-Mask that's only visible if the user is not logged in but it's permanently visible and covers some important areas. So here's my idea: hide it via toggle.
I know it's ... | You are calling jQuery wrong by the shorthand `$`. If you will look in your console you will see an error that `$` is not a function / undeclared etc (this is due to jQuery's conflict mode if I am not wrong).
Your code should look something like this:
```
<script type="text/javascript">
jQuery(function($) {
$( "a... |
198,502 | <p>I'm trying to make a query for users using <code>WP_User_Query()</code>
I need to filter users by role <code>shop_manager</code> and custom taxonomy called <code>shop-category</code> and current taxonomy term ID.</p>
<p>The code I have so far:</p>
<pre><code><?php
// WP_User_Query arguments
$args = array (
... | [
{
"answer_id": 198510,
"author": "webtoure",
"author_id": 72992,
"author_profile": "https://wordpress.stackexchange.com/users/72992",
"pm_score": 2,
"selected": false,
"text": "<p>There is no <code>tax_query</code> parameter for the <code>WP_User_Query</code> class. Since you've tagged t... | 2015/08/13 | [
"https://wordpress.stackexchange.com/questions/198502",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77725/"
] | I'm trying to make a query for users using `WP_User_Query()`
I need to filter users by role `shop_manager` and custom taxonomy called `shop-category` and current taxonomy term ID.
The code I have so far:
```
<?php
// WP_User_Query arguments
$args = array (
'role' => 'shop_manager',
'order' ... | Apparently there is no core implementation of `'tax_query'` in `WP_User_Query` yet.
Check the ticket here for more info --> <https://core.trac.wordpress.org/ticket/31383>
Nevertheless there is an alternative way using `get_objects_in_term`
```
$taxonomy = 'shop-category';
$users = get_objects_in_term( $term_id, $tax... |
198,560 | <p>I have a page called "News", and I have created a custom post type for news. In "News" page I need to show all news custom posts and they need to be clickable. "News" page url is <a href="http://example.com/media/lajmet" rel="nofollow">http://example.com/media/lajmet</a>. When I click on news it goes on url "<a href... | [
{
"answer_id": 198566,
"author": "Kevin Fodness",
"author_id": 77460,
"author_profile": "https://wordpress.stackexchange.com/users/77460",
"pm_score": 0,
"selected": false,
"text": "<p>You can do it, but it's not straightforward. When you register a custom post type in WordPress, the fir... | 2015/08/13 | [
"https://wordpress.stackexchange.com/questions/198560",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44921/"
] | I have a page called "News", and I have created a custom post type for news. In "News" page I need to show all news custom posts and they need to be clickable. "News" page url is <http://example.com/media/lajmet>. When I click on news it goes on url "<http://example.com/news/article1>". How to rewrite URL on custom pos... | You can set the `rewrite` `slug` when you [register your post type](https://codex.wordpress.org/Function_Reference/register_post_type):
```
$args = array(
'rewrite' => array( 'slug' => 'media/lajmet' )
// other args...
);
``` |
198,563 | <p>I have a wierd problem.
If I inspect my WP pages using chrome element inspector I see two body tags thus:</p>
<pre><code><body cz-shortcut-listen="true">
<body>
</code></pre>
<p>This bit is to do with colorzilla (cz-shortcut-listen="true") in firebug it disappears. you have just 2 body tags with n... | [
{
"answer_id": 198649,
"author": "Kevin Fodness",
"author_id": 77460,
"author_profile": "https://wordpress.stackexchange.com/users/77460",
"pm_score": 1,
"selected": true,
"text": "<p>I think this is the browser modifying the DOM due to a weird character you have in your body tag. When I... | 2015/08/13 | [
"https://wordpress.stackexchange.com/questions/198563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77748/"
] | I have a wierd problem.
If I inspect my WP pages using chrome element inspector I see two body tags thus:
```
<body cz-shortcut-listen="true">
<body>
```
This bit is to do with colorzilla (cz-shortcut-listen="true") in firebug it disappears. you have just 2 body tags with no classes.
The issue is not about the ... | I think this is the browser modifying the DOM due to a weird character you have in your body tag. When I view source in Firefox, I'm seeing the "character not recognized" box next to the body tag. This is also visible in Firefox inspector.
Modern browsers automatically fix issues in your HTML for you when rendering th... |
198,598 | <p>I am looking to echo the most recent post in the loop of content. Only 1 post.</p>
<p>Do I need to put some sort of parameter on the following code:</p>
<pre><code>if (have_posts()) :
while (have_posts()) :
the_post();
the_content();
endwhile;
endif;
</code></pre>
<p>How could I do t... | [
{
"answer_id": 198649,
"author": "Kevin Fodness",
"author_id": 77460,
"author_profile": "https://wordpress.stackexchange.com/users/77460",
"pm_score": 1,
"selected": true,
"text": "<p>I think this is the browser modifying the DOM due to a weird character you have in your body tag. When I... | 2015/08/14 | [
"https://wordpress.stackexchange.com/questions/198598",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58657/"
] | I am looking to echo the most recent post in the loop of content. Only 1 post.
Do I need to put some sort of parameter on the following code:
```
if (have_posts()) :
while (have_posts()) :
the_post();
the_content();
endwhile;
endif;
```
How could I do this? | I think this is the browser modifying the DOM due to a weird character you have in your body tag. When I view source in Firefox, I'm seeing the "character not recognized" box next to the body tag. This is also visible in Firefox inspector.
Modern browsers automatically fix issues in your HTML for you when rendering th... |
198,601 | <p>Is there any way to style the message delivered by wp_debug?</p>
<p>Whenever I set WP_Debug to true, it pushes all my content down the page. While I admit it's easy to just set it back to false after using it, it can be somewhat tedious switching it on and off when it's needed.</p>
<p>Is there a way to style the m... | [
{
"answer_id": 198604,
"author": "Charles",
"author_id": 15605,
"author_profile": "https://wordpress.stackexchange.com/users/15605",
"pm_score": 2,
"selected": false,
"text": "<p>You could add following code (if not done already) in <code>wp-config.php</code> (please make a backup first ... | 2015/08/14 | [
"https://wordpress.stackexchange.com/questions/198601",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64387/"
] | Is there any way to style the message delivered by wp\_debug?
Whenever I set WP\_Debug to true, it pushes all my content down the page. While I admit it's easy to just set it back to false after using it, it can be somewhat tedious switching it on and off when it's needed.
Is there a way to style the message it creat... | You could add following code (if not done already) in `wp-config.php` (please make a backup first of this file):
```
define('WP_DEBUG', true);
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
```
This way `debug` is activated but the results (if have errors/notices) will not be shown but will b... |
198,610 | <p>I have a custom post type (speaker) and I would like to load the list of speakers sorted by last name. I can't seem to figure it out. I tried the code from this post: <a href="https://stackoverflow.com/questions/16416217/wordpress-orderby-last-word-in-title">https://stackoverflow.com/questions/16416217/wordpress-o... | [
{
"answer_id": 198624,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 5,
"selected": true,
"text": "<h2>Order by the last word in the post title</h2>\n\n<p>To order by the <em>speaker's last name</em>, you can use... | 2015/08/14 | [
"https://wordpress.stackexchange.com/questions/198610",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77767/"
] | I have a custom post type (speaker) and I would like to load the list of speakers sorted by last name. I can't seem to figure it out. I tried the code from this post: <https://stackoverflow.com/questions/16416217/wordpress-orderby-last-word-in-title>
but it didn't seem to work.
```
add_action( 'init', 'create_post_ty... | Order by the last word in the post title
----------------------------------------
To order by the *speaker's last name*, you can use the following setup (PHP 5.4+):
```
// args
$args = [
'posts_per_page' => 10,
'post_type' => 'speaker',
'meta_key' => 'speaker-front-page',
'meta_valu... |
198,620 | <p>I tried to add arrow down when the menu has a sub-menus. But the down arrow not showing up. Please help me.</p>
<p>Here's the link: <a href="http://bit.ly/1UH4FlT" rel="nofollow">http://bit.ly/1UH4FlT</a></p>
<p>Currently using this script that I found somewhere.</p>
<pre><code>function add_menu_parent_class( $it... | [
{
"answer_id": 198631,
"author": "vivek mengu",
"author_id": 77782,
"author_profile": "https://wordpress.stackexchange.com/users/77782",
"pm_score": 3,
"selected": true,
"text": "<p>Add below code</p>\n\n<pre><code>#site-navigation .menu > ul > li.menu-item-has-children > a::aft... | 2015/08/14 | [
"https://wordpress.stackexchange.com/questions/198620",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62417/"
] | I tried to add arrow down when the menu has a sub-menus. But the down arrow not showing up. Please help me.
Here's the link: <http://bit.ly/1UH4FlT>
Currently using this script that I found somewhere.
```
function add_menu_parent_class( $items ) {
$parents = array();
foreach ( $items as $item ) {
if ( $item->curre... | Add below code
```
#site-navigation .menu > ul > li.menu-item-has-children > a::after {
content: '\f107';
font-family: FontAwesome;
font-size: 10px;
margin-left: 10px;
vertical-align: 1px;
}
#site-navigation .menu > ul > li > ul > li.menu-item-has-children > a::after {
color: rgb(34, 34, 34);
content: '\f105';
font-f... |
198,634 | <p>I have a very simple WordPress plugin that shows a menu/admin page. The page contains Glyphicons - Font Awesome.</p>
<p>These glyphicons are never showing. I cannot figure out why because I know the font-awesome css file is being loaded correctly and I know that the admin pages HTML works fine outside of a wordpres... | [
{
"answer_id": 198631,
"author": "vivek mengu",
"author_id": 77782,
"author_profile": "https://wordpress.stackexchange.com/users/77782",
"pm_score": 3,
"selected": true,
"text": "<p>Add below code</p>\n\n<pre><code>#site-navigation .menu > ul > li.menu-item-has-children > a::aft... | 2015/08/14 | [
"https://wordpress.stackexchange.com/questions/198634",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75260/"
] | I have a very simple WordPress plugin that shows a menu/admin page. The page contains Glyphicons - Font Awesome.
These glyphicons are never showing. I cannot figure out why because I know the font-awesome css file is being loaded correctly and I know that the admin pages HTML works fine outside of a wordpress plugin a... | Add below code
```
#site-navigation .menu > ul > li.menu-item-has-children > a::after {
content: '\f107';
font-family: FontAwesome;
font-size: 10px;
margin-left: 10px;
vertical-align: 1px;
}
#site-navigation .menu > ul > li > ul > li.menu-item-has-children > a::after {
color: rgb(34, 34, 34);
content: '\f105';
font-f... |
198,655 | <p>I'm having an issue with me rewrite rule works fine here:</p>
<p>example.com/resources/<br>
example.com/resources/articles/</p>
<p>but when i use pagination to the next page i get a 404 here:</p>
<p>example.com//resources/articles/page/2/<br>
example.com//resources/articles/page/3/<br>
example.com//resources/arti... | [
{
"answer_id": 198631,
"author": "vivek mengu",
"author_id": 77782,
"author_profile": "https://wordpress.stackexchange.com/users/77782",
"pm_score": 3,
"selected": true,
"text": "<p>Add below code</p>\n\n<pre><code>#site-navigation .menu > ul > li.menu-item-has-children > a::aft... | 2015/08/14 | [
"https://wordpress.stackexchange.com/questions/198655",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77788/"
] | I'm having an issue with me rewrite rule works fine here:
example.com/resources/
example.com/resources/articles/
but when i use pagination to the next page i get a 404 here:
example.com//resources/articles/page/2/
example.com//resources/articles/page/3/
example.com//resources/articles/page/4/
I was able to... | Add below code
```
#site-navigation .menu > ul > li.menu-item-has-children > a::after {
content: '\f107';
font-family: FontAwesome;
font-size: 10px;
margin-left: 10px;
vertical-align: 1px;
}
#site-navigation .menu > ul > li > ul > li.menu-item-has-children > a::after {
color: rgb(34, 34, 34);
content: '\f105';
font-f... |
198,667 | <p>I want to automate updating plugin options. There are some things that I repeat a lot.</p>
<p>With <a href="http://wp-cli.org">wp-cli</a> I know I can update simple options like this:</p>
<pre><code>php wp-cli.phar option update blog_public 1
</code></pre>
<p>However, some plugin options save their options in a s... | [
{
"answer_id": 198673,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 0,
"selected": false,
"text": "<p>The <a href=\"http://wp-cli.org/\" rel=\"nofollow\">WP-CLI</a> command <a href=\"http://wp-cli.org/... | 2015/08/14 | [
"https://wordpress.stackexchange.com/questions/198667",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75628/"
] | I want to automate updating plugin options. There are some things that I repeat a lot.
With [wp-cli](http://wp-cli.org) I know I can update simple options like this:
```
php wp-cli.phar option update blog_public 1
```
However, some plugin options save their options in a serialized string.
Example of serialized op... | WP-CLI is definitely the answer to this after the update to 1.4.0 which introduced the [pluck](https://developer.wordpress.org/cli/commands/option/pluck/) and [patch](https://developer.wordpress.org/cli/commands/option/patch/) commands for accessing serialized data in WordPress.
The pluck command takes this format for... |
198,681 | <p>I am trying to confirm if a filter I have applied has changed the wp_login_url to the correct address. I just want to print out the result of wp_login_url somewhere I can see it.</p>
<pre><code>if ( has_shortcode( $post->post_content, 'clean-login' ) ) {
add_filter('login_url', get_permalink( $post->I... | [
{
"answer_id": 198673,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 0,
"selected": false,
"text": "<p>The <a href=\"http://wp-cli.org/\" rel=\"nofollow\">WP-CLI</a> command <a href=\"http://wp-cli.org/... | 2015/08/14 | [
"https://wordpress.stackexchange.com/questions/198681",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77144/"
] | I am trying to confirm if a filter I have applied has changed the wp\_login\_url to the correct address. I just want to print out the result of wp\_login\_url somewhere I can see it.
```
if ( has_shortcode( $post->post_content, 'clean-login' ) ) {
add_filter('login_url', get_permalink( $post->ID ), 10, 2);
... | WP-CLI is definitely the answer to this after the update to 1.4.0 which introduced the [pluck](https://developer.wordpress.org/cli/commands/option/pluck/) and [patch](https://developer.wordpress.org/cli/commands/option/patch/) commands for accessing serialized data in WordPress.
The pluck command takes this format for... |
198,689 | <p>I'm creating a widget, and cannot figure out how to get an event right before the person clicks "save" or presses the enter button on the widget admin panel. What would be the javascript code to get the event on the widget admins' form submit? </p>
<p>Example:
<a href="https://i.stack.imgur.com/zkhjg.png" rel="nofo... | [
{
"answer_id": 198864,
"author": "webtoure",
"author_id": 72992,
"author_profile": "https://wordpress.stackexchange.com/users/72992",
"pm_score": 4,
"selected": true,
"text": "<p>You need to listen for the <code>click</code> event (there is no such thing as a pre/before click) and do som... | 2015/08/15 | [
"https://wordpress.stackexchange.com/questions/198689",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2001/"
] | I'm creating a widget, and cannot figure out how to get an event right before the person clicks "save" or presses the enter button on the widget admin panel. What would be the javascript code to get the event on the widget admins' form submit?
Example:
[ and do some work right then or figure out if you want to allow the `click` to "go through" or not based on some validation for example.
```
jQuery(function($) {
// We are binding to the body so that the code
// will work fo... |
198,693 | <p>I have a widget form with custom fields like age,pincode etc.The submitted form data will be submitted through a 3rd party API which will output me JSON. Now I want to redirect to a page showing the results.How can i redirect to a page from the widget with the result.?</p>
| [
{
"answer_id": 198864,
"author": "webtoure",
"author_id": 72992,
"author_profile": "https://wordpress.stackexchange.com/users/72992",
"pm_score": 4,
"selected": true,
"text": "<p>You need to listen for the <code>click</code> event (there is no such thing as a pre/before click) and do som... | 2015/08/15 | [
"https://wordpress.stackexchange.com/questions/198693",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77808/"
] | I have a widget form with custom fields like age,pincode etc.The submitted form data will be submitted through a 3rd party API which will output me JSON. Now I want to redirect to a page showing the results.How can i redirect to a page from the widget with the result.? | You need to listen for the `click` event (there is no such thing as a pre/before click) and do some work right then or figure out if you want to allow the `click` to "go through" or not based on some validation for example.
```
jQuery(function($) {
// We are binding to the body so that the code
// will work fo... |
198,781 | <p>So I have been reading through every WordPress front-end AJAX file upload tutorial I can fine. Nothing is working for me at the moment. The one that makes the most sense to me is this one: <a href="http://theaveragedev.com/wordpress-files-ajax/" rel="noreferrer">http://theaveragedev.com/wordpress-files-ajax/</a></p>... | [
{
"answer_id": 263934,
"author": "Adnan Limdiwala",
"author_id": 85960,
"author_profile": "https://wordpress.stackexchange.com/users/85960",
"pm_score": 4,
"selected": false,
"text": "<p>Hi You have Use this COde For WordPress front-end AJAX file upload tutorial Code\nHere is my code:</p... | 2015/08/16 | [
"https://wordpress.stackexchange.com/questions/198781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77850/"
] | So I have been reading through every WordPress front-end AJAX file upload tutorial I can fine. Nothing is working for me at the moment. The one that makes the most sense to me is this one: <http://theaveragedev.com/wordpress-files-ajax/>
Here is my code:
In my template file example.php
```
<script>var ajax_url = "<?... | Hi You have Use this COde For WordPress front-end AJAX file upload tutorial Code
Here is my code:
In my template file example.php
```
<form enctype="multipart/form-data">
<input type="text" name="support_title" class="support-title">
<input type="file" id="sortpicture" name="upload">
<input class="save-suppo... |
198,792 | <p>I am trying to limit the files that are shown in the wordpress media library popup (from wp_editor). </p>
<p><em>Currently every single file that I have ever uploaded to my site is shown in the library but I would like to limit what users see to just files uploaded in the last 24 hours.</em></p>
<p>It is possible ... | [
{
"answer_id": 198809,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p>You can adjust the <em>attachment query</em> in the media library popup, through the <code>ajax_query_attachme... | 2015/08/16 | [
"https://wordpress.stackexchange.com/questions/198792",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25609/"
] | I am trying to limit the files that are shown in the wordpress media library popup (from wp\_editor).
*Currently every single file that I have ever uploaded to my site is shown in the library but I would like to limit what users see to just files uploaded in the last 24 hours.*
It is possible to limit the media libr... | You can adjust the *attachment query* in the media library popup, through the `ajax_query_attachments_args` filter.
Here are two PHP 5.4+ examples:
**Example #1:**
Show only attachments that where uploaded during the last 24 hours:
```
/**
* Media Library popup
* - Only display attachments uploaded during the la... |
198,824 | <p>I am trying to create custom menu nav walker. I added below code </p>
<pre><code>function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output )
{
$id_field = $this->db_fields['id'];
if ( is_object( $args[0] ) ) {
$args[0]->has_children = ! empty( $chil... | [
{
"answer_id": 199847,
"author": "Jorge Raigoza",
"author_id": 74600,
"author_profile": "https://wordpress.stackexchange.com/users/74600",
"pm_score": 3,
"selected": true,
"text": "<p>I have the same issue. Some answers claim that you can use <code>$args->has_children</code> or <code>... | 2015/08/17 | [
"https://wordpress.stackexchange.com/questions/198824",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77480/"
] | I am trying to create custom menu nav walker. I added below code
```
function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output )
{
$id_field = $this->db_fields['id'];
if ( is_object( $args[0] ) ) {
$args[0]->has_children = ! empty( $children_elements[$element->$id_... | I have the same issue. Some answers claim that you can use `$args->has_children` or `$args[0]->has_children`, but it's never added to $args. Sometimes, `has_children` is added under `$args->walker->has_children`, but it's always set to `false`, in other words, useless...
As a work around, the current template that I'm... |
198,837 | <p>I am new to PHP and WordPress.<br></p>
<p>I have this scenario.<br>
There are 4 custom fields saved in page, named: <br>
_custField1<br>
_custField2<br>
_custField3<br>
_custField4<br></p>
<p>What I need to do now is to fetch their values and save them in an array and save that array back to page as custom field.<... | [
{
"answer_id": 199847,
"author": "Jorge Raigoza",
"author_id": 74600,
"author_profile": "https://wordpress.stackexchange.com/users/74600",
"pm_score": 3,
"selected": true,
"text": "<p>I have the same issue. Some answers claim that you can use <code>$args->has_children</code> or <code>... | 2015/08/17 | [
"https://wordpress.stackexchange.com/questions/198837",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77888/"
] | I am new to PHP and WordPress.
I have this scenario.
There are 4 custom fields saved in page, named:
\_custField1
\_custField2
\_custField3
\_custField4
What I need to do now is to fetch their values and save them in an array and save that array back to page as custom field.
I tried following.
`... | I have the same issue. Some answers claim that you can use `$args->has_children` or `$args[0]->has_children`, but it's never added to $args. Sometimes, `has_children` is added under `$args->walker->has_children`, but it's always set to `false`, in other words, useless...
As a work around, the current template that I'm... |
198,880 | <p>I tried to migrate my old blogs to a new server. The domain remained the same (it was also transfered to the new server). To perform this task I tried to follow these steps: <a href="https://codex.wordpress.org/Moving_WordPress#Keeping_Your_Domain_Name_and_URLs" rel="nofollow">https://codex.wordpress.org/Moving_Word... | [
{
"answer_id": 198881,
"author": "Dale Allen",
"author_id": 77912,
"author_profile": "https://wordpress.stackexchange.com/users/77912",
"pm_score": 0,
"selected": false,
"text": "<p>If the old blog and new blog have different domains then they didn't not remain the same. Share:</p>\n\n<u... | 2015/08/17 | [
"https://wordpress.stackexchange.com/questions/198880",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4544/"
] | I tried to migrate my old blogs to a new server. The domain remained the same (it was also transfered to the new server). To perform this task I tried to follow these steps: <https://codex.wordpress.org/Moving_WordPress#Keeping_Your_Domain_Name_and_URLs>
When I now visit the moved blogs, I get nothing more than the "i... | You may not have configured Apache. Add this line in your `apache2.conf` file:
```
AddType application/x-httpd-php .php .htm .html
```
Evidently, you should make sure you actually have [installed and activated the PHP module](http://php.net/manual/en/install.unix.debian.php) first and foremost (the above Apache dire... |
198,904 | <p>I have a wordpress site, against which I ran a penetration testing tool (debug mode was on at the time)</p>
<p>It reported a (medium severity) issue in that errors were being displayed, and cited</p>
<blockquote>
<p><code>/wp-login.php?redirect_to[]=blah</code> </p>
<p>as triggering a warning: <code>urlenco... | [
{
"answer_id": 198881,
"author": "Dale Allen",
"author_id": 77912,
"author_profile": "https://wordpress.stackexchange.com/users/77912",
"pm_score": 0,
"selected": false,
"text": "<p>If the old blog and new blog have different domains then they didn't not remain the same. Share:</p>\n\n<u... | 2015/08/18 | [
"https://wordpress.stackexchange.com/questions/198904",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77928/"
] | I have a wordpress site, against which I ran a penetration testing tool (debug mode was on at the time)
It reported a (medium severity) issue in that errors were being displayed, and cited
>
> `/wp-login.php?redirect_to[]=blah`
>
>
> as triggering a warning: `urlencode()` expects parameter 1 to be string,
> arra... | You may not have configured Apache. Add this line in your `apache2.conf` file:
```
AddType application/x-httpd-php .php .htm .html
```
Evidently, you should make sure you actually have [installed and activated the PHP module](http://php.net/manual/en/install.unix.debian.php) first and foremost (the above Apache dire... |
198,906 | <p>After my WordPress site was updated to 4.2.4, my PayPal buttons no longer work. I can SEE the buttons, but can't click on them and go to PayPal. Hovering over the button shows no web link. I've recopied the code from PayPal several times, to no avail. </p>
<p>I notice that the (form) command gets screwed up every t... | [
{
"answer_id": 198881,
"author": "Dale Allen",
"author_id": 77912,
"author_profile": "https://wordpress.stackexchange.com/users/77912",
"pm_score": 0,
"selected": false,
"text": "<p>If the old blog and new blog have different domains then they didn't not remain the same. Share:</p>\n\n<u... | 2015/08/18 | [
"https://wordpress.stackexchange.com/questions/198906",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77933/"
] | After my WordPress site was updated to 4.2.4, my PayPal buttons no longer work. I can SEE the buttons, but can't click on them and go to PayPal. Hovering over the button shows no web link. I've recopied the code from PayPal several times, to no avail.
I notice that the (form) command gets screwed up every time I save... | You may not have configured Apache. Add this line in your `apache2.conf` file:
```
AddType application/x-httpd-php .php .htm .html
```
Evidently, you should make sure you actually have [installed and activated the PHP module](http://php.net/manual/en/install.unix.debian.php) first and foremost (the above Apache dire... |
198,943 | <p>WordPress already has a default URL for jQuery-WordPress application calls and it's well known as the <code>ajaxurl</code>. However, there are cases wherein one would need to enable <strong>Cross-Origin Resource Sharing</strong> (CORS) on it such that any hostname will be able to access using it.</p>
<p>My current ... | [
{
"answer_id": 198961,
"author": "Sundar",
"author_id": 75205,
"author_profile": "https://wordpress.stackexchange.com/users/75205",
"pm_score": 1,
"selected": false,
"text": "<p>You can achieve it by the following code. </p>\n\n<p>Open you <strong>header.php</strong> </p>\n\n<p>find the ... | 2015/08/18 | [
"https://wordpress.stackexchange.com/questions/198943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58915/"
] | WordPress already has a default URL for jQuery-WordPress application calls and it's well known as the `ajaxurl`. However, there are cases wherein one would need to enable **Cross-Origin Resource Sharing** (CORS) on it such that any hostname will be able to access using it.
My current solutions is by adding a line in `... | Milo is correct.
For instance, go to your theme's functions.php file, and add the following:
```
add_filter( 'allowed_http_origins', 'add_allowed_origins' );
function add_allowed_origins( $origins ) {
$origins[] = 'https://site1.example.com';
$origins[] = 'https://site2.example.com';
return $origins;
}
`... |
198,950 | <p>I use a <code>get_posts()</code> call with these arguments:</p>
<pre><code>array(6) {
["include"]=> string(14) "1633,1634,1635"
["post_status"]=> string(3) "any"
["post_type"]=> string(10) "attachment"
["post_mime_type"]=> string(5) "image"
["order"]=> string(3) "ASC"
["orderb... | [
{
"answer_id": 198961,
"author": "Sundar",
"author_id": 75205,
"author_profile": "https://wordpress.stackexchange.com/users/75205",
"pm_score": 1,
"selected": false,
"text": "<p>You can achieve it by the following code. </p>\n\n<p>Open you <strong>header.php</strong> </p>\n\n<p>find the ... | 2015/08/18 | [
"https://wordpress.stackexchange.com/questions/198950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28069/"
] | I use a `get_posts()` call with these arguments:
```
array(6) {
["include"]=> string(14) "1633,1634,1635"
["post_status"]=> string(3) "any"
["post_type"]=> string(10) "attachment"
["post_mime_type"]=> string(5) "image"
["order"]=> string(3) "ASC"
["orderby"]=> string(8) "post__in"
}
```
While... | Milo is correct.
For instance, go to your theme's functions.php file, and add the following:
```
add_filter( 'allowed_http_origins', 'add_allowed_origins' );
function add_allowed_origins( $origins ) {
$origins[] = 'https://site1.example.com';
$origins[] = 'https://site2.example.com';
return $origins;
}
`... |
198,981 | <p>So I have created a custom post type and under that taxonomy named "Category" which serves for categories. How can I list all the categories from there?</p>
| [
{
"answer_id": 198985,
"author": "artist learning to code",
"author_id": 34034,
"author_profile": "https://wordpress.stackexchange.com/users/34034",
"pm_score": 2,
"selected": false,
"text": "<p>If you just want to list them you can use the get_terms function:</p>\n\n<pre><code>$terms = ... | 2015/08/18 | [
"https://wordpress.stackexchange.com/questions/198981",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77967/"
] | So I have created a custom post type and under that taxonomy named "Category" which serves for categories. How can I list all the categories from there? | If you just want to list them you can use the get\_terms function:
```
$terms = get_terms( 'my_taxonomy' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
echo '<ul>';
foreach ( $terms as $term ) {
echo '<li>' . $term->name . '</li>';
}
echo '</ul>';
}
```
Read the codex, it has a lot of examples:
<htt... |
199,070 | <p>I'm trying to return a custom field as soon as a post gets published. I'm using the <code>publish_post</code> (or <code>{status}_{post_type}</code>) action, but it looks like the custom fields are created after the hook.</p>
<p>My code in <code>functions.php</code>:</p>
<pre><code>function create_recurring_posts( ... | [
{
"answer_id": 199077,
"author": "David",
"author_id": 31323,
"author_profile": "https://wordpress.stackexchange.com/users/31323",
"pm_score": 2,
"selected": false,
"text": "<p>Your action is triggered in <code>wp_transition_post_status()</code> which gets called by <code>wp_insert_post(... | 2015/08/19 | [
"https://wordpress.stackexchange.com/questions/199070",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78023/"
] | I'm trying to return a custom field as soon as a post gets published. I'm using the `publish_post` (or `{status}_{post_type}`) action, but it looks like the custom fields are created after the hook.
My code in `functions.php`:
```
function create_recurring_posts( $ID, $post ) {
logMe(print_r(get_post_custom($ID),... | Your action is triggered in `wp_transition_post_status()` which gets called by `wp_insert_post()` *before* the action `save_post` is triggered. `save_post` is the typical action to handle custom fields. ACF also works on this.
Basically you have to wait until ACF is done with its stuff, means you'll have to hook to `... |
199,072 | <p>This error only happened this morning as I updated my wordpress site to version 4.3. Two other sites on the same hosting ( and all using CPanel as an admin portal for the hosting) are not having any problem. On this one problematic site company.com though on the wordpress admin portal and the live site there is an e... | [
{
"answer_id": 199098,
"author": "bishless",
"author_id": 31169,
"author_profile": "https://wordpress.stackexchange.com/users/31169",
"pm_score": 0,
"selected": false,
"text": "<p>I was in a similar boat (first had to fix some custom widgets in a theme), but had the message even after fi... | 2015/08/19 | [
"https://wordpress.stackexchange.com/questions/199072",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77953/"
] | This error only happened this morning as I updated my wordpress site to version 4.3. Two other sites on the same hosting ( and all using CPanel as an admin portal for the hosting) are not having any problem. On this one problematic site company.com though on the wordpress admin portal and the live site there is an erro... | The error isn't actually caused by your PHP version (PHP 4 constructors won't be removed until PHP 7) - it's a warning produced by WordPress in preparation for this. Each repetition of the error represents a plugin using the outdated code.
Until your plugins' authors update them, you can run the following shell comman... |
199,086 | <p>What is the best way to pass some information from <code>functions.php</code> to a plugin?</p>
<p>I need to give a user the ability to <em>pass</em> a piece of data <em>from</em> their <code>functions.php</code> file <em>to</em> my plugin. (It can be any data, just something that I can check for; it can be a variab... | [
{
"answer_id": 199087,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>This is the correct method - except the function is <code>apply_filters</code>, not apply_filter. Hence your... | 2015/08/19 | [
"https://wordpress.stackexchange.com/questions/199086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60192/"
] | What is the best way to pass some information from `functions.php` to a plugin?
I need to give a user the ability to *pass* a piece of data *from* their `functions.php` file *to* my plugin. (It can be any data, just something that I can check for; it can be a variable's value, or even the fact that a variable was set ... | Plugins are loaded before the theme which means that your `apply_filters` won't have any actual callbacks registered to it. Instead, you need to call your `apply_filters` sometime after the theme has been loaded. Something like this:
```
/* Your plugin's file: */
add_action( 'init', 'my_lovely_funky_filters' );
func... |
199,111 | <p>I have a little problem that I can not solve. I have a website "multi-site" system with ADS script. I wish I could enter leaderboard banner.</p>
<p>This is an example script:</p>
<pre><code><div id=""><script src=""></script><script src="" ></script></div>
</code></pre>
<p>i ha... | [
{
"answer_id": 199087,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>This is the correct method - except the function is <code>apply_filters</code>, not apply_filter. Hence your... | 2015/08/19 | [
"https://wordpress.stackexchange.com/questions/199111",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78038/"
] | I have a little problem that I can not solve. I have a website "multi-site" system with ADS script. I wish I could enter leaderboard banner.
This is an example script:
```
<div id=""><script src=""></script><script src="" ></script></div>
```
i have insert this code script is work, but the problem is that it appear... | Plugins are loaded before the theme which means that your `apply_filters` won't have any actual callbacks registered to it. Instead, you need to call your `apply_filters` sometime after the theme has been loaded. Something like this:
```
/* Your plugin's file: */
add_action( 'init', 'my_lovely_funky_filters' );
func... |
199,114 | <p>I have a custom post type that is an Event.</p>
<p>I'm trying to query those Events and only return Events that are in the current month or later. So the event could be in the past, but it has to be in the same month. The event date is a custom field.</p>
<p>So right now I would only want events that were in the m... | [
{
"answer_id": 199122,
"author": "Marek",
"author_id": 54031,
"author_profile": "https://wordpress.stackexchange.com/users/54031",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <code>meta_query</code>, if you date information is saved in custom field. Like this:</p>\n\n<pre><... | 2015/08/20 | [
"https://wordpress.stackexchange.com/questions/199114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75134/"
] | I have a custom post type that is an Event.
I'm trying to query those Events and only return Events that are in the current month or later. So the event could be in the past, but it has to be in the same month. The event date is a custom field.
So right now I would only want events that were in the month of August or... | You can use `meta_query`, if you date information is saved in custom field. Like this:
```
$args = array(
'post_type' => $custom_post_type,
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'event_date_and_time',
'value' => current_time('Ymd'),
'comp... |
199,141 | <p>I have some problems to asign a class to tag with wp_nav_menu() instead of asign the class to the tag it creates a and asign the class to that one.</p>
<p>My register_nav_menu function:</p>
<pre><code> function register_primary_menu() {
register_nav_menu('primary-menu', __('Primary Menu'));
}
add_action(... | [
{
"answer_id": 199143,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": -1,
"selected": true,
"text": "<p>Make sure your menu does setup correctly in that location in Appearance / Menus, unless it wont display that c... | 2015/08/20 | [
"https://wordpress.stackexchange.com/questions/199141",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66256/"
] | I have some problems to asign a class to tag with wp\_nav\_menu() instead of asign the class to the tag it creates a and asign the class to that one.
My register\_nav\_menu function:
```
function register_primary_menu() {
register_nav_menu('primary-menu', __('Primary Menu'));
}
add_action('init', 'register_pr... | Make sure your menu does setup correctly in that location in Appearance / Menus, unless it wont display that class. After you set the theme location to Primary Menu, it should work fine. No idea why, guess its a bug in WordPress.
Also fix the typo: `'container' => false` |
199,146 | <p>How do I query for a specific user role?</p>
<pre><code>if (is_user_logged_in() && user_role == "user") {}
</code></pre>
<p>The part I'm unsure about is user_role.</p>
<p><strong>Is there a way I can ask WordPress to check for a specific user role by name/string</strong>?</p>
| [
{
"answer_id": 199158,
"author": "theHubi",
"author_id": 63130,
"author_profile": "https://wordpress.stackexchange.com/users/63130",
"pm_score": 0,
"selected": false,
"text": "<p>You can make WordPress query for a certain user role by using <code>current_user_can(\"role_name\")</code>.</... | 2015/08/20 | [
"https://wordpress.stackexchange.com/questions/199146",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63130/"
] | How do I query for a specific user role?
```
if (is_user_logged_in() && user_role == "user") {}
```
The part I'm unsure about is user\_role.
**Is there a way I can ask WordPress to check for a specific user role by name/string**? | You can check for specific user role using following code -
```
if (is_user_logged_in() && current_user_can('administrator')) {}
```
The function current\_user\_can() takes role name as parameter.
For more info - <https://codex.wordpress.org/Function_Reference/current_user_can/> |
199,160 | <p>Im have a little issue querying a custom post type by category using the_title(); </p>
<p>The reason why im doing it like this is because the title is the same as the category name.</p>
<pre><code>$args = array('post_type' => 'Testimonials', 'order' => 'ASC', 'category_name' =>the_title());
</code></pre>
... | [
{
"answer_id": 199162,
"author": "David",
"author_id": 31323,
"author_profile": "https://wordpress.stackexchange.com/users/31323",
"pm_score": 1,
"selected": false,
"text": "<p>Look at the declaration of the function <code>the_title()</code>, it prints the title, if the third parameter <... | 2015/08/20 | [
"https://wordpress.stackexchange.com/questions/199160",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67253/"
] | Im have a little issue querying a custom post type by category using the\_title();
The reason why im doing it like this is because the title is the same as the category name.
```
$args = array('post_type' => 'Testimonials', 'order' => 'ASC', 'category_name' =>the_title());
```
However with this im not getting a th... | Look at the declaration of the function `the_title()`, it prints the title, if the third parameter `$echo` is set to `TRUE` which is the default:
```
/**
* Display or retrieve the current post title with optional content.
*
* @since 0.71
*
* @param string $before Optional. Content to prepend to the title.
* @par... |
199,182 | <p>I've a pretty basic problem that I'm surprised WP doesn't have a native solution for (unless I'm overlooking something, hopefully). </p>
<p>I've a WP site with <code>static page</code> set as front page in reading setting. In a plugin code, I'm trying to determine whether WP is displaying the front page and add a ... | [
{
"answer_id": 199676,
"author": "jim.duck",
"author_id": 78337,
"author_profile": "https://wordpress.stackexchange.com/users/78337",
"pm_score": -1,
"selected": false,
"text": "<p>WordPress uses different templates for pages on your site. If you have a page.php template in your theme, t... | 2015/08/20 | [
"https://wordpress.stackexchange.com/questions/199182",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56722/"
] | I've a pretty basic problem that I'm surprised WP doesn't have a native solution for (unless I'm overlooking something, hopefully).
I've a WP site with `static page` set as front page in reading setting. In a plugin code, I'm trying to determine whether WP is displaying the front page and add a class to `$classes` ar... | Just speculation, but I wonder if you're running into an anonymous function problem. Anonymous functions are allowed in WP, and usually work fine (presuming updated PHP), but, if you search around you'll find reports of suspected bugs or at least of unexpected behavior.
For that matter, I'm not sure that I've ever se... |
199,197 | <p>i want to restrict all authors to spesific categories i already done it but via theme function.php, i trying to build as a plugin:</p>
<p>this my plugin content:</p>
<pre><code><?php
/**
* Plugin Name: My Restricted
* Plugin URI:
* Description: Restrcted
* Version: 0.0.1
* Author: mm
* Author URI: http://www... | [
{
"answer_id": 199676,
"author": "jim.duck",
"author_id": 78337,
"author_profile": "https://wordpress.stackexchange.com/users/78337",
"pm_score": -1,
"selected": false,
"text": "<p>WordPress uses different templates for pages on your site. If you have a page.php template in your theme, t... | 2015/08/20 | [
"https://wordpress.stackexchange.com/questions/199197",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78089/"
] | i want to restrict all authors to spesific categories i already done it but via theme function.php, i trying to build as a plugin:
this my plugin content:
```
<?php
/**
* Plugin Name: My Restricted
* Plugin URI:
* Description: Restrcted
* Version: 0.0.1
* Author: mm
* Author URI: http://www.mm.com
* License: A "Mi... | Just speculation, but I wonder if you're running into an anonymous function problem. Anonymous functions are allowed in WP, and usually work fine (presuming updated PHP), but, if you search around you'll find reports of suspected bugs or at least of unexpected behavior.
For that matter, I'm not sure that I've ever se... |
199,226 | <p>I'm creating a template for archive-product.php page in WooCommerce.</p>
<p>I would like to have 3 boxes and link each to a different product category. </p>
<p><strong>How do I get dynamic link to each product category in <code><a></code> tag?</strong>
For now I put static links, but I'm sure there is a way... | [
{
"answer_id": 199263,
"author": "Marek",
"author_id": 54031,
"author_profile": "https://wordpress.stackexchange.com/users/54031",
"pm_score": 3,
"selected": true,
"text": "<p>For this purpose there is <code>get_term_link</code> function (<a href=\"https://codex.wordpress.org/Function_Re... | 2015/08/20 | [
"https://wordpress.stackexchange.com/questions/199226",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78105/"
] | I'm creating a template for archive-product.php page in WooCommerce.
I would like to have 3 boxes and link each to a different product category.
**How do I get dynamic link to each product category in `<a>` tag?**
For now I put static links, but I'm sure there is a way to make them dynamic in WordPress
Here's what... | For this purpose there is `get_term_link` function ([documentation](https://codex.wordpress.org/Function_Reference/get_term_link)).
```
<a href="<?php echo get_term_link( 42 ,'product_cat') ?>">Fine Art ... etc.</a>
```
Product category is just WP taxonomy, so there is plenty of functions to work with. In this case ... |
199,243 | <p>I use this function to get the last time a user logged in.</p>
<pre><code>function jkn_last_login($user_login) {
$user = get_user_by( 'login', $user_login );
global $last_login;
$last_login = array();
$last_login[$user->ID] = get_user_meta($user->ID,'last-login',true);
update_user_meta( $u... | [
{
"answer_id": 199263,
"author": "Marek",
"author_id": 54031,
"author_profile": "https://wordpress.stackexchange.com/users/54031",
"pm_score": 3,
"selected": true,
"text": "<p>For this purpose there is <code>get_term_link</code> function (<a href=\"https://codex.wordpress.org/Function_Re... | 2015/08/20 | [
"https://wordpress.stackexchange.com/questions/199243",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78113/"
] | I use this function to get the last time a user logged in.
```
function jkn_last_login($user_login) {
$user = get_user_by( 'login', $user_login );
global $last_login;
$last_login = array();
$last_login[$user->ID] = get_user_meta($user->ID,'last-login',true);
update_user_meta( $user->ID, 'last-login... | For this purpose there is `get_term_link` function ([documentation](https://codex.wordpress.org/Function_Reference/get_term_link)).
```
<a href="<?php echo get_term_link( 42 ,'product_cat') ?>">Fine Art ... etc.</a>
```
Product category is just WP taxonomy, so there is plenty of functions to work with. In this case ... |
199,244 | <p>I'm having a hard time getting my 'Hello World' to display on the theme page I created. It all at least appears to be correct (but obviously isn't) - what am I missing here?</p>
<pre><code>// Add Theme Options to menu
function add_theme_menu_item() {
add_theme_page("Theme Panel", "Theme Panel", "manage_options", ... | [
{
"answer_id": 199246,
"author": "Emetrop",
"author_id": 64623,
"author_profile": "https://wordpress.stackexchange.com/users/64623",
"pm_score": 1,
"selected": false,
"text": "<p>This is wrong:</p>\n\n<pre><code>add_theme_page(\"Theme Panel\", \"Theme Panel\", \"manage_options\", \"theme... | 2015/08/20 | [
"https://wordpress.stackexchange.com/questions/199244",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25475/"
] | I'm having a hard time getting my 'Hello World' to display on the theme page I created. It all at least appears to be correct (but obviously isn't) - what am I missing here?
```
// Add Theme Options to menu
function add_theme_menu_item() {
add_theme_page("Theme Panel", "Theme Panel", "manage_options", "theme-panel",... | This is wrong:
```
add_theme_page("Theme Panel", "Theme Panel", "manage_options", "theme-panel", "initialize_theme_options", null, 99);
```
The last two parameters shouldn't be there. Check this function in codex [here](https://codex.wordpress.org/Function_Reference/add_theme_page).
EDIT:
What's more, the last par... |
199,265 | <p>I am planning to build a WordPress site in which I will setup WooCommerce to sell products. I have created a test site before in which I used my personal email account (gmail) as admin email. Then I tested selling from the site. The problem I faced is that the order confirmation emails were going to spam folder of t... | [
{
"answer_id": 199246,
"author": "Emetrop",
"author_id": 64623,
"author_profile": "https://wordpress.stackexchange.com/users/64623",
"pm_score": 1,
"selected": false,
"text": "<p>This is wrong:</p>\n\n<pre><code>add_theme_page(\"Theme Panel\", \"Theme Panel\", \"manage_options\", \"theme... | 2015/08/21 | [
"https://wordpress.stackexchange.com/questions/199265",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54832/"
] | I am planning to build a WordPress site in which I will setup WooCommerce to sell products. I have created a test site before in which I used my personal email account (gmail) as admin email. Then I tested selling from the site. The problem I faced is that the order confirmation emails were going to spam folder of test... | This is wrong:
```
add_theme_page("Theme Panel", "Theme Panel", "manage_options", "theme-panel", "initialize_theme_options", null, 99);
```
The last two parameters shouldn't be there. Check this function in codex [here](https://codex.wordpress.org/Function_Reference/add_theme_page).
EDIT:
What's more, the last par... |
199,266 | <p>I am using co-author plus and I have posts in my site that are done by multiple authors. I would like that when I click on the co-author's author page, I will be able to get the posts that he/she co-authored.</p>
<p>For now, I am using a vanilla WP_Query call to primary authors. I followed db trail and the co-autho... | [
{
"answer_id": 199270,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the template functions given by Co-Authors Plus plugin such as,</p>\n\n<ol>\n<li>coauthors_posts_l... | 2015/08/21 | [
"https://wordpress.stackexchange.com/questions/199266",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17199/"
] | I am using co-author plus and I have posts in my site that are done by multiple authors. I would like that when I click on the co-author's author page, I will be able to get the posts that he/she co-authored.
For now, I am using a vanilla WP\_Query call to primary authors. I followed db trail and the co-authors are po... | Use the [Co-Authors Plus](https://wordpress.org/plugins/co-authors-plus/) to assign the authors and the post will show **automatically** on both author pages. I've used it and works pretty well. |
199,274 | <p>So, WordPress 4.3 has a new password system as we all know.
Unfortunately, this new system has done away with the ability to <strong>NOT</strong> send new users an email.</p>
<p>My client was using a system where he sent a custom email to his clients, manually registering their emails, and then sending them an emai... | [
{
"answer_id": 199321,
"author": "Emetrop",
"author_id": 64623,
"author_profile": "https://wordpress.stackexchange.com/users/64623",
"pm_score": 2,
"selected": false,
"text": "<p>Actually it depends how you create the new user. If you do it from administration - Users - Add New you are r... | 2015/08/21 | [
"https://wordpress.stackexchange.com/questions/199274",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75600/"
] | So, WordPress 4.3 has a new password system as we all know.
Unfortunately, this new system has done away with the ability to **NOT** send new users an email.
My client was using a system where he sent a custom email to his clients, manually registering their emails, and then sending them an email with the login info w... | You can intercept this email before it is sent using the [`phpmailer_init`](https://developer.wordpress.org/reference/hooks/phpmailer_init/) hook.
By default, this hook fires before any email is sent. In the function below, `$phpmailer` will be an instance of [PHPMailer](https://github.com/PHPMailer/PHPMailer), and y... |
199,289 | <p>I've tried the below code to create custom status.</p>
<pre><code>add_action( 'init', function() {
$term = get_term_by( 'name', 'shipped', 'shop_order_status' );
if ( ! $term ) {
wp_insert_term( 'shipped', 'shop_order_status' );
}
} );
</code></pre>
<p>But it is not working. I tried some other ... | [
{
"answer_id": 199295,
"author": "Magnetize",
"author_id": 49181,
"author_profile": "https://wordpress.stackexchange.com/users/49181",
"pm_score": 5,
"selected": true,
"text": "<p>This is what I have used to create a custom order status called \"Invoiced\".\nAdd this to your theme's func... | 2015/08/21 | [
"https://wordpress.stackexchange.com/questions/199289",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76222/"
] | I've tried the below code to create custom status.
```
add_action( 'init', function() {
$term = get_term_by( 'name', 'shipped', 'shop_order_status' );
if ( ! $term ) {
wp_insert_term( 'shipped', 'shop_order_status' );
}
} );
```
But it is not working. I tried some other methods also. Please can a... | This is what I have used to create a custom order status called "Invoiced".
Add this to your theme's functions.php
```
// New order status AFTER woo 2.2
add_action( 'init', 'register_my_new_order_statuses' );
function register_my_new_order_statuses() {
register_post_status( 'wc-invoiced', array(
'label' ... |
199,322 | <p>I am using ACF (last version) with WordPress (last version too).
I need to modify the post_object fields of ACF so I use this <a href="http://www.advancedcustomfields.com/resources/acf-fields-post_object-query/" rel="nofollow"><code>acf/fields/post_object/query</code></a> function. </p>
<p>All works fine but when I... | [
{
"answer_id": 199324,
"author": "Emetrop",
"author_id": 64623,
"author_profile": "https://wordpress.stackexchange.com/users/64623",
"pm_score": 1,
"selected": false,
"text": "<p>Probably nowhere because it outputs too early. I recommend to use <code>error_log</code> function and turn on... | 2015/08/21 | [
"https://wordpress.stackexchange.com/questions/199322",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40648/"
] | I am using ACF (last version) with WordPress (last version too).
I need to modify the post\_object fields of ACF so I use this [`acf/fields/post_object/query`](http://www.advancedcustomfields.com/resources/acf-fields-post_object-query/) function.
All works fine but when I do a var\_dump in the function in the functio... | Probably nowhere because it outputs too early. I recommend to use `error_log` function and turn on `WP_DEBUG_LOG`.
Just add to the `wp-config.php` file somewhere in front of this line:
```
require_once(ABSPATH . 'wp-settings.php');
```
these new lines:
```
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true )... |
199,378 | <p>I have built an isotope portfolio Wordpress theme which so far is working perfectly:</p>
<p>Anything posted in the custom post type 'portfolio' shows on the homepage and is filterable by the 'portfolio-category' taxonomy using the Isotope JQuery plugin.</p>
<p>So far so good.</p>
<p>However, I wish to make a smal... | [
{
"answer_id": 199324,
"author": "Emetrop",
"author_id": 64623,
"author_profile": "https://wordpress.stackexchange.com/users/64623",
"pm_score": 1,
"selected": false,
"text": "<p>Probably nowhere because it outputs too early. I recommend to use <code>error_log</code> function and turn on... | 2015/08/22 | [
"https://wordpress.stackexchange.com/questions/199378",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78183/"
] | I have built an isotope portfolio Wordpress theme which so far is working perfectly:
Anything posted in the custom post type 'portfolio' shows on the homepage and is filterable by the 'portfolio-category' taxonomy using the Isotope JQuery plugin.
So far so good.
However, I wish to make a small improvement.
**I only... | Probably nowhere because it outputs too early. I recommend to use `error_log` function and turn on `WP_DEBUG_LOG`.
Just add to the `wp-config.php` file somewhere in front of this line:
```
require_once(ABSPATH . 'wp-settings.php');
```
these new lines:
```
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true )... |
199,403 | <p>What is the <em>keyboard shortcut</em> key for <em>updating</em> a page or post? It could save me a lot of time as rolling down a page draft is time consuming. </p>
| [
{
"answer_id": 199411,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": false,
"text": "<p>I was curious about this and checked the Codex on <a href=\"https://codex.wordpress.org/Keyboard_Shortcuts\" ... | 2015/08/22 | [
"https://wordpress.stackexchange.com/questions/199403",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78191/"
] | What is the *keyboard shortcut* key for *updating* a page or post? It could save me a lot of time as rolling down a page draft is time consuming. | I was curious about this and checked the Codex on [keyboard shortcuts](https://codex.wordpress.org/Keyboard_Shortcuts), but didn't find it mentioned there.
I searched and found out that this seems to be already solved, e.g. [here](https://wordpress.org/plugins/save-with-keyboard/) and [here](https://github.com/johnbil... |
199,419 | <p>I'm fine with <code>P</code> tags for most of the content, since it makes styling easier. However I'd like to have <code>span</code> <code>div</code> <code>iframe</code> and possibly other HTML tags to not be placed inside of a <code>p</code> for post.</p>
<p>I saw <a href="https://wordpress.stackexchange.com/quest... | [
{
"answer_id": 199540,
"author": "Huginn",
"author_id": 70043,
"author_profile": "https://wordpress.stackexchange.com/users/70043",
"pm_score": -1,
"selected": false,
"text": "<p>Try this. Open your <code>functions.php</code> file and add the following PHP snippet</p>\n\n<pre><code>remov... | 2015/08/23 | [
"https://wordpress.stackexchange.com/questions/199419",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35801/"
] | I'm fine with `P` tags for most of the content, since it makes styling easier. However I'd like to have `span` `div` `iframe` and possibly other HTML tags to not be placed inside of a `p` for post.
I saw [this question](https://wordpress.stackexchange.com/questions/7090/stop-wordpress-wrapping-images-in-a-p-tag?rq=1) ... | To me you code looks good, I would recommend adding priority as high as 9999
Heres how :
```
add_filter('the_content', 'filter_ptags_on_images', '9999');
``` |