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 |
|---|---|---|---|---|---|---|
251,877 | <p>Thanks for any help.</p>
<p>I am in a custom post (not an archive) with a taxonomy.
And I'd like to display : </p>
<ul>
<li>some other custom posts</li>
<li>with this <b>current taxonomy</b></li>
</ul>
<p>Doesn't seems so hard but for me it does...
I didn't find the right way to use the term of my tax in the que... | [
{
"answer_id": 251884,
"author": "Aniruddha Gawade",
"author_id": 101818,
"author_profile": "https://wordpress.stackexchange.com/users/101818",
"pm_score": 2,
"selected": true,
"text": "<p>Try this for <code>WP_Query</code></p>\n\n<pre><code>$args = array(\n'post_type' => 'example',\n... | 2017/01/09 | [
"https://wordpress.stackexchange.com/questions/251877",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110465/"
] | Thanks for any help.
I am in a custom post (not an archive) with a taxonomy.
And I'd like to display :
* some other custom posts
* with this **current taxonomy**
Doesn't seems so hard but for me it does...
I didn't find the right way to use the term of my tax in the query...
Here is (one of) my try :
```
$terms... | Try this for `WP_Query`
```
$args = array(
'post_type' => 'example',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'identite',
'field' => 'ID',
'terms' => $term->term_id
)
),
);// end args
```
OR
```
$args = array(
'post_type' => 'example',
'tax_... |
251,890 | <p>I've custom post "products" with standart categories and subcategories. Now I need to display a list of products on category page, that current category contains.</p>
<p>If category don't have subcategories I need to display this:</p>
<pre><code><ul class="cat-arc-links">
<li><a href="#" class="... | [
{
"answer_id": 251892,
"author": "Marc-Antoine Parent",
"author_id": 110578,
"author_profile": "https://wordpress.stackexchange.com/users/110578",
"pm_score": 0,
"selected": false,
"text": "<p>Once you have the primary category (the one that's loaded to the categories.php template), you ... | 2017/01/10 | [
"https://wordpress.stackexchange.com/questions/251890",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48584/"
] | I've custom post "products" with standart categories and subcategories. Now I need to display a list of products on category page, that current category contains.
If category don't have subcategories I need to display this:
```
<ul class="cat-arc-links">
<li><a href="#" class="product-link">Product 1</a></li>
... | Thanks to all! Here is my solution which worknig well
```
<?php
$cat = get_query_var('cat');
$categories = get_categories('parent='.$cat.'');
if(isset($categories) && !empty($categories)){
foreach ($categories as $category) { ?>
<span class="subhead-title"><?php echo $category->name; ?></span>
... |
251,898 | <p>In a plugin I have a payment form that needs to be submitted (via the action= attribute) to a .php file, also located in my plugin directly. After some research, it seems like the "wordpress way" to call up individual plugin files is to actually use custom queries on index.php instead. I've done so with the below co... | [
{
"answer_id": 251945,
"author": "Kudratullah",
"author_id": 62726,
"author_profile": "https://wordpress.stackexchange.com/users/62726",
"pm_score": 2,
"selected": true,
"text": "<p>the easiest way is using init action hook</p>\n\n<pre><code>add_action(\"init\", \"your_form_handler_actio... | 2017/01/10 | [
"https://wordpress.stackexchange.com/questions/251898",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23492/"
] | In a plugin I have a payment form that needs to be submitted (via the action= attribute) to a .php file, also located in my plugin directly. After some research, it seems like the "wordpress way" to call up individual plugin files is to actually use custom queries on index.php instead. I've done so with the below code,... | the easiest way is using init action hook
```
add_action("init", "your_form_handler_action");
function your_form_handler_action(){
if( isset( $_REQUEST["action"] ) && $_REQUEST["action"] == "your_action_name" ) {
echo "Response!!!";
}
}
``` |
251,908 | <p>So I've been working in Wordpress lately with Ajax and I managed to get some stock data into my site from my database. However, I am now trying to use Ajax to load Wordpress posts into my left sidebar, which requires the use of Wordpress functions and it seems as if I am not doing this properly.get_option() shows NU... | [
{
"answer_id": 251911,
"author": "magicroundabout",
"author_id": 10046,
"author_profile": "https://wordpress.stackexchange.com/users/10046",
"pm_score": 3,
"selected": true,
"text": "<p>I confess that I'm slightly confused by how your sending email function loads posts into your sidebar.... | 2017/01/10 | [
"https://wordpress.stackexchange.com/questions/251908",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101257/"
] | So I've been working in Wordpress lately with Ajax and I managed to get some stock data into my site from my database. However, I am now trying to use Ajax to load Wordpress posts into my left sidebar, which requires the use of Wordpress functions and it seems as if I am not doing this properly.get\_option() shows NULL... | I confess that I'm slightly confused by how your sending email function loads posts into your sidebar...the code does not seem to be doing the thing that you described.
Are you loading WordPress in sendContactForm.php? Is what you've shown here the only code in sendContactForm.php?
`get_option()` is a WordPress funct... |
252,004 | <p>I'm attempting to change the "← Back to sitename" text on the wp-login.php page using gettext but not having much luck.</p>
<p>No matter what I try it doesn't seem to want to work, although I've had success changing the "Lost your password?" text using the same method.</p>
<p>Here is my latest snippet</p>
<pre><c... | [
{
"answer_id": 251952,
"author": "socki03",
"author_id": 43511,
"author_profile": "https://wordpress.stackexchange.com/users/43511",
"pm_score": 1,
"selected": false,
"text": "<p>It's usually a permissions error. We used to have these issues on our older servers. As a general rule for ... | 2017/01/10 | [
"https://wordpress.stackexchange.com/questions/252004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12238/"
] | I'm attempting to change the "← Back to sitename" text on the wp-login.php page using gettext but not having much luck.
No matter what I try it doesn't seem to want to work, although I've had success changing the "Lost your password?" text using the same method.
Here is my latest snippet
```
function custom_login_te... | It's usually a permissions error. We used to have these issues on our older servers. As a general rule for file permissions, you should never allow a folder to be "777" (Read/Write/Execute), but the uploads folder on this server, unfortunately, might need it. If you don't know what I'm talking about, please take a read... |
252,027 | <p>I want to sanitize the title of a specific custom post type. I've managed to create a filter which sanitizes the titles. How ever It affects rest of the post types as well. After a lot of search I've managed to write an action which enables me to execute functions on specific pages on the admin panel. But I'm incapa... | [
{
"answer_id": 252030,
"author": "Kudratullah",
"author_id": 62726,
"author_profile": "https://wordpress.stackexchange.com/users/62726",
"pm_score": 2,
"selected": true,
"text": "<p>you want to sanitize the title or the post_name (slug)?\n<br>\nif you want to filter post_name you can che... | 2017/01/11 | [
"https://wordpress.stackexchange.com/questions/252027",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48438/"
] | I want to sanitize the title of a specific custom post type. I've managed to create a filter which sanitizes the titles. How ever It affects rest of the post types as well. After a lot of search I've managed to write an action which enables me to execute functions on specific pages on the admin panel. But I'm incapable... | you want to sanitize the title or the post\_name (slug)?
if you want to filter post\_name you can check `wp_unique_post_slug` filter or you can use the `wp_insert_post_data` filter to filter all post data before insert or update in db.
```
add_filter( "wp_unique_post_slug", "url_sanitizer", 10, 4 );
function url_sani... |
252,035 | <p>I am trying to make the page have 3 posts in each row, and then after 3 columns (12 posts) show the ajax load more button. Right now only one post is showing up. I don't know how to make it correctly loop through everything. Can anyone provide help? Thanks in advance.</p>
<pre class="lang-html prettyprint-overrid... | [
{
"answer_id": 252036,
"author": "Aniruddha Gawade",
"author_id": 101818,
"author_profile": "https://wordpress.stackexchange.com/users/101818",
"pm_score": 0,
"selected": false,
"text": "<p>Your code doesn't have <code>while</code> loop</p>\n\n<pre><code>if ( $the_query->have_posts() ... | 2017/01/11 | [
"https://wordpress.stackexchange.com/questions/252035",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101743/"
] | I am trying to make the page have 3 posts in each row, and then after 3 columns (12 posts) show the ajax load more button. Right now only one post is showing up. I don't know how to make it correctly loop through everything. Can anyone provide help? Thanks in advance.
```html
<?php
get_header();
get_template_part ('in... | I just tested the following example code:
```
<?php
$the_query = new WP_Query( array(
'posts_per_page' => 12,
'paged' => get_query_var('paged', 1)
));
if ( $the_query->have_posts() ) {
// display #ajax wrapper only if we have posts
echo '<div id="ajax">';
while($the_query->have_posts()) {
... |
252,054 | <p><em>(Queries are definitively an infinite source of misunderstanding...)</em></p>
<p>I try to display two types of informations in a tax archive (<code>taxonomy-artiste.php</code>) : </p>
<ol>
<li>The content of a page from a custom post (bio)</li>
<li>And after, a list of post from another custom post (works)</li... | [
{
"answer_id": 252057,
"author": "David Navia",
"author_id": 92828,
"author_profile": "https://wordpress.stackexchange.com/users/92828",
"pm_score": 1,
"selected": false,
"text": "<p>Ok, first of all I found a misleading in your code, check the <code>while</code> part I ammended:</p>\n\n... | 2017/01/11 | [
"https://wordpress.stackexchange.com/questions/252054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110465/"
] | *(Queries are definitively an infinite source of misunderstanding...)*
I try to display two types of informations in a tax archive (`taxonomy-artiste.php`) :
1. The content of a page from a custom post (bio)
2. And after, a list of post from another custom post (works)
If I understood well, it could be interesting ... | You've added the filter `lm_exclude_bio` to `pre_get_posts`. So when you need to run another query you can remove the filter to get normal query. You can remove the filter like below-
```
// Here we're removing the filter first. Then we are running the query.
remove_filter( 'pre_get_posts', 'lm_exclude_bio' );
$args ... |
252,071 | <p>I am attempting to import a site using XML generated by WordPress.com</p>
<p>All the posts and media seem to import, but the comments fail with errors</p>
<pre><code>Failed to import “Sarah Toon - 2015-10-10 08:29:30”: Invalid post type feedback
Failed to import “Kylie - 2015-10-10 08:34:50”: Invalid post type fee... | [
{
"answer_id": 252078,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 4,
"selected": true,
"text": "<p>The issue is you're trying to import posts with a post type of <code>feedback</code>, but there is no such ... | 2017/01/11 | [
"https://wordpress.stackexchange.com/questions/252071",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25717/"
] | I am attempting to import a site using XML generated by WordPress.com
All the posts and media seem to import, but the comments fail with errors
```
Failed to import “Sarah Toon - 2015-10-10 08:29:30”: Invalid post type feedback
Failed to import “Kylie - 2015-10-10 08:34:50”: Invalid post type feedback
Failed to impor... | The issue is you're trying to import posts with a post type of `feedback`, but there is no such post type registered on your install of WordPress.
Quick-and-easy fix is to register one:
```
add_action( 'init', function () {
register_post_type( 'feedback', [
'public' => true,
'labels' => [
... |
252,073 | <p>Hi Guys i found this code snippet on here: </p>
<pre><code>add_action( 'set_user_role', function( $user_id, $role, $old_roles )
{
// Your code ...
}, 10, 3 );
</code></pre>
<p>Source: <a href="https://wordpress.stackexchange.com/questions/194324/execute-a-function-when-admin-changes-the-user-role">Execute a f... | [
{
"answer_id": 252078,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 4,
"selected": true,
"text": "<p>The issue is you're trying to import posts with a post type of <code>feedback</code>, but there is no such ... | 2017/01/11 | [
"https://wordpress.stackexchange.com/questions/252073",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102810/"
] | Hi Guys i found this code snippet on here:
```
add_action( 'set_user_role', function( $user_id, $role, $old_roles )
{
// Your code ...
}, 10, 3 );
```
Source: [Execute a function when admin changes the user role](https://wordpress.stackexchange.com/questions/194324/execute-a-function-when-admin-changes-the-use... | The issue is you're trying to import posts with a post type of `feedback`, but there is no such post type registered on your install of WordPress.
Quick-and-easy fix is to register one:
```
add_action( 'init', function () {
register_post_type( 'feedback', [
'public' => true,
'labels' => [
... |
252,079 | <p>I am using a Genesis theme (digital-pro), and inside of the front-page.php file (companion to functions.php) I am noticing that js files are enqueued in two different ways.</p>
<p>Example 1: </p>
<pre><code>wp_enqueue_script( 'localScroll', get_stylesheet_directory_uri() . '/js/jquery.localScroll.min.js', array( '... | [
{
"answer_id": 252083,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>Starting from WordPress 4.7, I would use <a href=\"https://developer.wordpress.org/reference/functions/get_th... | 2017/01/11 | [
"https://wordpress.stackexchange.com/questions/252079",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110604/"
] | I am using a Genesis theme (digital-pro), and inside of the front-page.php file (companion to functions.php) I am noticing that js files are enqueued in two different ways.
Example 1:
```
wp_enqueue_script( 'localScroll', get_stylesheet_directory_uri() . '/js/jquery.localScroll.min.js', array( 'scrollTo' ), '1.2.8b'... | Starting from WordPress 4.7, I would use [`get_theme_file_uri()`](https://developer.wordpress.org/reference/functions/get_theme_file_uri/), so any child theme can override the file easily: if the file exists in the child theme, `get_theme_file_uri()` returns the URI to that file, otherwise returns the file in the paren... |
252,085 | <p>Hi I am using thevoux theme for my website as i need to add pagination links like "Older Posts and Newer Posts" to home page.Here is an example screen shot how it should be.
<a href="https://i.stack.imgur.com/4rWAj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4rWAj.jpg" alt="enter image descrip... | [
{
"answer_id": 252083,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>Starting from WordPress 4.7, I would use <a href=\"https://developer.wordpress.org/reference/functions/get_th... | 2017/01/11 | [
"https://wordpress.stackexchange.com/questions/252085",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110685/"
] | Hi I am using thevoux theme for my website as i need to add pagination links like "Older Posts and Newer Posts" to home page.Here is an example screen shot how it should be.
[](https://i.stack.imgur.com/4rWAj.jpg)
Actually right now i am getting these... | Starting from WordPress 4.7, I would use [`get_theme_file_uri()`](https://developer.wordpress.org/reference/functions/get_theme_file_uri/), so any child theme can override the file easily: if the file exists in the child theme, `get_theme_file_uri()` returns the URI to that file, otherwise returns the file in the paren... |
252,121 | <p>I want to resize images in uploads folder. What would be the best way to resize images on a live website?</p>
| [
{
"answer_id": 252083,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>Starting from WordPress 4.7, I would use <a href=\"https://developer.wordpress.org/reference/functions/get_th... | 2017/01/11 | [
"https://wordpress.stackexchange.com/questions/252121",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I want to resize images in uploads folder. What would be the best way to resize images on a live website? | Starting from WordPress 4.7, I would use [`get_theme_file_uri()`](https://developer.wordpress.org/reference/functions/get_theme_file_uri/), so any child theme can override the file easily: if the file exists in the child theme, `get_theme_file_uri()` returns the URI to that file, otherwise returns the file in the paren... |
252,133 | <p>I am having trouble finding a good resource on using the $wpdb function.</p>
<p>I am trying to delete a row from a custom table named: eLearning_progress</p>
<pre><code>$removefromdb = $wpdb->query("DELETE FROM eLearning_progress WHERE ID = '$user_id' AND module_id = '$singlecomparearrays_remove'" );
</code></p... | [
{
"answer_id": 252222,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 6,
"selected": true,
"text": "<p>The best WP API solution for this goal is to use the <a href=\"https://developer.wordpress.org/reference/classes/w... | 2017/01/11 | [
"https://wordpress.stackexchange.com/questions/252133",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110723/"
] | I am having trouble finding a good resource on using the $wpdb function.
I am trying to delete a row from a custom table named: eLearning\_progress
```
$removefromdb = $wpdb->query("DELETE FROM eLearning_progress WHERE ID = '$user_id' AND module_id = '$singlecomparearrays_remove'" );
```
The row I would like to del... | The best WP API solution for this goal is to use the [`delete()`](https://developer.wordpress.org/reference/classes/wpdb/delete/) function to remove a row.
A small example, to delete the raw `ID` in the custom table `eLearning_progress`.
```php
$id = 0815;
$table = 'eLearning_progress';
$wpdb->delete( $ta... |
252,134 | <p>I'm trying to get value of hidden <code>textarea</code> created by <code>wp_editor()</code> or check if anything is typed it, but the problem is that the value is updated on submit, not dynamically. What I need is to validate with jQuery whether the field is filled in or not.</p>
<p>My field:</p>
<pre><code>$setti... | [
{
"answer_id": 252222,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 6,
"selected": true,
"text": "<p>The best WP API solution for this goal is to use the <a href=\"https://developer.wordpress.org/reference/classes/w... | 2017/01/11 | [
"https://wordpress.stackexchange.com/questions/252134",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105189/"
] | I'm trying to get value of hidden `textarea` created by `wp_editor()` or check if anything is typed it, but the problem is that the value is updated on submit, not dynamically. What I need is to validate with jQuery whether the field is filled in or not.
My field:
```
$settings = array(
'e... | The best WP API solution for this goal is to use the [`delete()`](https://developer.wordpress.org/reference/classes/wpdb/delete/) function to remove a row.
A small example, to delete the raw `ID` in the custom table `eLearning_progress`.
```php
$id = 0815;
$table = 'eLearning_progress';
$wpdb->delete( $ta... |
252,135 | <p>After I moved Wordpress to a subfolder, I'm getting the following error at Chrome console:</p>
<pre><code>GET http://www.mydomain.comwp-includes/js/wp-embed.min.js?ver=4.5.4 net::ERR_NAME_NOT_RESOLVED
</code></pre>
<p>See? It's missing a "/" after the domain name.</p>
<p>What's the best approach to solve this? 30... | [
{
"answer_id": 252136,
"author": "Lucas Bustamante",
"author_id": 27278,
"author_profile": "https://wordpress.stackexchange.com/users/27278",
"pm_score": 2,
"selected": false,
"text": "<p>I solved it by logging in into admin panel and saving site URL with a trailing slash at the end.</p>... | 2017/01/11 | [
"https://wordpress.stackexchange.com/questions/252135",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27278/"
] | After I moved Wordpress to a subfolder, I'm getting the following error at Chrome console:
```
GET http://www.mydomain.comwp-includes/js/wp-embed.min.js?ver=4.5.4 net::ERR_NAME_NOT_RESOLVED
```
See? It's missing a "/" after the domain name.
What's the best approach to solve this? 301 redirects on htaccess seems ver... | I solved it by logging in into admin panel and saving site URL with a trailing slash at the end. |
252,143 | <p>I have a snippet in my functions PHP file that allows me to upload SVG files. Since upgrading to the latest version of WP today, I can no longer upload svgs. I also tried a second code snippet from CSS tricks website and that doesn't work either. </p>
<p>Does anyone know a) what may have caused this with the last... | [
{
"answer_id": 252162,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": false,
"text": "<p>Seems like this might be related to this ticket <a href=\"https://core.trac.wordpress.org/ticket/39552\">... | 2017/01/11 | [
"https://wordpress.stackexchange.com/questions/252143",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/106972/"
] | I have a snippet in my functions PHP file that allows me to upload SVG files. Since upgrading to the latest version of WP today, I can no longer upload svgs. I also tried a second code snippet from CSS tricks website and that doesn't work either.
Does anyone know a) what may have caused this with the last update and ... | In WordPress 4.7.1 [a change was introduced](https://core.trac.wordpress.org/changeset/39831) that checks for the real mime type of an uploaded file. This breaks uploading file types like SVG or DOCX. There already exist tickets for this issue in WordPress Core, where you can read more about this:
* Some Non-image fil... |
252,150 | <p>I have a sidebar with all my post the page only displays one post at a time. I want to display the post that is clicked from the sidebar.</p>
<p>This is the single post display</p>
<pre><code><?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 1
);
$the_query = new WP_Query( $args );
i... | [
{
"answer_id": 252162,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": false,
"text": "<p>Seems like this might be related to this ticket <a href=\"https://core.trac.wordpress.org/ticket/39552\">... | 2017/01/11 | [
"https://wordpress.stackexchange.com/questions/252150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63922/"
] | I have a sidebar with all my post the page only displays one post at a time. I want to display the post that is clicked from the sidebar.
This is the single post display
```
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 1
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() )... | In WordPress 4.7.1 [a change was introduced](https://core.trac.wordpress.org/changeset/39831) that checks for the real mime type of an uploaded file. This breaks uploading file types like SVG or DOCX. There already exist tickets for this issue in WordPress Core, where you can read more about this:
* Some Non-image fil... |
252,171 | <p>I'm having trouble trying to display the current logged in author's first_name even if they haven't published a custom post outside the loop. Could someone get me started please.</p>
| [
{
"answer_id": 252175,
"author": "Eckstein",
"author_id": 23492,
"author_profile": "https://wordpress.stackexchange.com/users/23492",
"pm_score": 1,
"selected": false,
"text": "<p>This should do it:</p>\n\n<pre><code>$user = get_current_user_id();\n$userdata = get_userdata($user);\n$firs... | 2017/01/12 | [
"https://wordpress.stackexchange.com/questions/252171",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37346/"
] | I'm having trouble trying to display the current logged in author's first\_name even if they haven't published a custom post outside the loop. Could someone get me started please. | author's name or logged in user's name?
can use `global $current_user;` or `wp_get_current_user();` if the user is logged in.
```
if( is_user_logged_in() ) {
$current_user = wp_get_current_user();
echo $current_user->user_firstname;
}
```
for specific user role you can check `$current_user->roles` array.
R... |
252,253 | <p>I updated Wordpress to 4.7.1 and cant upload SVG anymore.</p>
<p>I had a function in my functions.php file </p>
<pre><code>function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
</code></pre>
<p>but it also dont help now.</p>
| [
{
"answer_id": 252324,
"author": "Don-Silvermann",
"author_id": 110815,
"author_profile": "https://wordpress.stackexchange.com/users/110815",
"pm_score": 4,
"selected": true,
"text": "<p>Per the thread below, a <strong>temporary solution</strong> would be to add this code to your wp-conf... | 2017/01/12 | [
"https://wordpress.stackexchange.com/questions/252253",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110781/"
] | I updated Wordpress to 4.7.1 and cant upload SVG anymore.
I had a function in my functions.php file
```
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
```
but it also dont help now. | Per the thread below, a **temporary solution** would be to add this code to your wp-config file:
```
define( 'ALLOW_UNFILTERED_UPLOADS', true );
```
<https://wordpress.org/support/topic/wp-4-7-1-kills-svg/page/3/> |
252,255 | <p>I am trying to learn TDD and am struggling with creating factories for custom objects. For instance, if I have a custom user type and all users of that type must have a specific capability, it's cumbersome to use the WP_UnitTest factory to create a user and then add the capability manually in each test before using ... | [
{
"answer_id": 252324,
"author": "Don-Silvermann",
"author_id": 110815,
"author_profile": "https://wordpress.stackexchange.com/users/110815",
"pm_score": 4,
"selected": true,
"text": "<p>Per the thread below, a <strong>temporary solution</strong> would be to add this code to your wp-conf... | 2017/01/12 | [
"https://wordpress.stackexchange.com/questions/252255",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38193/"
] | I am trying to learn TDD and am struggling with creating factories for custom objects. For instance, if I have a custom user type and all users of that type must have a specific capability, it's cumbersome to use the WP\_UnitTest factory to create a user and then add the capability manually in each test before using th... | Per the thread below, a **temporary solution** would be to add this code to your wp-config file:
```
define( 'ALLOW_UNFILTERED_UPLOADS', true );
```
<https://wordpress.org/support/topic/wp-4-7-1-kills-svg/page/3/> |
252,258 | <p>I have a shortcode that takes 1 argument for post category slug and returns and list of posts.</p>
<pre><code> //[list-products] creates the product table in the wholesale page, can be used to create a table list of any category
function list_products_func ( $atts ) {
$a = shortcode_atts( array (
'category' =... | [
{
"answer_id": 252263,
"author": "Robbert",
"author_id": 25834,
"author_profile": "https://wordpress.stackexchange.com/users/25834",
"pm_score": 2,
"selected": true,
"text": "<p>Maybe you can make it so that you can use the shortcode like [list-products categories=\"1,2,3\"], and then ex... | 2017/01/12 | [
"https://wordpress.stackexchange.com/questions/252258",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110308/"
] | I have a shortcode that takes 1 argument for post category slug and returns and list of posts.
```
//[list-products] creates the product table in the wholesale page, can be used to create a table list of any category
function list_products_func ( $atts ) {
$a = shortcode_atts( array (
'category' => '',
), $att... | Maybe you can make it so that you can use the shortcode like [list-products categories="1,2,3"], and then explode them as an array to insert them as your terms?
```
<?php
function list_products_func($atts) {
$a = shortcode_atts(array(
'categories' => '',
), $atts);
// Check for multiple categories by ... |
252,260 | <p>For some reason, I am battling to make sense of everything. This is my code on paste bin: <a href="http://pastebin.com/dJxGS6x6" rel="nofollow noreferrer">http://pastebin.com/dJxGS6x6</a></p>
<p>I want to be able to retrieve the options that are saved in the fields. This does not return anything: </p>
<pre><code>&... | [
{
"answer_id": 252263,
"author": "Robbert",
"author_id": 25834,
"author_profile": "https://wordpress.stackexchange.com/users/25834",
"pm_score": 2,
"selected": true,
"text": "<p>Maybe you can make it so that you can use the shortcode like [list-products categories=\"1,2,3\"], and then ex... | 2017/01/12 | [
"https://wordpress.stackexchange.com/questions/252260",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | For some reason, I am battling to make sense of everything. This is my code on paste bin: <http://pastebin.com/dJxGS6x6>
I want to be able to retrieve the options that are saved in the fields. This does not return anything:
```
<a href="<?php echo get_option('contact_details_vimeo_render'); ?>" target="_blank">
... | Maybe you can make it so that you can use the shortcode like [list-products categories="1,2,3"], and then explode them as an array to insert them as your terms?
```
<?php
function list_products_func($atts) {
$a = shortcode_atts(array(
'categories' => '',
), $atts);
// Check for multiple categories by ... |
252,262 | <p>I am just beginning a page, and for my current purposes it seems that the only extra things I need are a couple of extra fields for posts of a certain category. Because I only need to add a little information, I think that it might be appropriate to give posts belonging to this category custom fields using Advanced ... | [
{
"answer_id": 252263,
"author": "Robbert",
"author_id": 25834,
"author_profile": "https://wordpress.stackexchange.com/users/25834",
"pm_score": 2,
"selected": true,
"text": "<p>Maybe you can make it so that you can use the shortcode like [list-products categories=\"1,2,3\"], and then ex... | 2017/01/12 | [
"https://wordpress.stackexchange.com/questions/252262",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105196/"
] | I am just beginning a page, and for my current purposes it seems that the only extra things I need are a couple of extra fields for posts of a certain category. Because I only need to add a little information, I think that it might be appropriate to give posts belonging to this category custom fields using Advanced Cus... | Maybe you can make it so that you can use the shortcode like [list-products categories="1,2,3"], and then explode them as an array to insert them as your terms?
```
<?php
function list_products_func($atts) {
$a = shortcode_atts(array(
'categories' => '',
), $atts);
// Check for multiple categories by ... |
252,277 | <p>I'm still a noob with php but I'm trying to display a different layout for my Wordpress webpage for a single post id. </p>
<p>I thought it would have been simple but I've tried a quiet few variations of the code below. Including <code>is_singular</code> and without the <code>$post</code> etc. and I've ran out of in... | [
{
"answer_id": 252286,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 4,
"selected": false,
"text": "<p>This looks almost correct. Let's have a look at <a href=\"https://developer.wordpress.org/reference/functio... | 2017/01/12 | [
"https://wordpress.stackexchange.com/questions/252277",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110792/"
] | I'm still a noob with php but I'm trying to display a different layout for my Wordpress webpage for a single post id.
I thought it would have been simple but I've tried a quiet few variations of the code below. Including `is_singular` and without the `$post` etc. and I've ran out of inspiration. What can I do? What d... | This looks almost correct. Let's have a look at [`is_single()`](https://developer.wordpress.org/reference/functions/is_single/):
>
> Works for any post type, **except attachments and pages**...
>
>
>
So if the given ID isn't that of a `page` or `attachment` post type then you can use the function as so:
```
if( ... |
252,300 | <p>I'm very new to WordPress Development and I'm attempting to make a custom post type business directory style plugin in my plugins folder for my site, but everytime I activate it I get the white screen of death over my entire web site. I've definitely tracked it down to this plugin but I can't see what I've done that... | [
{
"answer_id": 252286,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 4,
"selected": false,
"text": "<p>This looks almost correct. Let's have a look at <a href=\"https://developer.wordpress.org/reference/functio... | 2017/01/12 | [
"https://wordpress.stackexchange.com/questions/252300",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110800/"
] | I'm very new to WordPress Development and I'm attempting to make a custom post type business directory style plugin in my plugins folder for my site, but everytime I activate it I get the white screen of death over my entire web site. I've definitely tracked it down to this plugin but I can't see what I've done that's ... | This looks almost correct. Let's have a look at [`is_single()`](https://developer.wordpress.org/reference/functions/is_single/):
>
> Works for any post type, **except attachments and pages**...
>
>
>
So if the given ID isn't that of a `page` or `attachment` post type then you can use the function as so:
```
if( ... |
252,328 | <p>I have upgraded my WordPress to <code>4.7.1</code>, and after that I've tried to enumerate users through REST API, which should be fixed, but I was able to retrieve users.</p>
<pre><code>https://mywebsite.com/wp-json/wp/v2/users
</code></pre>
<p>Output:</p>
<pre><code>[{"id":1,"name":"admin","url":"","description... | [
{
"answer_id": 254251,
"author": "BlueSuiter",
"author_id": 92665,
"author_profile": "https://wordpress.stackexchange.com/users/92665",
"pm_score": 6,
"selected": true,
"text": "<p>This code snippet will hide the users, posts, and comments endpoint results and give 404 as the result, whi... | 2017/01/13 | [
"https://wordpress.stackexchange.com/questions/252328",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91550/"
] | I have upgraded my WordPress to `4.7.1`, and after that I've tried to enumerate users through REST API, which should be fixed, but I was able to retrieve users.
```
https://mywebsite.com/wp-json/wp/v2/users
```
Output:
```
[{"id":1,"name":"admin","url":"","description":"","link":"https:\/\/mywebsite\/author\/admin\... | This code snippet will hide the users, posts, and comments endpoint results and give 404 as the result, while the rest of the API calls keep running as they were.
**::UPDATE::**
```
add_filter('rest_endpoints', function(){
$toRemove = ['users', 'posts', 'comments'];
foreach($toRemove as $val)
{
if... |
252,369 | <p>What are the proper filter/hooks to modify the wp-login.php?action=logout confirmation page</p>
<p><a href="https://i.stack.imgur.com/toDrN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/toDrN.png" alt="enter image description here" /></a>When you logout of your site using <strong>yoursite.com/wp... | [
{
"answer_id": 252370,
"author": "Umer Shoukat",
"author_id": 94940,
"author_profile": "https://wordpress.stackexchange.com/users/94940",
"pm_score": 2,
"selected": false,
"text": "<p>Its seems we don't have any hook to modify that page. But you can use alternative way and redirect user ... | 2017/01/13 | [
"https://wordpress.stackexchange.com/questions/252369",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60720/"
] | What are the proper filter/hooks to modify the wp-login.php?action=logout confirmation page
[](https://i.stack.imgur.com/toDrN.png)When you logout of your site using **yoursite.com/wp-login.php?action=logout** , You will go to a standard page WordPres... | Its seems we don't have any hook to modify that page. But you can use alternative way and redirect user to a desire template and modify that template according to your needs.
```
<?php wp_loginout( $redirect, $echo ); ?>
```
<https://codex.wordpress.org/Function_Reference/wp_loginout>
This might helps you. |
252,379 | <p>I developed a plugin which processes data following user input into a number of forms on the front end. The field types within the forms and the data input varies significantly.</p>
<p>To process the data, I hook into <code>init</code> and use the following function;</p>
<pre><code>function mh_post_actions() {
... | [
{
"answer_id": 252370,
"author": "Umer Shoukat",
"author_id": 94940,
"author_profile": "https://wordpress.stackexchange.com/users/94940",
"pm_score": 2,
"selected": false,
"text": "<p>Its seems we don't have any hook to modify that page. But you can use alternative way and redirect user ... | 2017/01/13 | [
"https://wordpress.stackexchange.com/questions/252379",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69112/"
] | I developed a plugin which processes data following user input into a number of forms on the front end. The field types within the forms and the data input varies significantly.
To process the data, I hook into `init` and use the following function;
```
function mh_post_actions() {
if ( isset( $_POST['mh_action']... | Its seems we don't have any hook to modify that page. But you can use alternative way and redirect user to a desire template and modify that template according to your needs.
```
<?php wp_loginout( $redirect, $echo ); ?>
```
<https://codex.wordpress.org/Function_Reference/wp_loginout>
This might helps you. |
252,419 | <p>Is there a way to post content that does not move or remains "static" within different pages? I am trying to set a description of each of my pages on my blog to give the reader an intro about each page. Is this Possible?</p>
<p>Example:</p>
<p>This is how I would want my "Audio Stories" page to look....</p>
<p>(P... | [
{
"answer_id": 252370,
"author": "Umer Shoukat",
"author_id": 94940,
"author_profile": "https://wordpress.stackexchange.com/users/94940",
"pm_score": 2,
"selected": false,
"text": "<p>Its seems we don't have any hook to modify that page. But you can use alternative way and redirect user ... | 2017/01/13 | [
"https://wordpress.stackexchange.com/questions/252419",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110866/"
] | Is there a way to post content that does not move or remains "static" within different pages? I am trying to set a description of each of my pages on my blog to give the reader an intro about each page. Is this Possible?
Example:
This is how I would want my "Audio Stories" page to look....
(Page)Audio Stories
(Conte... | Its seems we don't have any hook to modify that page. But you can use alternative way and redirect user to a desire template and modify that template according to your needs.
```
<?php wp_loginout( $redirect, $echo ); ?>
```
<https://codex.wordpress.org/Function_Reference/wp_loginout>
This might helps you. |
252,426 | <p><strong>TLDR</strong>: While in the backend, I would like to add custom post type inside a menu page (which I can do). But I cannot order the resulting submenu pages.</p>
<hr>
<p>I have <strong>3 custom post types</strong> “A”, “B”, “C”, and I want to:</p>
<ol>
<li><strong>Group</strong> the 3 contents <strong>un... | [
{
"answer_id": 252428,
"author": "Cerere",
"author_id": 16281,
"author_profile": "https://wordpress.stackexchange.com/users/16281",
"pm_score": 3,
"selected": true,
"text": "<p>I found the answer. To make it short:</p>\n<h1>SOLUTION 1</h1>\n<p>If you want to simply add a custom post type... | 2017/01/13 | [
"https://wordpress.stackexchange.com/questions/252426",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16281/"
] | **TLDR**: While in the backend, I would like to add custom post type inside a menu page (which I can do). But I cannot order the resulting submenu pages.
---
I have **3 custom post types** “A”, “B”, “C”, and I want to:
1. **Group** the 3 contents **under one menu page** called “My Custom Page”
2. When I click “My Cu... | I found the answer. To make it short:
SOLUTION 1
==========
If you want to simply add a custom post type to a menu item, go with solution number one (which involves creating a menu page with `add_menu_page`and setting `'show_in_menu=>'` to your menu page slug). It works, but if you click on your newly created menu pa... |
252,431 | <p>I'm hooking into <code>the_editor_content</code> to add a signature to new posts. However, when a user edits their post the content is lost and replaced with the signature. </p>
<p>I tried something like the following in the hopes that the <code>the_editor_content</code> would only fire for new posts: </p>
<pre><c... | [
{
"answer_id": 252445,
"author": "Mike",
"author_id": 69112,
"author_profile": "https://wordpress.stackexchange.com/users/69112",
"pm_score": 1,
"selected": false,
"text": "<p>OK, so the <code>new_to_publish</code> hook is probably not the right hook to use here.</p>\n\n<p>The <code>stat... | 2017/01/13 | [
"https://wordpress.stackexchange.com/questions/252431",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98236/"
] | I'm hooking into `the_editor_content` to add a signature to new posts. However, when a user edits their post the content is lost and replaced with the signature.
I tried something like the following in the hopes that the `the_editor_content` would only fire for new posts:
```
add_action( 'new_to_publish', 'my_new_p... | I went with a different approach to solve this (probably not the cleanest one but it works for me).
I parsed the current url and added the signature with `the_editor_content` if on the page for new posts.
If on the page for editing posts, I parsed the url again to get the post id and return the post content in the e... |
252,458 | <p>Trying to create a 'switching' blog template using home.php, controlled by 'Blog posts per page' setting in the admin area. If set to '1', it will show the single post template. Anything higher and it will display the archive template.</p>
<p><strong>In detail:</strong></p>
<p>The following code works, except for ... | [
{
"answer_id": 252459,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>You can control what template loads for any type of query via the <a href=\"https://developer.wordpress.org/themes/... | 2017/01/14 | [
"https://wordpress.stackexchange.com/questions/252458",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Trying to create a 'switching' blog template using home.php, controlled by 'Blog posts per page' setting in the admin area. If set to '1', it will show the single post template. Anything higher and it will display the archive template.
**In detail:**
The following code works, except for archive pagination (clicking o... | You can control what template loads for any type of query via the [Template Filters](https://developer.wordpress.org/themes/basics/template-hierarchy/#filter-hierarchy).
Here's an example using `home_template` that checks if `posts_per_page` is equal to `1`, and loads `single.php` in that case.
```
function wpd_home_... |
252,532 | <p>After upgrading to php 5.6.4 my widgets file causes:</p>
<p><code>Parse error: syntax error, unexpected 'class' (T_CLASS) in /home/path/fss-widgets.php on line 1</code></p>
<p>I'm mystified - several hours research has yielded nothing. The problem doesn't appear to be quoting, escaping, or anything else you would ... | [
{
"answer_id": 252577,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>An error about something on <strong>line 1</strong> that is actually on a later position means that PHP doesn't recogn... | 2017/01/14 | [
"https://wordpress.stackexchange.com/questions/252532",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3782/"
] | After upgrading to php 5.6.4 my widgets file causes:
`Parse error: syntax error, unexpected 'class' (T_CLASS) in /home/path/fss-widgets.php on line 1`
I'm mystified - several hours research has yielded nothing. The problem doesn't appear to be quoting, escaping, or anything else you would expect in this situation and... | An error about something on **line 1** that is actually on a later position means that PHP doesn't recognize your line endings.
There are three ways to encode a line ending, and PHP understands only two of them:
1. LF, or `\n`, Line Feed, [U+000A](http://www.fileformat.info/info/unicode/char/000A/index.htm)
2. CR, o... |
252,559 | <p>I have image file stored inside theme directory called site.</p>
<p>Now in my home page using wordpress page editor I have put the following code but it didn't display image, seems location is wrong.</p>
<pre><code><img src="site/images/footLogo.png" style="padding: 0px!important; color:white">
</code></pre>... | [
{
"answer_id": 252561,
"author": "Samuel Asor",
"author_id": 84265,
"author_profile": "https://wordpress.stackexchange.com/users/84265",
"pm_score": 1,
"selected": false,
"text": "<p>You'll have to copy the full path to the image like so:<br>\n<code>http://www.your-site-name.extension/wp... | 2017/01/15 | [
"https://wordpress.stackexchange.com/questions/252559",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110935/"
] | I have image file stored inside theme directory called site.
Now in my home page using wordpress page editor I have put the following code but it didn't display image, seems location is wrong.
```
<img src="site/images/footLogo.png" style="padding: 0px!important; color:white">
```
let me know what issue? | You can define constant in theme function file as:
```
if( !defined(THEME_IMG_PATH)){
define( 'THEME_IMG_PATH', get_stylesheet_directory_uri() . '/site/images' );
}
```
and then you can use img tag as
```
<img src="<?php echo THEME_IMG_PATH; ?>/footLogo.png" style="padding: 0px!important; color:white">
``` |
252,595 | <p>Here's the codes i used to display the posts of my custom post "episode"</p>
<pre><code><?php
if( is_home() ){
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( array('post_type'=>array('episodes',),'paged'=>$paged ) ); } ?>
<?php if (have_posts()) : ?>
<?php post_m... | [
{
"answer_id": 252561,
"author": "Samuel Asor",
"author_id": 84265,
"author_profile": "https://wordpress.stackexchange.com/users/84265",
"pm_score": 1,
"selected": false,
"text": "<p>You'll have to copy the full path to the image like so:<br>\n<code>http://www.your-site-name.extension/wp... | 2017/01/15 | [
"https://wordpress.stackexchange.com/questions/252595",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110405/"
] | Here's the codes i used to display the posts of my custom post "episode"
```
<?php
if( is_home() ){
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( array('post_type'=>array('episodes',),'paged'=>$paged ) ); } ?>
<?php if (have_posts()) : ?>
<?php post_movies_true(); ?>
<?php while (have_... | You can define constant in theme function file as:
```
if( !defined(THEME_IMG_PATH)){
define( 'THEME_IMG_PATH', get_stylesheet_directory_uri() . '/site/images' );
}
```
and then you can use img tag as
```
<img src="<?php echo THEME_IMG_PATH; ?>/footLogo.png" style="padding: 0px!important; color:white">
``` |
252,609 | <p>i want show last 3 days posts Randomly.
how can i edit this code?</p>
<pre><code><?php
$randompost = array(
'numberposts' => 2,
'type' => 'news',
'orderby' => 'rand',
'year' => date( 'Y' ),
'week' => date( 'W' ),
);
$rand_posts = get_posts( $randompost );
foreach( $rand_posts as $post ) : ?>
&l... | [
{
"answer_id": 252621,
"author": "Samuel Asor",
"author_id": 84265,
"author_profile": "https://wordpress.stackexchange.com/users/84265",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the code below:</p>\n\n<pre><code>$today = getdate();\n$randompost = array(\n 'date_query'... | 2017/01/15 | [
"https://wordpress.stackexchange.com/questions/252609",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107899/"
] | i want show last 3 days posts Randomly.
how can i edit this code?
```
<?php
$randompost = array(
'numberposts' => 2,
'type' => 'news',
'orderby' => 'rand',
'year' => date( 'Y' ),
'week' => date( 'W' ),
);
$rand_posts = get_posts( $randompost );
foreach( $rand_posts as $post ) : ?>
<?php endforeach; ?>
``` | You can use this code for show last 3 days post. Best of luck...
```
$args = array(
'post_status' => 'publish',
'type' => 'news',
'posts_per_page' => 2,
'order' => 'rand',
'date_query' => array(
array(
'after' => '3 days ago'
)
)
);
``` |
252,620 | <p>As in wordpress multi site, wordpress removed "Ping List Text Area" from Setting->Writing added Text Field in Network-Admin->All-Sites->Edit->Settings, I'm not able to understand that How we should add Ping List Url in text field.
Eg.:
http ://xyz [dot] com/rpc2 , http ://xyz1 [dot] com/rpc2
or
http ://xyz [dot] co... | [
{
"answer_id": 252621,
"author": "Samuel Asor",
"author_id": 84265,
"author_profile": "https://wordpress.stackexchange.com/users/84265",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the code below:</p>\n\n<pre><code>$today = getdate();\n$randompost = array(\n 'date_query'... | 2017/01/15 | [
"https://wordpress.stackexchange.com/questions/252620",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110962/"
] | As in wordpress multi site, wordpress removed "Ping List Text Area" from Setting->Writing added Text Field in Network-Admin->All-Sites->Edit->Settings, I'm not able to understand that How we should add Ping List Url in text field.
Eg.:
http ://xyz [dot] com/rpc2 , http ://xyz1 [dot] com/rpc2
or
http ://xyz [dot] com/r... | You can use this code for show last 3 days post. Best of luck...
```
$args = array(
'post_status' => 'publish',
'type' => 'news',
'posts_per_page' => 2,
'order' => 'rand',
'date_query' => array(
array(
'after' => '3 days ago'
)
)
);
``` |
252,622 | <p>I'm using the plugin 'Ninja From' and I'm trying to stop it from loading a CSS file in the header.</p>
<p>The CSS file:</p>
<pre><code><link rel='stylesheet' id='nf-display-css' href='http://example.com/wp-content/plugins/ninja-forms/assets/css/display-structure.css?ver=4.7.1' type='text/css' media='all' />... | [
{
"answer_id": 252623,
"author": "Samuel Asor",
"author_id": 84265,
"author_profile": "https://wordpress.stackexchange.com/users/84265",
"pm_score": -1,
"selected": false,
"text": "<p>In WordPress priority <code>$arg</code>, <em>Lower numbers correspond with earlier execution, and functi... | 2017/01/15 | [
"https://wordpress.stackexchange.com/questions/252622",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110964/"
] | I'm using the plugin 'Ninja From' and I'm trying to stop it from loading a CSS file in the header.
The CSS file:
```
<link rel='stylesheet' id='nf-display-css' href='http://example.com/wp-content/plugins/ninja-forms/assets/css/display-structure.css?ver=4.7.1' type='text/css' media='all' />
```
My code:
```
functi... | Extract the ninja form plugin's files to a folder, and use a text editor such as Notepad++ to search within the files of the plugin and find either one of these phrases:
```
`wp_enqueue_style` OR `css_ninja_form`
```
You will end up with at least 1 result, which will be similar to :
```
add_action( 'wp_enqueue_sc... |
252,640 | <p>I have implemented AAPL on a new website which loads in Wordpress pages using AJAX.</p>
<p>Problem: For some unknown reason, css styles which are supposed to be loaded via enqueue are not being loaded.</p>
<p>If I click a page, some effects and transitions don't load - when checking the element, the css isn't visi... | [
{
"answer_id": 252623,
"author": "Samuel Asor",
"author_id": 84265,
"author_profile": "https://wordpress.stackexchange.com/users/84265",
"pm_score": -1,
"selected": false,
"text": "<p>In WordPress priority <code>$arg</code>, <em>Lower numbers correspond with earlier execution, and functi... | 2017/01/16 | [
"https://wordpress.stackexchange.com/questions/252640",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10368/"
] | I have implemented AAPL on a new website which loads in Wordpress pages using AJAX.
Problem: For some unknown reason, css styles which are supposed to be loaded via enqueue are not being loaded.
If I click a page, some effects and transitions don't load - when checking the element, the css isn't visible. I then click... | Extract the ninja form plugin's files to a folder, and use a text editor such as Notepad++ to search within the files of the plugin and find either one of these phrases:
```
`wp_enqueue_style` OR `css_ninja_form`
```
You will end up with at least 1 result, which will be similar to :
```
add_action( 'wp_enqueue_sc... |
252,645 | <p>I am new in wordpress, and I want to change a word in theme,for example in one of pages I have "view all" word, I want to change it to "see all"
How can i do this?</p>
| [
{
"answer_id": 252646,
"author": "prosti",
"author_id": 88606,
"author_profile": "https://wordpress.stackexchange.com/users/88606",
"pm_score": 3,
"selected": true,
"text": "<p>Some would say it is hard to answer based on the few information you provided.</p>\n\n<p>However, the answer ma... | 2017/01/16 | [
"https://wordpress.stackexchange.com/questions/252645",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110983/"
] | I am new in wordpress, and I want to change a word in theme,for example in one of pages I have "view all" word, I want to change it to "see all"
How can i do this? | Some would say it is hard to answer based on the few information you provided.
However, the answer may be general enough to cover many more problems similar to your case.
First I would install this [plugin](https://wordpress.org/plugins/show-current-template/).
Check the screenshots section for more info:
<https://w... |
252,658 | <p>Need to switch theme when accessed from sub domain. There is nothing installed in the sub domain. I have setup a subdomain as a CNAME pointing to the original domain. Then, detect whether or not the visitor is on the subdomain by looking at $_SERVER[‘SERVER_NAME’]. Went through various sources and have found out thi... | [
{
"answer_id": 252665,
"author": "KAGG Design",
"author_id": 108721,
"author_profile": "https://wordpress.stackexchange.com/users/108721",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress supports only one theme on site. Actions like shown will cause a adverse effects.\nInstead, ... | 2017/01/16 | [
"https://wordpress.stackexchange.com/questions/252658",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111003/"
] | Need to switch theme when accessed from sub domain. There is nothing installed in the sub domain. I have setup a subdomain as a CNAME pointing to the original domain. Then, detect whether or not the visitor is on the subdomain by looking at $\_SERVER[‘SERVER\_NAME’]. Went through various sources and have found out this... | WordPress supports only one theme on site. Actions like shown will cause a adverse effects.
Instead, you should use WordPress Multisite, which allows to use different themes on subdomains. This is the way recommended by the WordPress team.
There is solution for WooCommerce on WordPress Multisite: [WooCommerce Multisto... |
252,680 | <p><strong>TL;DR</strong> - Why is my user account not logged in during an AJAX request which is made inside wp-admin?</p>
<hr>
<p>I have the following setup:</p>
<pre><code><?php
add_action('wp_ajax_foobar_action', 'foobar_action');
add_action('wp_ajax_nopriv_foobar_action', 'foobar_action');
function foobar_a... | [
{
"answer_id": 252683,
"author": "T.Todua",
"author_id": 33667,
"author_profile": "https://wordpress.stackexchange.com/users/33667",
"pm_score": 0,
"selected": false,
"text": "<p>I think problem could be due to the consequence: </p>\n\n<p>in HTML source, firstly, this should be outputed:... | 2017/01/16 | [
"https://wordpress.stackexchange.com/questions/252680",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34299/"
] | **TL;DR** - Why is my user account not logged in during an AJAX request which is made inside wp-admin?
---
I have the following setup:
```
<?php
add_action('wp_ajax_foobar_action', 'foobar_action');
add_action('wp_ajax_nopriv_foobar_action', 'foobar_action');
function foobar_action() {
check_ajax_referrer();
... | After some fiddling and sparring with @t-todua I found the issue:
With the Fetch API `fetch` call you must manually set to send cookies with a request. After setting the `credentials` option properly the cookies were sent and the AJAX endpoint recognized the current user. So the JS becomes:
```
var msg = '';
// I'm ... |
252,689 | <p>I have written following js code</p>
<pre><code>jQuery(".selectbox").change(function(){
var id = this.id;
var key_id=id;
var selectname='';
jQuery.post(
// see tip #1 for how we declare global javascript variables
MyAjax.ajaxurl,
{
// here we declare the parameters to send along with the... | [
{
"answer_id": 252683,
"author": "T.Todua",
"author_id": 33667,
"author_profile": "https://wordpress.stackexchange.com/users/33667",
"pm_score": 0,
"selected": false,
"text": "<p>I think problem could be due to the consequence: </p>\n\n<p>in HTML source, firstly, this should be outputed:... | 2017/01/16 | [
"https://wordpress.stackexchange.com/questions/252689",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/95126/"
] | I have written following js code
```
jQuery(".selectbox").change(function(){
var id = this.id;
var key_id=id;
var selectname='';
jQuery.post(
// see tip #1 for how we declare global javascript variables
MyAjax.ajaxurl,
{
// here we declare the parameters to send along with the request
... | After some fiddling and sparring with @t-todua I found the issue:
With the Fetch API `fetch` call you must manually set to send cookies with a request. After setting the `credentials` option properly the cookies were sent and the AJAX endpoint recognized the current user. So the JS becomes:
```
var msg = '';
// I'm ... |
252,700 | <p>Sorry if it's a duplicate question,
I just want to change a little the WordPress core function <code>get_header()</code> with new function <code>new_get_header()</code>.</p>
<pre><code>function new_get_header() {
// new header fragments;
}
</code></pre>
<p><strong>Is this possible?</strong></p>
<pre><code>ad... | [
{
"answer_id": 252683,
"author": "T.Todua",
"author_id": 33667,
"author_profile": "https://wordpress.stackexchange.com/users/33667",
"pm_score": 0,
"selected": false,
"text": "<p>I think problem could be due to the consequence: </p>\n\n<p>in HTML source, firstly, this should be outputed:... | 2017/01/16 | [
"https://wordpress.stackexchange.com/questions/252700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101492/"
] | Sorry if it's a duplicate question,
I just want to change a little the WordPress core function `get_header()` with new function `new_get_header()`.
```
function new_get_header() {
// new header fragments;
}
```
**Is this possible?**
```
add_filter( 'get_header', 'new_get_header' );
```
**Or should I use:**
... | After some fiddling and sparring with @t-todua I found the issue:
With the Fetch API `fetch` call you must manually set to send cookies with a request. After setting the `credentials` option properly the cookies were sent and the AJAX endpoint recognized the current user. So the JS becomes:
```
var msg = '';
// I'm ... |
252,709 | <p>I am trying to figure out if it is possible to add elements to the widgetpage in WordPress' dashboard without editing the widgets.php core file. Is there a WordPress function or something else (maybe even a jQuery solution) that will get this done? </p>
<p>If I google this the only results are about widget area's b... | [
{
"answer_id": 252721,
"author": "Kudratullah",
"author_id": 62726,
"author_profile": "https://wordpress.stackexchange.com/users/62726",
"pm_score": 0,
"selected": false,
"text": "<p>There is few <code>action</code> hooks in <a href=\"https://core.trac.wordpress.org/browser/tags/4.7/src/... | 2017/01/16 | [
"https://wordpress.stackexchange.com/questions/252709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111030/"
] | I am trying to figure out if it is possible to add elements to the widgetpage in WordPress' dashboard without editing the widgets.php core file. Is there a WordPress function or something else (maybe even a jQuery solution) that will get this done?
If I google this the only results are about widget area's but I just ... | You can use @kudratullah's suggestion to hook into the widgets page. The downside is that this allows insertion of a piece of html only in one specific place. If that location is ok, use that solution.
Otherwise, there are two other possibilities.
The first is to use jquery. Examine the source to identify the html el... |
252,715 | <p>I have created the following "plugin" following the codex but it doesn't seem to work. It is supposed to add 100 points to user meta everytime he/she posts a new blog post.</p>
<p>Could you please let me know what is wrong with it...</p>
<pre><code>function post_published_add_points( $ID, $post ) {
$author = $po... | [
{
"answer_id": 252721,
"author": "Kudratullah",
"author_id": 62726,
"author_profile": "https://wordpress.stackexchange.com/users/62726",
"pm_score": 0,
"selected": false,
"text": "<p>There is few <code>action</code> hooks in <a href=\"https://core.trac.wordpress.org/browser/tags/4.7/src/... | 2017/01/16 | [
"https://wordpress.stackexchange.com/questions/252715",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110131/"
] | I have created the following "plugin" following the codex but it doesn't seem to work. It is supposed to add 100 points to user meta everytime he/she posts a new blog post.
Could you please let me know what is wrong with it...
```
function post_published_add_points( $ID, $post ) {
$author = $post->post_author; /* P... | You can use @kudratullah's suggestion to hook into the widgets page. The downside is that this allows insertion of a piece of html only in one specific place. If that location is ok, use that solution.
Otherwise, there are two other possibilities.
The first is to use jquery. Examine the source to identify the html el... |
252,730 | <p>I need to set 1 cookie, saving a data sent from a form.</p>
<p>I see that I have to hook my setcookie() to the 'init'. That's OK.</p>
<pre><code>add_action( 'init', 'cookie_function');
</code></pre>
<p>My 'cookie_function' will have $cookieName, $cookieValue, $time, COOKIEPATH, COOKIEDOMAIN.</p>
<p>If I need som... | [
{
"answer_id": 252734,
"author": "CK MacLeod",
"author_id": 35923,
"author_profile": "https://wordpress.stackexchange.com/users/35923",
"pm_score": 1,
"selected": false,
"text": "<p>You use setcookie() like any other function, with parameters as described in the Codex. </p>\n\n<p>How you... | 2017/01/16 | [
"https://wordpress.stackexchange.com/questions/252730",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111037/"
] | I need to set 1 cookie, saving a data sent from a form.
I see that I have to hook my setcookie() to the 'init'. That's OK.
```
add_action( 'init', 'cookie_function');
```
My 'cookie\_function' will have $cookieName, $cookieValue, $time, COOKIEPATH, COOKIEDOMAIN.
If I need something like setcookie('test', $\_POST['... | You use setcookie() like any other function, with parameters as described in the Codex.
How you would use it in a form would usually depend on how and when the $\_COOKIE variable needs to be made accessible.
One common method, if you want a change in the DOM both to register immediately and to persist, is to use a ... |
252,740 | <p>I'm building currently a website on WordPress. The site has a custom post type. I have a customized search form, which selects entries from custom post type. Entries are being selected and sorted as they are supposed to, however on my search result page (job-search.php) I need a pagination, and it's not working, alt... | [
{
"answer_id": 252742,
"author": "socki03",
"author_id": 43511,
"author_profile": "https://wordpress.stackexchange.com/users/43511",
"pm_score": -1,
"selected": false,
"text": "<p>Everything looks like things I've used in a similar fashion. The only thing, is, I believe the <code>functi... | 2017/01/16 | [
"https://wordpress.stackexchange.com/questions/252740",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105223/"
] | I'm building currently a website on WordPress. The site has a custom post type. I have a customized search form, which selects entries from custom post type. Entries are being selected and sorted as they are supposed to, however on my search result page (job-search.php) I need a pagination, and it's not working, althou... | From your job-search.php replace `'posts_per_page' => 10,` to `'posts_per_page' => 3,`
and Simply add this following code in your search page, i mean where you are searching the posts.
```
the_posts_pagination( array( 'mid_size' => 2 ) );
``` |
252,743 | <p>I have a taxonomy called "location". I'm outputting a comma separated list of these taxonomy terms for a post. This is fine, but I don't know how to split the second-to-last and last items with "and" instead of a comma. </p>
<p>Here is my code. Is there a way to do it using the counter maybe?</p>
<pre><code>$locat... | [
{
"answer_id": 252746,
"author": "Shibi",
"author_id": 62500,
"author_profile": "https://wordpress.stackexchange.com/users/62500",
"pm_score": 3,
"selected": true,
"text": "<p>This is how your code should look like I added some comments so you will understand its simple programming not r... | 2017/01/16 | [
"https://wordpress.stackexchange.com/questions/252743",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22448/"
] | I have a taxonomy called "location". I'm outputting a comma separated list of these taxonomy terms for a post. This is fine, but I don't know how to split the second-to-last and last items with "and" instead of a comma.
Here is my code. Is there a way to do it using the counter maybe?
```
$locations = get_the_terms(... | This is how your code should look like I added some comments so you will understand its simple programming not really wordpress related.
```
$locations = get_the_terms($post->ID, 'location');
$locations = array_values($locations);
$total_locations = count($locations); // the total start from 1
for($i = 0; $i < $tota... |
252,760 | <p>I am trying to load more content with ajax. the script does not return anything when I am logged out.</p>
<p>this is my php code</p>
<pre><code><?php
function get_blog_items()
{
$offset = (int)intval($_POST['offset']);
$args = array(
'posts_per_page' => 4,
'post_type' => 'post',... | [
{
"answer_id": 252761,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<pre><code>function add_ajax_actions() {\n add_action( 'wp_ajax_nopriv_get_blog_items', 'get_blog_items' );\... | 2017/01/16 | [
"https://wordpress.stackexchange.com/questions/252760",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107702/"
] | I am trying to load more content with ajax. the script does not return anything when I am logged out.
this is my php code
```
<?php
function get_blog_items()
{
$offset = (int)intval($_POST['offset']);
$args = array(
'posts_per_page' => 4,
'post_type' => 'post',
'offset' => $offset
... | ```
function add_ajax_actions() {
add_action( 'wp_ajax_nopriv_get_blog_items', 'get_blog_items' );
}
add_action( 'admin_init', 'add_ajax_actions' );
```
`admin_init` only runs when the admin area is initialised. Logged out people can't access wp-admin, so `add_action( 'wp_ajax_nopriv_get_blog_items', 'get_blog_i... |
252,765 | <p>I plan to bulid up a nice developer environment and for this I need to clone the actual running website to a 100% into a <code>dev</code> directory.</p>
<p>I've now uploaded the same version of wordpress as on my running site and wondering if I could enter the same database and the same prefix as for the running si... | [
{
"answer_id": 252766,
"author": "kirillrocks",
"author_id": 111056,
"author_profile": "https://wordpress.stackexchange.com/users/111056",
"pm_score": 0,
"selected": false,
"text": "<p>If you production server allows database connection from anywhere - it will connect. but every update y... | 2017/01/17 | [
"https://wordpress.stackexchange.com/questions/252765",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93282/"
] | I plan to bulid up a nice developer environment and for this I need to clone the actual running website to a 100% into a `dev` directory.
I've now uploaded the same version of wordpress as on my running site and wondering if I could enter the same database and the same prefix as for the running site while running thro... | Based on your question, I am not exactly sure where your local build sits right now.
This answer is assuming you are starting from scratch, but have a copy of a working wordpress website on a live web server, and working on a mac.
You need to install a web server onto your local computer. I am recommending MAMP.
<h... |
252,774 | <p>Simple question: I know this can be achieved with a hook somewhere, but I'm having trouble tracking down exactly where I need to look to implement it. Basically, I need to hook into the featured image / thumbnail hook and update the image URL on the fly. Can someone lend a hand on how I might achieve this with the h... | [
{
"answer_id": 252783,
"author": "Vishal Kumar Sahu",
"author_id": 101300,
"author_profile": "https://wordpress.stackexchange.com/users/101300",
"pm_score": 0,
"selected": false,
"text": "<p>With PHP it is possible... Just create a function which copies your featured image and renames it... | 2017/01/17 | [
"https://wordpress.stackexchange.com/questions/252774",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27041/"
] | Simple question: I know this can be achieved with a hook somewhere, but I'm having trouble tracking down exactly where I need to look to implement it. Basically, I need to hook into the featured image / thumbnail hook and update the image URL on the fly. Can someone lend a hand on how I might achieve this with the hook... | HTML generated by `the_post_thumbnail()` & `get_the_post_thumbnail()` can be altered using the `post_thumbnail_html` filter. This works even when there is no post thumbnail. Example:
```
/**
* Filters the post thumbnail HTML.
*
* @since 2.9.0
*
* @param string $html The post thumbnail HTML.
* ... |
252,799 | <p>Is there a way to disable the edit shortcut buttons that was added in WordPress 4.7?</p>
<p>I noticed they have a class <code>customize-partial-edit-shortcut-button</code> and I can add <code>display:none</code> in css but trying to find a solution in php.</p>
<p><a href="https://i.stack.imgur.com/qfJZ2.png" rel="... | [
{
"answer_id": 252800,
"author": "Umer Shoukat",
"author_id": 94940,
"author_profile": "https://wordpress.stackexchange.com/users/94940",
"pm_score": -1,
"selected": false,
"text": "<p>This featured is enabled by just adding theme support feature. Here is the code</p>\n\n<pre><code>add_t... | 2017/01/17 | [
"https://wordpress.stackexchange.com/questions/252799",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111079/"
] | Is there a way to disable the edit shortcut buttons that was added in WordPress 4.7?
I noticed they have a class `customize-partial-edit-shortcut-button` and I can add `display:none` in css but trying to find a solution in php.
[](https://i.stack.img... | The simplest way to disable edit shortcuts without unwanted side effects is to no-op override the JS function that generates them in the first place. You can do this from PHP as follows:
```
add_action( 'wp_enqueue_scripts', function () {
$js = 'wp.customize.selectiveRefresh.Partial.prototype.createEditShortcutFor... |
252,816 | <p>I have a rtl.css file for my theme. when i change site language
to Persian (from settings), rtl.css loaded and work properly.But i want to keep in english lanuage and load rtl.css file. How i do it? when language change, what happens?
please help me.
Tnx a lot.</p>
| [
{
"answer_id": 252800,
"author": "Umer Shoukat",
"author_id": 94940,
"author_profile": "https://wordpress.stackexchange.com/users/94940",
"pm_score": -1,
"selected": false,
"text": "<p>This featured is enabled by just adding theme support feature. Here is the code</p>\n\n<pre><code>add_t... | 2017/01/17 | [
"https://wordpress.stackexchange.com/questions/252816",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111093/"
] | I have a rtl.css file for my theme. when i change site language
to Persian (from settings), rtl.css loaded and work properly.But i want to keep in english lanuage and load rtl.css file. How i do it? when language change, what happens?
please help me.
Tnx a lot. | The simplest way to disable edit shortcuts without unwanted side effects is to no-op override the JS function that generates them in the first place. You can do this from PHP as follows:
```
add_action( 'wp_enqueue_scripts', function () {
$js = 'wp.customize.selectiveRefresh.Partial.prototype.createEditShortcutFor... |
252,825 | <p>I would like to know the best part of the code to catch a 404 that doesn't match a template.
However at this point I will check for the url string and output my own dynamic html if it matches a pattern. It is DYNAMIC content because there is no content in the wordpress backend for it. So I am looking to echo html an... | [
{
"answer_id": 252800,
"author": "Umer Shoukat",
"author_id": 94940,
"author_profile": "https://wordpress.stackexchange.com/users/94940",
"pm_score": -1,
"selected": false,
"text": "<p>This featured is enabled by just adding theme support feature. Here is the code</p>\n\n<pre><code>add_t... | 2017/01/17 | [
"https://wordpress.stackexchange.com/questions/252825",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96548/"
] | I would like to know the best part of the code to catch a 404 that doesn't match a template.
However at this point I will check for the url string and output my own dynamic html if it matches a pattern. It is DYNAMIC content because there is no content in the wordpress backend for it. So I am looking to echo html and e... | The simplest way to disable edit shortcuts without unwanted side effects is to no-op override the JS function that generates them in the first place. You can do this from PHP as follows:
```
add_action( 'wp_enqueue_scripts', function () {
$js = 'wp.customize.selectiveRefresh.Partial.prototype.createEditShortcutFor... |
252,849 | <p>I've done numerous WP sites, written my own plugins, run my own server, etc etc.</p>
<p>But I have not seen this before. I just installed a fresh 4.7.1 and installed the <a href="http://www.newsmartwave.net/?theme=porto_wp" rel="nofollow noreferrer">Proto theme</a> and all its plugins.</p>
<p>When I went to add me... | [
{
"answer_id": 252857,
"author": "prosti",
"author_id": 88606,
"author_profile": "https://wordpress.stackexchange.com/users/88606",
"pm_score": 2,
"selected": false,
"text": "<p>Three things you need to check.</p>\n\n<p><code>upload_max_filesize</code>, <code>memory_limit</code> and <cod... | 2017/01/17 | [
"https://wordpress.stackexchange.com/questions/252849",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111117/"
] | I've done numerous WP sites, written my own plugins, run my own server, etc etc.
But I have not seen this before. I just installed a fresh 4.7.1 and installed the [Proto theme](http://www.newsmartwave.net/?theme=porto_wp) and all its plugins.
When I went to add media files, I got:
```
Maximum upload file size: 2 KB.... | Three things you need to check.
`upload_max_filesize`, `memory_limit` and `post_max_size` in the php.ini configuration file exactly.
All of these three settings limit the maximum size of data that can be submitted and handled by PHP.
Typically `post_max_size` and `memory_limit` need to be larger than `upload_max_fil... |
252,865 | <p>I want to make a custom WP_Query using custom taxonomy terms ID´s.</p>
<p>Example of the term’s ID’s : 19,18,214,226,20</p>
<p>Why does this work:</p>
<pre><code>$query_args = array (
'post_type' => 'works’,
'tax_query' => array(
array(
'taxonomy' => 'materials',
... | [
{
"answer_id": 252868,
"author": "Pedro Coitinho",
"author_id": 111122,
"author_profile": "https://wordpress.stackexchange.com/users/111122",
"pm_score": 5,
"selected": true,
"text": "<p>It looks like you are making an array with a single string inside.</p>\n\n<p>Check if making $tax int... | 2017/01/17 | [
"https://wordpress.stackexchange.com/questions/252865",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16324/"
] | I want to make a custom WP\_Query using custom taxonomy terms ID´s.
Example of the term’s ID’s : 19,18,214,226,20
Why does this work:
```
$query_args = array (
'post_type' => 'works’,
'tax_query' => array(
array(
'taxonomy' => 'materials',
'field' => 'term_id',
... | It looks like you are making an array with a single string inside.
Check if making $tax into an array before passing it will work:
```
$tax = array( 19, 18, 214, 226, 20 );
$query_args = array (
'post_type' => 'works',
'tax_query' => array(
array(
'taxonomy' => 'materials',
'... |
252,877 | <p>I've created a new custom post type called <code>doctors</code>. I've been using ACF and pulling these fields to help create my banner. I was wondering what a post would look like if no fields were filled out, so I created a second test post, but I noticed it has all of the same content as my first post.</p>
<p>I f... | [
{
"answer_id": 252881,
"author": "Pedro Coitinho",
"author_id": 111122,
"author_profile": "https://wordpress.stackexchange.com/users/111122",
"pm_score": 0,
"selected": false,
"text": "<p>It looks like you are not supplying the ID into the loop, forcing it to get the first item chronolog... | 2017/01/17 | [
"https://wordpress.stackexchange.com/questions/252877",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96257/"
] | I've created a new custom post type called `doctors`. I've been using ACF and pulling these fields to help create my banner. I was wondering what a post would look like if no fields were filled out, so I created a second test post, but I noticed it has all of the same content as my first post.
I feel like I'm writing ... | You are querying the entire posts of `doctors` type, and setting the number of posts per page to one. This will obviously always return the same post.
You need to either set the id of the post, or navigate through the loop to find a match. If you are calling this function in single post page, to filter the results bas... |
252,920 | <p>I want to change the default WordPress author link (which is /author/user_nicename) to/author/user_id.</p>
<p>And I found it's easy to do that, I achieved this in two ways:</p>
<p>1.I just copy the <code>get_author_posts_url()</code> function from <code>wp-includes/author-template.php</code> and rewrite it in my t... | [
{
"answer_id": 252899,
"author": "fatwombat",
"author_id": 81482,
"author_profile": "https://wordpress.stackexchange.com/users/81482",
"pm_score": 1,
"selected": false,
"text": "<p>I am doing the same thing at the moment and I just use the standard WP login/register systems/pages.</p>\n\... | 2017/01/18 | [
"https://wordpress.stackexchange.com/questions/252920",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105000/"
] | I want to change the default WordPress author link (which is /author/user\_nicename) to/author/user\_id.
And I found it's easy to do that, I achieved this in two ways:
1.I just copy the `get_author_posts_url()` function from `wp-includes/author-template.php` and rewrite it in my theme:
```
function ji_get_user_url($... | I am doing the same thing at the moment and I just use the standard WP login/register systems/pages.
You can use [wp\_signon()](https://developer.wordpress.org/reference/functions/wp_signon/) to do logon.
Then on a standard page, you can create a custom template and use this for retrieving their info: [wp\_get\_curre... |
252,922 | <p>Why is it that when I attempt to change the URL for searches, it breaks if set to anything other than <code>search</code>?</p>
<pre><code>function bfm_pretty_search () {
if (is_search() && !empty($_GET['s'])) {
wp_redirect(home_url('/search/').urlencode(get_query_var('s')));
exit();
... | [
{
"answer_id": 252924,
"author": "Umer Shoukat",
"author_id": 94940,
"author_profile": "https://wordpress.stackexchange.com/users/94940",
"pm_score": 2,
"selected": false,
"text": "<p>To change the search url hook in this function this will replace \"search\" to whatever you want.</p>\n\... | 2017/01/18 | [
"https://wordpress.stackexchange.com/questions/252922",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25735/"
] | Why is it that when I attempt to change the URL for searches, it breaks if set to anything other than `search`?
```
function bfm_pretty_search () {
if (is_search() && !empty($_GET['s'])) {
wp_redirect(home_url('/search/').urlencode(get_query_var('s')));
exit();
}
}
add_action('template_redire... | To change the search url hook in this function this will replace "search" to whatever you want.
```
add_action( 'init', 'wpse21549_init' );
function wpse21549_init()
{
$GLOBALS['wp_rewrite']->search_base = 'results';
}
```
place this code in your functions.php file and after saving this file. Go to permalink set... |
252,925 | <p>For the homepage, I'd like the main page background to be the background for the entire page, including the footer.</p>
<p>Please help!?</p>
<p>Reed</p>
<p><a href="https://i.stack.imgur.com/4YifW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4YifW.jpg" alt="enter image description here"></a>... | [
{
"answer_id": 252928,
"author": "Umer Shoukat",
"author_id": 94940,
"author_profile": "https://wordpress.stackexchange.com/users/94940",
"pm_score": 1,
"selected": false,
"text": "<p>It's better if you share the the link to your site OR if you can show us the attempts you have made and ... | 2017/01/18 | [
"https://wordpress.stackexchange.com/questions/252925",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111160/"
] | For the homepage, I'd like the main page background to be the background for the entire page, including the footer.
Please help!?
Reed
[](https://i.stack.imgur.com/4YifW.jpg) | It's better if you share the the link to your site OR if you can show us the attempts you have made and the problems which your are facing while doing so.
A suggestion for to do so is to make footer background transparent and apply background image to your .page class which is default wordpress class you can be more ... |
252,947 | <p>I have wordpress template from themeforest and I would like to set it up, just like demo page on themeforest....</p>
<p>I found files like customizer.dat.txt, demo=content.xml, widgets.json ...</p>
<p>they probably serve for this purpose but as I'm newbie in Wordpress, have no idea how to use them.</p>
<p>Can you... | [
{
"answer_id": 252928,
"author": "Umer Shoukat",
"author_id": 94940,
"author_profile": "https://wordpress.stackexchange.com/users/94940",
"pm_score": 1,
"selected": false,
"text": "<p>It's better if you share the the link to your site OR if you can show us the attempts you have made and ... | 2017/01/18 | [
"https://wordpress.stackexchange.com/questions/252947",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111175/"
] | I have wordpress template from themeforest and I would like to set it up, just like demo page on themeforest....
I found files like customizer.dat.txt, demo=content.xml, widgets.json ...
they probably serve for this purpose but as I'm newbie in Wordpress, have no idea how to use them.
Can you please help me how to i... | It's better if you share the the link to your site OR if you can show us the attempts you have made and the problems which your are facing while doing so.
A suggestion for to do so is to make footer background transparent and apply background image to your .page class which is default wordpress class you can be more ... |
252,951 | <p>how to insert data in wordpress using jquery ajax for my plugin, i tried a lot but my action.php page not access global $wpdb, Please tell me where is the problem.</p>
<p>Here is the code of my submenu page of plugin</p>
<pre><code><?php
function pincode()
{
?>
<link re... | [
{
"answer_id": 252957,
"author": "Ravi Shinde",
"author_id": 99294,
"author_profile": "https://wordpress.stackexchange.com/users/99294",
"pm_score": 2,
"selected": false,
"text": "<p>The code you have shared can work in core PHP and not in Wordpress. Using AJAX in Wordpress plugin is exp... | 2017/01/18 | [
"https://wordpress.stackexchange.com/questions/252951",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110592/"
] | how to insert data in wordpress using jquery ajax for my plugin, i tried a lot but my action.php page not access global $wpdb, Please tell me where is the problem.
Here is the code of my submenu page of plugin
```
<?php
function pincode()
{
?>
<link rel="stylesheet" href="http://ma... | The code you have shared can work in core PHP and not in Wordpress. Using AJAX in Wordpress plugin is explained in Wordpress documentation. Please refer - <https://codex.wordpress.org/AJAX_in_Plugins>
I have tried this and it works well. |
252,963 | <p>How to make this query more simplest and in one query? </p>
<p>Problem - only topics has a meta_key 'include_newsletter_feed'<br>
So i need get all posts ("product", "post", "page") excluding categories (124, 52)<br>
And join all topics with meta. </p>
<p>Example ugly code</p>
<pre><code>$arg = array(
... | [
{
"answer_id": 252957,
"author": "Ravi Shinde",
"author_id": 99294,
"author_profile": "https://wordpress.stackexchange.com/users/99294",
"pm_score": 2,
"selected": false,
"text": "<p>The code you have shared can work in core PHP and not in Wordpress. Using AJAX in Wordpress plugin is exp... | 2017/01/18 | [
"https://wordpress.stackexchange.com/questions/252963",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111184/"
] | How to make this query more simplest and in one query?
Problem - only topics has a meta\_key 'include\_newsletter\_feed'
So i need get all posts ("product", "post", "page") excluding categories (124, 52)
And join all topics with meta.
Example ugly code
```
$arg = array(
"post_type" => array("product... | The code you have shared can work in core PHP and not in Wordpress. Using AJAX in Wordpress plugin is explained in Wordpress documentation. Please refer - <https://codex.wordpress.org/AJAX_in_Plugins>
I have tried this and it works well. |
252,968 | <p>Below is my code in which everything is working fine except when clicking read more button it's doing nothing</p>
<pre><code><?php get_header() ; ?>
<section class="container">
<div class="row">
<div class="col-sm-8">
<?php if ( have_posts() ) : while ... | [
{
"answer_id": 252957,
"author": "Ravi Shinde",
"author_id": 99294,
"author_profile": "https://wordpress.stackexchange.com/users/99294",
"pm_score": 2,
"selected": false,
"text": "<p>The code you have shared can work in core PHP and not in Wordpress. Using AJAX in Wordpress plugin is exp... | 2017/01/18 | [
"https://wordpress.stackexchange.com/questions/252968",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/100679/"
] | Below is my code in which everything is working fine except when clicking read more button it's doing nothing
```
<?php get_header() ; ?>
<section class="container">
<div class="row">
<div class="col-sm-8">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
... | The code you have shared can work in core PHP and not in Wordpress. Using AJAX in Wordpress plugin is explained in Wordpress documentation. Please refer - <https://codex.wordpress.org/AJAX_in_Plugins>
I have tried this and it works well. |
252,976 | <p>I am trying to fetch more posts on click via ajax. In my functions I have localised the script </p>
<pre><code>wp_enqueue_script( 'news', get_template_directory_uri().'/news/js/news.js', '', '', true );
//Localise script for ajax call
wp_localize_script( 'news', 'ajax_posts', array(
'ajaxurl' => admin_... | [
{
"answer_id": 252988,
"author": "Anton Pedan",
"author_id": 105771,
"author_profile": "https://wordpress.stackexchange.com/users/105771",
"pm_score": 2,
"selected": false,
"text": "<p>Try die() function in the end of PHP function. It will helps.</p>\n\n<p>UPD: I<code>ve made some simple... | 2017/01/18 | [
"https://wordpress.stackexchange.com/questions/252976",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111192/"
] | I am trying to fetch more posts on click via ajax. In my functions I have localised the script
```
wp_enqueue_script( 'news', get_template_directory_uri().'/news/js/news.js', '', '', true );
//Localise script for ajax call
wp_localize_script( 'news', 'ajax_posts', array(
'ajaxurl' => admin_url( 'admin-ajax.p... | Try die() function in the end of PHP function. It will helps.
UPD: I`ve made some simple version of your problem code to check it and it works. I think it will helps you.
You are able to change inner PHP script to your logic and it won`t returns 0.
PHP:
```
function more_post_ajax(){
echo "Hello";
die();
}
add_... |
253,032 | <p>I have two wordpress installs each on their own sub domain.</p>
<p><strong>sub1.domain.com</strong> and <strong>sub2.domain.com</strong></p>
<p>I want to share the login information between sub1 and sub2. I already have configured them to use the same MySQL database, and they use the same database table.</p>
<p>I... | [
{
"answer_id": 264504,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 1,
"selected": false,
"text": "<p>Today, I've posted a working solution for exactly the same problem. You can see it here: <a hr... | 2017/01/18 | [
"https://wordpress.stackexchange.com/questions/253032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111226/"
] | I have two wordpress installs each on their own sub domain.
**sub1.domain.com** and **sub2.domain.com**
I want to share the login information between sub1 and sub2. I already have configured them to use the same MySQL database, and they use the same database table.
I am able to log in on both websites with the same ... | Today, I've posted a working solution for exactly the same problem. You can see it here: [How to share WordPress session and cookies between domain and subdomain?](https://wordpress.stackexchange.com/questions/130753/how-to-share-wordpress-session-and-cookies-between-domain-and-subdomain/264490#264490). I use this meth... |
253,037 | <p>I have used this function to change the number of posts per page on a category page, but I can't get it to work for a <strong>sub</strong>-category page. </p>
<p>I'm trying to show 6 posts on the sub-category page and 12 on the parent category page. </p>
<pre><code>function my_post_queries( $query ) {
if (!is_ad... | [
{
"answer_id": 264504,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 1,
"selected": false,
"text": "<p>Today, I've posted a working solution for exactly the same problem. You can see it here: <a hr... | 2017/01/18 | [
"https://wordpress.stackexchange.com/questions/253037",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78026/"
] | I have used this function to change the number of posts per page on a category page, but I can't get it to work for a **sub**-category page.
I'm trying to show 6 posts on the sub-category page and 12 on the parent category page.
```
function my_post_queries( $query ) {
if (!is_admin() && $query->is_main_query()){... | Today, I've posted a working solution for exactly the same problem. You can see it here: [How to share WordPress session and cookies between domain and subdomain?](https://wordpress.stackexchange.com/questions/130753/how-to-share-wordpress-session-and-cookies-between-domain-and-subdomain/264490#264490). I use this meth... |
253,078 | <p>I'm getting this in my json response</p>
<pre><code>"main_image":
[
"11125,11122,11123,11127,11128"
],
</code></pre>
<p>Those are the ID's of my post, I need to get the URL of each ID in the 'thumbnail' size. I did't find any solution, just this code but It's more for Custom Meta of a plugin.</p>
<pre><code>func... | [
{
"answer_id": 253282,
"author": "Pedro Coitinho",
"author_id": 111122,
"author_profile": "https://wordpress.stackexchange.com/users/111122",
"pm_score": 0,
"selected": false,
"text": "<p>based on your comment I think what you need is <code>wp_get_attachment_image_src</code>.</p>\n\n<p>W... | 2017/01/19 | [
"https://wordpress.stackexchange.com/questions/253078",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84237/"
] | I'm getting this in my json response
```
"main_image":
[
"11125,11122,11123,11127,11128"
],
```
Those are the ID's of my post, I need to get the URL of each ID in the 'thumbnail' size. I did't find any solution, just this code but It's more for Custom Meta of a plugin.
```
function xxx_past_poss_custom_metadata( $... | This is the correct way to achieve it is this:
```
function show_main_image($object, $field_name, $request){
$custom_fields = get_post_custom($object['id']);
$main_image = $custom_fields['main_image'];
$arregloimg = explode(',',$main_image[0]);
$image_urls = array();
foreach ( $arregloimg as $key ... |
253,082 | <p>My site URL in the database shows <code>sitea.com</code>. Is it possible to change this via <code>functions.php</code> into <code>siteb.com</code>, however still maintaining <code>sitea.com</code> in the database? </p>
<p>My current scenario is that I have three developers who work locally and we want to use one da... | [
{
"answer_id": 253100,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>theme_root_uri</code> filter will allow the URLs returned by <code>get_stylesheet_directory_uri()... | 2017/01/19 | [
"https://wordpress.stackexchange.com/questions/253082",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111250/"
] | My site URL in the database shows `sitea.com`. Is it possible to change this via `functions.php` into `siteb.com`, however still maintaining `sitea.com` in the database?
My current scenario is that I have three developers who work locally and we want to use one database. We all connect to a remote database, however, ... | If instead of modifying functions.php you can modify wp-config.php, you can use the following:
```
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
```
*Source: <https://codex.wordpress.org/Changing_The_Site_URL#Edit_wp-config.php>* |
253,092 | <p>I noticed there are plugins to allow shortcode usage in widgets, and they obviously work on posts/pages, but they don't seem to work when added directly to the theme files.</p>
<p>Is there a way to allow shortcodes to work when added to a theme file?</p>
| [
{
"answer_id": 253100,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>theme_root_uri</code> filter will allow the URLs returned by <code>get_stylesheet_directory_uri()... | 2017/01/19 | [
"https://wordpress.stackexchange.com/questions/253092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94819/"
] | I noticed there are plugins to allow shortcode usage in widgets, and they obviously work on posts/pages, but they don't seem to work when added directly to the theme files.
Is there a way to allow shortcodes to work when added to a theme file? | If instead of modifying functions.php you can modify wp-config.php, you can use the following:
```
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
```
*Source: <https://codex.wordpress.org/Changing_The_Site_URL#Edit_wp-config.php>* |
253,098 | <p>I'm loading posts via Ajax into a div that I have set up on index page.</p>
<p><strong>index page loop:</strong></p>
<pre><code> <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div>
<button class="post-link" rel="<?php the_ID(); ?>"> ADD </button>
&l... | [
{
"answer_id": 253102,
"author": "Kudratullah",
"author_id": 62726,
"author_profile": "https://wordpress.stackexchange.com/users/62726",
"pm_score": 3,
"selected": true,
"text": "<p>First of all you need to <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action... | 2017/01/19 | [
"https://wordpress.stackexchange.com/questions/253098",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/97572/"
] | I'm loading posts via Ajax into a div that I have set up on index page.
**index page loop:**
```
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div>
<button class="post-link" rel="<?php the_ID(); ?>"> ADD </button>
<?php the_post_thumbnail(); ?>
<a href="<?php echo esc_url(... | First of all you need to [register a action callback](https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action)) for you ajax request.
Secondly you need to send all ajax request to `wp-admin/admin-ajax.php` (both `GET` and `POST`).
And lastly you need to modify your javascript a little to pass the ... |
253,114 | <p>I was wondering how to achieve this navigation style in WordPress. The menu structure is like this --</p>
<pre><code><ul>
<li>
<a href="index.php">
Home
<span>
MAIN PAGE
</span>
</a>
</li>
</ul>
</code></pre>
<p><a href="ht... | [
{
"answer_id": 253102,
"author": "Kudratullah",
"author_id": 62726,
"author_profile": "https://wordpress.stackexchange.com/users/62726",
"pm_score": 3,
"selected": true,
"text": "<p>First of all you need to <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action... | 2017/01/19 | [
"https://wordpress.stackexchange.com/questions/253114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111268/"
] | I was wondering how to achieve this navigation style in WordPress. The menu structure is like this --
```
<ul>
<li>
<a href="index.php">
Home
<span>
MAIN PAGE
</span>
</a>
</li>
</ul>
```
[](https://i.stac... | First of all you need to [register a action callback](https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action)) for you ajax request.
Secondly you need to send all ajax request to `wp-admin/admin-ajax.php` (both `GET` and `POST`).
And lastly you need to modify your javascript a little to pass the ... |
253,133 | <p>My current site has custom post types, that run of off the root domain, so anything created inside the CPT will be something like: domain.com/page-name/ rather than domain.com/custom-post-type-name/post-name/. With this, I want to update to WP 4.7 but I cannot because it breaks my website and the CPT's mess up.</p>
... | [
{
"answer_id": 253135,
"author": "Kudratullah",
"author_id": 62726,
"author_profile": "https://wordpress.stackexchange.com/users/62726",
"pm_score": 2,
"selected": false,
"text": "<p>checkout this <a href=\"https://stackoverflow.com/questions/14323582/wordpress-how-to-add-categories-and-... | 2017/01/19 | [
"https://wordpress.stackexchange.com/questions/253133",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98494/"
] | My current site has custom post types, that run of off the root domain, so anything created inside the CPT will be something like: domain.com/page-name/ rather than domain.com/custom-post-type-name/post-name/. With this, I want to update to WP 4.7 but I cannot because it breaks my website and the CPT's mess up.
Here's... | If you don't want to attach the default post category taxonomy, you can always create a new one specifically for pages. Insert this into your `functions.php` file:
```
add_action( 'init', 'create_page_taxonomies' );
function create_page_taxonomies() {
register_taxonomy('page_category', 'page', array(
'hier... |
253,134 | <p>Is there a way to remove "Save draft" button without the use of CSS?</p>
| [
{
"answer_id": 253136,
"author": "Pratik bhatt",
"author_id": 60922,
"author_profile": "https://wordpress.stackexchange.com/users/60922",
"pm_score": -1,
"selected": false,
"text": "<p>Please put the below lines in your wp-config.php </p>\n\n<pre><code>define('WP_POST_REVISIONS', 'false'... | 2017/01/19 | [
"https://wordpress.stackexchange.com/questions/253134",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109705/"
] | Is there a way to remove "Save draft" button without the use of CSS? | You cannot just remove the "Save draft" as the button is tied up in the `submitdiv` metabox HTML defined in the function `post_submit_meta_box()`.
However we can alter the callback for this metabox and replace it with our own function.
We can bind to the `submitpost_box` event and give the binding a height weight so ... |
253,144 | <p>I'm fairly new to Wordpress and I'm a little confuse on how to take the database from my local server and replace it with the one on the server on a Wordpress multisite.</p>
<p>I've replace database before from local to server, but it was a multisite.</p>
<p>The step I usually take is:</p>
<ol>
<li>backup the dat... | [
{
"answer_id": 253147,
"author": "DGRFDSGN",
"author_id": 108736,
"author_profile": "https://wordpress.stackexchange.com/users/108736",
"pm_score": 1,
"selected": false,
"text": "<p>The database is indeed configured different for a multiwp, those tenp_12 are prefixes for each site in the... | 2017/01/19 | [
"https://wordpress.stackexchange.com/questions/253144",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101431/"
] | I'm fairly new to Wordpress and I'm a little confuse on how to take the database from my local server and replace it with the one on the server on a Wordpress multisite.
I've replace database before from local to server, but it was a multisite.
The step I usually take is:
1. backup the database on the server
2. expo... | Merging WordPress Standalone Installation with WordPress Multisite Installation
-------------------------------------------------------------------------------
**Before You Begin:**
1. Create a new site in your Multisite Network, which will be the site
you're migrating from the Standalone installation. (Take note of ... |
253,155 | <p>How do I fit a function inside an opening and closing shortcode.</p>
<p>I have this function that displays the post's pdf attachment url</p>
<pre><code>$file= get_post_meta( $post->ID, 'teacher-resume-upload' );
if ( $file) { foreach ( $file as $attachment_id ) { $full_size = wp_get_attachment_url( $attachment... | [
{
"answer_id": 253159,
"author": "Pete",
"author_id": 37346,
"author_profile": "https://wordpress.stackexchange.com/users/37346",
"pm_score": 0,
"selected": false,
"text": "<p>Worked it out...</p>\n\n<pre><code><?php $file= get_post_meta( $post->ID, 'teacher-resume-upload' ); $full... | 2017/01/19 | [
"https://wordpress.stackexchange.com/questions/253155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37346/"
] | How do I fit a function inside an opening and closing shortcode.
I have this function that displays the post's pdf attachment url
```
$file= get_post_meta( $post->ID, 'teacher-resume-upload' );
if ( $file) { foreach ( $file as $attachment_id ) { $full_size = wp_get_attachment_url( $attachment_id );
printf( '%s', $f... | This should work assuming your trying to pass the URL to the PDF short code
```
$file= get_post_meta( $post->ID, 'teacher-resume-upload' );
if ( $file) {
foreach ( $file as $attachment_id ) {
$full_size = wp_get_attachment_url( $attachment_id );
echo do_shortcode( '[pdf]' . $full_size . '[/pdf]' )... |
253,216 | <p>how can I create non-Wordpress sites on subdomains (map them to directories), when I have an active subdomain-multisite WP installation?</p>
<p>Can I insert some .. exemptions into htaccess or something?</p>
| [
{
"answer_id": 266673,
"author": "Karthik",
"author_id": 68260,
"author_profile": "https://wordpress.stackexchange.com/users/68260",
"pm_score": 0,
"selected": false,
"text": "<p>Yes. We can add rewrite rule in WordPress root <code>.htaccess</code> to rewrite all requests for a particula... | 2017/01/19 | [
"https://wordpress.stackexchange.com/questions/253216",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38435/"
] | how can I create non-Wordpress sites on subdomains (map them to directories), when I have an active subdomain-multisite WP installation?
Can I insert some .. exemptions into htaccess or something? | The [WP Codex gives two examples of excluding a subdirectory from multisite's control.](https://codex.wordpress.org/WPMS_Ignore_Some_Subdomains)
1. .htaccess method [(as Karthik noted)](https://wordpress.stackexchange.com/a/266673/118366)
2. Virtual host method
.htaccess
---------
Being sure to call the sub rewrite ... |
253,226 | <p>I have an attachment page for post images, so that when I click on the thumbnail (on the front end) it takes the user to the attachment page for that image, how would I do the same for pdf files, so that when I click on the direct link to the pdf on the front end to redirects to the pdf attachment page?</p>
<pre><c... | [
{
"answer_id": 253291,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>From the <a href=\"https://developer.wordpress.org/reference/functions/get_attachment_template/\" rel=\"nofol... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253226",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37346/"
] | I have an attachment page for post images, so that when I click on the thumbnail (on the front end) it takes the user to the attachment page for that image, how would I do the same for pdf files, so that when I click on the direct link to the pdf on the front end to redirects to the pdf attachment page?
```
<?php if (... | You can use `pdf.php` or a number of other specially-named template files [as described birgire's answer](https://wordpress.stackexchange.com/a/253291/8559) to show an attachment page specifically for PDFs, or use a generic `attachment.php` page that includes conditional statements for the type of attachment (like the ... |
253,235 | <p>I am trying to display the numerical post order ranking on the home page, however, I am using template_parts and am not aware of how to do this when the html is separated from the wordpress loop.</p>
<p>Here's what I want to see:</p>
<p><a href="https://i.stack.imgur.com/bO3EC.png" rel="nofollow noreferrer"><img s... | [
{
"answer_id": 253242,
"author": "Samuel Asor",
"author_id": 84265,
"author_profile": "https://wordpress.stackexchange.com/users/84265",
"pm_score": -1,
"selected": false,
"text": "<p>There are two ways I suggest you do that:</p>\n\n<ul>\n<li>You can store the post rankings in your datab... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253235",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105532/"
] | I am trying to display the numerical post order ranking on the home page, however, I am using template\_parts and am not aware of how to do this when the html is separated from the wordpress loop.
Here's what I want to see:
[](https://i.stack.imgur.com/bO3EC.png)... | It is not straightforward to pass a variable to a template part. However, when you are in a loop, WP has [a counter called `current_post`](https://codex.wordpress.org/Class_Reference/WP_Query#Properties) that you can use in this way in your template part:
```
global $post;
$ranking = $post->$current_post + 1; // +1 be... |
253,239 | <p>I would like to make my pagination for single post look like this:</p>
<p><a href="https://i.stack.imgur.com/f2kJe.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f2kJe.jpg" alt="pagination with next, prev and links in between and also disabled"></a></p>
<p>and <strong>not</strong> like that....... | [
{
"answer_id": 253242,
"author": "Samuel Asor",
"author_id": 84265,
"author_profile": "https://wordpress.stackexchange.com/users/84265",
"pm_score": -1,
"selected": false,
"text": "<p>There are two ways I suggest you do that:</p>\n\n<ul>\n<li>You can store the post rankings in your datab... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253239",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111342/"
] | I would like to make my pagination for single post look like this:
[](https://i.stack.imgur.com/f2kJe.jpg)
and **not** like that.....
[](https://i.stack.im... | It is not straightforward to pass a variable to a template part. However, when you are in a loop, WP has [a counter called `current_post`](https://codex.wordpress.org/Class_Reference/WP_Query#Properties) that you can use in this way in your template part:
```
global $post;
$ranking = $post->$current_post + 1; // +1 be... |
253,245 | <p>I just migrated my ecommerce website (www.getfitkart.com) from shared hosting to Linode. Now only the home page is working but the other pages are not getting served. I am getting the following error on all other pages like say, <a href="http://www.getfitkart.com/privacy-policy/" rel="noreferrer">http://www.getfitka... | [
{
"answer_id": 253246,
"author": "Umer Shoukat",
"author_id": 94940,
"author_profile": "https://wordpress.stackexchange.com/users/94940",
"pm_score": 4,
"selected": false,
"text": "<p>Go to settings->permalinks and click on save button to rewrite flush. And then empty your browser cache... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253245",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43567/"
] | I just migrated my ecommerce website (www.getfitkart.com) from shared hosting to Linode. Now only the home page is working but the other pages are not getting served. I am getting the following error on all other pages like say, <http://www.getfitkart.com/privacy-policy/>
>
> Not Found
>
> The requested URL /priv... | I found the solution here:
<https://www.digitalocean.com/community/questions/wordpress-permalinks-not-working-on-ubuntu-14-04>
The thing is that we need to allow the override *all* option in httpd.conf (location: /etc/httpd/conf/httpd.conf) for your specific hosting directory. |
253,270 | <p>I have a lot of 404s on posts without /%category%/ (I have change permalink structure). I have noticed that if I put /anything/ in 404 link as category I'll end up in the right post.
How can I solve it? I have around 25k 404s in google console and I need a bulk solution. </p>
<p>My thoughts are either to do it in ... | [
{
"answer_id": 253271,
"author": "Ravi Shinde",
"author_id": 99294,
"author_profile": "https://wordpress.stackexchange.com/users/99294",
"pm_score": 0,
"selected": false,
"text": "<p>Use Redirection plugin - <a href=\"https://wordpress.org/plugins/redirection/\" rel=\"nofollow noreferrer... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253270",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78008/"
] | I have a lot of 404s on posts without /%category%/ (I have change permalink structure). I have noticed that if I put /anything/ in 404 link as category I'll end up in the right post.
How can I solve it? I have around 25k 404s in google console and I need a bulk solution.
My thoughts are either to do it in htaccess o... | Ok, resolved it in 404.php
```
<?php
$klo_link = $_SERVER['REQUEST_URI'];
if (preg_match("/^\/[a-zA-Z0-9\-\_]+\/$/", $klo_link)) {
//echo "A match was found. \n";
//echo $klo_link;
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url')."/a".$klo_link);
exit();
}else {... |
253,274 | <p>I'm seeing an error while trying to change the colours of a theme:</p>
<pre><code>Notice: Use of undefined constant FS_CHMOD_DIR - assumed 'FS_CHMOD_DIR' in
/var/www/vhosts/xxx/wp-content/themes/consulting/inc/print_styles.php on line 141
</code></pre>
<p>The theme creator has given me the following advice, but ca... | [
{
"answer_id": 253277,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>It's really quite simple. The theme author is using a constant that you can put in <code>wp-config.php</code>... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253274",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111367/"
] | I'm seeing an error while trying to change the colours of a theme:
```
Notice: Use of undefined constant FS_CHMOD_DIR - assumed 'FS_CHMOD_DIR' in
/var/www/vhosts/xxx/wp-content/themes/consulting/inc/print_styles.php on line 141
```
The theme creator has given me the following advice, but cannot provide any further d... | It's really quite simple. The theme author is using a constant that you can put in `wp-config.php`, but because you don't use that constant, and the author never checks if it's actually defined, the code throws a PHP warning
<https://codex.wordpress.org/Editing_wp-config.php#Override_of_default_file_permissions>
>
>... |
253,278 | <p>When user created URL comes as <strong>www.sitename.com/user/username</strong></p>
<p>I want to change to<br>
<strong>www.sitename.com/username</strong> (Remove User from URL)</p>
<p>How can I do this </p>
| [
{
"answer_id": 253277,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>It's really quite simple. The theme author is using a constant that you can put in <code>wp-config.php</code>... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253278",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111277/"
] | When user created URL comes as **www.sitename.com/user/username**
I want to change to
**www.sitename.com/username** (Remove User from URL)
How can I do this | It's really quite simple. The theme author is using a constant that you can put in `wp-config.php`, but because you don't use that constant, and the author never checks if it's actually defined, the code throws a PHP warning
<https://codex.wordpress.org/Editing_wp-config.php#Override_of_default_file_permissions>
>
>... |
253,283 | <p>when i install a theme it appears to be completely different and doenst shows contents which are supposed to be there. And nothing happens if a do changes from dashboard appearance and customize. kindly help!
[![see here][1]][1]</p>
<p>[![?][2]][2]</p>
<p><a href="https://i.stack.imgur.com/6MQE4.png" rel="nofollow... | [
{
"answer_id": 253277,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>It's really quite simple. The theme author is using a constant that you can put in <code>wp-config.php</code>... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253283",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111374/"
] | when i install a theme it appears to be completely different and doenst shows contents which are supposed to be there. And nothing happens if a do changes from dashboard appearance and customize. kindly help!
[![see here][1]][1]
[![?][2]][2]
[](https://i.stack.imgur.com/6MQE4.... | It's really quite simple. The theme author is using a constant that you can put in `wp-config.php`, but because you don't use that constant, and the author never checks if it's actually defined, the code throws a PHP warning
<https://codex.wordpress.org/Editing_wp-config.php#Override_of_default_file_permissions>
>
>... |
253,290 | <p>I have this php file on the root directory, and i seen this example for inserting post from external php file
but for some reason it doesn't work for me, <code>wp_insert_post()</code> always returns <code>0</code></p>
<p>So whats the problem ? and how i can fix it?</p>
<p>I'm trying to build a Cron Job file to ins... | [
{
"answer_id": 253277,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>It's really quite simple. The theme author is using a constant that you can put in <code>wp-config.php</code>... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253290",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110929/"
] | I have this php file on the root directory, and i seen this example for inserting post from external php file
but for some reason it doesn't work for me, `wp_insert_post()` always returns `0`
So whats the problem ? and how i can fix it?
I'm trying to build a Cron Job file to insert new posts from XML file In the end
... | It's really quite simple. The theme author is using a constant that you can put in `wp-config.php`, but because you don't use that constant, and the author never checks if it's actually defined, the code throws a PHP warning
<https://codex.wordpress.org/Editing_wp-config.php#Override_of_default_file_permissions>
>
>... |
253,315 | <p>Looks like WordPress unnecessarily fire WP CRON on every page load. I'm thinking, instead of having it run on every visit, why not just schedule it to run every 5 minutes via server? I could simply trigger wp-cron.php every five minutes and achieve desired result?</p>
<p>Is there any downside to this? </p>
| [
{
"answer_id": 253329,
"author": "TechnicalChaos",
"author_id": 111398,
"author_profile": "https://wordpress.stackexchange.com/users/111398",
"pm_score": 2,
"selected": false,
"text": "<p>There are a couple of downsides:\nFirstly, when using wp-cron.php as a cli things such as $_SERVER v... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253315",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21100/"
] | Looks like WordPress unnecessarily fire WP CRON on every page load. I'm thinking, instead of having it run on every visit, why not just schedule it to run every 5 minutes via server? I could simply trigger wp-cron.php every five minutes and achieve desired result?
Is there any downside to this? | There is no downside for running WP CRON using the server's cron jobs. In fact this is the recommended practice.
According to [Official WordPress Plugin Development Document](https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/):
>
> WP-Cron does not run continuously, which ca... |
253,316 | <p>I just reinstalled Wordpress to fix another problem. I followed careful instructions about backing up my database but now I get error 1062 from mySQL when I try to reinstall the database. This is because a duplicate database seems to have been created, stopping me uploading my saved version.</p>
<p>How can I delete... | [
{
"answer_id": 253329,
"author": "TechnicalChaos",
"author_id": 111398,
"author_profile": "https://wordpress.stackexchange.com/users/111398",
"pm_score": 2,
"selected": false,
"text": "<p>There are a couple of downsides:\nFirstly, when using wp-cron.php as a cli things such as $_SERVER v... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253316",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110850/"
] | I just reinstalled Wordpress to fix another problem. I followed careful instructions about backing up my database but now I get error 1062 from mySQL when I try to reinstall the database. This is because a duplicate database seems to have been created, stopping me uploading my saved version.
How can I delete/override ... | There is no downside for running WP CRON using the server's cron jobs. In fact this is the recommended practice.
According to [Official WordPress Plugin Development Document](https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/):
>
> WP-Cron does not run continuously, which ca... |
253,333 | <p>I have a search page that when you enter a blank query, it shows posts and pages together. This isn't an issue, it's fine. However I'd like to remove some details like the date from the pages as it doesn't make much sense.</p>
<p>I'm using the is_page function but that doesn't seem to work and I have no idea why, I... | [
{
"answer_id": 253329,
"author": "TechnicalChaos",
"author_id": 111398,
"author_profile": "https://wordpress.stackexchange.com/users/111398",
"pm_score": 2,
"selected": false,
"text": "<p>There are a couple of downsides:\nFirstly, when using wp-cron.php as a cli things such as $_SERVER v... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253333",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have a search page that when you enter a blank query, it shows posts and pages together. This isn't an issue, it's fine. However I'd like to remove some details like the date from the pages as it doesn't make much sense.
I'm using the is\_page function but that doesn't seem to work and I have no idea why, I'm includ... | There is no downside for running WP CRON using the server's cron jobs. In fact this is the recommended practice.
According to [Official WordPress Plugin Development Document](https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/):
>
> WP-Cron does not run continuously, which ca... |
253,344 | <p>I dont want to show image in my read_more function in homepage. read_more shows first 25 strings of my content. when I add image in the content it shows with the string inline. I don't want the image. Anyone know how to do it? here is my code below..</p>
<pre><code><div id="leadnewsbox" class="col-md-5 col-sm-4 ... | [
{
"answer_id": 253329,
"author": "TechnicalChaos",
"author_id": 111398,
"author_profile": "https://wordpress.stackexchange.com/users/111398",
"pm_score": 2,
"selected": false,
"text": "<p>There are a couple of downsides:\nFirstly, when using wp-cron.php as a cli things such as $_SERVER v... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253344",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111404/"
] | I dont want to show image in my read\_more function in homepage. read\_more shows first 25 strings of my content. when I add image in the content it shows with the string inline. I don't want the image. Anyone know how to do it? here is my code below..
```
<div id="leadnewsbox" class="col-md-5 col-sm-4 col-xs-12">
<?p... | There is no downside for running WP CRON using the server's cron jobs. In fact this is the recommended practice.
According to [Official WordPress Plugin Development Document](https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/):
>
> WP-Cron does not run continuously, which ca... |
253,351 | <p>Hi I am new to Wordpress development and I have learned a lot already but I do not understand why the text and content in the pages and posts does not keep the format that the user sets in the back-end editor for posts or pages. And everything looks like a mess, formatting goes wild and it does not resemble the edit... | [
{
"answer_id": 253329,
"author": "TechnicalChaos",
"author_id": 111398,
"author_profile": "https://wordpress.stackexchange.com/users/111398",
"pm_score": 2,
"selected": false,
"text": "<p>There are a couple of downsides:\nFirstly, when using wp-cron.php as a cli things such as $_SERVER v... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253351",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/106353/"
] | Hi I am new to Wordpress development and I have learned a lot already but I do not understand why the text and content in the pages and posts does not keep the format that the user sets in the back-end editor for posts or pages. And everything looks like a mess, formatting goes wild and it does not resemble the editor ... | There is no downside for running WP CRON using the server's cron jobs. In fact this is the recommended practice.
According to [Official WordPress Plugin Development Document](https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/):
>
> WP-Cron does not run continuously, which ca... |
253,353 | <p>I'm looking for help on how to add specific menu on a specific page or pages with no plugin.</p>
<p>I know how to add and register a new menu like this:</p>
<pre><code>//* Register third navigation menu position
function register_additional_menu() {
register_nav_menu( 'third-menu' ,__( 'Third Navigation Menu' ))... | [
{
"answer_id": 253329,
"author": "TechnicalChaos",
"author_id": 111398,
"author_profile": "https://wordpress.stackexchange.com/users/111398",
"pm_score": 2,
"selected": false,
"text": "<p>There are a couple of downsides:\nFirstly, when using wp-cron.php as a cli things such as $_SERVER v... | 2017/01/20 | [
"https://wordpress.stackexchange.com/questions/253353",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111269/"
] | I'm looking for help on how to add specific menu on a specific page or pages with no plugin.
I know how to add and register a new menu like this:
```
//* Register third navigation menu position
function register_additional_menu() {
register_nav_menu( 'third-menu' ,__( 'Third Navigation Menu' ));
}
add_action( 'init... | There is no downside for running WP CRON using the server's cron jobs. In fact this is the recommended practice.
According to [Official WordPress Plugin Development Document](https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/):
>
> WP-Cron does not run continuously, which ca... |
253,385 | <p>Goal: convert Facebook url itself (without full code snippet) into Facebook post on website front-end</p>
<p>Problem: The experimental o2 / p2 / breathe theme, by default, converts a full Facebook code snippet in the editor to a full Facebook post on the front-end. Example snippet:</p>
<pre><code><div class="fb... | [
{
"answer_id": 253390,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 0,
"selected": false,
"text": "<p>You need to use the php <code>preg_replace</code>function in order to transform your url into an snippet.</... | 2017/01/21 | [
"https://wordpress.stackexchange.com/questions/253385",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1697/"
] | Goal: convert Facebook url itself (without full code snippet) into Facebook post on website front-end
Problem: The experimental o2 / p2 / breathe theme, by default, converts a full Facebook code snippet in the editor to a full Facebook post on the front-end. Example snippet:
```
<div class="fb-post" data-href="https:... | Note that Facebook is a registered *oEmbed* provider in the WordPress core.
You could e.g. use the [`pre_oembed_result`](https://core.trac.wordpress.org/browser/tags/4.7/src/wp-includes/class-oembed.php#L350) filter, before the HTTP request is made, to cancel it and override it to your needs.
Here's an example for Fa... |
253,401 | <p>I am using wordpress ajax and following code not passing parameter value <code>metakey: id</code> to <code>$_POST["metakey"]</code>. So <code>var_dump($_POST)</code> shows <code>array(0) { }</code> and <code>$_REQUEST</code> shows <code>array()</code></p>
<p>if I enter static value of variable in PHP function <code... | [
{
"answer_id": 253406,
"author": "Tunji",
"author_id": 54764,
"author_profile": "https://wordpress.stackexchange.com/users/54764",
"pm_score": 2,
"selected": false,
"text": "<p>First of all you should read the codex on <a href=\"https://codex.wordpress.org/AJAX_in_Plugins\" rel=\"nofollo... | 2017/01/21 | [
"https://wordpress.stackexchange.com/questions/253401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/95126/"
] | I am using wordpress ajax and following code not passing parameter value `metakey: id` to `$_POST["metakey"]`. So `var_dump($_POST)` shows `array(0) { }` and `$_REQUEST` shows `array()`
if I enter static value of variable in PHP function `$key=<any meta
key>` then its works fine
```
jQuery(".selectbox").change(funct... | The issue was with google api as stated in question by showing api related error message
>
> jquery.js?ver=1.12.4:2 Uncaught TypeError: Cannot use 'in' operator to search for 'length' in
>
>
>
So I have added following code snippet in theme functions.php that called previous version of google api. It has solved t... |
253,410 | <p>hi i want to display posts by term.
first the code display all the posts:</p>
<pre><code> $aProjectArgs = array(
'post_type' => 'uni_project',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'asc'
);
</code></pre>
<p>so i add another part of... | [
{
"answer_id": 253411,
"author": "Md. Mrinal Haque",
"author_id": 111354,
"author_profile": "https://wordpress.stackexchange.com/users/111354",
"pm_score": 1,
"selected": false,
"text": "<p>put <code>,</code> in 'order' => 'asc' 'tax_query'</p>\n"
},
{
"answer_id": 253412,
"a... | 2017/01/21 | [
"https://wordpress.stackexchange.com/questions/253410",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111459/"
] | hi i want to display posts by term.
first the code display all the posts:
```
$aProjectArgs = array(
'post_type' => 'uni_project',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'asc'
);
```
so i add another part of code to display posts by term:
```
$... | put `,` in 'order' => 'asc' 'tax\_query' |
253,428 | <p>I have had a look at the source code of Wordpress, as well as php.net for a possible answer. However, I was not able to get close to finding it.</p>
<p>For the source code, I was assuming I would find it in one of the many files I checked in the wp-includes folder. However, there are way! to many files to look thro... | [
{
"answer_id": 253440,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>The function is called <a href=\"https://developer.wordpress.org/reference/functions/get_file_data/\" rel=\"nofoll... | 2017/01/21 | [
"https://wordpress.stackexchange.com/questions/253428",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48443/"
] | I have had a look at the source code of Wordpress, as well as php.net for a possible answer. However, I was not able to get close to finding it.
For the source code, I was assuming I would find it in one of the many files I checked in the wp-includes folder. However, there are way! to many files to look through.
What... | The function is called [`get_file_data`](https://developer.wordpress.org/reference/functions/get_file_data/), it uses a regular expression to parse the text and find headers. |
253,445 | <p>I have a custom endpoint where I want to change HTTP response status to 404 in certain scenarios (e.g post does not exist). How can I do that? Here is an example of custom endpoint:</p>
<pre><code>function af_news_single( \WP_REST_Request $data ) {
global $wpdb;
$year = (int) $data['year'];
$month = (i... | [
{
"answer_id": 253472,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 6,
"selected": true,
"text": "<p>You can return a <code>WP_Error</code> object in which you define the status code. Here's a snippet from <a hr... | 2017/01/21 | [
"https://wordpress.stackexchange.com/questions/253445",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67305/"
] | I have a custom endpoint where I want to change HTTP response status to 404 in certain scenarios (e.g post does not exist). How can I do that? Here is an example of custom endpoint:
```
function af_news_single( \WP_REST_Request $data ) {
global $wpdb;
$year = (int) $data['year'];
$month = (int) $data['mon... | You can return a `WP_Error` object in which you define the status code. Here's a snippet from [the REST API documentation](https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/#return-value):
```
function my_awesome_func( $data ) {
$posts = get_posts( array(
'author' => $... |
253,473 | <p>Suppose I have created an app that uses WordPress REST API plugin and displays the posts from the WordPress site.</p>
<p>Now, if I find the WordPress site which is having the WP REST API plugin and I am able to fetch the data from it (only displaying the data into the app, not storing it). Is it legal to do so as p... | [
{
"answer_id": 253472,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 6,
"selected": true,
"text": "<p>You can return a <code>WP_Error</code> object in which you define the status code. Here's a snippet from <a hr... | 2017/01/22 | [
"https://wordpress.stackexchange.com/questions/253473",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111492/"
] | Suppose I have created an app that uses WordPress REST API plugin and displays the posts from the WordPress site.
Now, if I find the WordPress site which is having the WP REST API plugin and I am able to fetch the data from it (only displaying the data into the app, not storing it). Is it legal to do so as per WordPre... | You can return a `WP_Error` object in which you define the status code. Here's a snippet from [the REST API documentation](https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/#return-value):
```
function my_awesome_func( $data ) {
$posts = get_posts( array(
'author' => $... |