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 |
|---|---|---|---|---|---|---|
210,837 | <p>Working on a categories/ front page, I would like to display an image and title for posts with an image. When there is no image, it leaves a big blank space -- looks empty, of course ... So I'd like to use bigger text for the title if there is no image. </p>
<p>Has anyone found a way to do so with WordPress?</p>
<... | [
{
"answer_id": 210832,
"author": "mrbobbybryant",
"author_id": 64953,
"author_profile": "https://wordpress.stackexchange.com/users/64953",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress uses the post_parent column in the database to track which posts an attachment is linked to. ... | 2015/12/05 | [
"https://wordpress.stackexchange.com/questions/210837",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77987/"
] | Working on a categories/ front page, I would like to display an image and title for posts with an image. When there is no image, it leaves a big blank space -- looks empty, of course ... So I'd like to use bigger text for the title if there is no image.
Has anyone found a way to do so with WordPress?
My code is:
``... | It looks like the image (for which you've done a var\_dump) is not attached to any post. If an image is attached to a post - the post's ID would appear as `'post_parent'`, which in this case equals `0`. This is often the case if you upload the image directly from withing media library ('Media Library' page in your WP a... |
210,859 | <p>I am using a static frontpage and a page for my blogposts. In my header.php I want to display the title of the selected page of my blogposts.</p>
<p>For example:</p>
<pre><code><?php
if( is_home() )
echo '<h1>' . get_the_title() . '</h1>';
?><nav>
...
</nav>
</code></pre>
<p>But ... | [
{
"answer_id": 210867,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>You can make use the queried object to return the title of the page used as blogpage</p>\n\n<p>You can u... | 2015/12/05 | [
"https://wordpress.stackexchange.com/questions/210859",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48693/"
] | I am using a static frontpage and a page for my blogposts. In my header.php I want to display the title of the selected page of my blogposts.
For example:
```
<?php
if( is_home() )
echo '<h1>' . get_the_title() . '</h1>';
?><nav>
...
</nav>
```
But of course `get_the_title()` returns the first element of the di... | You can make use the queried object to return the title of the page used as blogpage
You can use the following: (*Require PHP 5.4+*)
```
$title = get_queried_object()->post_title;
var_dump( $title );
``` |
210,889 | <p>I am unable to change the location of src attribute mentioned below</p>
<pre><code><img class="srcimage" src=server-side4.php/>
</code></pre>
<p>I want to change it to </p>
<pre><code>src=scripts/server-side4.php
</code></pre>
<p>This is the javascript that is also included in the file</p>
<pre><code>jQue... | [
{
"answer_id": 210895,
"author": "Unicco",
"author_id": 52622,
"author_profile": "https://wordpress.stackexchange.com/users/52622",
"pm_score": -1,
"selected": false,
"text": "<p>You can use:</p>\n\n<pre><code>jQuery('img.srcimage').attr('src', 'scripts/server-side4.php');\n</code></pre>... | 2015/12/05 | [
"https://wordpress.stackexchange.com/questions/210889",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80347/"
] | I am unable to change the location of src attribute mentioned below
```
<img class="srcimage" src=server-side4.php/>
```
I want to change it to
```
src=scripts/server-side4.php
```
This is the javascript that is also included in the file
```
jQuery(".preview img").attr("src",base+'?'+jQuery("#realtime-form").se... | One problem could be that you're missing **"**
```
***<img class="srcimage" src=server-side4.php/>***
```
Change it to
```
***<img class="srcimage" src="http://example.com/your-path/server-side4.php" />***
```
Then if that doesn't fix it, try outputting your variables to see what you're working with. Make sure t... |
210,896 | <p>I need to trying to get the Facebook SDK for JavaScript code inserted just after the tag.</p>
<p>What's the easiest way to do this? </p>
| [
{
"answer_id": 210895,
"author": "Unicco",
"author_id": 52622,
"author_profile": "https://wordpress.stackexchange.com/users/52622",
"pm_score": -1,
"selected": false,
"text": "<p>You can use:</p>\n\n<pre><code>jQuery('img.srcimage').attr('src', 'scripts/server-side4.php');\n</code></pre>... | 2015/12/05 | [
"https://wordpress.stackexchange.com/questions/210896",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80672/"
] | I need to trying to get the Facebook SDK for JavaScript code inserted just after the tag.
What's the easiest way to do this? | One problem could be that you're missing **"**
```
***<img class="srcimage" src=server-side4.php/>***
```
Change it to
```
***<img class="srcimage" src="http://example.com/your-path/server-side4.php" />***
```
Then if that doesn't fix it, try outputting your variables to see what you're working with. Make sure t... |
210,899 | <p>I'm just getting my feet wet with nginx. In the past I've used an .htaccess file in /wp-content/uploads so if my dev or staging server doesn't have the file it redirects to the production server:</p>
<pre><code><IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQ... | [
{
"answer_id": 215189,
"author": "Ben Cole",
"author_id": 32532,
"author_profile": "https://wordpress.stackexchange.com/users/32532",
"pm_score": 3,
"selected": false,
"text": "<p>You could try something like this:</p>\n\n<pre><code>server {\n root /srv/www/example/htdocs;\n index ... | 2015/12/05 | [
"https://wordpress.stackexchange.com/questions/210899",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15555/"
] | I'm just getting my feet wet with nginx. In the past I've used an .htaccess file in /wp-content/uploads so if my dev or staging server doesn't have the file it redirects to the production server:
```
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
... | You could try something like this:
```
server {
root /srv/www/example/htdocs;
index index.php;
# Matches any URL containing /wp-content/uploads/
location ~ "^(.*)/wp-content/uploads/(.*)$" {
try_files $uri @prod_serv;
}
# Will redirect requests to your production server
locati... |
210,901 | <p>The hook </p>
<pre><code> profile_update
</code></pre>
<p>gets fired in case the user updates his profile, that is also when he reset the first time his password after registration and when he register.</p>
<p>How do I distinguish between the three cases?</p>
<p>EDIT: There are, at least, 3 cases to distinguish,... | [
{
"answer_id": 211055,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>Technically, you can't. That filter doesn't pass in any data that will specifically allow you to distinguish ... | 2015/12/05 | [
"https://wordpress.stackexchange.com/questions/210901",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/71652/"
] | The hook
```
profile_update
```
gets fired in case the user updates his profile, that is also when he reset the first time his password after registration and when he register.
How do I distinguish between the three cases?
EDIT: There are, at least, 3 cases to distinguish, in which that hook is called.
1. user'... | Technically, you can't. That filter doesn't pass in any data that will specifically allow you to distinguish between those two cases.
```
2086 /**
2087 * Fires immediately after an existing user is updated.
2088 *
2089 * @since 2.0.0
2090 ... |
210,904 | <p>I'm using <code>wp_dropdown_pages()</code> but would like to number the options returned for the user. So instead of something like...</p>
<pre><code><option value='http://someurl'>item one</option>
<option value='http://someurl'>item two</option>
<option value='http://someurl'>item t... | [
{
"answer_id": 210906,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>To change</p>\n\n<pre><code><option value='http://someurl'>item one</option>\n<option value='ht... | 2015/12/05 | [
"https://wordpress.stackexchange.com/questions/210904",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7162/"
] | I'm using `wp_dropdown_pages()` but would like to number the options returned for the user. So instead of something like...
```
<option value='http://someurl'>item one</option>
<option value='http://someurl'>item two</option>
<option value='http://someurl'>item three</option>
```
I end up with:
```
<option value='h... | To change
```
<option value='http://someurl'>item one</option>
<option value='http://someurl'>item two</option>
<option value='http://someurl'>item three</option>
```
to
```
<option value='http://someurl'>1. item one</option>
<option value='http://someurl'>2. item two</option>
<option value='http://someurl'>3. item... |
210,929 | <p>How can I remove the link from the page title in my WordPress theme? </p>
<p>Here's the link to my test <a href="http://leon-aver.com/" rel="nofollow">site</a> and below is the code responsible for that:</p>
<pre><code><h1 class='post-title <?php echo $titleClass; ?>'>
<a href="<?php echo get... | [
{
"answer_id": 210932,
"author": "Craig Pearson",
"author_id": 17295,
"author_profile": "https://wordpress.stackexchange.com/users/17295",
"pm_score": 1,
"selected": false,
"text": "<p>Perhaps when you removed your a tag you also remove the nested <code>the_title();</code> function?</p>\... | 2015/12/06 | [
"https://wordpress.stackexchange.com/questions/210929",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84831/"
] | How can I remove the link from the page title in my WordPress theme?
Here's the link to my test [site](http://leon-aver.com/) and below is the code responsible for that:
```
<h1 class='post-title <?php echo $titleClass; ?>'>
<a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php
_e('Permane... | Perhaps when you removed your a tag you also remove the nested `the_title();` function?
`the_title();` is the Wordpress function which spits out the plain text post/page title so having that in your h1 like below should get you the results you're expecting. Of course there may also be some CSS which is affected due to... |
210,933 | <p>i have add 4 custom fields in the checkout page (in functions.php )</p>
<p>Now i show the value in the Order page with </p>
<pre><code>get_post_meta( $order->id, 'My Field', true )
</code></pre>
<p>I need that the customer can edit the Value on the order Page (front-end) if the order status is processing.</p>
... | [
{
"answer_id": 211074,
"author": "kreativcube",
"author_id": 84829,
"author_profile": "https://wordpress.stackexchange.com/users/84829",
"pm_score": 1,
"selected": true,
"text": "<p>I found a solution.</p>\n\n<p>i have use this code on my order-details.php Page</p>\n\n<pre><code> <?ph... | 2015/12/06 | [
"https://wordpress.stackexchange.com/questions/210933",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84829/"
] | i have add 4 custom fields in the checkout page (in functions.php )
Now i show the value in the Order page with
```
get_post_meta( $order->id, 'My Field', true )
```
I need that the customer can edit the Value on the order Page (front-end) if the order status is processing.
I dont know who can i make this.
I hav... | I found a solution.
i have use this code on my order-details.php Page
```
<?php
global $post;
$post = $order_id;
if ( isset( $_POST['submit'] ) )
{
echo 'Update nicht';
} else if ( ! empty( $_POST['frontstrasse'] ) ) {
update_... |
210,937 | <p>One can customize single comment markup using the <code>callback</code> argument in <code>wp_list_comments</code> like this:</p>
<pre><code>$args = array( 'callback' => 'my_callback', 'avatar_size' => 48, 'type' => 'comment' );
wp_list_comments( $args );
</code></pre>
<p>The question is, how to pass argum... | [
{
"answer_id": 210939,
"author": "Peyman Mohamadpour",
"author_id": 75020,
"author_profile": "https://wordpress.stackexchange.com/users/75020",
"pm_score": 3,
"selected": true,
"text": "<p>Finally I figured it out. you may simply add your arguments to the <code>wp_list_comments</code> as... | 2015/12/06 | [
"https://wordpress.stackexchange.com/questions/210937",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75020/"
] | One can customize single comment markup using the `callback` argument in `wp_list_comments` like this:
```
$args = array( 'callback' => 'my_callback', 'avatar_size' => 48, 'type' => 'comment' );
wp_list_comments( $args );
```
The question is, how to pass arguments to that `my_callback` function?
Already it gets thre... | Finally I figured it out. you may simply add your arguments to the `wp_list_comments` as associative `key` => `value` pairs like this:
```
$args = array( 'callback' => 'my_callback', 'avatar_size' => 48, 'type' => 'comment', 'arg1' => $arg1 );
wp_list_comments( $args );
```
and then in your `my_callback` you have:
... |
210,947 | <p>I have this permalinks settings: <code>/%postname%/</code></p>
<p>I have a custom taxonomy <code>issue</code>.</p>
<p>I want replace all my taxonomy links <code>(site.com/category/wordpress)</code> to <code>(site.com/category/wordpress/issue/any-child)</code>. Like tags.</p>
<p>Maybe this picture help</p>
<p><a... | [
{
"answer_id": 210939,
"author": "Peyman Mohamadpour",
"author_id": 75020,
"author_profile": "https://wordpress.stackexchange.com/users/75020",
"pm_score": 3,
"selected": true,
"text": "<p>Finally I figured it out. you may simply add your arguments to the <code>wp_list_comments</code> as... | 2015/12/06 | [
"https://wordpress.stackexchange.com/questions/210947",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84842/"
] | I have this permalinks settings: `/%postname%/`
I have a custom taxonomy `issue`.
I want replace all my taxonomy links `(site.com/category/wordpress)` to `(site.com/category/wordpress/issue/any-child)`. Like tags.
Maybe this picture help
[](https:/... | Finally I figured it out. you may simply add your arguments to the `wp_list_comments` as associative `key` => `value` pairs like this:
```
$args = array( 'callback' => 'my_callback', 'avatar_size' => 48, 'type' => 'comment', 'arg1' => $arg1 );
wp_list_comments( $args );
```
and then in your `my_callback` you have:
... |
210,975 | <p>I have some code in my loop that will determine the term in my custom taxonomy, if it's a specific term, it will output a specific image. </p>
<pre><code><?php if( has_term('10', 'review-score' ) ) { ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<img src=... | [
{
"answer_id": 210939,
"author": "Peyman Mohamadpour",
"author_id": 75020,
"author_profile": "https://wordpress.stackexchange.com/users/75020",
"pm_score": 3,
"selected": true,
"text": "<p>Finally I figured it out. you may simply add your arguments to the <code>wp_list_comments</code> as... | 2015/12/06 | [
"https://wordpress.stackexchange.com/questions/210975",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84582/"
] | I have some code in my loop that will determine the term in my custom taxonomy, if it's a specific term, it will output a specific image.
```
<?php if( has_term('10', 'review-score' ) ) { ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<img src="<?php echo get_stylesheet_directory_uri(... | Finally I figured it out. you may simply add your arguments to the `wp_list_comments` as associative `key` => `value` pairs like this:
```
$args = array( 'callback' => 'my_callback', 'avatar_size' => 48, 'type' => 'comment', 'arg1' => $arg1 );
wp_list_comments( $args );
```
and then in your `my_callback` you have:
... |
210,993 | <p>I have a problem with some page URLs.
The page URL structure is like this:</p>
<pre><code>www.example.com/wp/custom-taxonomy/somepagename/?token=12345
</code></pre>
<p>I want that when I access the URL above to redirect me to:</p>
<pre><code>www.example.com/wp/custom-taxonomy/somepagename/
</code></pre>
<p>In <code>... | [
{
"answer_id": 211001,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <a href=\"https://codex.wordpress.org/Rewrite_API/add_rewrite_rule\" rel=\"nofollow\">add_rewrite_... | 2015/12/07 | [
"https://wordpress.stackexchange.com/questions/210993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51967/"
] | I have a problem with some page URLs.
The page URL structure is like this:
```
www.example.com/wp/custom-taxonomy/somepagename/?token=12345
```
I want that when I access the URL above to redirect me to:
```
www.example.com/wp/custom-taxonomy/somepagename/
```
In `/wp/` is WordPress installed. I tried this in `.ht... | >
>
> ```
> RewriteBase /wp/
> RewriteCond %{query_string} ^token=12345
> RewriteRule (.*) /$1? [R=301,L]
>
> ```
>
> but it redirects me to:
>
>
>
> ```
> www.example.com/custom-taxonomy/somepagename
>
> ```
>
>
There are two issues here with the redirected URL:
1. The `/wp` prefix is missing.
2. The trail... |
211,029 | <p>I will that the custome can update in the order the custom fileds (who was insert in the checkout page)</p>
<p>I have this code in the order-details.php Page but it show only the value in the input but he don't update with the new value</p>
<pre><code><?php
global $post;
if ( isset( $_POST['submit'] ) )
{
... | [
{
"answer_id": 211132,
"author": "kreativcube",
"author_id": 84829,
"author_profile": "https://wordpress.stackexchange.com/users/84829",
"pm_score": 1,
"selected": true,
"text": "<p>This code works for me. Sorry that the code is not good readable.</p>\n<pre><code><?php\nglobal $post;\... | 2015/12/07 | [
"https://wordpress.stackexchange.com/questions/211029",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84829/"
] | I will that the custome can update in the order the custom fileds (who was insert in the checkout page)
I have this code in the order-details.php Page but it show only the value in the input but he don't update with the new value
```
<?php
global $post;
if ( isset( $_POST['submit'] ) )
{
if( ! isset( $post ) ) {... | This code works for me. Sorry that the code is not good readable.
```
<?php
global $post;
$post = $order_id;
if ( isset( $_POST['submit'] ) ){
echo 'Update nicht';
} else if ( ! empty( $_POST['frontstrasse'] ) ) {
update_post_meta( $order_id, 'Strasse', sanitize_text_field( $_POST['frontstrasse'] ) );
update_po... |
211,032 | <p>I want to use check_ajax_referer() to verify a WP_nonce field using AJAX. Here you can find my html element. </p>
<pre><code><input type="hidden" name="login_nonce" value="<?= wp_create_nonce('login_nonce'); ?>"/>
</code></pre>
<p>Using jQuery I'm sending all the values from input fields to a POST requ... | [
{
"answer_id": 219824,
"author": "db306",
"author_id": 90056,
"author_profile": "https://wordpress.stackexchange.com/users/90056",
"pm_score": 3,
"selected": false,
"text": "<p>Difficult to say for sure where the mistake is as you have not mentioned about your <code>add_action('wp_ajax_m... | 2015/12/07 | [
"https://wordpress.stackexchange.com/questions/211032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57798/"
] | I want to use check\_ajax\_referer() to verify a WP\_nonce field using AJAX. Here you can find my html element.
```
<input type="hidden" name="login_nonce" value="<?= wp_create_nonce('login_nonce'); ?>"/>
```
Using jQuery I'm sending all the values from input fields to a POST request:
```
request = $.ajax({
typ... | Difficult to say for sure where the mistake is as you have not mentioned about your `add_action('wp_ajax_my_function','whatever_callback');`which I think you missed out on that. But your question is missing info in this respect.
This is how I would get on about this:
In your functions.php file or similar:
```
add_ac... |
211,039 | <p>I want every user to get a profile in the front-end of my website.
So I want to visit website.com/user/user-name and view all the information of this user. Is this somehow possible? </p>
<p>I would like to do this without a plug-in. All things I'll found on Google did include a plug-in like <a href="https://nl.word... | [
{
"answer_id": 219824,
"author": "db306",
"author_id": 90056,
"author_profile": "https://wordpress.stackexchange.com/users/90056",
"pm_score": 3,
"selected": false,
"text": "<p>Difficult to say for sure where the mistake is as you have not mentioned about your <code>add_action('wp_ajax_m... | 2015/12/07 | [
"https://wordpress.stackexchange.com/questions/211039",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57798/"
] | I want every user to get a profile in the front-end of my website.
So I want to visit website.com/user/user-name and view all the information of this user. Is this somehow possible?
I would like to do this without a plug-in. All things I'll found on Google did include a plug-in like [Front-End Only Users](https://nl.... | Difficult to say for sure where the mistake is as you have not mentioned about your `add_action('wp_ajax_my_function','whatever_callback');`which I think you missed out on that. But your question is missing info in this respect.
This is how I would get on about this:
In your functions.php file or similar:
```
add_ac... |
211,072 | <p>I'm working on a website for an artist. He has many images that he would like a user to be able to sort and filter by custom taxonomy. In addition, he would like a user to be able to navigate through a hierarchical gallery with folders (that display a thumbnail) for each level of the hierarchy.</p>
<p>I started b... | [
{
"answer_id": 211078,
"author": "John Ellmore",
"author_id": 13649,
"author_profile": "https://wordpress.stackexchange.com/users/13649",
"pm_score": 1,
"selected": false,
"text": "<p>NextGen gallery isn't built on top of custom post types, so you won't be able to easily link your custom... | 2015/12/07 | [
"https://wordpress.stackexchange.com/questions/211072",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84806/"
] | I'm working on a website for an artist. He has many images that he would like a user to be able to sort and filter by custom taxonomy. In addition, he would like a user to be able to navigate through a hierarchical gallery with folders (that display a thumbnail) for each level of the hierarchy.
I started by creating a... | NextGen gallery isn't built on top of custom post types, so you won't be able to easily link your custom Artwork taxonomies with NextGen. Your best bet is to create archive template files in your theme that can display the artwork like NextGen would. The nested approach you mentioned could be accomplished using [hierar... |
211,082 | <p>I am using a plugin that has shortcodes. It is called according shortcodes</p>
<pre><code>[accordion]
[accordion-item title="Title of accordion item"]Drop-down content goes here.[/accordion-item]
[accordion-item title="Second accordion item"]Drop-down content goes here.[/accordion-item]
[/accordion]
</code></pre>
... | [
{
"answer_id": 211087,
"author": "coopersita",
"author_id": 21258,
"author_profile": "https://wordpress.stackexchange.com/users/21258",
"pm_score": 1,
"selected": true,
"text": "<p>I think it needs to be like this:</p>\n\n<pre><code><?php $output = '[accordion]'; ?> \n ... | 2015/12/07 | [
"https://wordpress.stackexchange.com/questions/211082",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77767/"
] | I am using a plugin that has shortcodes. It is called according shortcodes
```
[accordion]
[accordion-item title="Title of accordion item"]Drop-down content goes here.[/accordion-item]
[accordion-item title="Second accordion item"]Drop-down content goes here.[/accordion-item]
[/accordion]
```
I wanted put it in a wp... | I think it needs to be like this:
```
<?php $output = '[accordion]'; ?>
<?php
$args = array(
'posts_per_page' => '-1',
'post_type' => 'post',
... |
211,106 | <p>Is there a function to set WP_POST_REVISIONS from a plugin instead of having to do it in config.php? I was thinking of doing this:</p>
<pre><code>runkit_constant_redefine( 'WP_POST_REVISIONS', 0 );
</code></pre>
<p>but that puts a dependency on runkit being compiled in with PHP which I'm not sure is usual/typical... | [
{
"answer_id": 211108,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 1,
"selected": true,
"text": "<ol>\n<li>Create a no-revs.php</li>\n<li>Set the contents to <code><?php defined('WP_POST_REVISIONS') or define... | 2015/12/08 | [
"https://wordpress.stackexchange.com/questions/211106",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83299/"
] | Is there a function to set WP\_POST\_REVISIONS from a plugin instead of having to do it in config.php? I was thinking of doing this:
```
runkit_constant_redefine( 'WP_POST_REVISIONS', 0 );
```
but that puts a dependency on runkit being compiled in with PHP which I'm not sure is usual/typical.
I want to turn revisio... | 1. Create a no-revs.php
2. Set the contents to `<?php defined('WP_POST_REVISIONS') or define ('WP_POST_REVISIONS', false);`
3. Place it in the [Must Use Plugins Folder](https://codex.wordpress.org/Must_Use_Plugins) located at `wp-content/mu-plugins`.
Be warned; It is [recommended](http://www.wpstuffs.com/how-to-limit-... |
211,122 | <p>I have customised the standard Wordpress search.php and everything is working fine.</p>
<p>Now, my client would like to be able to add some content to the beginning of the search results page in the same way he can add content to any other page he has created in the admin area.</p>
<p>So, my thinking is to declare... | [
{
"answer_id": 211114,
"author": "bosco",
"author_id": 25324,
"author_profile": "https://wordpress.stackexchange.com/users/25324",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>Is this practical?</p>\n</blockquote>\n\n<p>If you'd like to take advantage of all WordPress ha... | 2015/12/08 | [
"https://wordpress.stackexchange.com/questions/211122",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84924/"
] | I have customised the standard Wordpress search.php and everything is working fine.
Now, my client would like to be able to add some content to the beginning of the search results page in the same way he can add content to any other page he has created in the admin area.
So, my thinking is to declare my custom search... | In my opinion as long as your needs are exclusively about *looks* it's never a good reason to migrate to entirely different code base. The separation of backend code and frontend site is inherently one of the strengths in web development.
When you you are a lone developer on own project there are roughly three design ... |
211,156 | <p>Recently I have transferred my WordPress from development server to live server. I noticed that I have to change all the "guid" with live domain url. Is there any mysql query or simple function available to change it easily. </p>
| [
{
"answer_id": 211198,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 2,
"selected": false,
"text": "<p>Use the <a href=\"http://wp-cli.org\" rel=\"nofollow\">WP-CLI</a> to <a href=\"http://wp-cli.org/commands/sear... | 2015/12/08 | [
"https://wordpress.stackexchange.com/questions/211156",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43308/"
] | Recently I have transferred my WordPress from development server to live server. I noticed that I have to change all the "guid" with live domain url. Is there any mysql query or simple function available to change it easily. | It should be something like:
```
UPDATE wp_posts SET guid = REPLACE(guid, 'oldurl.com', 'newurl.com') WHERE guid LIKE 'http://oldurl.com/%';
```
* `oldurl.com` - Previous URL shown in wordpress settings > general options
* `newurl.com` - New URL |
211,164 | <p>I've added several customisation options to my theme, and I'm (trying to) use the <code>active_callback</code> argument with <code>$wp_customiser->add_section()</code>.</p>
<p>In the first instance, this appears to be working just fine. The active callbacks that I am using are <code>is_search</code>, <code>is_ar... | [
{
"answer_id": 211166,
"author": "Megan Rose",
"author_id": 84643,
"author_profile": "https://wordpress.stackexchange.com/users/84643",
"pm_score": 2,
"selected": false,
"text": "<p>The is_single template tag takes an optional parameter and therefore does not work for an active callback.... | 2015/12/08 | [
"https://wordpress.stackexchange.com/questions/211164",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10097/"
] | I've added several customisation options to my theme, and I'm (trying to) use the `active_callback` argument with `$wp_customiser->add_section()`.
In the first instance, this appears to be working just fine. The active callbacks that I am using are `is_search`, `is_archive` and `is_single`, so I'd expect for those sec... | After much hair pulling, swearing my mum would be shocked with, and some totally acceptable man-crying I finally found what the issue here was.
As mentioned in my updated question, no JS errors were reported by either Firefox (Firebug) or Chrome (Developer Tools), but the issue was to be found within a custom JS scrip... |
211,167 | <p>My goal is to lazy load thumbnails. As seen in <a href="http://www.appelsiini.net/projects/lazyload" rel="nofollow">here</a>, I need to add <code>class="lazy"</code>, placeholder has to be in <code>src</code> and lazy loaded image as <code>data-original</code>.</p>
<p>This code works perfectly:</p>
<pre><code>if (... | [
{
"answer_id": 211178,
"author": "flomei",
"author_id": 65455,
"author_profile": "https://wordpress.stackexchange.com/users/65455",
"pm_score": 3,
"selected": true,
"text": "<p>You got everything you need, simply build your own <code>img</code>-element like this:</p>\n\n<pre><code>if ( h... | 2015/12/08 | [
"https://wordpress.stackexchange.com/questions/211167",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80903/"
] | My goal is to lazy load thumbnails. As seen in [here](http://www.appelsiini.net/projects/lazyload), I need to add `class="lazy"`, placeholder has to be in `src` and lazy loaded image as `data-original`.
This code works perfectly:
```
if ( has_post_thumbnail() ) {
$size = 'attachment-thumbnail-400-300';
//Ge... | You got everything you need, simply build your own `img`-element like this:
```
if ( has_post_thumbnail() ) {
$class = 'lazy attachment-thumbnail-400-300';
//Get thumbnail source
$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'thumbnail-400-300');
$src = $thumb['0'];
$placehol... |
211,173 | <p>I have a page where I'm calling event titles based on the current user. I'm calling them into a table and associating a 'credit' with each event. </p>
<p>The table gets populated with the events and credits. At the bottom of the page at the moment I'm just bringing in the credits from each event, but I'd like to ad... | [
{
"answer_id": 211181,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 2,
"selected": true,
"text": "<p><a href=\"http://www.advancedcustomfields.com\" rel=\"nofollow\">ACF</a> uses <a href=\"http://www.advancedcust... | 2015/12/08 | [
"https://wordpress.stackexchange.com/questions/211173",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84954/"
] | I have a page where I'm calling event titles based on the current user. I'm calling them into a table and associating a 'credit' with each event.
The table gets populated with the events and credits. At the bottom of the page at the moment I'm just bringing in the credits from each event, but I'd like to add up all t... | [ACF](http://www.advancedcustomfields.com) uses [get\_field](http://www.advancedcustomfields.com/resources/get_field/) so you can get the value before you output it. Just make sure you have a `$total_credit` variable before you start the loop and just add to it. When the loop is done print the total to your table.
*NO... |
211,209 | <p>I'm trying to convert this to using a $wpdb class.
It will return all the enums possible and i have to use this $wpdb due to mysql_query giving me weird error (no database selected)
Code is following</p>
<pre><code>function getEnumValues($table, $field)
{
$enum_array = array();
$query = 'SHOW COLUMNS FROM... | [
{
"answer_id": 211181,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 2,
"selected": true,
"text": "<p><a href=\"http://www.advancedcustomfields.com\" rel=\"nofollow\">ACF</a> uses <a href=\"http://www.advancedcust... | 2015/12/08 | [
"https://wordpress.stackexchange.com/questions/211209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84975/"
] | I'm trying to convert this to using a $wpdb class.
It will return all the enums possible and i have to use this $wpdb due to mysql\_query giving me weird error (no database selected)
Code is following
```
function getEnumValues($table, $field)
{
$enum_array = array();
$query = 'SHOW COLUMNS FROM `' . $table ... | [ACF](http://www.advancedcustomfields.com) uses [get\_field](http://www.advancedcustomfields.com/resources/get_field/) so you can get the value before you output it. Just make sure you have a `$total_credit` variable before you start the loop and just add to it. When the loop is done print the total to your table.
*NO... |
211,226 | <p>When I am creating a post from the admin panel and using a youtube link in the Editor, the editor automatically fetching the video from youtube and displaying right away in the editor.</p>
<p><a href="https://i.stack.imgur.com/342mk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/342mk.png" alt="... | [
{
"answer_id": 211181,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 2,
"selected": true,
"text": "<p><a href=\"http://www.advancedcustomfields.com\" rel=\"nofollow\">ACF</a> uses <a href=\"http://www.advancedcust... | 2015/12/09 | [
"https://wordpress.stackexchange.com/questions/211226",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44528/"
] | When I am creating a post from the admin panel and using a youtube link in the Editor, the editor automatically fetching the video from youtube and displaying right away in the editor.
[](https://i.stack.imgur.com/342mk.png)
But When i am using custo... | [ACF](http://www.advancedcustomfields.com) uses [get\_field](http://www.advancedcustomfields.com/resources/get_field/) so you can get the value before you output it. Just make sure you have a `$total_credit` variable before you start the loop and just add to it. When the loop is done print the total to your table.
*NO... |
211,238 | <p>I need you help here.
After updating to WordPress 4.4 locally all was fine ... but after updating on my server I get the following error:</p>
<pre><code>Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 8193 bytes) in /home/proondernemer/public_html/wp-includes/functions.php on line 44... | [
{
"answer_id": 211263,
"author": "Maruti Mohanty",
"author_id": 37890,
"author_profile": "https://wordpress.stackexchange.com/users/37890",
"pm_score": 1,
"selected": false,
"text": "<p>This is a memory issue and can be handled from the <strong>wp-config.php</strong> file if the server a... | 2015/12/09 | [
"https://wordpress.stackexchange.com/questions/211238",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84173/"
] | I need you help here.
After updating to WordPress 4.4 locally all was fine ... but after updating on my server I get the following error:
```
Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 8193 bytes) in /home/proondernemer/public_html/wp-includes/functions.php on line 4461
```
Anyon... | This is a memory issue and can be handled from the **wp-config.php** file if the server allows.
From what I see you have tried
`define('WP_MEMORY_LIMIT', '64M');`
which takes care of the front end, but if you still have memory issue in the admin end, then try
`define( 'WP_MAX_MEMORY_LIMIT', '64M' );`
>
> Please ... |
211,240 | <p>When I try to google search my web address, the follow comes up as the meta description </p>
<blockquote>
<p>"A description for this result is not available because of this site's
robots.txt – learn more."</p>
</blockquote>
<p>The <a href="http://www.kaushakisrealestate.com/" rel="noreferrer">website</a>
I hav... | [
{
"answer_id": 211241,
"author": "Nikhil",
"author_id": 26760,
"author_profile": "https://wordpress.stackexchange.com/users/26760",
"pm_score": 2,
"selected": false,
"text": "<p>Once I experienced the same issue, this is what I did to fix the issue.</p>\n\n<p>Edit the robots.txt file dir... | 2015/12/09 | [
"https://wordpress.stackexchange.com/questions/211240",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84989/"
] | When I try to google search my web address, the follow comes up as the meta description
>
> "A description for this result is not available because of this site's
> robots.txt – learn more."
>
>
>
The [website](http://www.kaushakisrealestate.com/)
I have tried to edit the robots.txt (downloaded the WP Robot plu... | Once I experienced the same issue, this is what I did to fix the issue.
Edit the robots.txt file directly (using FTP/SSH),
```
User-agent: *
Disallow: /wp-admin/
Disallow: /wp-includes/
```
There are two reasons if the robots files not updated when you edited using a plugin.
1. File permission.
2. Some other plu... |
211,256 | <p>I'm trying to insert a post image thumbnail from my php scritp. It's inserting the post, the content, a download link, and I only need to set the thumbnail image to finish my script. This is my code but I can't figure out why is not working, anyhelp would be appreciated:</p>
<pre><code> $url = "http://www.test.c... | [
{
"answer_id": 211241,
"author": "Nikhil",
"author_id": 26760,
"author_profile": "https://wordpress.stackexchange.com/users/26760",
"pm_score": 2,
"selected": false,
"text": "<p>Once I experienced the same issue, this is what I did to fix the issue.</p>\n\n<p>Edit the robots.txt file dir... | 2015/12/09 | [
"https://wordpress.stackexchange.com/questions/211256",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69187/"
] | I'm trying to insert a post image thumbnail from my php scritp. It's inserting the post, the content, a download link, and I only need to set the thumbnail image to finish my script. This is my code but I can't figure out why is not working, anyhelp would be appreciated:
```
$url = "http://www.test.com/wp-content/... | Once I experienced the same issue, this is what I did to fix the issue.
Edit the robots.txt file directly (using FTP/SSH),
```
User-agent: *
Disallow: /wp-admin/
Disallow: /wp-includes/
```
There are two reasons if the robots files not updated when you edited using a plugin.
1. File permission.
2. Some other plu... |
211,271 | <p>I'm trying to remove a filter on the register_url hook a parent theme added, that seems to have a class nomenclature I can't figure out.</p>
<p>Ordinarily, a filter for this hook would be easily added like so:</p>
<pre><code> add_filter( 'register_url', 'custom_register_url' );
function custom_register_url(... | [
{
"answer_id": 211275,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>It looks like the plugin doesn't want you do access the <code>APP_Registration</code> instance, so you can try... | 2015/12/09 | [
"https://wordpress.stackexchange.com/questions/211271",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31403/"
] | I'm trying to remove a filter on the register\_url hook a parent theme added, that seems to have a class nomenclature I can't figure out.
Ordinarily, a filter for this hook would be easily added like so:
```
add_filter( 'register_url', 'custom_register_url' );
function custom_register_url( $register_url )
... | It looks like the plugin doesn't want you do access the `APP_Registration` instance, so you can try this:
```
add_filter( 'register_url', function( $url )
{
// Adjust this to your needs
$url = site_url( 'wp-login.php?action=register', 'login' );
return $url;
}, 11 );
```
to override the plugin's modific... |
211,303 | <p>During theme or plugin upgrades, maintenance mode is enabled and then disabled once complete.</p>
<p>Is it possible to manually enable / disable maintenance mode?</p>
<p><code>Enabling Maintenance mode...
Downloading update from xxxx
Disabling Maintenance mode...</code></p>
| [
{
"answer_id": 211317,
"author": "Daniel Bachhuber",
"author_id": 82349,
"author_profile": "https://wordpress.stackexchange.com/users/82349",
"pm_score": 3,
"selected": false,
"text": "<p>You can enable maintenance mode in WordPress by adding a <code>.maintenance</code> file to your root... | 2015/12/09 | [
"https://wordpress.stackexchange.com/questions/211303",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85027/"
] | During theme or plugin upgrades, maintenance mode is enabled and then disabled once complete.
Is it possible to manually enable / disable maintenance mode?
`Enabling Maintenance mode...
Downloading update from xxxx
Disabling Maintenance mode...` | WP-CLI now has native commands for it.
```
# Activate Maintenance mode
$ wp maintenance-mode activate
# Deactivate Maintenance mode
$ wp maintenance-mode deactivate
```
See [`wp-cli/maintenance-mode-command`](https://github.com/wp-cli/maintenance-mode-command/blob/master/README.md) for more information. |
211,305 | <p>Ok, I am building this membership plugin. </p>
<p>Plugin sends user to a digital payment site and this one is sending user after the operation back to the wp site with a code (POST), to a page that was chosen by user (on plugin's options panel). Plugin listens to this POST, grabs the code and makes a <code>wp_remot... | [
{
"answer_id": 211343,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Your code runs on <code>init</code> which is well before the <code>the_content</code> filter is called. Ther... | 2015/12/09 | [
"https://wordpress.stackexchange.com/questions/211305",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67000/"
] | Ok, I am building this membership plugin.
Plugin sends user to a digital payment site and this one is sending user after the operation back to the wp site with a code (POST), to a page that was chosen by user (on plugin's options panel). Plugin listens to this POST, grabs the code and makes a `wp_remote_get` request ... | If you have to add our message before/after content then you're stuck with 'the\_content' filter. It would be better if you put your message in a shortcode or hook so the theme customizations were more integrated. But essentially after you run your logic to get the status you just need to wait till the message makes se... |
211,354 | <p>Pages :</p>
<ul>
<li>Home - set as static home page;</li>
<li>blog - for blog posts;</li>
<li>About ;</li>
<li>Contact;</li>
<li>Projects;</li>
</ul>
<p>List of templates:</p>
<ul>
<li>front-page.php - for Home page;</li>
<li>home.php - for blog page;</li>
<li>about.php;</li>
<li>contact.php;</li>
<li>projects.ph... | [
{
"answer_id": 211343,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Your code runs on <code>init</code> which is well before the <code>the_content</code> filter is called. Ther... | 2015/12/10 | [
"https://wordpress.stackexchange.com/questions/211354",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85056/"
] | Pages :
* Home - set as static home page;
* blog - for blog posts;
* About ;
* Contact;
* Projects;
List of templates:
* front-page.php - for Home page;
* home.php - for blog page;
* about.php;
* contact.php;
* projects.php
I have dummy text set up for About and Contact page which shows up when respective pages are... | If you have to add our message before/after content then you're stuck with 'the\_content' filter. It would be better if you put your message in a shortcode or hook so the theme customizations were more integrated. But essentially after you run your logic to get the status you just need to wait till the message makes se... |
211,363 | <p>I want to add functionality like Add member record with birthrate and as per the current date it shows on page.</p>
<p><strong>Ex :</strong> </p>
<p>Add record - [name] [birth_date] [position]</p>
<p>And on the front page we can shows all the member list who have birthday today.</p>
<p>Is there any way to achiev... | [
{
"answer_id": 211370,
"author": "Nikhil",
"author_id": 26760,
"author_profile": "https://wordpress.stackexchange.com/users/26760",
"pm_score": 1,
"selected": false,
"text": "<p><strong>Step - 1</strong></p>\n\n<p>Create a custom post type called Birthday</p>\n\n<pre><code>add_action( 'i... | 2015/12/10 | [
"https://wordpress.stackexchange.com/questions/211363",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82575/"
] | I want to add functionality like Add member record with birthrate and as per the current date it shows on page.
**Ex :**
Add record - [name] [birth\_date] [position]
And on the front page we can shows all the member list who have birthday today.
Is there any way to achieve that? | **Step - 1**
Create a custom post type called Birthday
```
add_action( 'init', 'register_birthday_content_type' );
function register_birthday_content_type() {
register_post_type( 'birthday', array(
'labels' => array(
'name' => 'Birthdays',
'singular_name' => 'Birthday',
),
'desc... |
211,368 | <p>I'm glad that WP 4.4. ships with a built-in responsive image feature. But I'm not that happy with it.</p>
<p>I have set up some custom image sizes in my <code>functions.php</code>:</p>
<pre>add_image_size('post-thumbnails', 600, 600, true);
add_image_size('news-large', 1024, false);
add_image_size('news-small', 50... | [
{
"answer_id": 211405,
"author": "kraftner",
"author_id": 47733,
"author_profile": "https://wordpress.stackexchange.com/users/47733",
"pm_score": 4,
"selected": true,
"text": "<p>Concerning documentation there is this blog post on the Make Blog:</p>\n\n<p><a href=\"https://make.wordpress... | 2015/12/10 | [
"https://wordpress.stackexchange.com/questions/211368",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29055/"
] | I'm glad that WP 4.4. ships with a built-in responsive image feature. But I'm not that happy with it.
I have set up some custom image sizes in my `functions.php`:
```
add_image_size('post-thumbnails', 600, 600, true);
add_image_size('news-large', 1024, false);
add_image_size('news-small', 500, false);
add_image_size(... | Concerning documentation there is this blog post on the Make Blog:
[Responsive Images in WordPress 4.4](https://make.wordpress.org/core/2015/11/10/responsive-images-in-wordpress-4-4/)
To increase the 1600px limit mentioned in the comments try this:
```
add_filter('max_srcset_image_width', function($max_srcset_image_... |
211,375 | <p>I succesfully converted my 4.3.1 install to all https. After updating to 4.4. I have a problem with the new <code>srcset</code> attribute. While the <code>src</code> attribute for images is set using https, the <code>srcset</code> attribute is http. This causes browsers to not display any image at all. </p>
<p>Whil... | [
{
"answer_id": 211376,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 6,
"selected": true,
"text": "<p>Here are few things you could try to remove the responsive image support in 4.4:</p>\n\n<pre><code>/**\n * Dis... | 2015/12/10 | [
"https://wordpress.stackexchange.com/questions/211375",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27184/"
] | I succesfully converted my 4.3.1 install to all https. After updating to 4.4. I have a problem with the new `srcset` attribute. While the `src` attribute for images is set using https, the `srcset` attribute is http. This causes browsers to not display any image at all.
While waiting for a better fix, I wish to disab... | Here are few things you could try to remove the responsive image support in 4.4:
```
/**
* Disable responsive image support (test!)
*/
// Clean the up the image from wp_get_attachment_image()
add_filter( 'wp_get_attachment_image_attributes', function( $attr )
{
if( isset( $attr['sizes'] ) )
unset( $attr... |
211,393 | <p>I installed wp-cli back in April on my Windows box using composer. I believe with the following command: <code>composer create-project wp-cli/wp-cli --no-dev</code> as outlined in the alternate install methods on <a href="https://github.com/wp-cli/wp-cli/wiki/Alternative-Install-Methods" rel="nofollow">here</a>.</p... | [
{
"answer_id": 211376,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 6,
"selected": true,
"text": "<p>Here are few things you could try to remove the responsive image support in 4.4:</p>\n\n<pre><code>/**\n * Dis... | 2015/12/10 | [
"https://wordpress.stackexchange.com/questions/211393",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64298/"
] | I installed wp-cli back in April on my Windows box using composer. I believe with the following command: `composer create-project wp-cli/wp-cli --no-dev` as outlined in the alternate install methods on [here](https://github.com/wp-cli/wp-cli/wiki/Alternative-Install-Methods).
I have since used "`composer update --no-d... | Here are few things you could try to remove the responsive image support in 4.4:
```
/**
* Disable responsive image support (test!)
*/
// Clean the up the image from wp_get_attachment_image()
add_filter( 'wp_get_attachment_image_attributes', function( $attr )
{
if( isset( $attr['sizes'] ) )
unset( $attr... |
211,415 | <p>On the checkout page I have a custom field that gets saved to the order meta data. I need to grab the order meta data and create a custom post type and fill the custom fields with order meta data.</p>
<pre><code>add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admi... | [
{
"answer_id": 211424,
"author": "Tim Plummer",
"author_id": 15236,
"author_profile": "https://wordpress.stackexchange.com/users/15236",
"pm_score": 0,
"selected": false,
"text": "<p>Check out <code>$website_url = get_post_meta($order_id->id, 'My Field', true);</code> You're trying ... | 2015/12/10 | [
"https://wordpress.stackexchange.com/questions/211415",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85089/"
] | On the checkout page I have a custom field that gets saved to the order meta data. I need to grab the order meta data and create a custom post type and fill the custom fields with order meta data.
```
add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta',... | I managed to figure it out by placing the wp\_insert\_post function in the same function that saves the order meta data |
211,436 | <p>I'm attempting to modify a WordPress theme so that it appends a version number to a particular stylesheet. This is all done on a local development machine, tested on a staging server, too, for good measure. Following the instructions here:
<a href="https://www.mojowill.com/developer/get-your-wordpress-css-changes-no... | [
{
"answer_id": 211438,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 0,
"selected": false,
"text": "<p>Make sure to <a href=\"https://codex.wordpress.org/Function_Reference/wp_register_style\" rel=\"nofollow\">wp_... | 2015/12/10 | [
"https://wordpress.stackexchange.com/questions/211436",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76674/"
] | I'm attempting to modify a WordPress theme so that it appends a version number to a particular stylesheet. This is all done on a local development machine, tested on a staging server, too, for good measure. Following the instructions here:
<https://www.mojowill.com/developer/get-your-wordpress-css-changes-noticed-immed... | At long last, I have identified the issue. The theme I was working in used the [Minikit theme starter](https://github.com/stefanolaru/minikit), which has a function that strips version numbers.
`function minikit_remove_wp_ver_css_js($src) {
if (strpos($src, 'ver='))
$src = remove_query_arg('ver', $src);
return $sr... |
211,467 | <p>Does anyone know how to remove the WordPress JSON API links in the header tag?</p>
<pre><code><head>
...
<link rel='https://api.w.org/' href='http://example.com/wp-json/' />
<link rel="alternate" type="application/json+oembed" href="http://example.com/wp-json/oembed/1.0/embed?url=..." />
<link ... | [
{
"answer_id": 211469,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 6,
"selected": true,
"text": "<p>I see in filters.php \"add_action( 'wp_head', 'rest_output_link_wp_head', 10, 0 )\" Which makes me think this s... | 2015/12/10 | [
"https://wordpress.stackexchange.com/questions/211467",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18814/"
] | Does anyone know how to remove the WordPress JSON API links in the header tag?
```
<head>
...
<link rel='https://api.w.org/' href='http://example.com/wp-json/' />
<link rel="alternate" type="application/json+oembed" href="http://example.com/wp-json/oembed/1.0/embed?url=..." />
<link rel="alternate" type="text/xml+oemb... | I see in filters.php "add\_action( 'wp\_head', 'rest\_output\_link\_wp\_head', 10, 0 )" Which makes me think this should do the trick to remove `rel='https://api.w.org/'`.
```
remove_action( 'wp_head', 'rest_output_link_wp_head' );
```
The rest... \* *cough* \* seem to be in default-filters.php
``... |
211,481 | <p>I'm currently trying to work on a WordPress theme based on <a href="https://roots.io/sage/" rel="nofollow">Sage</a>. The stage I'm at is creating custom controls to display on the customize screen for WordPress where you typically change things like the site title or theme colors if you're an end user. </p>
<p>It s... | [
{
"answer_id": 211482,
"author": "AddWeb Solution Pvt Ltd",
"author_id": 73643,
"author_profile": "https://wordpress.stackexchange.com/users/73643",
"pm_score": -1,
"selected": false,
"text": "<p>From <a href=\"https://codex.wordpress.org/Theme_Customization_API\" rel=\"nofollow\">Theme_... | 2015/12/11 | [
"https://wordpress.stackexchange.com/questions/211481",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85138/"
] | I'm currently trying to work on a WordPress theme based on [Sage](https://roots.io/sage/). The stage I'm at is creating custom controls to display on the customize screen for WordPress where you typically change things like the site title or theme colors if you're an end user.
It seems that the new setting I'm trying... | The problem with the code sample is that the setting is using `widget_` as the prefix. This is a reserved prefix for *widgets*, per the [customizer handbook](https://developer.wordpress.org/themes/customize-api/customizer-objects/#settings):
>
> **Important:** Do not use a setting ID that looks like `widget_*`, `side... |
211,496 | <p>I'm using Visual Composer, but I think it has more to do with WordPress than VC ;-)
I did a shortcode (with the <a href="https://wpbakery.atlassian.net/wiki/display/VC/Adding+Custom+Shortcode+to+Grid+Builder" rel="nofollow noreferrer">VC API</a>) to get the content of a post.
Here it is (in functions.php):</p>
<pre>... | [
{
"answer_id": 211519,
"author": "Douglas.Sesar",
"author_id": 19945,
"author_profile": "https://wordpress.stackexchange.com/users/19945",
"pm_score": -1,
"selected": false,
"text": "<p>you could try <code>do_shortcode()</code> - <a href=\"https://developer.wordpress.org/reference/functi... | 2015/12/11 | [
"https://wordpress.stackexchange.com/questions/211496",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85151/"
] | I'm using Visual Composer, but I think it has more to do with WordPress than VC ;-)
I did a shortcode (with the [VC API](https://wpbakery.atlassian.net/wiki/display/VC/Adding+Custom+Shortcode+to+Grid+Builder)) to get the content of a post.
Here it is (in functions.php):
```
add_filter( 'vc_grid_item_shortcodes', 'my_m... | Here's the code given by the VC team. And it works.
```
// display content in grid
add_filter( 'vc_grid_item_shortcodes', 'my_module_add_grid_shortcodes' );
function my_module_add_grid_shortcodes( $shortcodes ) {
$shortcodes['vc_post_content'] = array(
'name' => __( 'Post content', 'fluidtopics' ),
'base' => '... |
211,505 | <p>I am trying to change the background for a the 'recent posts' widget in my Wordpress theme. </p>
<p>My problem is that Wordpress generates ids like <code>recent-posts-2</code> and so on, so how can I address this id in css. I intend to create an inclusive id in css to address which includes all automatically genera... | [
{
"answer_id": 211506,
"author": "ajax20",
"author_id": 85160,
"author_profile": "https://wordpress.stackexchange.com/users/85160",
"pm_score": 0,
"selected": false,
"text": "<p>Ok, I seem to have found the answer to my own question with the help of the following link.</p>\n\n<ul>\n<li><... | 2015/12/11 | [
"https://wordpress.stackexchange.com/questions/211505",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85160/"
] | I am trying to change the background for a the 'recent posts' widget in my Wordpress theme.
My problem is that Wordpress generates ids like `recent-posts-2` and so on, so how can I address this id in css. I intend to create an inclusive id in css to address which includes all automatically generated IDs.
Something l... | Use a plugin to add custom css classes. This plugin does just that and a little more: <https://wordpress.org/plugins/widget-css-classes/>
For example, add the class `.recent-posts` to the recent posts widgets. Then you should be able to style them just like any other css class. |
211,556 | <p>Some call it light OCD, some might call it security risk. I just don't like how it throws it all in there, especially template names. </p>
<p>How to only assign page id or even better - slug?</p>
<p>Note that this is in header template, it should output current page's id / slug.</p>
<p>All "professional", high qu... | [
{
"answer_id": 211558,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 3,
"selected": true,
"text": "<p>Honestly, it's source code. The only people who see it are you and other developers. Anybody casually visiti... | 2015/12/11 | [
"https://wordpress.stackexchange.com/questions/211556",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80903/"
] | Some call it light OCD, some might call it security risk. I just don't like how it throws it all in there, especially template names.
How to only assign page id or even better - slug?
Note that this is in header template, it should output current page's id / slug.
All "professional", high quality WP sites I've exam... | Honestly, it's source code. The only people who see it are you and other developers. Anybody casually visiting your website will never know or understand this stuff so really there's no harm keeping it there. *Buttttt...* if you want to get rid of it you could filter [`body_class`](https://codex.wordpress.org/Plugin_AP... |
211,565 | <h1>Update 2016-01-21</h1>
<p>All current testing on my end is being done on fresh installs of 4.4.1 with the following settings:
<code>Plain permalinks</code>
<code>Twentysixteen Theme</code>
<code>No plugins activated</code></p>
<p><strong>If the post only has 1 page</strong> (ie <code><!--nextpage--></code> ... | [
{
"answer_id": 211579,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>Note that there's a syntax error for all those three examples you provided:</p>\n\n<pre><code>add_filter('con... | 2015/12/11 | [
"https://wordpress.stackexchange.com/questions/211565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85182/"
] | Update 2016-01-21
=================
All current testing on my end is being done on fresh installs of 4.4.1 with the following settings:
`Plain permalinks`
`Twentysixteen Theme`
`No plugins activated`
**If the post only has 1 page** (ie `<!--nextpage-->` doesn't appear in the post) then the **extra pages are appended ... | UPDATE 21-01-2016 19:35 SA TIME - BUG FOUND!!!!! YEAH!!!!!!
===========================================================
I finally found the bug. As you stated in your last update, the failure only happens when `$post_content` has a `<!--nextpage-->` tag in the content. I tested it, and did confirm that any other page ... |
211,581 | <p>When creating a new term in a custom taxonomy with wp_insert_term, i've noticed that name should be unique.
I get a wp error message if it is not :</p>
<pre><code>A term with the name provided already exists with this parent
</code></pre>
<p>I would like a way to automatically check if name is already exist and ap... | [
{
"answer_id": 211599,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<h2>EDIT</h2>\n\n<h2><a href=\"http://askville.amazon.com/deux-part-speech-sense-carry/AnswerViewer.do?req... | 2015/12/12 | [
"https://wordpress.stackexchange.com/questions/211581",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85162/"
] | When creating a new term in a custom taxonomy with wp\_insert\_term, i've noticed that name should be unique.
I get a wp error message if it is not :
```
A term with the name provided already exists with this parent
```
I would like a way to automatically check if name is already exist and append it if yes.
So chec... | EDIT
----
[PART DEUX](http://askville.amazon.com/deux-part-speech-sense-carry/AnswerViewer.do?requestId=13424467) OR [PART DEUX](http://www.urbandictionary.com/define.php?term=part%20deux) - The Dirty Sequal, The Term Saga Continues...
-----------------------------------------------------------------------------------... |
211,626 | <p>I want to use static HTML for a landing page on a WordPress site. For example:</p>
<ul>
<li><code>example.com</code> - WordPress already running in root folder</li>
<li><code>landingPage.example.com</code> - I purchased this static landing page using
ThemeForest</li>
</ul>
| [
{
"answer_id": 211630,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": false,
"text": "<p>Just name the landing page file <code>index.html</code> and place it (and any assets) in the root director... | 2015/12/12 | [
"https://wordpress.stackexchange.com/questions/211626",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85229/"
] | I want to use static HTML for a landing page on a WordPress site. For example:
* `example.com` - WordPress already running in root folder
* `landingPage.example.com` - I purchased this static landing page using
ThemeForest | Just name the landing page file `index.html` and place it (and any assets) in the root directory, then add this to your `.htaccess` (assuming you're using Apache):
```
DirectoryIndex index.html index.php
```
When accessing `http://example.com`, Apache will serve `index.html`. WordPress will scoop up all other reques... |
211,628 | <p>Just upgraded to WordPress 4.4 and I notice now my users' profile page in admin, there's a section called "profile picture", with a link to Gravatar.</p>
<p>The plugin I'm developing restricts a lot of things in profile.php; unfortunately by deleting from the DOM via jQuery:</p>
<pre><code>jQuery( document ).ready... | [
{
"answer_id": 211650,
"author": "Por",
"author_id": 31832,
"author_profile": "https://wordpress.stackexchange.com/users/31832",
"pm_score": 0,
"selected": false,
"text": "<p>Here is simple solutions for that, add more ids to hide more fields</p>\n\n<pre><code><script type=\"text/java... | 2015/12/12 | [
"https://wordpress.stackexchange.com/questions/211628",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83299/"
] | Just upgraded to WordPress 4.4 and I notice now my users' profile page in admin, there's a section called "profile picture", with a link to Gravatar.
The plugin I'm developing restricts a lot of things in profile.php; unfortunately by deleting from the DOM via jQuery:
```
jQuery( document ).ready(function() {
jQu... | We can use the `show_avatars` option to remove the *Profile Picture* section.
* We can visit `/wp-admin/options.php` to turn it off manually.
* Or update it with:
```
update_option( 'show_avatars', 0 );
```
* Or modify it through a filter:
```
add_filter( 'option_show_avatars', '__return_false' );
```
* We could a... |
211,647 | <p>I'm a developer of a private Wp plugin that has been running for 3+ yrs.
The plugin displays in table format users custom information.
I just upgraded to v 4.4 and now I'm getting a fatal error: Fatal error: Call to undefined method stdClass::render_screen_reader_content() in .../wp-admin/includes/class-wp-list-tabl... | [
{
"answer_id": 211695,
"author": "TECC1",
"author_id": 83840,
"author_profile": "https://wordpress.stackexchange.com/users/83840",
"pm_score": 3,
"selected": false,
"text": "<p>This has been resolved</p>\n\n<p>Had to add 2 new files ...looks like Wordpress moved some methods to new locat... | 2015/12/13 | [
"https://wordpress.stackexchange.com/questions/211647",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83840/"
] | I'm a developer of a private Wp plugin that has been running for 3+ yrs.
The plugin displays in table format users custom information.
I just upgraded to v 4.4 and now I'm getting a fatal error: Fatal error: Call to undefined method stdClass::render\_screen\_reader\_content() in .../wp-admin/includes/class-wp-list-tabl... | This has been resolved
Had to add 2 new files ...looks like Wordpress moved some methods to new locations.
These are the files that worked for me
```
// Include WP's list table class
if(!class_exists('WP_List_Table')){
require_once( ABSPATH . 'wp-admin/includes/class-wp-screen.php' );//added
require_once( A... |
211,655 | <p>I am trying to create a member directory and using a custom post type members. I am familiar on how to use the ACF plugin but is there any methods on how to associate a custom field for a specific custom post type to have a simple input box like phone number and address?</p>
| [
{
"answer_id": 211760,
"author": "Carl Alberto",
"author_id": 60720,
"author_profile": "https://wordpress.stackexchange.com/users/60720",
"pm_score": 4,
"selected": true,
"text": "<p>If you don't want to use a plugin, you can try implementing a meta box to be associated with that custom ... | 2015/12/13 | [
"https://wordpress.stackexchange.com/questions/211655",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85192/"
] | I am trying to create a member directory and using a custom post type members. I am familiar on how to use the ACF plugin but is there any methods on how to associate a custom field for a specific custom post type to have a simple input box like phone number and address? | If you don't want to use a plugin, you can try implementing a meta box to be associated with that custom post type, This is the code that I use if I want to add a simple input field for a certain post type, in the example below, I assume that the **member\_post\_type** is your declared post type:
```
function member_a... |
211,662 | <p>I upgraded from Windows 7 to Windows 10, and had to reinstall WampServer to get it running.</p>
<p>I'd like to reinstall Wordpress for a local WampServer site.</p>
<p>I have deleted the old database and username, and created a new user + associated database of the same name. I left the password blank.</p>
<p>When... | [
{
"answer_id": 211760,
"author": "Carl Alberto",
"author_id": 60720,
"author_profile": "https://wordpress.stackexchange.com/users/60720",
"pm_score": 4,
"selected": true,
"text": "<p>If you don't want to use a plugin, you can try implementing a meta box to be associated with that custom ... | 2015/12/13 | [
"https://wordpress.stackexchange.com/questions/211662",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | I upgraded from Windows 7 to Windows 10, and had to reinstall WampServer to get it running.
I'd like to reinstall Wordpress for a local WampServer site.
I have deleted the old database and username, and created a new user + associated database of the same name. I left the password blank.
When I try to run the instal... | If you don't want to use a plugin, you can try implementing a meta box to be associated with that custom post type, This is the code that I use if I want to add a simple input field for a certain post type, in the example below, I assume that the **member\_post\_type** is your declared post type:
```
function member_a... |
211,666 | <p>I want to add a front end post editing functionality to one of my Wordpress sites. I found a few plugins that do this, but they don't fits all my needs, so I decided to adapt <a href="http://voodoopress.com/edit-and-delete-posts-from-front-end-with-no-plugin-part-2/" rel="nofollow">an existing solution</a> to develo... | [
{
"answer_id": 211674,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>From the code it seems like your warning comes from doing the redirect too late. redirects should be done... | 2015/12/13 | [
"https://wordpress.stackexchange.com/questions/211666",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | I want to add a front end post editing functionality to one of my Wordpress sites. I found a few plugins that do this, but they don't fits all my needs, so I decided to adapt [an existing solution](http://voodoopress.com/edit-and-delete-posts-from-front-end-with-no-plugin-part-2/) to develop a my own plugin that will r... | From the code it seems like your warning comes from doing the redirect too late. redirects should be done, as a rule of thumb, not later then the init action. And after the redirect you should die() (I don't think the `wp_redirect` does it for you)
As for security, it is not enough to check that the user is logged-in,... |
211,672 | <p><a href="http://codex.wordpress.org/Function_Reference/register_taxonomy" rel="nofollow">The Codex page for <code>register_taxonomy</code> says that</a></p>
<blockquote>
<p>This function adds or overwrites a taxonomy.</p>
</blockquote>
<p>How can I use it to overwrite a core taxonomy without redefining all the p... | [
{
"answer_id": 211676,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>Version 4.4 saw the introduction of the <code>register_taxonomy_args</code> filter in <a href=\"https:/... | 2015/12/13 | [
"https://wordpress.stackexchange.com/questions/211672",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16975/"
] | [The Codex page for `register_taxonomy` says that](http://codex.wordpress.org/Function_Reference/register_taxonomy)
>
> This function adds or overwrites a taxonomy.
>
>
>
How can I use it to overwrite a core taxonomy without redefining all the parameters ?
For example, let's imagine that I want to make the core ... | I found another reliable way to overwrite a taxonomy : I can just get the registered one before and change only the parameter I want. Registered taxonomies can be retrieved by `get_taxonomy`. But there are two catches :
1. `get_taxonomy` returns an object, whereas `register_taxonomy` ask for an associative array, so w... |
211,688 | <p>Is there any way to redirect WooCommerce default '<a href="http://website.com/shop/" rel="nofollow noreferrer">http://website.com/shop/</a>' URL to '<a href="http://website.com/shop/all/" rel="nofollow noreferrer">http://website.com/shop/all/</a>'?</p>
<p>After a long research found this :
<a href="https://wordpre... | [
{
"answer_id": 211931,
"author": "Scarecrow",
"author_id": 52025,
"author_profile": "https://wordpress.stackexchange.com/users/52025",
"pm_score": 2,
"selected": false,
"text": "<p>You can use woocommerce_return_to_shop_redirect filter to overwrite the redirection url. </p>\n\n<pre><code... | 2015/12/13 | [
"https://wordpress.stackexchange.com/questions/211688",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82575/"
] | Is there any way to redirect WooCommerce default '<http://website.com/shop/>' URL to '<http://website.com/shop/all/>'?
After a long research found this :
[How does Wordpress redirect to WooCommerce shop page?](https://wordpress.stackexchange.com/questions/151397/how-does-wordpress-redirect-to-woocommerce-shop-page) b... | You can use woocommerce\_return\_to\_shop\_redirect filter to overwrite the redirection url.
```
add_filter( 'woocommerce_return_to_shop_redirect', "custom_woocommerce_return_to_shop_redirect" ,20 );
function custom_woocommerce_return_to_shop_redirect(){
return site_url()."shop/all/";
}
``` |
211,701 | <p><strong>Question</strong></p>
<ol>
<li>What does the <code>wp-embed.min.js</code> file do? I noticed it is added to the end of my blog page footer.</li>
<li>How can I get rid of it?</li>
</ol>
<p><strong>Effort</strong></p>
<p>After some googling and I found <a href="https://codex.wordpress.org/Embeds">Embeds</a>... | [
{
"answer_id": 211705,
"author": "Peyman Mohamadpour",
"author_id": 75020,
"author_profile": "https://wordpress.stackexchange.com/users/75020",
"pm_score": 7,
"selected": true,
"text": "<h2>What is it?</h2>\n<p>It is responsible for converting links into embed frames.</p>\n<p>For example... | 2015/12/13 | [
"https://wordpress.stackexchange.com/questions/211701",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75020/"
] | **Question**
1. What does the `wp-embed.min.js` file do? I noticed it is added to the end of my blog page footer.
2. How can I get rid of it?
**Effort**
After some googling and I found [Embeds](https://codex.wordpress.org/Embeds) on the Codex. Why does WordPress think I want to add videos, etc. to my page by default... | What is it?
-----------
It is responsible for converting links into embed frames.
For example you can paste a Youtube video link into the editor content section and the Youtube embed will be generated for you when your page is viewed.
More information on [WordPress Documentation](https://wordpress.org/support/articl... |
211,710 | <p>Yes, I know that we have <code>get_template_directory_uri();</code> in referencing to the theme's directory. It's working when I put the following code inside <code>index.php</code> or in <code>header.php</code>:</p>
<pre><code><img src="<?php echo get_template_directory_uri(); ?>/images/sample.png">
</... | [
{
"answer_id": 211711,
"author": "Por",
"author_id": 31832,
"author_profile": "https://wordpress.stackexchange.com/users/31832",
"pm_score": 1,
"selected": false,
"text": "<p>The answer is yes. You could run php code in editor. But that is not for proper way of adding images. Instead, yo... | 2015/12/14 | [
"https://wordpress.stackexchange.com/questions/211710",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85242/"
] | Yes, I know that we have `get_template_directory_uri();` in referencing to the theme's directory. It's working when I put the following code inside `index.php` or in `header.php`:
```
<img src="<?php echo get_template_directory_uri(); ?>/images/sample.png">
```
But when I'm adding an image inside pages when editing ... | ```
<img src="<?php echo esc_url( get_template_directory_uri() . '/images/logo.jpg' ); ?>" alt="" >
```
Try this. It should work.
You have to concatenate the results from `get_template_directory_uri()` and your images directory in echo. |
211,728 | <p>I'm developing a plugin and I've started from <a href="http://wppb.io/" rel="nofollow">WPPB</a> and Wordpress 4.3.1. I've named it dogmaweb. I need to submit a form to the plugin via Ajax. The form is created by the plugin itself. In my class-dogmaweb.php I'm trying to add the action that processes the form data ser... | [
{
"answer_id": 211711,
"author": "Por",
"author_id": 31832,
"author_profile": "https://wordpress.stackexchange.com/users/31832",
"pm_score": 1,
"selected": false,
"text": "<p>The answer is yes. You could run php code in editor. But that is not for proper way of adding images. Instead, yo... | 2015/12/14 | [
"https://wordpress.stackexchange.com/questions/211728",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84622/"
] | I'm developing a plugin and I've started from [WPPB](http://wppb.io/) and Wordpress 4.3.1. I've named it dogmaweb. I need to submit a form to the plugin via Ajax. The form is created by the plugin itself. In my class-dogmaweb.php I'm trying to add the action that processes the form data server side, and here is what I'... | ```
<img src="<?php echo esc_url( get_template_directory_uri() . '/images/logo.jpg' ); ?>" alt="" >
```
Try this. It should work.
You have to concatenate the results from `get_template_directory_uri()` and your images directory in echo. |
211,734 | <p>I have a simple function in functions.php that creates a custom shortcode:</p>
<pre><code>function my_line_break() {
return "<br>";
}
add_shortcode( 'new line', 'my_line_break' );
</code></pre>
<p>Now, I don't know if this happened after upgrading to 4.4 but it's not longer working and pages just render ... | [
{
"answer_id": 211749,
"author": "Danial",
"author_id": 85280,
"author_profile": "https://wordpress.stackexchange.com/users/85280",
"pm_score": 1,
"selected": false,
"text": "<p>Your shortcode name is incorrect . <a href=\"https://codex.wordpress.org/Shortcode_API#Names\" rel=\"nofollow\... | 2015/12/14 | [
"https://wordpress.stackexchange.com/questions/211734",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44953/"
] | I have a simple function in functions.php that creates a custom shortcode:
```
function my_line_break() {
return "<br>";
}
add_shortcode( 'new line', 'my_line_break' );
```
Now, I don't know if this happened after upgrading to 4.4 but it's not longer working and pages just render `[new line]` in plain text.
Any... | Converting the comment to an answer,
please rename your Shortcode to not contain spaces (`new_line`):
```
function my_line_break() {
return "<br>";
}
add_shortcode( 'new_line', 'my_line_break' );
``` |
211,742 | <p>The goal is very simple - to print page content on a page.
I tried:</p>
<pre><code><?php the_content() ?>
<?= get_the_content() ?>
</code></pre>
<p>then</p>
<pre><code><?php the_content(get_the_ID()) ?>
<?= get_the_content(get_the_ID()) ?>
</code></pre>
<p>None of them worked.</p>
<p>The... | [
{
"answer_id": 211747,
"author": "Danial",
"author_id": 85280,
"author_profile": "https://wordpress.stackexchange.com/users/85280",
"pm_score": 1,
"selected": false,
"text": "<p>Displays the contents of the current post. This template tag must be within while loop.</p>\n\n<pre><code><... | 2015/12/14 | [
"https://wordpress.stackexchange.com/questions/211742",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85230/"
] | The goal is very simple - to print page content on a page.
I tried:
```
<?php the_content() ?>
<?= get_the_content() ?>
```
then
```
<?php the_content(get_the_ID()) ?>
<?= get_the_content(get_the_ID()) ?>
```
None of them worked.
Then I found this bizarre solution:
```
<?= apply_filters('the_content', get_post_... | A few notes before I start
* NEVER EVER use php shortcodes, they are bad, confusing and not supported by default on some servers. IMHO, they should have never made it into PHP in the first place. WordPress Standards (*which doesn't mean much*) also "prohibits" the use of shorttags. Use proper php tags and forget that ... |
211,767 | <p>I have a custom plugin that I have written to manage a lot of stuff. I want to use this for the main website.com. I don't want any of the subdomain sites e.g. website.com/site1 to have access to this plugin. I was thinking of implementing something in the plugin itself so it would check the URL and wouldn't do anyth... | [
{
"answer_id": 211747,
"author": "Danial",
"author_id": 85280,
"author_profile": "https://wordpress.stackexchange.com/users/85280",
"pm_score": 1,
"selected": false,
"text": "<p>Displays the contents of the current post. This template tag must be within while loop.</p>\n\n<pre><code><... | 2015/12/14 | [
"https://wordpress.stackexchange.com/questions/211767",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190834/"
] | I have a custom plugin that I have written to manage a lot of stuff. I want to use this for the main website.com. I don't want any of the subdomain sites e.g. website.com/site1 to have access to this plugin. I was thinking of implementing something in the plugin itself so it would check the URL and wouldn't do anything... | A few notes before I start
* NEVER EVER use php shortcodes, they are bad, confusing and not supported by default on some servers. IMHO, they should have never made it into PHP in the first place. WordPress Standards (*which doesn't mean much*) also "prohibits" the use of shorttags. Use proper php tags and forget that ... |
211,771 | <p>I have a search form which searches the DB and returns back some data. I have managed to use Wordpress wpdb to connect and use select statement on the table and retrieve data. Everything works fine..But..I have page refresh issue. I want to add AJAX code in order to get my data without refreshing. So, I have follow... | [
{
"answer_id": 211747,
"author": "Danial",
"author_id": 85280,
"author_profile": "https://wordpress.stackexchange.com/users/85280",
"pm_score": 1,
"selected": false,
"text": "<p>Displays the contents of the current post. This template tag must be within while loop.</p>\n\n<pre><code><... | 2015/12/14 | [
"https://wordpress.stackexchange.com/questions/211771",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85213/"
] | I have a search form which searches the DB and returns back some data. I have managed to use Wordpress wpdb to connect and use select statement on the table and retrieve data. Everything works fine..But..I have page refresh issue. I want to add AJAX code in order to get my data without refreshing. So, I have followed a... | A few notes before I start
* NEVER EVER use php shortcodes, they are bad, confusing and not supported by default on some servers. IMHO, they should have never made it into PHP in the first place. WordPress Standards (*which doesn't mean much*) also "prohibits" the use of shorttags. Use proper php tags and forget that ... |
211,774 | <p>I need a code that causes: <code><?php while ( have_posts() ) : the_post(); ?></code> List according to the amount of VIEW, is like to list popular posts only that it will enter the table <strong>mh_postmeta</strong>, and list according to who has the most <strong>view</strong>.</p>
<p><a href="https://i.stac... | [
{
"answer_id": 211787,
"author": "Bram_Boterham",
"author_id": 81263,
"author_profile": "https://wordpress.stackexchange.com/users/81263",
"pm_score": 0,
"selected": false,
"text": "<p>If you don't want to register your own meta-boxes: give <a href=\"http://www.advancedcustomfields.com/\... | 2015/12/14 | [
"https://wordpress.stackexchange.com/questions/211774",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85291/"
] | I need a code that causes: `<?php while ( have_posts() ) : the_post(); ?>` List according to the amount of VIEW, is like to list popular posts only that it will enter the table **mh\_postmeta**, and list according to who has the most **view**.
[... | Seems like you already have the custom field for views set up since that's a phpMyAdmin screenshot. If so, you can use `order_by="post_views_count"` in most `wp_query` based calls. For instance:
```
$args = array(
'post_type' => 'your_post_type',
'orderby' => 'meta_value_num',
'meta_key' => 'post_views_... |
211,802 | <p>How can I set a post's featured image using the content of a shortcode? For instance, the following shortcode should set the post's featured image to the image at <code>www.google.de/nicepic.jpg</code>:</p>
<pre><code>[post_image]www.google.de/nicepic.jpg[/post_image]
</code></pre>
| [
{
"answer_id": 211808,
"author": "Manu",
"author_id": 22963,
"author_profile": "https://wordpress.stackexchange.com/users/22963",
"pm_score": 0,
"selected": false,
"text": "<p>Not a full answer, but maybe a hint in the right direction...</p>\n\n<p>In terms of saved data, a featured image... | 2015/12/14 | [
"https://wordpress.stackexchange.com/questions/211802",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85306/"
] | How can I set a post's featured image using the content of a shortcode? For instance, the following shortcode should set the post's featured image to the image at `www.google.de/nicepic.jpg`:
```
[post_image]www.google.de/nicepic.jpg[/post_image]
``` | The Shortcode API is more geared for altering post content rather than performing actions in response to content, and as such tend to require more creativity to alter other post data - though it can still be done. Ultimately, using a shortcode to set a featured image is kind of bizarre considering that you can do the s... |
211,803 | <p>My plugin uses camelCase in file and folder like</p>
<pre><code>myPlugin/myPlugin.php
</code></pre>
<p>I've encountered several issues with this on plugin updates. Most of them work just fine and it's more a cosmetic thing but on some places I just like to go with all lowercase.</p>
<p>What's the best way (or is ... | [
{
"answer_id": 211915,
"author": "grappler",
"author_id": 17937,
"author_profile": "https://wordpress.stackexchange.com/users/17937",
"pm_score": 1,
"selected": false,
"text": "<p>If you just wanted to just change the filename you would have both <code>myPlugin.php</code> and <code>myplu... | 2015/12/14 | [
"https://wordpress.stackexchange.com/questions/211803",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18981/"
] | My plugin uses camelCase in file and folder like
```
myPlugin/myPlugin.php
```
I've encountered several issues with this on plugin updates. Most of them work just fine and it's more a cosmetic thing but on some places I just like to go with all lowercase.
What's the best way (or is there any) to update the plugin t... | Ok, I did some research/testing on it an in short terms:
**Don't use uppercase in the first place!**
I've currently noticed only one problem where the ajax based update from the plugins overview (introduced in WP 4.2) throws a JS error but it may be a problem in the future.
This is because the ajax response uses `sa... |
211,804 | <p>PHP noob here. I've got this query I've written to get the information of all child pages of the page you're currently on:</p>
<pre><code> <?php
$pages = get_pages('child_of=1015&sort_column=post_title');
$count = 0;
foreach($pages as... | [
{
"answer_id": 211915,
"author": "grappler",
"author_id": 17937,
"author_profile": "https://wordpress.stackexchange.com/users/17937",
"pm_score": 1,
"selected": false,
"text": "<p>If you just wanted to just change the filename you would have both <code>myPlugin.php</code> and <code>myplu... | 2015/12/14 | [
"https://wordpress.stackexchange.com/questions/211804",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66039/"
] | PHP noob here. I've got this query I've written to get the information of all child pages of the page you're currently on:
```
<?php
$pages = get_pages('child_of=1015&sort_column=post_title');
$count = 0;
foreach($pages as $page)
... | Ok, I did some research/testing on it an in short terms:
**Don't use uppercase in the first place!**
I've currently noticed only one problem where the ajax based update from the plugins overview (introduced in WP 4.2) throws a JS error but it may be a problem in the future.
This is because the ajax response uses `sa... |
211,811 | <p>This is sort of a follow up to <a href="https://wordpress.stackexchange.com/questions/211632/can-i-put-my-wordpress-theme-files-in-another-folder">Can I put my Wordpress theme files in another folder?</a></p>
<p>I found that following</p>
<pre><code>...\wp-content\themes\MyTheme
- \dist
- \lib
- \src
- \wp... | [
{
"answer_id": 211813,
"author": "Thomas Withers",
"author_id": 85307,
"author_profile": "https://wordpress.stackexchange.com/users/85307",
"pm_score": 0,
"selected": false,
"text": "<p>well you could probably create a variable at the start of your header.php and assign its value string ... | 2015/12/14 | [
"https://wordpress.stackexchange.com/questions/211811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70599/"
] | This is sort of a follow up to [Can I put my Wordpress theme files in another folder?](https://wordpress.stackexchange.com/questions/211632/can-i-put-my-wordpress-theme-files-in-another-folder)
I found that following
```
...\wp-content\themes\MyTheme
- \dist
- \lib
- \src
- \wp - All my Wordpress files like i... | If you look at the function [in source](https://core.trac.wordpress.org/browser/tags/4.4/src/wp-includes/theme.php#L319), you'll see the `template_directory_uri` hook [you can filter](https://codex.wordpress.org/Function_Reference/add_filter) to modify output.
```
return apply_filters( 'template_directory_uri', $templ... |
211,830 | <p>The admin bar displays on the dashboard, but does not display on pages or posts.</p>
<p>I'm working with a child theme of Twenty Thirteen that I did not code. I'm a beginning level coder and work mostly with builders. So the builder plugin I installed is also not showing up either.</p>
<p>I've read some potential ... | [
{
"answer_id": 211813,
"author": "Thomas Withers",
"author_id": 85307,
"author_profile": "https://wordpress.stackexchange.com/users/85307",
"pm_score": 0,
"selected": false,
"text": "<p>well you could probably create a variable at the start of your header.php and assign its value string ... | 2015/12/15 | [
"https://wordpress.stackexchange.com/questions/211830",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85318/"
] | The admin bar displays on the dashboard, but does not display on pages or posts.
I'm working with a child theme of Twenty Thirteen that I did not code. I'm a beginning level coder and work mostly with builders. So the builder plugin I installed is also not showing up either.
I've read some potential causes and checke... | If you look at the function [in source](https://core.trac.wordpress.org/browser/tags/4.4/src/wp-includes/theme.php#L319), you'll see the `template_directory_uri` hook [you can filter](https://codex.wordpress.org/Function_Reference/add_filter) to modify output.
```
return apply_filters( 'template_directory_uri', $templ... |
211,831 | <p>I'm trying to echo the post ID in a post Javascript and not having any luck.</p>
<pre><code>var post_id = '123'; // works fine
var post_id = '<?php global $post; echo $post->ID; ?>'; // echos 'ID; ?>'
var post_id = '<?php echo $post->ID;?>'; // echos 'ID; ?>'
</code></pre>
<p>Is there ... | [
{
"answer_id": 211832,
"author": "Fid",
"author_id": 43105,
"author_profile": "https://wordpress.stackexchange.com/users/43105",
"pm_score": 2,
"selected": false,
"text": "<p>Ok, got it. Maybe this'll help someone. In theme functions.php:</p>\n\n<pre><code>function pid() {\n\nglobal $cur... | 2015/12/15 | [
"https://wordpress.stackexchange.com/questions/211831",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43105/"
] | I'm trying to echo the post ID in a post Javascript and not having any luck.
```
var post_id = '123'; // works fine
var post_id = '<?php global $post; echo $post->ID; ?>'; // echos 'ID; ?>'
var post_id = '<?php echo $post->ID;?>'; // echos 'ID; ?>'
```
Is there a correct way to echo the post ID? | You can pass variables to javascript using wp\_localize\_script function:
<https://codex.wordpress.org/Function_Reference/wp_localize_script>
Add the following to functions.php
```
if(!function_exists('load_my_script')){
function load_my_script() {
global $post;
$deps = array('jquery');
$v... |
211,833 | <p>I decided to organize my work in FTP because I've got over 25 templates by now and the list of files/directories in theme's root is getting really long. </p>
<p>I stumbled on <a href="https://developer.wordpress.org/themes/basics/organizing-theme-files/" rel="nofollow">article</a> where I learned that <em>page-temp... | [
{
"answer_id": 211832,
"author": "Fid",
"author_id": 43105,
"author_profile": "https://wordpress.stackexchange.com/users/43105",
"pm_score": 2,
"selected": false,
"text": "<p>Ok, got it. Maybe this'll help someone. In theme functions.php:</p>\n\n<pre><code>function pid() {\n\nglobal $cur... | 2015/12/15 | [
"https://wordpress.stackexchange.com/questions/211833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80903/"
] | I decided to organize my work in FTP because I've got over 25 templates by now and the list of files/directories in theme's root is getting really long.
I stumbled on [article](https://developer.wordpress.org/themes/basics/organizing-theme-files/) where I learned that *page-templates* directory in theme's root is rea... | You can pass variables to javascript using wp\_localize\_script function:
<https://codex.wordpress.org/Function_Reference/wp_localize_script>
Add the following to functions.php
```
if(!function_exists('load_my_script')){
function load_my_script() {
global $post;
$deps = array('jquery');
$v... |
211,861 | <p><strong>How to pass the custom field values which were stored while creating a new user into the <code>wp_get_current_user</code> array function</strong></p>
<p>When I call the <code>wp_get_current_user()</code> function the result which I found is as follows: </p>
<pre><code>WP_User Object
(
[data] => stdC... | [
{
"answer_id": 212006,
"author": "1991wp",
"author_id": 80381,
"author_profile": "https://wordpress.stackexchange.com/users/80381",
"pm_score": 0,
"selected": false,
"text": "<p>I found the answer for my question. No need to pass the values in the array we can call the separate function ... | 2015/12/15 | [
"https://wordpress.stackexchange.com/questions/211861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80381/"
] | **How to pass the custom field values which were stored while creating a new user into the `wp_get_current_user` array function**
When I call the `wp_get_current_user()` function the result which I found is as follows:
```
WP_User Object
(
[data] => stdClass Object
(
[ID] => 20
[u... | You can simply do this like.
```
$user = wp_get_current_user();
$user->data->client = $user->client; // $user->meta_key
$user->data->user_groups = $user->user_groups; // $user->meta_key
``` |
211,876 | <p>I once had a Wordpress that completely went broke after just updating Wordpress itself. The theme wasn't compatible yet. Glad I had a back-up, with a loss of 2 weeks of development.. Ever since I'm unsure whether I should update anything.</p>
<p>Because of that I would like to have a way of automatic backups of the... | [
{
"answer_id": 211885,
"author": "Clay Hill",
"author_id": 83648,
"author_profile": "https://wordpress.stackexchange.com/users/83648",
"pm_score": 2,
"selected": true,
"text": "<p>As mentioned you can use a plugin to do this that will make backups\n to a directory or sftp location.</p>... | 2015/12/15 | [
"https://wordpress.stackexchange.com/questions/211876",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24727/"
] | I once had a Wordpress that completely went broke after just updating Wordpress itself. The theme wasn't compatible yet. Glad I had a back-up, with a loss of 2 weeks of development.. Ever since I'm unsure whether I should update anything.
Because of that I would like to have a way of automatic backups of the complete ... | As mentioned you can use a plugin to do this that will make backups
to a directory or sftp location.
---
I don't really like using a plugin to do this, so I use rsnapshot to backup my MySQL database and specified directories (including wordpress).
* Rsnapshot is way to complicated to give you instructions in a post... |
211,881 | <p>I am using the Theme Customizer to let users customize how their website looks.</p>
<p>I noticed on the Twenty Fifteen theme there is a panel for Widgets. I have seen this on quite a few other themes too, and the code for the panel has not been added to <code>customizer.php</code> (as far as I can tell)</p>
<p>On ... | [
{
"answer_id": 211901,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>Most likely you are not displaying the sidebar when the costumizer is active which prevents the costumize... | 2015/12/15 | [
"https://wordpress.stackexchange.com/questions/211881",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84836/"
] | I am using the Theme Customizer to let users customize how their website looks.
I noticed on the Twenty Fifteen theme there is a panel for Widgets. I have seen this on quite a few other themes too, and the code for the panel has not been added to `customizer.php` (as far as I can tell)
On my theme, I have a few sideb... | I see you're talking about the `dynamic_sidebar` function but I don't see you mention the sidebar file (eg. `sidebar.php` or `sidebar-single.php`).
There are basically 3 steps I follow to display sidebar widgets and they're always visible in customizer. If yours is not showing up, you probably may have missed somethin... |
211,889 | <p>The homepage on a site we've developed has four pieces of content: the parent page and three further "pages" of text which we bring into the parent page using PHP. Call them Foo, Bar1, Bar2, Bar3 if you like.</p>
<p>Maybe this is or isn't the correct way to solve the problem of a complex page but it works for us an... | [
{
"answer_id": 211896,
"author": "kraftner",
"author_id": 47733,
"author_profile": "https://wordpress.stackexchange.com/users/47733",
"pm_score": 3,
"selected": true,
"text": "<p>Well those are two different things:</p>\n\n<ol>\n<li><p>A redirect means they are not accessible any more at... | 2015/12/15 | [
"https://wordpress.stackexchange.com/questions/211889",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/875/"
] | The homepage on a site we've developed has four pieces of content: the parent page and three further "pages" of text which we bring into the parent page using PHP. Call them Foo, Bar1, Bar2, Bar3 if you like.
Maybe this is or isn't the correct way to solve the problem of a complex page but it works for us and for the ... | Well those are two different things:
1. A redirect means they are not accessible any more at all.
2. noindex just means that search engines ignore it while it is still accessible if you access the URL.
So I'd recommend option 1.
This is a simple way of doing this that you can improve an. (E.g. this expects to have a ... |
211,891 | <p>I want to use a shortcode to replace it with an image form a url.</p>
<p>My idea:</p>
<pre><code>[shortcode url="http://google.de/aImage.jpg"]
</code></pre>
<p>I post this shortcode usinbg IFTTT. After publishing the article the shortcode should be replaced by the image. But the image should come from my "local" ... | [
{
"answer_id": 211896,
"author": "kraftner",
"author_id": 47733,
"author_profile": "https://wordpress.stackexchange.com/users/47733",
"pm_score": 3,
"selected": true,
"text": "<p>Well those are two different things:</p>\n\n<ol>\n<li><p>A redirect means they are not accessible any more at... | 2015/12/15 | [
"https://wordpress.stackexchange.com/questions/211891",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85306/"
] | I want to use a shortcode to replace it with an image form a url.
My idea:
```
[shortcode url="http://google.de/aImage.jpg"]
```
I post this shortcode usinbg IFTTT. After publishing the article the shortcode should be replaced by the image. But the image should come from my "local" library. So the shortcode should ... | Well those are two different things:
1. A redirect means they are not accessible any more at all.
2. noindex just means that search engines ignore it while it is still accessible if you access the URL.
So I'd recommend option 1.
This is a simple way of doing this that you can improve an. (E.g. this expects to have a ... |
211,913 | <p>I have a sticky post that gets the image from background URL, but doesn't resize the image and leaves <a href="http://brancadenoiva.com.br/2015/" rel="nofollow">my blog</a> heavy. Here is the code:</p>
<pre><code>// is sticky
if ( ( is_home() || is_front_page() ) ) {
$sticky = get_option( 'sticky_posts' );
... | [
{
"answer_id": 211939,
"author": "victor",
"author_id": 85366,
"author_profile": "https://wordpress.stackexchange.com/users/85366",
"pm_score": -1,
"selected": false,
"text": "<p>I've already fixed the problem. Sorry for posting in portuguese.\nI've had some problems with CSS because i n... | 2015/12/15 | [
"https://wordpress.stackexchange.com/questions/211913",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85366/"
] | I have a sticky post that gets the image from background URL, but doesn't resize the image and leaves [my blog](http://brancadenoiva.com.br/2015/) heavy. Here is the code:
```
// is sticky
if ( ( is_home() || is_front_page() ) ) {
$sticky = get_option( 'sticky_posts' );
$query = new WP_Query( 'p=' . $sticky[0... | You're going to want to use responsive images in WP 4.4. Not a heck of a lot of documentation out yet but refer to this WP Core article [Responsive Images in WordPress 4.4](https://make.wordpress.org/core/2015/11/10/responsive-images-in-wordpress-4-4/).
Here is the example they give.
```
<?php
$img_src = wp_get_attac... |
211,916 | <p>I used this code to get all the products of a specific category, but how can I show only the author's products of a specific category?</p>
<pre><code><div class="author_products">
<ul class="author_pubproducts">
<?php
$args = array(
'post_type' => 'product',
... | [
{
"answer_id": 211918,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"https://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters\" rel=\"nofollow\">Pass aut... | 2015/12/15 | [
"https://wordpress.stackexchange.com/questions/211916",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85367/"
] | I used this code to get all the products of a specific category, but how can I show only the author's products of a specific category?
```
<div class="author_products">
<ul class="author_pubproducts">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12,
... | [Pass author data to the query](https://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters). It should be that hard.
>
> ### Author
> Parameters
>
> Show posts associated with certain author.
>
>
> * **author** (*int*) - use author id.
> * **author\_name** (*string*) - use
> 'user\_nicename' - NOT... |
211,954 | <p>I have a new WP install with the <a href="http://themeforest.net/item/jupiter-multipurpose-responsive-theme/5177775" rel="nofollow">Jupiter Theme</a> installed. I have a contact form created in Sharpspring, a CRM that purports to work perfectly with WP, and automatically generates embed codes for plugging into any ... | [
{
"answer_id": 211918,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"https://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters\" rel=\"nofollow\">Pass aut... | 2015/12/15 | [
"https://wordpress.stackexchange.com/questions/211954",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85384/"
] | I have a new WP install with the [Jupiter Theme](http://themeforest.net/item/jupiter-multipurpose-responsive-theme/5177775) installed. I have a contact form created in Sharpspring, a CRM that purports to work perfectly with WP, and automatically generates embed codes for plugging into any page. I'm no JS whiz and can't... | [Pass author data to the query](https://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters). It should be that hard.
>
> ### Author
> Parameters
>
> Show posts associated with certain author.
>
>
> * **author** (*int*) - use author id.
> * **author\_name** (*string*) - use
> 'user\_nicename' - NOT... |
211,974 | <p>I created an MU Plugin which will only display the posts from certain tags in the loop like this:</p>
<pre><code>function custom_tags( $query ) {
$query->set( 'tag', array( 'custom', 'general' ) );
}
add_action( 'pre_get_posts', 'custom_tags' );
</code></pre>
<p>It works fine when I remove the array and on... | [
{
"answer_id": 211975,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 2,
"selected": false,
"text": "<p>As Milo ( and your errors ) point out: you're passing an array where a string is expected. According to <a ... | 2015/12/15 | [
"https://wordpress.stackexchange.com/questions/211974",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15330/"
] | I created an MU Plugin which will only display the posts from certain tags in the loop like this:
```
function custom_tags( $query ) {
$query->set( 'tag', array( 'custom', 'general' ) );
}
add_action( 'pre_get_posts', 'custom_tags' );
```
It works fine when I remove the array and only check for 1 tag, but how do... | As Milo ( and your errors ) point out: you're passing an array where a string is expected. According to [WP\_Query tag parameter](https://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters)
>
> Show posts associated with certain tags.
>
>
> * tag (**string**) - use tag slug.
>
>
>
To get around this yo... |
212,003 | <p>Different pages often need different set of scripts and styles for them.</p>
<p>I use functions.php and construction like this to load scripts and styles:</p>
<pre><code>function load_assets() {
wp_enqueue_style( 'styles', get_template_directory_uri() . '/css/styles.css');
wp_enqueue_script('main-js', get_te... | [
{
"answer_id": 212004,
"author": "Aftab",
"author_id": 64614,
"author_profile": "https://wordpress.stackexchange.com/users/64614",
"pm_score": 1,
"selected": false,
"text": "<p>For admin you can do in this way.</p>\n\n<pre><code>function load_assets( $hook ) {\n\n global $post;\n\n ... | 2015/12/16 | [
"https://wordpress.stackexchange.com/questions/212003",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85230/"
] | Different pages often need different set of scripts and styles for them.
I use functions.php and construction like this to load scripts and styles:
```
function load_assets() {
wp_enqueue_style( 'styles', get_template_directory_uri() . '/css/styles.css');
wp_enqueue_script('main-js', get_template_directory_uri(... | Yes, you may add [conditional tags](https://codex.wordpress.org/Conditional_Tags) to the `wp_enqueue_scripts` action. See the examples below:
```
function load_assets() {
wp_enqueue_style( 'styles', get_template_directory_uri() . '/css/styles.css');
// loads on any 'page' post type
if( is_page() ){
w... |
212,012 | <p>Just a small question. Is there any difference in using</p>
<pre><code><?php the_title() ?>
</code></pre>
<p>or</p>
<pre><code><?= get_the_title() ?>
</code></pre>
<p>Yeah, I know somebody can consider using short echo tag a bad practice, I just want to know is there any difference in result of calli... | [
{
"answer_id": 212013,
"author": "TommyBs",
"author_id": 9278,
"author_profile": "https://wordpress.stackexchange.com/users/9278",
"pm_score": 2,
"selected": false,
"text": "<pre><code>the_title()\n</code></pre>\n\n<p>will echo the title for you and can only be used within 'the loop' <a ... | 2015/12/16 | [
"https://wordpress.stackexchange.com/questions/212012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85230/"
] | Just a small question. Is there any difference in using
```
<?php the_title() ?>
```
or
```
<?= get_the_title() ?>
```
Yeah, I know somebody can consider using short echo tag a bad practice, I just want to know is there any difference in result of calling these two functions. | The two are not 100% identical, though they are close.
1. `the_title()` will `echo` content *by default* but the third
parameter can be used to change that default.
2. `the_title()` prepends the optional `$before` and appends the
optional `$after` arguments. If theme or plugin code uses these
arguments the output of t... |
212,026 | <p>I have large number of images in media library so I am accessing images in chunks via pagination in my Ruby on Rails application. I pass page number and offset to <code>wp.getMediaLibrary</code> API and it returns fixed number of images. So counting returned images is useless.</p>
<p>Here is my approach to get tota... | [
{
"answer_id": 212061,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 1,
"selected": false,
"text": "<p><strong>VERSION 1</strong> will query all the images and give you a count by checking the size of the returned... | 2015/12/16 | [
"https://wordpress.stackexchange.com/questions/212026",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84678/"
] | I have large number of images in media library so I am accessing images in chunks via pagination in my Ruby on Rails application. I pass page number and offset to `wp.getMediaLibrary` API and it returns fixed number of images. So counting returned images is useless.
Here is my approach to get total number of images.
... | **VERSION 1** will query all the images and give you a count by checking the size of the returned array. **VERSION 2** is a much faster method introduced by [birgire](https://wordpress.stackexchange.com/users/26350/birgire).
```
// VERSION 1
$images = get_posts(array(
'post_type' => 'attachment',... |
212,030 | <p>Updating my WordPress to 4.4 I have that error: </p>
<blockquote>
<p>Fatal error: Class 'WP_Rewrite' not found</p>
</blockquote>
<p>The page who have the error is my custom ajax with the following code:</p>
<pre><code><?php
// Constantes propias para ajax
define("SHORTINIT",true);
define('WP_USE_THEMES', fal... | [
{
"answer_id": 212039,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>WP_Rewrite</code> class definition has been moved to it's own file:</p>\n\n<pre><code>/wp-includes/... | 2015/12/16 | [
"https://wordpress.stackexchange.com/questions/212030",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60178/"
] | Updating my WordPress to 4.4 I have that error:
>
> Fatal error: Class 'WP\_Rewrite' not found
>
>
>
The page who have the error is my custom ajax with the following code:
```
<?php
// Constantes propias para ajax
define("SHORTINIT",true);
define('WP_USE_THEMES', false);
define('WP_ALLOW_MULTISITE', false);
if ... | I can fixed the problem including this files:
```
require( ABSPATH . WPINC . '/class-wp-rewrite.php' );
require( ABSPATH . WPINC . '/class-wp-user.php' );
require( ABSPATH . WPINC . '/class-wp-tax-query.php' );
require( ABSPATH . WPINC . '/class-wp-meta-query.php' );
require( ABSPATH . WPINC . '/class-wp-term.php' );
... |
212,054 | <p>I have a site with 900+ posts, each with about 3-5 categories. I would like to copy each of the categories to be a tag and am looking for the SQL code to do just that. I do not want to delete or overwrite the categories. (I assume that's the best thing to do for SEO purposes?)</p>
<p>I am having a hard time figurin... | [
{
"answer_id": 212062,
"author": "N00b",
"author_id": 80903,
"author_profile": "https://wordpress.stackexchange.com/users/80903",
"pm_score": 1,
"selected": false,
"text": "<p>You requested SQL solution but SQL is not (yet) my speciality but I might still help you. SQL also seems pointle... | 2015/12/16 | [
"https://wordpress.stackexchange.com/questions/212054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85438/"
] | I have a site with 900+ posts, each with about 3-5 categories. I would like to copy each of the categories to be a tag and am looking for the SQL code to do just that. I do not want to delete or overwrite the categories. (I assume that's the best thing to do for SEO purposes?)
I am having a hard time figuring out exac... | As I said, we would rather use native functions here, which is safer and already does all the hard work for you. We need to be very careful here as this is a very expensive operation to run. Not doing this correctly can crash your site due to timing out
Your worksflow is also wrong here. I would first create all the t... |
212,055 | <p>I'm adding a custom menu to my wordpress theme. I need to add custom html to the final submenu item - before the primary sub-menu closes <code></ul></code> </p>
<p>I have registered my new menu</p>
<pre><code>//functions.php
function register_my_menus() {
register_nav_menus(
array(
'accessories' => __(... | [
{
"answer_id": 212062,
"author": "N00b",
"author_id": 80903,
"author_profile": "https://wordpress.stackexchange.com/users/80903",
"pm_score": 1,
"selected": false,
"text": "<p>You requested SQL solution but SQL is not (yet) my speciality but I might still help you. SQL also seems pointle... | 2015/12/16 | [
"https://wordpress.stackexchange.com/questions/212055",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85437/"
] | I'm adding a custom menu to my wordpress theme. I need to add custom html to the final submenu item - before the primary sub-menu closes `</ul>`
I have registered my new menu
```
//functions.php
function register_my_menus() {
register_nav_menus(
array(
'accessories' => __( 'Accessories Menu' )
)
);
}
```
and I ... | As I said, we would rather use native functions here, which is safer and already does all the hard work for you. We need to be very careful here as this is a very expensive operation to run. Not doing this correctly can crash your site due to timing out
Your worksflow is also wrong here. I would first create all the t... |
212,063 | <p>How can I make a code show the number of posts you have on my site, adding all fair categories??</p>
| [
{
"answer_id": 212066,
"author": "user5477769",
"author_id": 84959,
"author_profile": "https://wordpress.stackexchange.com/users/84959",
"pm_score": 0,
"selected": false,
"text": "<p>This forum thread has a great answer: <a href=\"https://wordpress.org/support/topic/show-number-of-post?r... | 2015/12/16 | [
"https://wordpress.stackexchange.com/questions/212063",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85291/"
] | How can I make a code show the number of posts you have on my site, adding all fair categories?? | Using a query could give you easier customization without having to use SQL directly.
```
$posts = get_posts( array(
'post_type' => 'post',
'post_status' => 'any',
'numberposts' => -1,
'fields' => 'ids',
));
$total_count = count( $posts );
print_r ( $total_count );
``` |
212,086 | <p>I have a special situation and need some help achieving the final step.</p>
<p><strong>Background:</strong></p>
<p>When I access <em>mydomain.com/category/postname</em>, I get the post as expected.</p>
<p>When I access <em>mydomain.com/category/postname?ajax=1</em>, I get the post html (baked into and including i... | [
{
"answer_id": 212066,
"author": "user5477769",
"author_id": 84959,
"author_profile": "https://wordpress.stackexchange.com/users/84959",
"pm_score": 0,
"selected": false,
"text": "<p>This forum thread has a great answer: <a href=\"https://wordpress.org/support/topic/show-number-of-post?r... | 2015/12/16 | [
"https://wordpress.stackexchange.com/questions/212086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85452/"
] | I have a special situation and need some help achieving the final step.
**Background:**
When I access *mydomain.com/category/postname*, I get the post as expected.
When I access *mydomain.com/category/postname?ajax=1*, I get the post html (baked into and including its corresponding page template markup, which is ext... | Using a query could give you easier customization without having to use SQL directly.
```
$posts = get_posts( array(
'post_type' => 'post',
'post_status' => 'any',
'numberposts' => -1,
'fields' => 'ids',
));
$total_count = count( $posts );
print_r ( $total_count );
``` |
212,092 | <p>(Wordpress 4.3.1) </p>
<p>I'm running a custom loop and only want to include posts that have file uploaded to a custom field: audio_file.</p>
<p>I have tried many solutions around the web and so far nothing works. </p>
<p>Can I use meta_query to check if a key has a value? </p>
<p>Here is my current attempt:</p>... | [
{
"answer_id": 212095,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>Can I use meta_query to check if a key has a value?</p>\n</blockquote>\n\n<p>Any value? <a h... | 2015/12/16 | [
"https://wordpress.stackexchange.com/questions/212092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59712/"
] | (Wordpress 4.3.1)
I'm running a custom loop and only want to include posts that have file uploaded to a custom field: audio\_file.
I have tried many solutions around the web and so far nothing works.
Can I use meta\_query to check if a key has a value?
Here is my current attempt:
```
global $post;
$arg... | I figured it out, meta\_query must be an array **within** an array as it is intended for advanced queries using 'relation'.
```
meta_query => array (
array (
//'relation' => 'OR',
'key' => 'audio_file', //The field to check.
'value' => '', //The value of the field.
'compare' => '!='... |
212,099 | <p>I want users who don't have permission to view content to be redirected to a page when they are presented with the default "Nothing Found" page. I've already redirected 404s but this is not exactly a 404. The content exists, they just don't have permission to view it. </p>
| [
{
"answer_id": 212095,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>Can I use meta_query to check if a key has a value?</p>\n</blockquote>\n\n<p>Any value? <a h... | 2015/12/16 | [
"https://wordpress.stackexchange.com/questions/212099",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85457/"
] | I want users who don't have permission to view content to be redirected to a page when they are presented with the default "Nothing Found" page. I've already redirected 404s but this is not exactly a 404. The content exists, they just don't have permission to view it. | I figured it out, meta\_query must be an array **within** an array as it is intended for advanced queries using 'relation'.
```
meta_query => array (
array (
//'relation' => 'OR',
'key' => 'audio_file', //The field to check.
'value' => '', //The value of the field.
'compare' => '!='... |
212,102 | <pre><code>$locations = get_the_terms( $post_id, 'location' );
foreach ( $locations as $location ) {
echo '<a href="'.site_url().'/location/'.$location->slug.'">'. $location->name .'</a>';
break;
}
</code></pre>
<hr>
<p>How to also get all parent taxonomies if there are any?</p>
<p>For... | [
{
"answer_id": 212095,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>Can I use meta_query to check if a key has a value?</p>\n</blockquote>\n\n<p>Any value? <a h... | 2015/12/16 | [
"https://wordpress.stackexchange.com/questions/212102",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80903/"
] | ```
$locations = get_the_terms( $post_id, 'location' );
foreach ( $locations as $location ) {
echo '<a href="'.site_url().'/location/'.$location->slug.'">'. $location->name .'</a>';
break;
}
```
---
How to also get all parent taxonomies if there are any?
For example:
1. Current code outputs `London` i... | I figured it out, meta\_query must be an array **within** an array as it is intended for advanced queries using 'relation'.
```
meta_query => array (
array (
//'relation' => 'OR',
'key' => 'audio_file', //The field to check.
'value' => '', //The value of the field.
'compare' => '!='... |
212,109 | <p>Creating redirects as a client has merged many sites into a single site.</p>
<p>How would I set up a rule to redirect to a parent page if the child does not exist - rather than directly to 404.</p>
<p><strong>Eg</strong>
Redirect from</p>
<pre><code>example.com/au/location1/staff (Does not exist)
</code></pre>
<... | [
{
"answer_id": 212118,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 0,
"selected": false,
"text": "<p>Grab the 404 during the <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect\" ... | 2015/12/17 | [
"https://wordpress.stackexchange.com/questions/212109",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85462/"
] | Creating redirects as a client has merged many sites into a single site.
How would I set up a rule to redirect to a parent page if the child does not exist - rather than directly to 404.
**Eg**
Redirect from
```
example.com/au/location1/staff (Does not exist)
```
to
```
example.com/au/location1
```
(there are a... | If you want to do this in your .htaccess file to ensure an early redirect, the method is as follows.
First check if the page does not exist using the rewrite condition:
```
RewriteCond %{REQUEST_FILENAME} !-f
```
Next comes the rewrite rule for the page that does not exist
```
RewriteRule ^/au/location1/(.*)$ http... |
212,127 | <p>Nothing happens when I select the datepicker field.</p>
<p>This is the code for the field:</p>
<pre><code><input id="sticky_date" name="sticky_date" class="datepicker hasDatepicker" type="text">
</code></pre>
<p>The javascript</p>
<pre><code>jQuery(function() {
jQuery( '.datepicker' ).datepicker({
ch... | [
{
"answer_id": 212118,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 0,
"selected": false,
"text": "<p>Grab the 404 during the <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect\" ... | 2015/12/17 | [
"https://wordpress.stackexchange.com/questions/212127",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74564/"
] | Nothing happens when I select the datepicker field.
This is the code for the field:
```
<input id="sticky_date" name="sticky_date" class="datepicker hasDatepicker" type="text">
```
The javascript
```
jQuery(function() {
jQuery( '.datepicker' ).datepicker({
changeMonth: true,
changeYear: true,
yearRan... | If you want to do this in your .htaccess file to ensure an early redirect, the method is as follows.
First check if the page does not exist using the rewrite condition:
```
RewriteCond %{REQUEST_FILENAME} !-f
```
Next comes the rewrite rule for the page that does not exist
```
RewriteRule ^/au/location1/(.*)$ http... |
212,130 | <p>I want to try the new REST API but I'm not used to this kind of things. Basically, I want to use it to GET custom posts via ajax and show on the website frontend (I'm building an ajax product filtering system).</p>
<p>I can't figure out how to authenticate from php and how to test authenticating from command line.<... | [
{
"answer_id": 212134,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 4,
"selected": true,
"text": "<p>GET requests, like listing posts, doesn't need authentication at least you need to get private posts. Your pro... | 2015/12/17 | [
"https://wordpress.stackexchange.com/questions/212130",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10381/"
] | I want to try the new REST API but I'm not used to this kind of things. Basically, I want to use it to GET custom posts via ajax and show on the website frontend (I'm building an ajax product filtering system).
I can't figure out how to authenticate from php and how to test authenticating from command line.
I guess I... | GET requests, like listing posts, doesn't need authentication at least you need to get private posts. Your problem is that you are using a route/endpoint that doesn't exist.
In WordPress 4.4, WP REST API infrastructure was merged, endpoints didn't; they will be merged in WordPress 4.5 (as WordPress 4.6 it seems endpoi... |
212,132 | <p>I have several posts that share the same layout but have different title and content.</p>
<p>This layout is different from that on the site.</p>
<p>I can use single.php to render them, but then ALL posts will have this layout.</p>
<p>If I add some category for this posts, could I render all post in this category ... | [
{
"answer_id": 212135,
"author": "Craig",
"author_id": 85474,
"author_profile": "https://wordpress.stackexchange.com/users/85474",
"pm_score": 1,
"selected": false,
"text": "<p>The category templates are just for post archives listing you would need to do this within the single.php templ... | 2015/12/17 | [
"https://wordpress.stackexchange.com/questions/212132",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85230/"
] | I have several posts that share the same layout but have different title and content.
This layout is different from that on the site.
I can use single.php to render them, but then ALL posts will have this layout.
If I add some category for this posts, could I render all post in this category in the same way?
I trie... | I believe you are talking about single post pages. The template hierarchy does not make provision for single templates according to the category a post belongs to, so `single-{$category}.php` does not exist.
To make `single-{$category}.php` work, we can make use of the `single_template` filter
```
add_filter( 'singl... |
212,143 | <p>I use the following link to delete a post in the frontend of wordpress: </p>
<pre><code><a href="<?php echo get_delete_post_link( $post->ID ) ?>">Delete Post</a>
</code></pre>
<p>This works fine. But after i delete the post its just showing a blank page of the index.php. I want to redirect the... | [
{
"answer_id": 212135,
"author": "Craig",
"author_id": 85474,
"author_profile": "https://wordpress.stackexchange.com/users/85474",
"pm_score": 1,
"selected": false,
"text": "<p>The category templates are just for post archives listing you would need to do this within the single.php templ... | 2015/12/17 | [
"https://wordpress.stackexchange.com/questions/212143",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/81609/"
] | I use the following link to delete a post in the frontend of wordpress:
```
<a href="<?php echo get_delete_post_link( $post->ID ) ?>">Delete Post</a>
```
This works fine. But after i delete the post its just showing a blank page of the index.php. I want to redirect the author who deletetd the post to a category sit... | I believe you are talking about single post pages. The template hierarchy does not make provision for single templates according to the category a post belongs to, so `single-{$category}.php` does not exist.
To make `single-{$category}.php` work, we can make use of the `single_template` filter
```
add_filter( 'singl... |
212,152 | <p>I am using Wordpress with Advanced Custom Fields. I have a custom post called "event" with a custom field "date" (I have added the field through ACF). The date field is formatted in the following way: "yyyy-mm-dd." Until now, sorting the custom posts worked fine using the following snippet:</p>
<pre><code>$query = ... | [
{
"answer_id": 212135,
"author": "Craig",
"author_id": 85474,
"author_profile": "https://wordpress.stackexchange.com/users/85474",
"pm_score": 1,
"selected": false,
"text": "<p>The category templates are just for post archives listing you would need to do this within the single.php templ... | 2015/12/17 | [
"https://wordpress.stackexchange.com/questions/212152",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67305/"
] | I am using Wordpress with Advanced Custom Fields. I have a custom post called "event" with a custom field "date" (I have added the field through ACF). The date field is formatted in the following way: "yyyy-mm-dd." Until now, sorting the custom posts worked fine using the following snippet:
```
$query = new WP_Query([... | I believe you are talking about single post pages. The template hierarchy does not make provision for single templates according to the category a post belongs to, so `single-{$category}.php` does not exist.
To make `single-{$category}.php` work, we can make use of the `single_template` filter
```
add_filter( 'singl... |
212,155 | <p>I have a form on wordpress page with a <code>POST</code> method.
I need to add an extra field to the form after submission but before it is sent to the URL in the action attribute. </p>
<p>I was thinking to use an actin hook, not sure which one would be the best for this case? or if it's the correct tool in the fi... | [
{
"answer_id": 212162,
"author": "N00b",
"author_id": 80903,
"author_profile": "https://wordpress.stackexchange.com/users/80903",
"pm_score": 3,
"selected": true,
"text": "<p>Im not entirely sure there is such action hook for custom forms (someone else might know) but there are definatel... | 2015/12/17 | [
"https://wordpress.stackexchange.com/questions/212155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64116/"
] | I have a form on wordpress page with a `POST` method.
I need to add an extra field to the form after submission but before it is sent to the URL in the action attribute.
I was thinking to use an actin hook, not sure which one would be the best for this case? or if it's the correct tool in the first place?
Thank you
... | Im not entirely sure there is such action hook for custom forms (someone else might know) but there are definately other ways if form is submitted *normally*, without ajax.
Let me know if you have any questions.
```
//This applies if you want it to happen only if form is submited and page refreshed
//It doesn't work ... |
212,190 | <p>Im storing using add_user_meta custom values that get sent to the front page of the website. Here is the php code.</p>
<pre><code>$user_query = new WP_User_Query( array(
'fields' => 'ID'
) );
$user_ids = $user_query->get_results();
foreach( $user_object->_custom_link as $user_id ) {... | [
{
"answer_id": 212201,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 1,
"selected": false,
"text": "<p>Here is an example of getting the user IDs, looping through each, grabbing a meta_key as an array, adding new ... | 2015/12/17 | [
"https://wordpress.stackexchange.com/questions/212190",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65437/"
] | Im storing using add\_user\_meta custom values that get sent to the front page of the website. Here is the php code.
```
$user_query = new WP_User_Query( array(
'fields' => 'ID'
) );
$user_ids = $user_query->get_results();
foreach( $user_object->_custom_link as $user_id ) {
$user_object... | Here is an example of getting the user IDs, looping through each, grabbing a meta\_key as an array, adding new values to it and remove old values, saving the meta back, then grabbing it again to loop through each item in the array for output. Array is just an example of duplicate keys.
```
$user_query = new WP_User_Qu... |
212,202 | <p>We have a custom plugin we have created for a customer, it simply configures a custom post type.</p>
<p>They upgraded to wp 4.4 today. Now that custom post type is the only one that you cannot add a new post for.I can edit a custom post with out issue and I can add the standard posts and other custom post types cr... | [
{
"answer_id": 212201,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 1,
"selected": false,
"text": "<p>Here is an example of getting the user IDs, looping through each, grabbing a meta_key as an array, adding new ... | 2015/12/17 | [
"https://wordpress.stackexchange.com/questions/212202",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85501/"
] | We have a custom plugin we have created for a customer, it simply configures a custom post type.
They upgraded to wp 4.4 today. Now that custom post type is the only one that you cannot add a new post for.I can edit a custom post with out issue and I can add the standard posts and other custom post types created with ... | Here is an example of getting the user IDs, looping through each, grabbing a meta\_key as an array, adding new values to it and remove old values, saving the meta back, then grabbing it again to loop through each item in the array for output. Array is just an example of duplicate keys.
```
$user_query = new WP_User_Qu... |
212,203 | <p>I used to have my website hosted through Godaddy and 4 months ago something weird started happening. Every time that I would make changes to my site, it wouldn't show up on the live website. The only exception was the homepage. Every change on the homepage would show up on the live website.</p>
<p>I did what everyo... | [
{
"answer_id": 212201,
"author": "jgraup",
"author_id": 84219,
"author_profile": "https://wordpress.stackexchange.com/users/84219",
"pm_score": 1,
"selected": false,
"text": "<p>Here is an example of getting the user IDs, looping through each, grabbing a meta_key as an array, adding new ... | 2015/12/17 | [
"https://wordpress.stackexchange.com/questions/212203",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85502/"
] | I used to have my website hosted through Godaddy and 4 months ago something weird started happening. Every time that I would make changes to my site, it wouldn't show up on the live website. The only exception was the homepage. Every change on the homepage would show up on the live website.
I did what everyone then to... | Here is an example of getting the user IDs, looping through each, grabbing a meta\_key as an array, adding new values to it and remove old values, saving the meta back, then grabbing it again to loop through each item in the array for output. Array is just an example of duplicate keys.
```
$user_query = new WP_User_Qu... |
212,239 | <p>I'm hosting a WP site on a VPN so I'm doing all of the server management. A while back, I simply renamed my WP folder so that it would be inaccessible. Now I need it to be accessible again and so I renamed it to what it was before. For some reason the site is now extremely slow. As you can see in this screenshot, th... | [
{
"answer_id": 212739,
"author": "winters",
"author_id": 85752,
"author_profile": "https://wordpress.stackexchange.com/users/85752",
"pm_score": 0,
"selected": false,
"text": "<p>This may be a stretch but I've had a similar problem in the past, for me it was connected to caching. I would... | 2015/12/18 | [
"https://wordpress.stackexchange.com/questions/212239",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85514/"
] | I'm hosting a WP site on a VPN so I'm doing all of the server management. A while back, I simply renamed my WP folder so that it would be inaccessible. Now I need it to be accessible again and so I renamed it to what it was before. For some reason the site is now extremely slow. As you can see in this screenshot, the s... | The problem is the amount of processes that your site has to carry out before being able to deliver the content, in this particular case to generate the HTML code and be able to dispatch it.
It is a fairly common problem among predesigned plugins and templates, even if they are paid they have this problem ... together... |