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 |
|---|---|---|---|---|---|---|
181,541 | <p>I have been researching on Google and WPSE and the only thing I see repeatedly is to use <code>showposts</code>, that is deprecated.</p>
<p>I am familiar with <code>WP_Query</code>, and I thought that if I set <code>posts_per_page</code> to my limit (ie. 5), and <code>nopaging</code> to <code>true</code>, it would ... | [
{
"answer_id": 181543,
"author": "shuvroMithun",
"author_id": 65928,
"author_profile": "https://wordpress.stackexchange.com/users/65928",
"pm_score": 3,
"selected": false,
"text": "<p>Ok , lets you have post type called 'blog_posts' , and you want to fetch 5 posts of that post type . H... | 2015/03/18 | [
"https://wordpress.stackexchange.com/questions/181541",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40743/"
] | I have been researching on Google and WPSE and the only thing I see repeatedly is to use `showposts`, that is deprecated.
I am familiar with `WP_Query`, and I thought that if I set `posts_per_page` to my limit (ie. 5), and `nopaging` to `true`, it would become to something like "*Ok, I'll give you only 5 posts*". But ... | I think that now I understand what you are trying to do. When you run a custom query with `WP_Query` and set the limit to get only 5 posts per page, only 5 posts will be retrieved by the query and that query will only hold 5 posts, **BUT** for the sake of pagination, `WP_Query` still runs through the whole database and... |
181,545 | <p>Is it possible to change the value of a custom field after X number of seconds has passed since it was modified?</p>
<p>For example, I have a checkbox that a user can check to say whether or not they are available. By default the box is unchecked and what I want to do is, 7200 seconds (2 hours) after a user has che... | [
{
"answer_id": 181555,
"author": "jimihenrik",
"author_id": 64625,
"author_profile": "https://wordpress.stackexchange.com/users/64625",
"pm_score": 0,
"selected": false,
"text": "<p>Is this like an option you have saved to the database?\nIf so you could use <a href=\"http://codex.wordpre... | 2015/03/18 | [
"https://wordpress.stackexchange.com/questions/181545",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19319/"
] | Is it possible to change the value of a custom field after X number of seconds has passed since it was modified?
For example, I have a checkbox that a user can check to say whether or not they are available. By default the box is unchecked and what I want to do is, 7200 seconds (2 hours) after a user has checked the b... | You'll need two meta fields: the 'available' field, and a 'lastchecked' field that contains a Unix timestamp for when the box was checked.
Then, you can use wp\_cron (assuming your site has enough traffic; but most sites will get at least one visit an hour; if not, you can always set up a regular cron to visit your si... |
181,580 | <p>Is this enough to change the user ID? I'm doing this for security purposes, where the administrator has user ID=1 and I want to keep all posts, pages and content.</p>
<pre><code>UPDATE wp_posts SET post_author='1000' WHERE post_author='1';
UPDATE wp_users SET ID = '1000' WHERE ID = '1';
UPDATE wp_usermeta SET user_... | [
{
"answer_id": 181586,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>It should work but it doesn't add even the tiniest security to the site (if the bad guy has enough permis... | 2015/03/18 | [
"https://wordpress.stackexchange.com/questions/181580",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7349/"
] | Is this enough to change the user ID? I'm doing this for security purposes, where the administrator has user ID=1 and I want to keep all posts, pages and content.
```
UPDATE wp_posts SET post_author='1000' WHERE post_author='1';
UPDATE wp_users SET ID = '1000' WHERE ID = '1';
UPDATE wp_usermeta SET user_id = '1000' WH... | Why not make a new account for this user which will generate a new database ID. Then delete the user with the ID of 1 and attribute all posts / content to the new user you created for them? Then you don't have to worry about queries or messing up your database. Also, as said before this makes absolutely no sense from a... |
181,606 | <p>I've created my template and installed extensions everything worked fine.
I work on localhost and then upload to my server and use searchreplacedb2.php to change the root url as usually.</p>
<p>But now, I can login and then access wp-admin in localhost, but on my server I can login (correctly and have the admin bar... | [
{
"answer_id": 181646,
"author": "tao",
"author_id": 45169,
"author_profile": "https://wordpress.stackexchange.com/users/45169",
"pm_score": 0,
"selected": false,
"text": "<p>WP 4.1.1 seems to need a lot more memory than previous versions. Just add </p>\n\n<p><code>define('WP_MEMORY_LIMI... | 2015/03/18 | [
"https://wordpress.stackexchange.com/questions/181606",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67808/"
] | I've created my template and installed extensions everything worked fine.
I work on localhost and then upload to my server and use searchreplacedb2.php to change the root url as usually.
But now, I can login and then access wp-admin in localhost, but on my server I can login (correctly and have the admin bar on top of... | WP 4.1.1 seems to need a lot more memory than previous versions. Just add
`define('WP_MEMORY_LIMIT', '256M');`
in your `wp-config.php` file just before the `/* Stop editing */` comment line and you should get rid of the blank screens. If you can't access that much memory, go for less, but from my tests the minimum r... |
181,619 | <p>I'm calling images with a wordpress loop to display in a flexslider on the home page.</p>
<p>However, the active class for the thumbnails of the slider aren't working in tandem with the slideshow -- I can't click on thumbnails to view the corresponding larger slideshow image. Instead when I click on the thumbnails ... | [
{
"answer_id": 181646,
"author": "tao",
"author_id": 45169,
"author_profile": "https://wordpress.stackexchange.com/users/45169",
"pm_score": 0,
"selected": false,
"text": "<p>WP 4.1.1 seems to need a lot more memory than previous versions. Just add </p>\n\n<p><code>define('WP_MEMORY_LIMI... | 2015/03/19 | [
"https://wordpress.stackexchange.com/questions/181619",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54520/"
] | I'm calling images with a wordpress loop to display in a flexslider on the home page.
However, the active class for the thumbnails of the slider aren't working in tandem with the slideshow -- I can't click on thumbnails to view the corresponding larger slideshow image. Instead when I click on the thumbnails all the im... | WP 4.1.1 seems to need a lot more memory than previous versions. Just add
`define('WP_MEMORY_LIMIT', '256M');`
in your `wp-config.php` file just before the `/* Stop editing */` comment line and you should get rid of the blank screens. If you can't access that much memory, go for less, but from my tests the minimum r... |
181,620 | <p>I have one meta key "game" containing this meta value "game 1, game 2".</p>
<p>I would like to display this meta value on my site like this:</p>
<pre><code><a href="http://www.url.com/game-1">game 1</a>
<a href="http://www.url.com/game-2">game 2</a>
</code></pre>
<p>Thanks for your help.</... | [
{
"answer_id": 181646,
"author": "tao",
"author_id": 45169,
"author_profile": "https://wordpress.stackexchange.com/users/45169",
"pm_score": 0,
"selected": false,
"text": "<p>WP 4.1.1 seems to need a lot more memory than previous versions. Just add </p>\n\n<p><code>define('WP_MEMORY_LIMI... | 2015/03/19 | [
"https://wordpress.stackexchange.com/questions/181620",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66753/"
] | I have one meta key "game" containing this meta value "game 1, game 2".
I would like to display this meta value on my site like this:
```
<a href="http://www.url.com/game-1">game 1</a>
<a href="http://www.url.com/game-2">game 2</a>
```
Thanks for your help. | WP 4.1.1 seems to need a lot more memory than previous versions. Just add
`define('WP_MEMORY_LIMIT', '256M');`
in your `wp-config.php` file just before the `/* Stop editing */` comment line and you should get rid of the blank screens. If you can't access that much memory, go for less, but from my tests the minimum r... |
181,624 | <p>Is it a good idea to harden your web server by disabling outbound connectivity on them?</p>
<p>I am using RHEL 7 for a WordPress Multisite installation.</p>
<p>After disabling outbound connectivity, the dashboard has become extremely slow, and the plugins page does not list the latest available ones.</p>
<p>Could... | [
{
"answer_id": 181646,
"author": "tao",
"author_id": 45169,
"author_profile": "https://wordpress.stackexchange.com/users/45169",
"pm_score": 0,
"selected": false,
"text": "<p>WP 4.1.1 seems to need a lot more memory than previous versions. Just add </p>\n\n<p><code>define('WP_MEMORY_LIMI... | 2015/03/19 | [
"https://wordpress.stackexchange.com/questions/181624",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5852/"
] | Is it a good idea to harden your web server by disabling outbound connectivity on them?
I am using RHEL 7 for a WordPress Multisite installation.
After disabling outbound connectivity, the dashboard has become extremely slow, and the plugins page does not list the latest available ones.
Could I still live with this?... | WP 4.1.1 seems to need a lot more memory than previous versions. Just add
`define('WP_MEMORY_LIMIT', '256M');`
in your `wp-config.php` file just before the `/* Stop editing */` comment line and you should get rid of the blank screens. If you can't access that much memory, go for less, but from my tests the minimum r... |
181,630 | <p>So I have the following code:</p>
<pre><code> <h3>
<div class="sellertitle"><a class="allseller" href="#">Something</a> </div>
<?php if ( is_user_logged_in() ) { ?>
<div class="otherseller"> <a class="allo... | [
{
"answer_id": 181632,
"author": "Reigel Gallarde",
"author_id": 974,
"author_profile": "https://wordpress.stackexchange.com/users/974",
"pm_score": 2,
"selected": false,
"text": "<p>you could try something like this... this will add css on the head</p>\n\n<pre><code>add_action('wp_head'... | 2015/03/19 | [
"https://wordpress.stackexchange.com/questions/181630",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67604/"
] | So I have the following code:
```
<h3>
<div class="sellertitle"><a class="allseller" href="#">Something</a> </div>
<?php if ( is_user_logged_in() ) { ?>
<div class="otherseller"> <a class="allotherseller" href="#">Else</a> </div>
<?php } ?... | Here is another CSS-only approach, without any inline-PHP and needless CSS-spam in the head.
If your theme is correctly using [body\_class()](http://codex.wordpress.org/Function_Reference/body_class) and a user is logged in, Wordpress adds a class "logged-in" to the body-element, so we can use this in our stylesheet:
... |
181,653 | <p>So, I have the following shortcode which is included in two different pages.</p>
<pre><code><?php echo do_shortcode('[shortcode]'); ?>
</code></pre>
<p>Since two pages are using one identical shortocode, I am thinking of adding a class to the first page so that I can customize the first page shortcode only.<... | [
{
"answer_id": 181632,
"author": "Reigel Gallarde",
"author_id": 974,
"author_profile": "https://wordpress.stackexchange.com/users/974",
"pm_score": 2,
"selected": false,
"text": "<p>you could try something like this... this will add css on the head</p>\n\n<pre><code>add_action('wp_head'... | 2015/03/19 | [
"https://wordpress.stackexchange.com/questions/181653",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67604/"
] | So, I have the following shortcode which is included in two different pages.
```
<?php echo do_shortcode('[shortcode]'); ?>
```
Since two pages are using one identical shortocode, I am thinking of adding a class to the first page so that I can customize the first page shortcode only.
So here is my question.
1. Do ... | Here is another CSS-only approach, without any inline-PHP and needless CSS-spam in the head.
If your theme is correctly using [body\_class()](http://codex.wordpress.org/Function_Reference/body_class) and a user is logged in, Wordpress adds a class "logged-in" to the body-element, so we can use this in our stylesheet:
... |
181,688 | <p>I'm creating a custom plugin. One of the fields in the plugin let's the user add data.<br>
If I add a <code>textarea</code> the user has no control over the text. So I would like to add a editor.<br> I know WordPress offers the <code>wp_editor();</code> function.<br>After some Google-ing I found that it is very easy... | [
{
"answer_id": 181753,
"author": "Interactive",
"author_id": 52240,
"author_profile": "https://wordpress.stackexchange.com/users/52240",
"pm_score": 4,
"selected": true,
"text": "<p>Solved it!</p>\n\n<p>Hope somebody else can use it or it answers their problem. If there is a better way p... | 2015/03/19 | [
"https://wordpress.stackexchange.com/questions/181688",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52240/"
] | I'm creating a custom plugin. One of the fields in the plugin let's the user add data.
If I add a `textarea` the user has no control over the text. So I would like to add a editor.
I know WordPress offers the `wp_editor();` function.
After some Google-ing I found that it is very easy to implement the editor.:
... | Solved it!
Hope somebody else can use it or it answers their problem. If there is a better way please share and tell why.
```
$editor_id = 'custom_editor_box';
$uploaded_csv = get_post_meta( $post->ID, 'custom_editor_box', true);
wp_editor( $uploaded_csv, $editor_id );
```
To save the data:
```
function save_wp_ed... |
181,706 | <p>Is it possible to add a class to links created with the link button in the posts editor of wordpress. If not is there a plugin that allow me to do that?
Thanks in advance</p>
| [
{
"answer_id": 181753,
"author": "Interactive",
"author_id": 52240,
"author_profile": "https://wordpress.stackexchange.com/users/52240",
"pm_score": 4,
"selected": true,
"text": "<p>Solved it!</p>\n\n<p>Hope somebody else can use it or it answers their problem. If there is a better way p... | 2015/03/19 | [
"https://wordpress.stackexchange.com/questions/181706",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69318/"
] | Is it possible to add a class to links created with the link button in the posts editor of wordpress. If not is there a plugin that allow me to do that?
Thanks in advance | Solved it!
Hope somebody else can use it or it answers their problem. If there is a better way please share and tell why.
```
$editor_id = 'custom_editor_box';
$uploaded_csv = get_post_meta( $post->ID, 'custom_editor_box', true);
wp_editor( $uploaded_csv, $editor_id );
```
To save the data:
```
function save_wp_ed... |
181,715 | <p>I'm running into a catch-22 situation running a request filter. I need the request to be correct in order to run the correct filter, but I need the filter to correct the request. GAH!</p>
<p>Here is the code:</p>
<pre><code>function cpt_parse_taxonomy_string( $request, $cpt, $ctax ){
if( array_key_exists( $cta... | [
{
"answer_id": 181753,
"author": "Interactive",
"author_id": 52240,
"author_profile": "https://wordpress.stackexchange.com/users/52240",
"pm_score": 4,
"selected": true,
"text": "<p>Solved it!</p>\n\n<p>Hope somebody else can use it or it answers their problem. If there is a better way p... | 2015/03/19 | [
"https://wordpress.stackexchange.com/questions/181715",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68905/"
] | I'm running into a catch-22 situation running a request filter. I need the request to be correct in order to run the correct filter, but I need the filter to correct the request. GAH!
Here is the code:
```
function cpt_parse_taxonomy_string( $request, $cpt, $ctax ){
if( array_key_exists( $ctax , $request )
... | Solved it!
Hope somebody else can use it or it answers their problem. If there is a better way please share and tell why.
```
$editor_id = 'custom_editor_box';
$uploaded_csv = get_post_meta( $post->ID, 'custom_editor_box', true);
wp_editor( $uploaded_csv, $editor_id );
```
To save the data:
```
function save_wp_ed... |
181,729 | <p>I have strong passwords enforced for all my clients but I got some complaints recently as some users tried to change their password and gave up trying to achieve a strong rating. I was initially dismissive until I tried it out. I spend some time trying to write a strong password using these resources:</p>
<p><a hre... | [
{
"answer_id": 181753,
"author": "Interactive",
"author_id": 52240,
"author_profile": "https://wordpress.stackexchange.com/users/52240",
"pm_score": 4,
"selected": true,
"text": "<p>Solved it!</p>\n\n<p>Hope somebody else can use it or it answers their problem. If there is a better way p... | 2015/03/20 | [
"https://wordpress.stackexchange.com/questions/181729",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6169/"
] | I have strong passwords enforced for all my clients but I got some complaints recently as some users tried to change their password and gave up trying to achieve a strong rating. I was initially dismissive until I tried it out. I spend some time trying to write a strong password using these resources:
<http://wpengine... | Solved it!
Hope somebody else can use it or it answers their problem. If there is a better way please share and tell why.
```
$editor_id = 'custom_editor_box';
$uploaded_csv = get_post_meta( $post->ID, 'custom_editor_box', true);
wp_editor( $uploaded_csv, $editor_id );
```
To save the data:
```
function save_wp_ed... |
181,795 | <p>So here is my button shortcode in my widget.</p>
<pre><code> [button title="EDIT" href="<?php ech edit_product_url( $post->ID ); ?>"]
</code></pre>
<p>As you can guess the href url does not work.</p>
<p>What would be the best way to add php in the shortcode?</p>
<p>Thanks</p>
| [
{
"answer_id": 181798,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 4,
"selected": true,
"text": "<p>To be honest, if you see yourself in the need of adding executable PHP code into a shortcode attribute, or in ... | 2015/03/20 | [
"https://wordpress.stackexchange.com/questions/181795",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67604/"
] | So here is my button shortcode in my widget.
```
[button title="EDIT" href="<?php ech edit_product_url( $post->ID ); ?>"]
```
As you can guess the href url does not work.
What would be the best way to add php in the shortcode?
Thanks | To be honest, if you see yourself in the need of adding executable PHP code into a shortcode attribute, or in content editor in general, you are doing something wrong. You should think again about what, why and how do it. There is a high security risk accepting executable PHP code form user inputs.
Instead, you should... |
181,806 | <p>I've made some custom post types, and some user roles. Each role has access to different custom post types.</p>
<p>The thing is that edit_others_customposttypecapability, isn't working.
I've tried logging in with the admin account, and it can't edit other's published custom post types.</p>
<p>I've installed User R... | [
{
"answer_id": 181953,
"author": "Laurence Stanley",
"author_id": 67816,
"author_profile": "https://wordpress.stackexchange.com/users/67816",
"pm_score": 0,
"selected": false,
"text": "<p>Is your problem occurring in a multisite setup? If so, here is a solution:</p>\n\n<p><a href=\"http:... | 2015/03/20 | [
"https://wordpress.stackexchange.com/questions/181806",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60311/"
] | I've made some custom post types, and some user roles. Each role has access to different custom post types.
The thing is that edit\_others\_customposttypecapability, isn't working.
I've tried logging in with the admin account, and it can't edit other's published custom post types.
I've installed User Role Editor plug... | Found it!
I was missing one custom capability. To the code above, I added this line:
```
$rol->add_cap( 'edit_' . $cap[0] );
```
It gives the capability edit\_ctpsinglename. (edit\_pb\_publicacion).
And now it works just fine.
Hope someone find's this useful. |
181,813 | <p>I have this <a href="https://picasaweb.google.com/data/feed/base/user/110981376645512804522/albumid/5638371435917293985?alt=rss&kind=photo&hl=en_US" rel="noreferrer">feed</a> from <a href="https://picasaweb.google.com/110981376645512804522/DropBox" rel="noreferrer">picasa</a> (correct but arbitrary, desired ... | [
{
"answer_id": 181954,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": false,
"text": "<p>I think you simply have to replace:</p>\n\n<pre><code>$feed->enable_order_by_date(false);\n</code></pre>\n... | 2015/03/20 | [
"https://wordpress.stackexchange.com/questions/181813",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28069/"
] | I have this [feed](https://picasaweb.google.com/data/feed/base/user/110981376645512804522/albumid/5638371435917293985?alt=rss&kind=photo&hl=en_US) from [picasa](https://picasaweb.google.com/110981376645512804522/DropBox) (correct but arbitrary, desired order).
The result is [messed up](http://jig.openelements.com/?pag... | At the end of `class-simplepie.php` there is this line:
```
usort($items, array(get_class($urls[0]), 'sort_items'));
```
Which force-sorts feed elements, in case of **multifeed**.
The `$feed->enable_order_by_date(false);` is indeed very important and the key to things, BUT it gets disregarded (what I was experienci... |
181,841 | <p>Unlike most of the spammer/spambot plugins out there, which stop registrations from a known list of spam IPs and email domains, I need to stop malicious users who may try and register more than one account from the same ip address. Their intentions may be to either harass people in the comments once they've been ban... | [
{
"answer_id": 181848,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 3,
"selected": true,
"text": "<p>Despite that this approach may be flawed by the fact that it can be by-passed using proxies, here is a simplistic... | 2015/03/21 | [
"https://wordpress.stackexchange.com/questions/181841",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65738/"
] | Unlike most of the spammer/spambot plugins out there, which stop registrations from a known list of spam IPs and email domains, I need to stop malicious users who may try and register more than one account from the same ip address. Their intentions may be to either harass people in the comments once they've been banned... | Despite that this approach may be flawed by the fact that it can be by-passed using proxies, here is a simplistic (yet untested) approach, which **you would need to improve upon** but would give you the foundation for achieving your desired goal.
The process as I see it:
* filter user registerations on the `pre_user_... |
181,868 | <p>I got a custom field and I want to toggle a specific custom field. So for example I have 2 custom fields named: Subject and Score. When viewing a single post the custom field 'Score' data is hidden until a user clicks on the button to see the data. How can I do this toggle effect?</p>
| [
{
"answer_id": 181871,
"author": "jimihenrik",
"author_id": 64625,
"author_profile": "https://wordpress.stackexchange.com/users/64625",
"pm_score": 3,
"selected": true,
"text": "<p>You could do this with jquery.</p>\n\n<p>I have a similar code on use which you could probably easily edit ... | 2015/03/21 | [
"https://wordpress.stackexchange.com/questions/181868",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17971/"
] | I got a custom field and I want to toggle a specific custom field. So for example I have 2 custom fields named: Subject and Score. When viewing a single post the custom field 'Score' data is hidden until a user clicks on the button to see the data. How can I do this toggle effect? | You could do this with jquery.
I have a similar code on use which you could probably easily edit to your needs:
load the admin js (I load css too but you can remove that)
```
function wpse181868_admin_css_js() {
wp_register_style( 'bones_admin_css', get_template_directory_uri() . '/library/css/admin.css', false ... |
181,877 | <p>I would like to know if there is a simple way (custom code or plugin) to create thumbnail sizes <strong>only for</strong> images that I intend to use as <strong>featured images</strong> (index.php, archive.php, etc.) , but not for the images used in the posts (single.php). My main goal is reduce server space usage b... | [
{
"answer_id": 181886,
"author": "Jakir Hossain",
"author_id": 68472,
"author_profile": "https://wordpress.stackexchange.com/users/68472",
"pm_score": 0,
"selected": false,
"text": "<p>You can see this <a href=\"https://codex.wordpress.org/Function_Reference/add_image_size\" rel=\"nofoll... | 2015/03/21 | [
"https://wordpress.stackexchange.com/questions/181877",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69406/"
] | I would like to know if there is a simple way (custom code or plugin) to create thumbnail sizes **only for** images that I intend to use as **featured images** (index.php, archive.php, etc.) , but not for the images used in the posts (single.php). My main goal is reduce server space usage by not creating thumbnails tha... | This function will generate an image by temporarily registering an image size, generating the image (if necessary) and the removing the size so new images will not be created in that size.
```
function lazy_image_size($image_id, $width, $height, $crop) {
// Temporarily create an image size
$size_id = 'lazy_' .... |
181,900 | <p>I have a custom post type for a group of people (employees). At first, I needed to display 7 random employees. That was easy</p>
<pre><code><?php
$args = array(
'post_type' => 'employees',
'orderby' => 'rand',
'posts_per_page' => 7,
);
$query = new WP_Query($args);
... | [
{
"answer_id": 181886,
"author": "Jakir Hossain",
"author_id": 68472,
"author_profile": "https://wordpress.stackexchange.com/users/68472",
"pm_score": 0,
"selected": false,
"text": "<p>You can see this <a href=\"https://codex.wordpress.org/Function_Reference/add_image_size\" rel=\"nofoll... | 2015/03/22 | [
"https://wordpress.stackexchange.com/questions/181900",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69417/"
] | I have a custom post type for a group of people (employees). At first, I needed to display 7 random employees. That was easy
```
<?php
$args = array(
'post_type' => 'employees',
'orderby' => 'rand',
'posts_per_page' => 7,
);
$query = new WP_Query($args);
while ( $query->have_po... | This function will generate an image by temporarily registering an image size, generating the image (if necessary) and the removing the size so new images will not be created in that size.
```
function lazy_image_size($image_id, $width, $height, $crop) {
// Temporarily create an image size
$size_id = 'lazy_' .... |
181,907 | <p>I want to add a field in my custom meta box, same as below, but not for tags. How can I repeatedly take more inputs in the same field? </p>
<p><img src="https://i.stack.imgur.com/CJj3W.png" alt="enter image description here"></p>
<p>Here is my code added to functions.php:</p>
<pre><code>function dikka_cmb_meoxes... | [
{
"answer_id": 181886,
"author": "Jakir Hossain",
"author_id": 68472,
"author_profile": "https://wordpress.stackexchange.com/users/68472",
"pm_score": 0,
"selected": false,
"text": "<p>You can see this <a href=\"https://codex.wordpress.org/Function_Reference/add_image_size\" rel=\"nofoll... | 2015/03/22 | [
"https://wordpress.stackexchange.com/questions/181907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69421/"
] | I want to add a field in my custom meta box, same as below, but not for tags. How can I repeatedly take more inputs in the same field?

Here is my code added to functions.php:
```
function dikka_cmb_meoxes( array $meta_boxes ) {
$prefix = 'dikk... | This function will generate an image by temporarily registering an image size, generating the image (if necessary) and the removing the size so new images will not be created in that size.
```
function lazy_image_size($image_id, $width, $height, $crop) {
// Temporarily create an image size
$size_id = 'lazy_' .... |
181,921 | <p>I want to add text but only appear on the homepage only. I have used this if script:</p>
<pre><code><?php if( is_home() ) : ?>
<p>Some text</p>
<?php endif;?>
</code></pre>
<p>but the problem with this is it's appearing on every paginated page. So for example if I view <code>http://www.exam... | [
{
"answer_id": 181922,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>You can use <a href=\"https://codex.wordpress.org/Function_Reference/is_paged\" rel=\"nofollow\"><code>i... | 2015/03/22 | [
"https://wordpress.stackexchange.com/questions/181921",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17971/"
] | I want to add text but only appear on the homepage only. I have used this if script:
```
<?php if( is_home() ) : ?>
<p>Some text</p>
<?php endif;?>
```
but the problem with this is it's appearing on every paginated page. So for example if I view `http://www.example.com/page/2/` it will show that text. I only want it... | You can use [`is_paged()`](https://codex.wordpress.org/Function_Reference/is_paged)
>
> ...checks if page being displayed is "paged" and the current page number is greater than one. This is a boolean function, meaning it returns either TRUE or FALSE.
>
>
>
You can adjust your code as follows
```
<?php if( is_hom... |
181,930 | <p>I have this code. But when i enter in subcategory which has no own sub, it disappears.
I want if has no subs return parent's subs.</p>
<p>$category->category_parent and $category->parent aren't returning parent cat id.</p>
<pre><code><div style="margin: 0 0 20px 0;">
<?php $thisCat = get_categories(... | [
{
"answer_id": 181922,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>You can use <a href=\"https://codex.wordpress.org/Function_Reference/is_paged\" rel=\"nofollow\"><code>i... | 2015/03/22 | [
"https://wordpress.stackexchange.com/questions/181930",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69437/"
] | I have this code. But when i enter in subcategory which has no own sub, it disappears.
I want if has no subs return parent's subs.
$category->category\_parent and $category->parent aren't returning parent cat id.
```
<div style="margin: 0 0 20px 0;">
<?php $thisCat = get_categories(array('child_of'=>$_GET['cat'... | You can use [`is_paged()`](https://codex.wordpress.org/Function_Reference/is_paged)
>
> ...checks if page being displayed is "paged" and the current page number is greater than one. This is a boolean function, meaning it returns either TRUE or FALSE.
>
>
>
You can adjust your code as follows
```
<?php if( is_hom... |
181,934 | <p>I'm building a child theme and it currently has a very simple <code><head></code> section in header.php:</p>
<pre><code><head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title><?... | [
{
"answer_id": 181963,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>The two title tags can be explained as that you are using a theme that is written for Wordpress4.1 and a... | 2015/03/22 | [
"https://wordpress.stackexchange.com/questions/181934",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4109/"
] | I'm building a child theme and it currently has a very simple `<head>` section in header.php:
```
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="prof... | The two title tags can be explained as that you are using a theme that is written for Wordpress4.1 and actually is using 4.1. As from 4.1 you don't need to call [`wp_title()`](https://codex.wordpress.org/Function_Reference/wp_title) in the head any more, you can make use of new `title_tag` theme support tag which autom... |
181,966 | <p>I am querying for most popular posts by custom view count by using the custom query below,</p>
<pre><code><?php
$mostpopular_args=array(
'post_type' => 'post',
'orderby' => 'meta_value_num',
'meta_key' => 'view_count',
'posts_per_page' =&... | [
{
"answer_id": 181963,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>The two title tags can be explained as that you are using a theme that is written for Wordpress4.1 and a... | 2015/03/23 | [
"https://wordpress.stackexchange.com/questions/181966",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64811/"
] | I am querying for most popular posts by custom view count by using the custom query below,
```
<?php
$mostpopular_args=array(
'post_type' => 'post',
'orderby' => 'meta_value_num',
'meta_key' => 'view_count',
'posts_per_page' => 2,
);
<?php $mostpo... | The two title tags can be explained as that you are using a theme that is written for Wordpress4.1 and actually is using 4.1. As from 4.1 you don't need to call [`wp_title()`](https://codex.wordpress.org/Function_Reference/wp_title) in the head any more, you can make use of new `title_tag` theme support tag which autom... |
181,977 | <p>I have created a custom post type portfolio with custom taxonomy Portfolio Category. I can create portfolio items and assign portfolio categories to them and save these custom posts. But what I need is the permalink to show <code>domain.com/portfolio-category/portfolio-item-name</code>. Portfolio Category is variabl... | [
{
"answer_id": 181963,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>The two title tags can be explained as that you are using a theme that is written for Wordpress4.1 and a... | 2015/03/23 | [
"https://wordpress.stackexchange.com/questions/181977",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12260/"
] | I have created a custom post type portfolio with custom taxonomy Portfolio Category. I can create portfolio items and assign portfolio categories to them and save these custom posts. But what I need is the permalink to show `domain.com/portfolio-category/portfolio-item-name`. Portfolio Category is variable depending on... | The two title tags can be explained as that you are using a theme that is written for Wordpress4.1 and actually is using 4.1. As from 4.1 you don't need to call [`wp_title()`](https://codex.wordpress.org/Function_Reference/wp_title) in the head any more, you can make use of new `title_tag` theme support tag which autom... |
182,006 | <p>Similar questions have been asked before, but no answer suits well.</p>
<p>I have: <code>site.com/parent-page/child-page</code>
and would like to have: <code>site.com/child-page</code></p>
<p>So I want to exclusively have permalinks with depth 1, without using the custom menu but still "hierarchizing" my pages in ... | [
{
"answer_id": 181963,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>The two title tags can be explained as that you are using a theme that is written for Wordpress4.1 and a... | 2015/03/23 | [
"https://wordpress.stackexchange.com/questions/182006",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56789/"
] | Similar questions have been asked before, but no answer suits well.
I have: `site.com/parent-page/child-page`
and would like to have: `site.com/child-page`
So I want to exclusively have permalinks with depth 1, without using the custom menu but still "hierarchizing" my pages in the admin all pages view and with paren... | The two title tags can be explained as that you are using a theme that is written for Wordpress4.1 and actually is using 4.1. As from 4.1 you don't need to call [`wp_title()`](https://codex.wordpress.org/Function_Reference/wp_title) in the head any more, you can make use of new `title_tag` theme support tag which autom... |
182,015 | <p>My goal is to have the slug www.domain.com/resources used by a <strong>Page Template</strong> rather than an <strong>Archive Page</strong>, and have single CPT posts as children of that slug, such as <code>www.domain.com/resources/post</code>.</p>
<p>Solution I thought would work:</p>
<p>I created a new Page in Wo... | [
{
"answer_id": 221099,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 5,
"selected": true,
"text": "<p>Since WordPress version 4.4 the hook <a href=\"https://developer.wordpress.org/reference/hooks/theme_page_temp... | 2015/03/23 | [
"https://wordpress.stackexchange.com/questions/182015",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54137/"
] | My goal is to have the slug www.domain.com/resources used by a **Page Template** rather than an **Archive Page**, and have single CPT posts as children of that slug, such as `www.domain.com/resources/post`.
Solution I thought would work:
I created a new Page in Wordpress and gave it a custom page template. I'm also r... | Since WordPress version 4.4 the hook [`'theme_page_templates'`](https://developer.wordpress.org/reference/hooks/theme_page_templates/) allows to set arbitrary page templates.
It means that it's possible to show arbitrary values in the "Page Template" menu of the page edit screen, and when selected, the value will be s... |
182,017 | <p>I have one default page template that I wish to use for two scenarios. I'd prefer to use only one page template for the sake of simplicity for my client. </p>
<p>Here's what I'm trying to accomplish: </p>
<pre><code>if parent_page OR if child-page without children {
display full-width-layout
}
if child page with... | [
{
"answer_id": 182036,
"author": "bravokeyl",
"author_id": 43098,
"author_profile": "https://wordpress.stackexchange.com/users/43098",
"pm_score": 2,
"selected": false,
"text": "<pre><code>Level-0\n--Level-1\n----Level-2\n------Level-3\n----Levelanother-2\n--Levelanother-1\n</code></pre>... | 2015/03/23 | [
"https://wordpress.stackexchange.com/questions/182017",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51337/"
] | I have one default page template that I wish to use for two scenarios. I'd prefer to use only one page template for the sake of simplicity for my client.
Here's what I'm trying to accomplish:
```
if parent_page OR if child-page without children {
display full-width-layout
}
if child page with children or if grand... | Before reading the solution Bravokeyl provided I had finally, through trial and error, come up with a solution that worked for me. I'm not sure which is the better of the two, or the most correct, I only know that mine worked for me, for the problem I had.
This is the code I used to display full-width layout or sideb... |
182,025 | <p>I have a simple PHP script that I want to load whenever someone lands on a homepage. It is fetching data from another service and then I have to display it in a container on the homepage. </p>
<p>I was looking at options on how to enable PHP code in an HTML box that is provided by Wordpress. </p>
<p>I found severa... | [
{
"answer_id": 182026,
"author": "Gabriel",
"author_id": 54569,
"author_profile": "https://wordpress.stackexchange.com/users/54569",
"pm_score": 1,
"selected": false,
"text": "<p>The <a href=\"https://wordpress.org/plugins/php-code-widget/\" rel=\"nofollow\">PHP Code Widget</a> does not ... | 2015/03/23 | [
"https://wordpress.stackexchange.com/questions/182025",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69485/"
] | I have a simple PHP script that I want to load whenever someone lands on a homepage. It is fetching data from another service and then I have to display it in a container on the homepage.
I was looking at options on how to enable PHP code in an HTML box that is provided by Wordpress.
I found several plugins that cl... | As you have already understated, running executable PHP inside a text box is not a good idea. It isn't only just not a good idea, but a terrible idea. This creates a loop hole in your security which can be very easily exploited by a hacker.
I would suggest writing your own custom widget for this functionality. It is r... |
182,040 | <p>I have this code fragment in my codebase:</p>
<pre><code> foreach($this->adverisers as $adveriser) {
$this->data[$adveriser->name]['image'] = bfi_thumb(get_post_meta($adveriser->ID,
'ss_advertisers_cats_image', true ),
... | [
{
"answer_id": 182026,
"author": "Gabriel",
"author_id": 54569,
"author_profile": "https://wordpress.stackexchange.com/users/54569",
"pm_score": 1,
"selected": false,
"text": "<p>The <a href=\"https://wordpress.org/plugins/php-code-widget/\" rel=\"nofollow\">PHP Code Widget</a> does not ... | 2015/03/23 | [
"https://wordpress.stackexchange.com/questions/182040",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60985/"
] | I have this code fragment in my codebase:
```
foreach($this->adverisers as $adveriser) {
$this->data[$adveriser->name]['image'] = bfi_thumb(get_post_meta($adveriser->ID,
'ss_advertisers_cats_image', true ),
... | As you have already understated, running executable PHP inside a text box is not a good idea. It isn't only just not a good idea, but a terrible idea. This creates a loop hole in your security which can be very easily exploited by a hacker.
I would suggest writing your own custom widget for this functionality. It is r... |
182,045 | <p>I'm on centOS 7 and I have a WordPress site. Due to some problems with the WordPress default wp-cron settings, I have chosen to do the cron tasks with my server instead.
I have used this command:</p>
<pre class="lang-none prettyprint-override"><code>wget http://www.example.com/wp-cron.php?doing_wp_cron=1 > /dev... | [
{
"answer_id": 182046,
"author": "Gaia",
"author_id": 5090,
"author_profile": "https://wordpress.stackexchange.com/users/5090",
"pm_score": 3,
"selected": true,
"text": "<p>Do you have <strong><code>define('DISABLE_WP_CRON', true);</code></strong> set in wp-config? You need it to have t... | 2015/03/23 | [
"https://wordpress.stackexchange.com/questions/182045",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69539/"
] | I'm on centOS 7 and I have a WordPress site. Due to some problems with the WordPress default wp-cron settings, I have chosen to do the cron tasks with my server instead.
I have used this command:
```none
wget http://www.example.com/wp-cron.php?doing_wp_cron=1 > /dev/null 2>&1
```
to run every 10 minutes. This works... | Do you have **`define('DISABLE_WP_CRON', true);`** set in wp-config? You need it to have the system cron fire up the wp-cron tasks. Go to the bottom of the database settings in wp-config.php, typically around line 37, and **add it**.
**Then setup the system cron to fire up the wp-cron tasks**:
```
*/5 * * * * wget -q... |
182,075 | <p>I'm using WP 4.1.1 and trying to create a default value for the 'Alt text' when uploading an image (dropping it straight into post and dialog appears).</p>
<p>I've tried doing this with this hook <a href="https://codex.wordpress.org/Plugin_API/Filter_Reference/attachment_fields_to_edit" rel="nofollow">https://codex... | [
{
"answer_id": 241824,
"author": "vralle",
"author_id": 34691,
"author_profile": "https://wordpress.stackexchange.com/users/34691",
"pm_score": 2,
"selected": false,
"text": "<p>Ok, the answer will not be short</p>\n\n<p>At first, You can't change the alt attribute using <a href=\"https:... | 2015/03/24 | [
"https://wordpress.stackexchange.com/questions/182075",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51271/"
] | I'm using WP 4.1.1 and trying to create a default value for the 'Alt text' when uploading an image (dropping it straight into post and dialog appears).
I've tried doing this with this hook <https://codex.wordpress.org/Plugin_API/Filter_Reference/attachment_fields_to_edit>
and while I seem to be able to ADD a new fiel... | Ok, the answer will not be short
At first, You can't change the alt attribute using [attachment\_fields\_to\_edit](https://developer.wordpress.org/reference/hooks/attachment_fields_to_edit/), because you can't modify default fields. To see how this works can be in the source code of [get\_compat\_media\_markup](https:... |
182,106 | <p>I would like to insert a custom field into a shortcode and use it in post(s). I want the shortcode to be used with parameters. I tried to solve this problem but it displays the "Array" word instead of the value of the custom field:</p>
<pre><code>function get_my_custom_field( $atts ) {
global $post;
return ... | [
{
"answer_id": 182109,
"author": "matheuscl",
"author_id": 41008,
"author_profile": "https://wordpress.stackexchange.com/users/41008",
"pm_score": -1,
"selected": false,
"text": "<p>The <code>$atts</code> don't extract automatic, try this before call <code>global $post</code></p>\n\n<pre... | 2015/03/24 | [
"https://wordpress.stackexchange.com/questions/182106",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69533/"
] | I would like to insert a custom field into a shortcode and use it in post(s). I want the shortcode to be used with parameters. I tried to solve this problem but it displays the "Array" word instead of the value of the custom field:
```
function get_my_custom_field( $atts ) {
global $post;
return get_post_meta(... | As I already stated in comments, `extract()` should never be used. It was removed from core and the codex for very specific reasons and the use there of is strictly not recommended in future applications and functions. Please [see trac ticket #22400](https://core.trac.wordpress.org/ticket/22400) for complete details.
... |
182,112 | <p>I have the following rules in my .htaccess file on a WordPress (single installation):</p>
<pre><code># REWRITE FORUMS DOMAIN TO FOLDER
RewriteCond %{HTTP_HOST} ^forums\.example\.com$
RewriteRule !^forums/? forums%{REQUEST_URI} [NC,L]
# REWRITE FORUMS FOLDER TO SUBDOMAIN
RewriteCond %{THE_REQUEST} \s/forums/([^\s]*... | [
{
"answer_id": 182109,
"author": "matheuscl",
"author_id": 41008,
"author_profile": "https://wordpress.stackexchange.com/users/41008",
"pm_score": -1,
"selected": false,
"text": "<p>The <code>$atts</code> don't extract automatic, try this before call <code>global $post</code></p>\n\n<pre... | 2015/03/24 | [
"https://wordpress.stackexchange.com/questions/182112",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/881/"
] | I have the following rules in my .htaccess file on a WordPress (single installation):
```
# REWRITE FORUMS DOMAIN TO FOLDER
RewriteCond %{HTTP_HOST} ^forums\.example\.com$
RewriteRule !^forums/? forums%{REQUEST_URI} [NC,L]
# REWRITE FORUMS FOLDER TO SUBDOMAIN
RewriteCond %{THE_REQUEST} \s/forums/([^\s]*) [NC]
Rewrite... | As I already stated in comments, `extract()` should never be used. It was removed from core and the codex for very specific reasons and the use there of is strictly not recommended in future applications and functions. Please [see trac ticket #22400](https://core.trac.wordpress.org/ticket/22400) for complete details.
... |
182,116 | <p>How to list all the categories that have a certain word in title - first word of the category? in category.php</p>
<p>so, for example, if I am viewing the category "Green Apples Sells", it will list all the categories that start with the word "Green"</p>
<p>Update, added another check:
IF the category contains on... | [
{
"answer_id": 182117,
"author": "matheuscl",
"author_id": 41008,
"author_profile": "https://wordpress.stackexchange.com/users/41008",
"pm_score": 2,
"selected": false,
"text": "<p>You can try this code below</p>\n\n<pre><code>$args = array(\n 'orderby' => 'name', \n 'orde... | 2015/03/24 | [
"https://wordpress.stackexchange.com/questions/182116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6927/"
] | How to list all the categories that have a certain word in title - first word of the category? in category.php
so, for example, if I am viewing the category "Green Apples Sells", it will list all the categories that start with the word "Green"
Update, added another check:
IF the category contains one of these two wo... | You can try this code below
```
$args = array(
'orderby' => 'name',
'order' => 'ASC',
'name__like' => '%LIKE%',
'description__like' => '%LIKE%',
);
$terms = get_terms( array( "taxonomy" ), $args );
```
See more in [Codex](https://codex.wordpress.org/Function_Reference/get_term... |
182,119 | <p>please forgive me I'm relatively new to PHP...</p>
<p>I would like to create a shortcode called [city-name] and have tried placing the following code in my functions.php file:</p>
<pre><code>function get_city_name() {
return $current_cityinfo['cityname'];
}
add_shortcode( 'city-name', 'get_city_name' );
</code></p... | [
{
"answer_id": 182122,
"author": "Ciprian",
"author_id": 7349,
"author_profile": "https://wordpress.stackexchange.com/users/7349",
"pm_score": 1,
"selected": false,
"text": "<p>You need to get $current_cityinfo first. As in:</p>\n\n<pre><code>$current_cityinfo = get_option('current_cityi... | 2015/03/24 | [
"https://wordpress.stackexchange.com/questions/182119",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69538/"
] | please forgive me I'm relatively new to PHP...
I would like to create a shortcode called [city-name] and have tried placing the following code in my functions.php file:
```
function get_city_name() {
return $current_cityinfo['cityname'];
}
add_shortcode( 'city-name', 'get_city_name' );
```
Then entered the [city-na... | You need to get $current\_cityinfo first. As in:
```
$current_cityinfo = get_option('current_cityinfo');
```
Or add this code:
```
global $current_cityinfo;
```
above your `return` line. |
182,139 | <p>I'm trying to implement a simple script:</p>
<pre><code>jQuery(document).ready(function($){
$(window).scroll(function(){
if($(window).scrollTop() >= $('#masthead').outerHeight()) {
$("#masthead").addClass("minimize");
} else{
$("#masthead").removeClass("minimize");
}
});
});
</code></... | [
{
"answer_id": 182122,
"author": "Ciprian",
"author_id": 7349,
"author_profile": "https://wordpress.stackexchange.com/users/7349",
"pm_score": 1,
"selected": false,
"text": "<p>You need to get $current_cityinfo first. As in:</p>\n\n<pre><code>$current_cityinfo = get_option('current_cityi... | 2015/03/24 | [
"https://wordpress.stackexchange.com/questions/182139",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69239/"
] | I'm trying to implement a simple script:
```
jQuery(document).ready(function($){
$(window).scroll(function(){
if($(window).scrollTop() >= $('#masthead').outerHeight()) {
$("#masthead").addClass("minimize");
} else{
$("#masthead").removeClass("minimize");
}
});
});
```
It works perfectly w... | You need to get $current\_cityinfo first. As in:
```
$current_cityinfo = get_option('current_cityinfo');
```
Or add this code:
```
global $current_cityinfo;
```
above your `return` line. |
182,166 | <p>I am not sure what is wrong but the navigation a:hover has a image that when you hover over it shows. I am looking to see why there is a small space between the end of the image and slideshow. I am wanting to to butt right up to it where there is no gap.</p>
<p>See test board here </p>
<p><a href="http://www.wpcre... | [
{
"answer_id": 182168,
"author": "Sean Grant",
"author_id": 67105,
"author_profile": "https://wordpress.stackexchange.com/users/67105",
"pm_score": 2,
"selected": true,
"text": "<p>This isn't a WordPress issue, although it <em>IS</em> an easy CSS fix.</p>\n\n<p>The small space between th... | 2015/03/24 | [
"https://wordpress.stackexchange.com/questions/182166",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48825/"
] | I am not sure what is wrong but the navigation a:hover has a image that when you hover over it shows. I am looking to see why there is a small space between the end of the image and slideshow. I am wanting to to butt right up to it where there is no gap.
See test board here
<http://www.wpcreations.net/test/> | This isn't a WordPress issue, although it *IS* an easy CSS fix.
The small space between the end of image and the slideshow is axtually 2 pixels wide and caused by the `#left-area` div.
You can just up the width by 2 pixels on #left-area.
Like this:
```
#left-area {
width: 639px;
}
```
It is currently 637px.
Yo... |
182,167 | <p>This isn't the usual "How do I change the media upload folder?" question. Our entire site is run through a CDN. The CDN drops POST requests with a 5-6MB file so the WordPress uploads fail. I can work around this I think by changing where WordPress sends file upload requests. </p>
<p>If the normal site URL is www.ex... | [
{
"answer_id": 182170,
"author": "jimihenrik",
"author_id": 64625,
"author_profile": "https://wordpress.stackexchange.com/users/64625",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not quite sure what do you mean.</p>\n\n<p>You can change from where the WP loads the files if that's ... | 2015/03/24 | [
"https://wordpress.stackexchange.com/questions/182167",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2744/"
] | This isn't the usual "How do I change the media upload folder?" question. Our entire site is run through a CDN. The CDN drops POST requests with a 5-6MB file so the WordPress uploads fail. I can work around this I think by changing where WordPress sends file upload requests.
If the normal site URL is www.example.com,... | It was actually easier than I thought.
```
function route_uploads_past_cdn( $url, $path ) {
$upload_paths = array( 'async-upload.php', 'media-new.php' );
if( !in_array( $path, $upload_paths ) ) {
return $url;
}
return str_replace('www.', '', $url);
}
add_filter( 'admin_url', 'pew_route_upload... |
182,201 | <p>My Server configuration is:</p>
<ul>
<li>Nginx</li>
<li>php-fpm5</li>
</ul>
<p>I set up WordPress and it's working fine with custom permalink 'Day and name'. Now I want to set the rewrite rule in the nginx file and it's not working with a clean URL. If I set the permalinks to 'default' the rule works fine.</p>
<p... | [
{
"answer_id": 182243,
"author": "Vikram Mandaviya",
"author_id": 69606,
"author_profile": "https://wordpress.stackexchange.com/users/69606",
"pm_score": 1,
"selected": false,
"text": "<p>Use this plugin in wordpress and write rule which will overwrite nginx rule.</p>\n\n<p><a href=\"htt... | 2015/03/25 | [
"https://wordpress.stackexchange.com/questions/182201",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20843/"
] | My Server configuration is:
* Nginx
* php-fpm5
I set up WordPress and it's working fine with custom permalink 'Day and name'. Now I want to set the rewrite rule in the nginx file and it's not working with a clean URL. If I set the permalinks to 'default' the rule works fine.
Also I disable the default WordPress 301 ... | Use this plugin in wordpress and write rule which will overwrite nginx rule.
<https://wordpress.org/plugins/rewrite/>
When you have wordpress, you have to set permalink to default to work your webserver rule work and if you dont want to do that you have to install above plugin and write rule. |
182,223 | <p>I have customized my admin users column to show the purchased leads of a role "lead buyer". The value of the column is a decimal (the number of leads). </p>
<p>The "posts" column of the users table has a class "num" so the <code><th></code> and the <code><td></code> are styled with <code>text-align: cen... | [
{
"answer_id": 182907,
"author": "redelschaap",
"author_id": 69725,
"author_profile": "https://wordpress.stackexchange.com/users/69725",
"pm_score": 2,
"selected": false,
"text": "<p>This is not possible, since the output of your <code>gtp_users_table_content</code> function for the <cod... | 2015/03/25 | [
"https://wordpress.stackexchange.com/questions/182223",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25834/"
] | I have customized my admin users column to show the purchased leads of a role "lead buyer". The value of the column is a decimal (the number of leads).
The "posts" column of the users table has a class "num" so the `<th>` and the `<td>` are styled with `text-align: center;`.
I want to add a the "num" class to my cu... | The solution is simple. Add the word `num` when defining the column like this:
```
// Add users table header columns
add_filter( 'manage_users_columns', 'gtp_users_table_columns' );
function gtp_users_table_columns( $defaults ) {
$defaults['purchased-leads num'] = __( 'Purchased leads', 'gtp_translate' );
retu... |
182,230 | <p>I've built a theme and have set the following image dimensions via functions.php: </p>
<pre><code>set_post_thumbnail_size( 1064, 347, true ); // Upload @ 2128(W) x 708(H)
add_image_size( 'standard', 352, 235, true ); // Upload @ 704(W) x 470(H)
add_image_size( 'gallery', 750, 500, true ); // Upload @ 1500(W) x 1000... | [
{
"answer_id": 182232,
"author": "priyanka",
"author_id": 69597,
"author_profile": "https://wordpress.stackexchange.com/users/69597",
"pm_score": -1,
"selected": false,
"text": "<p>You have to regenerate all the images with the specified sizes and for that you can use Regenerate Thumbnai... | 2015/03/25 | [
"https://wordpress.stackexchange.com/questions/182230",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37548/"
] | I've built a theme and have set the following image dimensions via functions.php:
```
set_post_thumbnail_size( 1064, 347, true ); // Upload @ 2128(W) x 708(H)
add_image_size( 'standard', 352, 235, true ); // Upload @ 704(W) x 470(H)
add_image_size( 'gallery', 750, 500, true ); // Upload @ 1500(W) x 1000(H)
```
I us... | You have to use `single_product_large_thumbnail_size` filter for Single Product page.
something like:
```
function custom_product_large_thumbnail_size() {
return 'gallery';
}
add_filter('single_product_large_thumbnail_size', 'custom_product_large_thumbnail_size');
``` |
182,330 | <p>I have a select dropdown in my custom meta box in the admin area. It offers two options <strong>Approved</strong> and <strong>In Progress</strong>. When I select an option and save it the database is updated, but the value in the admin area is not. What I see is the first item from the list displayed in the select b... | [
{
"answer_id": 182259,
"author": "Jonathan Foster",
"author_id": 69306,
"author_profile": "https://wordpress.stackexchange.com/users/69306",
"pm_score": 0,
"selected": false,
"text": "<p>There isn't a way to get their email address without them signing up for your site first, or giving i... | 2015/03/26 | [
"https://wordpress.stackexchange.com/questions/182330",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69240/"
] | I have a select dropdown in my custom meta box in the admin area. It offers two options **Approved** and **In Progress**. When I select an option and save it the database is updated, but the value in the admin area is not. What I see is the first item from the list displayed in the select box. i.e. if I select **In Pro... | I'm not sure if this is legal in all countries but you can send the emailadress back to you by adapting it in the link the user clicks to your website.
e.g. The email they receive has a button that links to your website.
the url of the button looks like this:
`<a href="http://www.yourwebsite.com?email='email@rec... |
182,341 | <p>I don't know why when I'm using "Enter", that add <code>&nbsp;</code> in Pages/Posts Editor. That doesn't matter, but on my website, when I look the code <code>&nbsp;</code> makes this code :</p>
<pre><code><p> � </p>
</code></pre>
<p>and � appears on my website...</p>
<p>How can I change that... | [
{
"answer_id": 182259,
"author": "Jonathan Foster",
"author_id": 69306,
"author_profile": "https://wordpress.stackexchange.com/users/69306",
"pm_score": 0,
"selected": false,
"text": "<p>There isn't a way to get their email address without them signing up for your site first, or giving i... | 2015/03/26 | [
"https://wordpress.stackexchange.com/questions/182341",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68028/"
] | I don't know why when I'm using "Enter", that add ` ` in Pages/Posts Editor. That doesn't matter, but on my website, when I look the code ` ` makes this code :
```
<p> � </p>
```
and � appears on my website...
How can I change that to simple code :
```
<p> </p>
``` | I'm not sure if this is legal in all countries but you can send the emailadress back to you by adapting it in the link the user clicks to your website.
e.g. The email they receive has a button that links to your website.
the url of the button looks like this:
`<a href="http://www.yourwebsite.com?email='email@rec... |
182,374 | <blockquote>
<p><strong>Fatal error</strong>: Cannot access protected property Some_Plugin::$_some_property</p>
</blockquote>
<p>What is the best/least-destructive way of accessing a protected property attached to a post.</p>
<p>The property is being affixed to the post by a plugin but I need to access it's stored... | [
{
"answer_id": 182380,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": true,
"text": "<p>The foolproof method here to grab a dynamic member variable is to use reflection!</p>\n\n<p>Lets say we have ... | 2015/03/26 | [
"https://wordpress.stackexchange.com/questions/182374",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20557/"
] | >
> **Fatal error**: Cannot access protected property Some\_Plugin::$\_some\_property
>
>
>
What is the best/least-destructive way of accessing a protected property attached to a post.
The property is being affixed to the post by a plugin but I need to access it's stored information to display.
The options I can... | The foolproof method here to grab a dynamic member variable is to use reflection!
Lets say we have this class:
```
class MyClass {
private $myProperty = true;
}
```
We can use reflection to acquire the class, and the property:
```
$class = new ReflectionClass("MyClass");
$property = $class->getProperty("myPro... |
182,385 | <p>I have a post type in called Publication. I also have few custom field in that post type such as Publication Year, Author... </p>
<p>I want to have a search box with 3 drop-down fields which is All Field, Publication Year, and Author. When user select on All Field, it will search everything all post in this post ty... | [
{
"answer_id": 182380,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": true,
"text": "<p>The foolproof method here to grab a dynamic member variable is to use reflection!</p>\n\n<p>Lets say we have ... | 2015/03/26 | [
"https://wordpress.stackexchange.com/questions/182385",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36921/"
] | I have a post type in called Publication. I also have few custom field in that post type such as Publication Year, Author...
I want to have a search box with 3 drop-down fields which is All Field, Publication Year, and Author. When user select on All Field, it will search everything all post in this post type, but wh... | The foolproof method here to grab a dynamic member variable is to use reflection!
Lets say we have this class:
```
class MyClass {
private $myProperty = true;
}
```
We can use reflection to acquire the class, and the property:
```
$class = new ReflectionClass("MyClass");
$property = $class->getProperty("myPro... |
182,388 | <p>As I'm making one page website. Here is question I asked earlier:</p>
<p><a href="https://wordpress.stackexchange.com/questions/181270/calling-specific-pages-with-wp-query-part-ii">Calling Specific Pages with wp query Part II</a></p>
<p>As I'm calling all pages by WP_Query which is "order by = ASC" I want to call ... | [
{
"answer_id": 182413,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 3,
"selected": true,
"text": "<p>You <em>may</em> be able to use a WP_Query on <code>nav_menu_item</code> since it is its own post type. I've... | 2015/03/26 | [
"https://wordpress.stackexchange.com/questions/182388",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68179/"
] | As I'm making one page website. Here is question I asked earlier:
[Calling Specific Pages with wp query Part II](https://wordpress.stackexchange.com/questions/181270/calling-specific-pages-with-wp-query-part-ii)
As I'm calling all pages by WP\_Query which is "order by = ASC" I want to call it "order by menu structure... | You *may* be able to use a WP\_Query on `nav_menu_item` since it is its own post type. I've never done this but maybe it would work like you need it to, worth a shot. There are three other possibilities:
Option 1 - Get Your Nav Menu Items
==================================
There's a functions called [`wp_get_nav_menu... |
182,389 | <p>I have a set of custom post types and taxonomies I've added using the <a href="https://wordpress.org/plugins/custom-post-type-ui/" rel="nofollow">Custom Post Type UI</a> plugin, and need to enter several hundred entries ( >500 )</p>
<p>How can I import this data in bulk? E.g. as a csv?</p>
| [
{
"answer_id": 182398,
"author": "LindsayAnnB",
"author_id": 69685,
"author_profile": "https://wordpress.stackexchange.com/users/69685",
"pm_score": -1,
"selected": false,
"text": "<p>You should really re-title this question and refine your question further. From what I gather you are ac... | 2015/03/26 | [
"https://wordpress.stackexchange.com/questions/182389",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69679/"
] | I have a set of custom post types and taxonomies I've added using the [Custom Post Type UI](https://wordpress.org/plugins/custom-post-type-ui/) plugin, and need to enter several hundred entries ( >500 )
How can I import this data in bulk? E.g. as a csv? | There are many options, but these functions are your friends:
* `wp_insert_post` - pass it some arguments and it will create a post and if succesful, return the post ID
* `wp_set_object_terms` - pass it a post ID, a custom taxonomy, and the terms you'd like to set
* `fopen` - for opening a csv file
* `fgetcsv` - reads... |
182,393 | <p>Right now I have a metakey called 'epicredvote', it sorts my posts by this epicredvote number. It is doing it on a daily basis at the moment, so if I have 2 posts the post with the highest epicredvote # will be at the top. I am wanting to sort it by the WEEK not the DAY. I am wanting all my posts for that week to th... | [
{
"answer_id": 182405,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>This is more of an MySQL question than WordPress one.</p>\n\n<p>You are already using date functions there, from a ... | 2015/03/26 | [
"https://wordpress.stackexchange.com/questions/182393",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22960/"
] | Right now I have a metakey called 'epicredvote', it sorts my posts by this epicredvote number. It is doing it on a daily basis at the moment, so if I have 2 posts the post with the highest epicredvote # will be at the top. I am wanting to sort it by the WEEK not the DAY. I am wanting all my posts for that week to then ... | I agree with Rarst about the WEEK function, but be sure to also use YEAR as well to order the posts. So your order by would look something like this:
```
ORDER BY YEAR($wpdb->posts.post_date) DESC, WEEK($wpdb->posts.post_date) DESC, $wpdb->postmeta.meta_value+0 DESC
```
Of course, this is still pulling all posts, so... |
182,408 | <p>I'm developing a plug-in that adds the possibility to import/export settings from another plug-in. However, I don't have access to the options ids saved by that plug-in.</p>
<p>Is it possible to get all options saved by a specific plug-in?</p>
<p>What I would like is something like this:</p>
<pre><code>get_plugin... | [
{
"answer_id": 182410,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think this is possible or a universal function for this exists. Whenever you add an option you do s... | 2015/03/26 | [
"https://wordpress.stackexchange.com/questions/182408",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69694/"
] | I'm developing a plug-in that adds the possibility to import/export settings from another plug-in. However, I don't have access to the options ids saved by that plug-in.
Is it possible to get all options saved by a specific plug-in?
What I would like is something like this:
```
get_plugin_options($pluginId); // retu... | Your best option is likely to copy all the names into your plugin to use for retrieval. Of course, this could change when the plugin is updated. When options are saved in the database using update\_option() there's no indication of which plugin they came from that gets stored anywhere. If the options all use a particul... |
182,421 | <p>I would like style the main horizontal Wordpress menu so that the first 3 items are aligned to the left and the last 3 items are aligned to the right.</p>
<p>This will create the appearance of two menus (with login, etc., on the right) but make it easy to restyle it to create a responsive menu with the last three i... | [
{
"answer_id": 182422,
"author": "tao",
"author_id": 45169,
"author_profile": "https://wordpress.stackexchange.com/users/45169",
"pm_score": 0,
"selected": false,
"text": "<p>You need to wrap your two groups (left and right aligned items) in two containers. You than set <code>float</code... | 2015/03/27 | [
"https://wordpress.stackexchange.com/questions/182421",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59712/"
] | I would like style the main horizontal Wordpress menu so that the first 3 items are aligned to the left and the last 3 items are aligned to the right.
This will create the appearance of two menus (with login, etc., on the right) but make it easy to restyle it to create a responsive menu with the last three items at th... | There's an easier way with no markup changes and minimal CSS. [Live demo/fiddle here](http://jsfiddle.net/silb3r/1eyk7pa4/2/), code below:
```
<ul>
<li>1a</li><li>2a</li><li>3a</li><li>4a</li><li>5a</li><li>6a</li>
</ul>
```
---
```
ul {
list-style: none;
margin: 0;
padding: 0;
text-align: right;... |
182,424 | <p>I have two pages
- new.hillsong.com/australia/sisterhood
- new.hillsong.com/hills/sisterhood</p>
<p>Both pages are displaying the content for the /hills/sisterhood site but they are different pages with different content. I can't seem to find anything online about this. Is this possible? Are there any ways to make ... | [
{
"answer_id": 182425,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p><strong>No, at the time of writing this, no you cannot</strong>. Once a slug is used by a page, it cannot be... | 2015/03/27 | [
"https://wordpress.stackexchange.com/questions/182424",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69701/"
] | I have two pages
- new.hillsong.com/australia/sisterhood
- new.hillsong.com/hills/sisterhood
Both pages are displaying the content for the /hills/sisterhood site but they are different pages with different content. I can't seem to find anything online about this. Is this possible? Are there any ways to make this work.... | **Yes, you can.**
In the old days, this was not possible (as evident from other answers). However, it's possible now.
WordPress now lets child pages (of any post type that is hierarchical) from different parents to have the same slug / name. This is possible because now WordPress considers the entire hierarchical tre... |
182,429 | <p>So, I don't know how to explain properly, but here is the current situation.</p>
<p>Let say the site is called "Demo.com" and site admin email is "admin@gmail.com"</p>
<p>Then, </p>
<ol>
<li>An author(example, user-X@gmail.com) posts a post.</li>
<li>a visitor (another user, user-Y@gmail.com) leaves a comment or ... | [
{
"answer_id": 182430,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>What you need to do is to modify the code that sends the email to the author and in it set the \"reply-to... | 2015/03/27 | [
"https://wordpress.stackexchange.com/questions/182429",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67604/"
] | So, I don't know how to explain properly, but here is the current situation.
Let say the site is called "Demo.com" and site admin email is "admin@gmail.com"
Then,
1. An author(example, user-X@gmail.com) posts a post.
2. a visitor (another user, user-Y@gmail.com) leaves a comment or reply on the post.
3. the author(... | What you need to do is to modify the code that sends the email to the author and in it set the "reply-to" header of the email, pass it as part of the headers parameters to `wp-mail`.
Your code should be something like (adapted from the php mail function documentation).
```
$to = 'author@example.com';
$subject = ... |
182,431 | <p>Why it is bad to use this </p>
<p><code>include("../../../wp-load.php");</code> ??</p>
<p>What is the proper way of use this?? </p>
<p>Thanks</p>
| [
{
"answer_id": 182469,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 1,
"selected": false,
"text": "<p>The problem in this solution is, that the location of this file are different. WordPress allow the definition of ... | 2015/03/27 | [
"https://wordpress.stackexchange.com/questions/182431",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65189/"
] | Why it is bad to use this
`include("../../../wp-load.php");` ??
What is the proper way of use this??
Thanks | The problem in this solution is, that the location of this file are different. WordPress allow the definition of the folder of plugins and themes, different to your static path check for the `wp-load.php`.
### Example for custom paths
```
//*
// Custom content directory
define( 'WP_CONTENT_DIR', dirname( __FILE__ ) ... |
182,434 | <p>I want to create a video gallery plugin. I am using this code to create a post: </p>
<pre><code>global $user_ID;
$new_post = array(
'post_title' => 'chapter1',
'post_content' => 'Lorem ipsum dolor sit amet...',
'post_status' => 'publish',
'post_date' => date( 'Y-m-d H:i:s' ),
... | [
{
"answer_id": 182447,
"author": "jimihenrik",
"author_id": 64625,
"author_profile": "https://wordpress.stackexchange.com/users/64625",
"pm_score": 0,
"selected": false,
"text": "<p><strong>Edit:</strong> I thought this would be fairly simple but seems I'm just not competent enough.</p>\... | 2015/03/27 | [
"https://wordpress.stackexchange.com/questions/182434",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69703/"
] | I want to create a video gallery plugin. I am using this code to create a post:
```
global $user_ID;
$new_post = array(
'post_title' => 'chapter1',
'post_content' => 'Lorem ipsum dolor sit amet...',
'post_status' => 'publish',
'post_date' => date( 'Y-m-d H:i:s' ),
'post_author' => $use... | And to create a custom post type is not an option?
```
'post_type' => 'custom_post_type'
```
then just hide the custom post type from the UI
see [Possible to hide Custom Post Type UI/Menu from specific User Roles?](https://wordpress.stackexchange.com/questions/28782/possible-to-hide-custom-post-type-ui-menu-from-sp... |
182,444 | <p>I am adding a new post format on my plugin activation using this code:</p>
<pre><code>wp_insert_term( 'post-format-interviews_ans', 'post_format' );
</code></pre>
<p>It's not working. The rest of the plugin activation code, like table generation, is working.</p>
<p><code>post_format</code> is a WordPress default ... | [
{
"answer_id": 182445,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"https://codex.wordpress.org/Post_Formats\" rel=\"nofollow\">Post Formats</a> aren't like other taxonomie... | 2015/03/27 | [
"https://wordpress.stackexchange.com/questions/182444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69710/"
] | I am adding a new post format on my plugin activation using this code:
```
wp_insert_term( 'post-format-interviews_ans', 'post_format' );
```
It's not working. The rest of the plugin activation code, like table generation, is working.
`post_format` is a WordPress default taxonomy type.
What is the issue? | Unlike the other taxonomies, you cannot use `wp_inset_term()` to add terms to the `post_format` taxonomy as you cannot add new terms to this taxonomy.
You need to add the terms for the `post_format` via [`add_theme_support()`](https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Formats), something li... |
182,455 | <p>Apologies I am a PHp beginner and I have no idea why this loop is not working on my tag.php page any help would be welcome.</p>
<pre><code><?php get_header(); ?>
<div class="posts"><!-- BLOG -->
<!-- Shapes on sides -->
<div class="shapes_left"> </div>
<div class=... | [
{
"answer_id": 182445,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"https://codex.wordpress.org/Post_Formats\" rel=\"nofollow\">Post Formats</a> aren't like other taxonomie... | 2015/03/27 | [
"https://wordpress.stackexchange.com/questions/182455",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67583/"
] | Apologies I am a PHp beginner and I have no idea why this loop is not working on my tag.php page any help would be welcome.
```
<?php get_header(); ?>
<div class="posts"><!-- BLOG -->
<!-- Shapes on sides -->
<div class="shapes_left"> </div>
<div class="shapes_right"> </div>
<?php if (is_tag()) {... | Unlike the other taxonomies, you cannot use `wp_inset_term()` to add terms to the `post_format` taxonomy as you cannot add new terms to this taxonomy.
You need to add the terms for the `post_format` via [`add_theme_support()`](https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Formats), something li... |
182,482 | <p>I have saved a string in post_meta table in wordpress database with html entities like-</p>
<p><code><p>Hello <b>Shashank</b>, I have an idea.</p></code></p>
<p>When I get this string on frontend using function </p>
<p><code>get_post_meta(get_the_id(),field_name, true)</code>. </p>
<p>It ... | [
{
"answer_id": 182490,
"author": "M-R",
"author_id": 17061,
"author_profile": "https://wordpress.stackexchange.com/users/17061",
"pm_score": 0,
"selected": false,
"text": "<p>I believe, you would need to decode encoded saved entities before echo them out using <a href=\"http://codex.word... | 2015/03/27 | [
"https://wordpress.stackexchange.com/questions/182482",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67983/"
] | I have saved a string in post\_meta table in wordpress database with html entities like-
`<p>Hello <b>Shashank</b>, I have an idea.</p>`
When I get this string on frontend using function
`get_post_meta(get_the_id(),field_name, true)`.
It echoes string with HTML entities as same as it stores in DB.
But I want to ... | Use the htmlspecialchars() function in PHP in the templates, because the wordpress-api does htmlspecialchars on import.
The following code works fine
```
<?php print htmlspecialchars_decode(get_post_meta($post->ID, 'field_name', true)); ?>
``` |
182,498 | <p>I have a big amount of images in WP, that are not attach to any post. They are grouped in custom taxonomies (ignored in code below).
The images get uploaded to WP in random order and the post_date is set to the time the image was taken. Therefor the IDs and the post_date are not in the same order.</p>
<p>I need the... | [
{
"answer_id": 182522,
"author": "Jan Beck",
"author_id": 18760,
"author_profile": "https://wordpress.stackexchange.com/users/18760",
"pm_score": 0,
"selected": false,
"text": "<p>The <a href=\"https://codex.wordpress.org/Function_Reference/get_adjacent_post\" rel=\"nofollow\">get_adjace... | 2015/03/27 | [
"https://wordpress.stackexchange.com/questions/182498",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45303/"
] | I have a big amount of images in WP, that are not attach to any post. They are grouped in custom taxonomies (ignored in code below).
The images get uploaded to WP in random order and the post\_date is set to the time the image was taken. Therefor the IDs and the post\_date are not in the same order.
I need the ID for ... | Based on the answer by @jan-becker I build this snippet. This works for me:
```
/*
* Get the next/prev image id inside c-tax: my_snapshot_position_ctax
*/
function my_return_relative_attachment_id( $this_post_ID, $prev = true ) {
global $post;
// overwrite global $post variable
$post = get_post( $this_p... |
182,502 | <p>I have developed a custom wordpress panel with a custom front-end recently. In single post pages there is a slider. I display the result of get_attached_media( 'image' ) function as the images of slider. </p>
<p>I told editor that upload only the images you would like to see in slider to post from edit post page, u... | [
{
"answer_id": 182522,
"author": "Jan Beck",
"author_id": 18760,
"author_profile": "https://wordpress.stackexchange.com/users/18760",
"pm_score": 0,
"selected": false,
"text": "<p>The <a href=\"https://codex.wordpress.org/Function_Reference/get_adjacent_post\" rel=\"nofollow\">get_adjace... | 2015/03/27 | [
"https://wordpress.stackexchange.com/questions/182502",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69753/"
] | I have developed a custom wordpress panel with a custom front-end recently. In single post pages there is a slider. I display the result of get\_attached\_media( 'image' ) function as the images of slider.
I told editor that upload only the images you would like to see in slider to post from edit post page, upload ot... | Based on the answer by @jan-becker I build this snippet. This works for me:
```
/*
* Get the next/prev image id inside c-tax: my_snapshot_position_ctax
*/
function my_return_relative_attachment_id( $this_post_ID, $prev = true ) {
global $post;
// overwrite global $post variable
$post = get_post( $this_p... |
182,558 | <p>God, this little problem drives me crazy and I really hope that you'll help me how to figure it out.</p>
<p>I searched over all previous threads and in the codex of wordpress, I find some close situations but none of the answers solved my problems.</p>
<p>This is it :
I've one host with a wordpress installed at th... | [
{
"answer_id": 182573,
"author": "Squish",
"author_id": 28821,
"author_profile": "https://wordpress.stackexchange.com/users/28821",
"pm_score": 0,
"selected": false,
"text": "<p>In your subdirectory, open your access and change it to the stock setting.</p>\n\n<p><strong>root/subfolder:</... | 2015/03/28 | [
"https://wordpress.stackexchange.com/questions/182558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69777/"
] | God, this little problem drives me crazy and I really hope that you'll help me how to figure it out.
I searched over all previous threads and in the codex of wordpress, I find some close situations but none of the answers solved my problems.
This is it :
I've one host with a wordpress installed at the root. I've one ... | All the config were good, the problem was with my host provider.
For the record, the htaccess for the site in the subfolder, when everything is ok :
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_F... |
182,582 | <p>I would like the user to be automatically logged in without entering username and password when they click the link in the email sent after completing the registration form.</p>
<p>How can I do that?</p>
| [
{
"answer_id": 182586,
"author": "butlerblog",
"author_id": 38603,
"author_profile": "https://wordpress.stackexchange.com/users/38603",
"pm_score": 1,
"selected": false,
"text": "<p>Here's a basic approach.</p>\n\n<p>First, you would need to pass something in the link to give some user i... | 2015/03/28 | [
"https://wordpress.stackexchange.com/questions/182582",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69664/"
] | I would like the user to be automatically logged in without entering username and password when they click the link in the email sent after completing the registration form.
How can I do that? | Here's a basic approach.
First, you would need to pass something in the link to give some user info you can use to log the user in. To do this, you need to filter the email that goes to the user. (It would be possible to actually load a custom new user registration email, but this would have to be done as a plugin as ... |
182,594 | <p>I inherited a WordPress site from a previous developer who had gone a little crazy with image sizes. As I was uploading it to the server I noticed there were at least 10 image sizes for every image. This resulted in a nice and long 9 hour upload time. </p>
<p>On the site, I reckon only 3-4 of these image sizes are ... | [
{
"answer_id": 182586,
"author": "butlerblog",
"author_id": 38603,
"author_profile": "https://wordpress.stackexchange.com/users/38603",
"pm_score": 1,
"selected": false,
"text": "<p>Here's a basic approach.</p>\n\n<p>First, you would need to pass something in the link to give some user i... | 2015/03/29 | [
"https://wordpress.stackexchange.com/questions/182594",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48204/"
] | I inherited a WordPress site from a previous developer who had gone a little crazy with image sizes. As I was uploading it to the server I noticed there were at least 10 image sizes for every image. This resulted in a nice and long 9 hour upload time.
On the site, I reckon only 3-4 of these image sizes are actually b... | Here's a basic approach.
First, you would need to pass something in the link to give some user info you can use to log the user in. To do this, you need to filter the email that goes to the user. (It would be possible to actually load a custom new user registration email, but this would have to be done as a plugin as ... |
182,595 | <p>I'm attempting to add a <a href="http://codex.wordpress.org/Function_Reference/WP_List_Table">list table</a> to a custom admin page. I've been following <a href="http://www.smashingmagazine.com/2011/11/03/native-admin-tables-wordpress/">this guide</a> and <a href="https://wordpress.org/plugins/custom-list-table-exam... | [
{
"answer_id": 182846,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": false,
"text": "<p>Now at home, I actually ran your code. I got this:</p>\n\n<blockquote>\n <p>Fatal error: Call to u... | 2015/03/29 | [
"https://wordpress.stackexchange.com/questions/182595",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68936/"
] | I'm attempting to add a [list table](http://codex.wordpress.org/Function_Reference/WP_List_Table) to a custom admin page. I've been following [this guide](http://www.smashingmagazine.com/2011/11/03/native-admin-tables-wordpress/) and [this reference implementation](https://wordpress.org/plugins/custom-list-table-exampl... | I did same error first time I implemented `WP_List_Table`.
The problem is that when you call `WP_List_Table::display()` WordPress in turn calls:
* [WP\_List\_Table::display\_rows\_or\_placeholder()](https://developer.wordpress.org/reference/classes/wp_list_table/display_rows_or_placeholder/)
* [WP\_List\_Table::displ... |
182,615 | <p>I´m trying to do an simple Wordpress-App for my Homepage.</p>
<p>I started using Appery.io, which is actually a good environment for a non-programmer.</p>
<p>But I wonder if anybody has experiences in hooking up a Wordpress Site to an App by Appery?
Where would I start?</p>
<p>What my basic needs are:</p>
<p>1) ... | [
{
"answer_id": 182640,
"author": "vozer",
"author_id": 45103,
"author_profile": "https://wordpress.stackexchange.com/users/45103",
"pm_score": 0,
"selected": false,
"text": "<p>I got it done! </p>\n\n<p>The key to all of it is to use a Plugin like \"JSON API\" in your Wordprss Installati... | 2015/03/29 | [
"https://wordpress.stackexchange.com/questions/182615",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45103/"
] | I´m trying to do an simple Wordpress-App for my Homepage.
I started using Appery.io, which is actually a good environment for a non-programmer.
But I wonder if anybody has experiences in hooking up a Wordpress Site to an App by Appery?
Where would I start?
What my basic needs are:
1) Read the Articles
2) Comment on... | If you're using Wordpress 4.6, you can use the REST API without the need for the plugin by simply using the following:
```
add_action('rest_api_init', function() {
$namespace = 'myapi';
register_rest_route($namespace, '/myroute', array(
'methods' => 'GET',
'callback' => 'handle_my_route'
... |
182,621 | <p>Instead of weighing the site down with plugins I've hardcoded a couple of sharing links.</p>
<p>I've used the_permalink to create the links, in the sidebar, which work ok on posts and pages, but on the homepage it shows the link of the last post, not the homepage.</p>
<p>The code I'm using is pretty basic:</p>
<p... | [
{
"answer_id": 182640,
"author": "vozer",
"author_id": 45103,
"author_profile": "https://wordpress.stackexchange.com/users/45103",
"pm_score": 0,
"selected": false,
"text": "<p>I got it done! </p>\n\n<p>The key to all of it is to use a Plugin like \"JSON API\" in your Wordprss Installati... | 2015/03/29 | [
"https://wordpress.stackexchange.com/questions/182621",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58011/"
] | Instead of weighing the site down with plugins I've hardcoded a couple of sharing links.
I've used the\_permalink to create the links, in the sidebar, which work ok on posts and pages, but on the homepage it shows the link of the last post, not the homepage.
The code I'm using is pretty basic:
```
<a href="http://ww... | If you're using Wordpress 4.6, you can use the REST API without the need for the plugin by simply using the following:
```
add_action('rest_api_init', function() {
$namespace = 'myapi';
register_rest_route($namespace, '/myroute', array(
'methods' => 'GET',
'callback' => 'handle_my_route'
... |
182,635 | <p>How can I add a single WordPress function for all WordPress actions/event.</p>
<p>I want to add something equivalent to the one which is below</p>
<pre><code>add_Action('All WordPress Event/Actions', 'My_Function');
</code></pre>
<p>And also I wanted to make this function compatible such a way that I will get all... | [
{
"answer_id": 182637,
"author": "David Lawrence",
"author_id": 69813,
"author_profile": "https://wordpress.stackexchange.com/users/69813",
"pm_score": 1,
"selected": false,
"text": "<p>This is a very very bad idea.</p>\n\n<p>You can achieve this by doing something like this:</p>\n\n<pre... | 2015/03/29 | [
"https://wordpress.stackexchange.com/questions/182635",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69814/"
] | How can I add a single WordPress function for all WordPress actions/event.
I want to add something equivalent to the one which is below
```
add_Action('All WordPress Event/Actions', 'My_Function');
```
And also I wanted to make this function compatible such a way that I will get all system implicit arguments like b... | There is a special action `all` that you can use. Be aware, this will be very slow, don’t do that in production.
Here is an example:
```
add_action( 'all', function() {
static $hooks = [];
$filter = current_filter();
if ( isset ( $hooks[ $filter ] ) )
return;
$types = array_map( function ... |
182,655 | <p>I need some help I have the iteration working for listing the wordpress users however I also want to wrap their names in links and can't seem to get the user url to work... Nothing is returned to me.</p>
<p>Here is what I have so far.... You will see that I am trying to pull in the user_url however it just returns ... | [
{
"answer_id": 182658,
"author": "bjrdesign",
"author_id": 69824,
"author_profile": "https://wordpress.stackexchange.com/users/69824",
"pm_score": -1,
"selected": false,
"text": "<p>Just needed to use <code>get_author_posts_url($user->ID)</code></p>\n"
},
{
"answer_id": 182666... | 2015/03/29 | [
"https://wordpress.stackexchange.com/questions/182655",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69824/"
] | I need some help I have the iteration working for listing the wordpress users however I also want to wrap their names in links and can't seem to get the user url to work... Nothing is returned to me.
Here is what I have so far.... You will see that I am trying to pull in the user\_url however it just returns as nothin... | You could take a look at the contributors function included in Twenty Fourteen
```
if ( ! function_exists( 'twentyfourteen_list_authors' ) ) :
/**
* Print a list of all site contributors who published at least one post.
*
* @since Twenty Fourteen 1.0
*/
function twentyfourteen_list_authors() {
$contributor_ids... |
182,657 | <p>Here is what I tried and couldn't reach it. Maybe I need a whole different approach?</p>
<p>1) I created a custom field in a post, called <code>post-class</code> and inserted the value <code>cita-flow800000</code> (weird class name means: citations flow structure using the <code>#800000</code> as the main color, fo... | [
{
"answer_id": 182664,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 1,
"selected": false,
"text": "<p>I believe the primary problem in your code is the <code>$custom_values</code> is set <em>after</em> you try to u... | 2015/03/29 | [
"https://wordpress.stackexchange.com/questions/182657",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69825/"
] | Here is what I tried and couldn't reach it. Maybe I need a whole different approach?
1) I created a custom field in a post, called `post-class` and inserted the value `cita-flow800000` (weird class name means: citations flow structure using the `#800000` as the main color, for those who might be curious)
2) I called ... | I believe the primary problem in your code is the `$custom_values` is set *after* you try to use it (and you need to use the same variable name). Otherwise, it doesn't have a value when it's in `post_class()`. In fact, I'm surprised you're not getting an error. That variable needs to get the value *before* the call to ... |
182,668 | <p>I searched the web for last couple of days for "Reply-to Address" in the email but had no luck so, here I am.</p>
<p>In my wordpress site, there are multiple store owners who can sell their products.
When visitors buy a certain item (listed by different owners), that particular owner gets an email notifica... | [
{
"answer_id": 182691,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 6,
"selected": true,
"text": "<p>If and when you are using <a href=\"https://codex.wordpress.org/Function_Reference/wp_mail\" rel=\"n... | 2015/03/30 | [
"https://wordpress.stackexchange.com/questions/182668",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67604/"
] | I searched the web for last couple of days for "Reply-to Address" in the email but had no luck so, here I am.
In my wordpress site, there are multiple store owners who can sell their products.
When visitors buy a certain item (listed by different owners), that particular owner gets an email notification (Note that it ... | If and when you are using [`wp_mail()`](https://codex.wordpress.org/Function_Reference/wp_mail), then you can just set `Reply-To` for the `$headers` parameter. Exemplary usage below:
```
$to = "abc@def.gh";
$subject = "Using Reply-To with wp_mail";
$message = "This is an example for using Reply-To wit... |
182,675 | <p><strike>I need to import users to my WP database once a day.
So I have a script that runs once a day to do an action.
The problem that I'm having is that I'm a little over my head on this one.</p>
<p>Another company provides me with userdata in a .csv file.
I then need to import this file to my WP database.</p>
<p... | [
{
"answer_id": 182683,
"author": "Mehul Kaklotar",
"author_id": 54271,
"author_profile": "https://wordpress.stackexchange.com/users/54271",
"pm_score": 0,
"selected": false,
"text": "<p>You can make use of CSV importer/exporter libraries to extract the CSV file data and save them as user... | 2015/03/30 | [
"https://wordpress.stackexchange.com/questions/182675",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52240/"
] | I need to import users to my WP database once a day.
So I have a script that runs once a day to do an action.
The problem that I'm having is that I'm a little over my head on this one.
Another company provides me with userdata in a .csv file.
I then need to import this file to my WP database.
The script I use for run... | You can use [wp\_create\_user](https://codex.wordpress.org/Function_Reference/wp_create_user) and pass necessary information like `$username, $password, $email` , where `$email` is optional.
If user created successfully it will return `ID` of newly created user, other wise will return error object.
Then update user'... |
182,693 | <p>I created a custom plugin which i want Users who are Editors to be able to use the plugin.</p>
<p>I found a link here to allow access for editors to allow editors to edit menus<a href="https://wordpress.stackexchange.com/questions/4191/allow-editors-to-edit-menus">allow editors to edit menus?</a></p>
<p>using this... | [
{
"answer_id": 182695,
"author": "user123451",
"author_id": 69128,
"author_profile": "https://wordpress.stackexchange.com/users/69128",
"pm_score": 2,
"selected": false,
"text": "<p>After a quick search, i got my answer here</p>\n\n<p><a href=\"https://wordpress.org/support/topic/how-to-... | 2015/03/30 | [
"https://wordpress.stackexchange.com/questions/182693",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69128/"
] | I created a custom plugin which i want Users who are Editors to be able to use the plugin.
I found a link here to allow access for editors to allow editors to edit menus[allow editors to edit menus?](https://wordpress.stackexchange.com/questions/4191/allow-editors-to-edit-menus)
using this code.
```
$role_object... | Please add the following code.
```
function activate_plugin_name() {
$role = get_role( 'editor' );
$role->add_cap( 'manage_options' ); // capability
}
// Register our activation hook
register_activation_hook( __FILE__, 'activate_plugin_name' );
function deactivate_plugin_name() {
$role = get_role( 'editor' ... |
182,708 | <p>I wonder if its possible to use a template file for a specific url without having to create a page for that template.</p>
<p>This is my simplified problem:</p>
<p>I have created a page in WP with some link content that points to a specific url with some trailing form data: <em>(mysite.com/retail/?a=test&b=1234... | [
{
"answer_id": 182718,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 6,
"selected": true,
"text": "<p>You can just look at url, load the file and exit.</p>\n\n<p>That can be done when WordPress loaded its environ... | 2015/03/30 | [
"https://wordpress.stackexchange.com/questions/182708",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15228/"
] | I wonder if its possible to use a template file for a specific url without having to create a page for that template.
This is my simplified problem:
I have created a page in WP with some link content that points to a specific url with some trailing form data: *(mysite.com/retail/?a=test&b=1234)*.
I want that url (r... | You can just look at url, load the file and exit.
That can be done when WordPress loaded its environment, e.g. on `'init'`.
```
add_action('init', function() {
$url_path = trim(parse_url(add_query_arg(array()), PHP_URL_PATH), '/');
if ( $url_path === 'retail' ) {
// load the file if exists
$load = locat... |
182,775 | <p>i have created new custom menu that act like link to some page using this code:</p>
<pre><code>add_menu_page( __( 'Gallery', '' ), __( 'Gallery', '' ), 'edit_posts', 'post.php?post='. $gallery_page_id .'&action=edit', '', 'dashicons-admin-gallery', 6 );
</code></pre>
<p>the problem is that, when i click on thi... | [
{
"answer_id": 182735,
"author": "Hybrid Web Dev",
"author_id": 36506,
"author_profile": "https://wordpress.stackexchange.com/users/36506",
"pm_score": 0,
"selected": false,
"text": "<p>It's easy. Just put this in your plugin/theme or what have you:</p>\n\n<pre><code>function remove_teh_... | 2015/03/31 | [
"https://wordpress.stackexchange.com/questions/182775",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36923/"
] | i have created new custom menu that act like link to some page using this code:
```
add_menu_page( __( 'Gallery', '' ), __( 'Gallery', '' ), 'edit_posts', 'post.php?post='. $gallery_page_id .'&action=edit', '', 'dashicons-admin-gallery', 6 );
```
the problem is that, when i click on this link, active class become on... | OR you can go into your own user profile (hover over your name on the right end of the bar and click on Edit My Profile) and uncheck the box that says Show Toolbar when viewing site. Click Update Profile at the bottom of the page and the bar will go away.
Reverse the process when you want to bring it back. |
182,798 | <p>I am developing a plugin for my own rapid development that creates a custom post type. The 'list' for this post type is displayed on a specific page that is created and managed by the plugin. This page can be place anywhere within the site's page hierarchy, so the slug for the single posts need to update if the site... | [
{
"answer_id": 182836,
"author": "Eric K",
"author_id": 40585,
"author_profile": "https://wordpress.stackexchange.com/users/40585",
"pm_score": 1,
"selected": false,
"text": "<p>I was able to resolve this problem. It would appear that the 'save_post' action occurs prior to the <code>init... | 2015/03/31 | [
"https://wordpress.stackexchange.com/questions/182798",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40585/"
] | I am developing a plugin for my own rapid development that creates a custom post type. The 'list' for this post type is displayed on a specific page that is created and managed by the plugin. This page can be place anywhere within the site's page hierarchy, so the slug for the single posts need to update if the site ad... | I know this has already been answered, but I felt as if it wasn't 100% real clear what the actual solution was.
Here's my answer to add some clarification.
He's right... You can't flush rewrite rules on `save_post`, because that action hook is fired AFTER the `init` action hook has been fired.
As you know, Post Typ... |
182,811 | <p>OK, I had no idea how to title this topic.</p>
<p>I'm trying to override the default behavior with ajax. The problem here is not actually a problem, but a wish more.</p>
<p>I have this url:</p>
<pre><code><a href="http://example.com/?reaction=smk_remove_post&id=1226&_nonce=7be82cd4a0" class="smk-remove... | [
{
"answer_id": 182815,
"author": "Rene Korss",
"author_id": 69908,
"author_profile": "https://wordpress.stackexchange.com/users/69908",
"pm_score": 1,
"selected": false,
"text": "<p>Make link like this</p>\n\n<pre><code><a href=\"http://example.com/?reaction=smk_remove_post&id=122... | 2015/03/31 | [
"https://wordpress.stackexchange.com/questions/182811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31111/"
] | OK, I had no idea how to title this topic.
I'm trying to override the default behavior with ajax. The problem here is not actually a problem, but a wish more.
I have this url:
```
<a href="http://example.com/?reaction=smk_remove_post&id=1226&_nonce=7be82cd4a0" class="smk-remove-post">Remove post</a>
```
In the `fu... | I finally got it.
First mistake was to process the same function twice. I've called it once after the function and one more time in ajax action. So when using the ajax call, the function got executed twice. In the example from the OP, this is not a problem at all, because it is simplified to do only one thing, but in ... |
182,859 | <p>I've set up some custom post types with Pods, but can't seem to get it to display my manual excerpt. It's working fine for my normal posts.</p>
<p>I've tried displaying it with echo get_the_excerpt() and the_excerpt(). I've tried doing it using get_posts() and setup_postdata(). I've also tried a standard WP_Query l... | [
{
"answer_id": 182815,
"author": "Rene Korss",
"author_id": 69908,
"author_profile": "https://wordpress.stackexchange.com/users/69908",
"pm_score": 1,
"selected": false,
"text": "<p>Make link like this</p>\n\n<pre><code><a href=\"http://example.com/?reaction=smk_remove_post&id=122... | 2015/03/31 | [
"https://wordpress.stackexchange.com/questions/182859",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69939/"
] | I've set up some custom post types with Pods, but can't seem to get it to display my manual excerpt. It's working fine for my normal posts.
I've tried displaying it with echo get\_the\_excerpt() and the\_excerpt(). I've tried doing it using get\_posts() and setup\_postdata(). I've also tried a standard WP\_Query loop.... | I finally got it.
First mistake was to process the same function twice. I've called it once after the function and one more time in ajax action. So when using the ajax call, the function got executed twice. In the example from the OP, this is not a problem at all, because it is simplified to do only one thing, but in ... |
182,891 | <p>I create custom plugin for import categories. now i have categories array from api.but when import categories into my wordpress woo commerce means not working.</p>
<p>My code is given below.</p>
<pre><code>public function sample_insert_category() {
if(!term_exists('sample-category')) {
wp_insert_term(
... | [
{
"answer_id": 182892,
"author": "Christopher Carvache",
"author_id": 15341,
"author_profile": "https://wordpress.stackexchange.com/users/15341",
"pm_score": 1,
"selected": false,
"text": "<p>The syntax for adding an action in WordPress WITHIN a class is somewhat different. Your code wi... | 2015/04/01 | [
"https://wordpress.stackexchange.com/questions/182891",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33786/"
] | I create custom plugin for import categories. now i have categories array from api.but when import categories into my wordpress woo commerce means not working.
My code is given below.
```
public function sample_insert_category() {
if(!term_exists('sample-category')) {
wp_insert_term(
'Sample C... | Finally i used the following code and i add category from my plug in.
```
class MyPluginClass {
public function __construct() {
add_action( 'init', array( $this, 'sample_insert_category') );
}
public function sample_insert_category() {
if(!term_exists('Test','product_cat')) {
... |
182,896 | <p>I'm trying to customize <code>single-product.php</code> to achieve the often requested <strong>different categories = different single product templates</strong>, but it seems this file it's not affecting anything at all.</p>
<p>It's like only <code>content-single-product.php</code> is doing what it should <em>(eg.... | [
{
"answer_id": 182892,
"author": "Christopher Carvache",
"author_id": 15341,
"author_profile": "https://wordpress.stackexchange.com/users/15341",
"pm_score": 1,
"selected": false,
"text": "<p>The syntax for adding an action in WordPress WITHIN a class is somewhat different. Your code wi... | 2015/04/01 | [
"https://wordpress.stackexchange.com/questions/182896",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69810/"
] | I'm trying to customize `single-product.php` to achieve the often requested **different categories = different single product templates**, but it seems this file it's not affecting anything at all.
It's like only `content-single-product.php` is doing what it should *(eg. if i customize it, the changes are reflected in... | Finally i used the following code and i add category from my plug in.
```
class MyPluginClass {
public function __construct() {
add_action( 'init', array( $this, 'sample_insert_category') );
}
public function sample_insert_category() {
if(!term_exists('Test','product_cat')) {
... |
182,909 | <p>Is there some wordpress magic/plugin that will make the media library only show images that were uploaded to a specific custom post type?
I have a custom post type called "artists", I want, when admin click to upload/attach an image, that the media library popup only show images that have been uploaded to the artist... | [
{
"answer_id": 190880,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 4,
"selected": true,
"text": "<p>I'm not 100% sure if I get your problem right, but... Maybe this will help you...</p>\n\n<p>Media uplo... | 2015/04/01 | [
"https://wordpress.stackexchange.com/questions/182909",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27260/"
] | Is there some wordpress magic/plugin that will make the media library only show images that were uploaded to a specific custom post type?
I have a custom post type called "artists", I want, when admin click to upload/attach an image, that the media library popup only show images that have been uploaded to the artists c... | I'm not 100% sure if I get your problem right, but... Maybe this will help you...
Media uploader gets attachments with simple `WP_Query`, so you can use many filters to modify it's contents.
The only problem is that you can't query posts with specific CPT as parent using `WP_Query` arguments... So, we will have to us... |
182,912 | <p>I am an editor of a blog with nearly 200 published articles that have been published within the last two years. All the popular posts plugins I've found show the most popular posts of all time. Understandably, the older posts have significantly more views because, well, they've been live for a lot longer than posts ... | [
{
"answer_id": 190880,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 4,
"selected": true,
"text": "<p>I'm not 100% sure if I get your problem right, but... Maybe this will help you...</p>\n\n<p>Media uplo... | 2015/04/01 | [
"https://wordpress.stackexchange.com/questions/182912",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37786/"
] | I am an editor of a blog with nearly 200 published articles that have been published within the last two years. All the popular posts plugins I've found show the most popular posts of all time. Understandably, the older posts have significantly more views because, well, they've been live for a lot longer than posts pub... | I'm not 100% sure if I get your problem right, but... Maybe this will help you...
Media uploader gets attachments with simple `WP_Query`, so you can use many filters to modify it's contents.
The only problem is that you can't query posts with specific CPT as parent using `WP_Query` arguments... So, we will have to us... |
182,921 | <p>I have two links in </p>
<ul>
<li>"news" where all the news posts goes </li>
<li>"blog" where the rest goes</li>
</ul>
<p>just wanted to exclude the category "news" in the blog page</p>
<p>I use the code </p>
<pre><code>$news = new WP_query ('category_name =-news')
</code></pre>
<p>and it is not working</p>
<p... | [
{
"answer_id": 182925,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 0,
"selected": false,
"text": "<p>Use the parameters <code>cat</code> or <code>category__not_in</code>:</p>\n\n<pre><code>$query = ne... | 2015/04/01 | [
"https://wordpress.stackexchange.com/questions/182921",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69971/"
] | I have two links in
* "news" where all the news posts goes
* "blog" where the rest goes
just wanted to exclude the category "news" in the blog page
I use the code
```
$news = new WP_query ('category_name =-news')
```
and it is not working
Essentially, I want tell wordpress, I want all the posts to go into the ... | In your functions.php file, use [`pre_get_posts`](https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) and swap out the -1 in the following code with the category I.D you want to exclude from your posts page.
```
function exclude_category( $query ) {
if ( $query->is_home() && $query->is_main_quer... |
182,929 | <p>Could someone please point me in the right direction, im currently using : </p>
<pre><code><?php if (get_the_time('H') >= 8 && get_the_time('H') < 20) : ?>
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/picture1.jpg" alt="randomalt2" />
<?ph... | [
{
"answer_id": 182925,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 0,
"selected": false,
"text": "<p>Use the parameters <code>cat</code> or <code>category__not_in</code>:</p>\n\n<pre><code>$query = ne... | 2015/04/01 | [
"https://wordpress.stackexchange.com/questions/182929",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69976/"
] | Could someone please point me in the right direction, im currently using :
```
<?php if (get_the_time('H') >= 8 && get_the_time('H') < 20) : ?>
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/picture1.jpg" alt="randomalt2" />
<?php else : ?>
<img src="<?php echo get_templ... | In your functions.php file, use [`pre_get_posts`](https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) and swap out the -1 in the following code with the category I.D you want to exclude from your posts page.
```
function exclude_category( $query ) {
if ( $query->is_home() && $query->is_main_quer... |
182,943 | <p>I have a the following</p>
<ul>
<li><p>Custom post type: <code>episode</code> </p></li>
<li><p>Custom taxonomy: <code>series</code> </p>
<ul>
<li>sub terms <code>real deal</code> -> <code>season 1</code>, <code>season 2</code>, <code>season 3</code>, etc. </li>
</ul></li>
</ul>
<p>The terms are hierarchical, and ... | [
{
"answer_id": 182945,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 0,
"selected": false,
"text": "<p>Your syntax is slightly off - <code>$episodes</code> is an instance of <code>WP_Query</code>, not an array... | 2015/04/01 | [
"https://wordpress.stackexchange.com/questions/182943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52619/"
] | I have a the following
* Custom post type: `episode`
* Custom taxonomy: `series`
+ sub terms `real deal` -> `season 1`, `season 2`, `season 3`, etc.
The terms are hierarchical, and the entire thing is intended to be structured like a TV series (each "series" has "seasons").
On the `single-episode.php` page, I wan... | You second approach (**EDIT 2**) is quite buggy and inefficient unfortunately. Also, you are not going to do this in one query.
As I already stated, you need to look at the approach in [this answer](https://wordpress.stackexchange.com/a/182786/31545) I have recently done. You were almost there in your first edit, the... |
182,946 | <p>I'm using the <a href="https://wordpress.org/plugins/wp-job-manager/" rel="nofollow">WP Job Manager plugin</a> in my wordpress website. The list of my jobs is currently found on <code>/jobs</code> . I would like to have it on <code>/careers</code> . The listing of all jobs is not a page so I can't change the url the... | [
{
"answer_id": 183761,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>If you check out the <code>output()</code> method in the <code>includes/admin/class-wp-job-manager-setup.php</... | 2015/04/01 | [
"https://wordpress.stackexchange.com/questions/182946",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65180/"
] | I'm using the [WP Job Manager plugin](https://wordpress.org/plugins/wp-job-manager/) in my wordpress website. The list of my jobs is currently found on `/jobs` . I would like to have it on `/careers` . The listing of all jobs is not a page so I can't change the url there.
I've found [this](https://wpjobmanager.com/do... | If you check out the `output()` method in the `includes/admin/class-wp-job-manager-setup.php` file, namely this part:
```
/**
* Output addons page
*/
public function output() {
$step = ! empty( $_GET['step'] ) ? absint( $_GET['step'] ) : 1;
if ( 3 === $step && ! empty( $_POST ) ) {
$create_pages ... |
182,989 | <p>I have a WordPress website running on a machine. PHP has allocated memory of 128MB. Since I have two WP sites being host under same hosting it is consuming around 95MB out of 128MB on normal load..</p>
<p>I wanted to move new theme with custom fields types (Advanced Custom Fields). We created a test environment on ... | [
{
"answer_id": 187734,
"author": "Pratik bhatt",
"author_id": 60922,
"author_profile": "https://wordpress.stackexchange.com/users/60922",
"pm_score": -1,
"selected": false,
"text": "<p>Please check your .htacess files there might be some issues in it. You may even try to rename it.Hope i... | 2015/04/02 | [
"https://wordpress.stackexchange.com/questions/182989",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26151/"
] | I have a WordPress website running on a machine. PHP has allocated memory of 128MB. Since I have two WP sites being host under same hosting it is consuming around 95MB out of 128MB on normal load..
I wanted to move new theme with custom fields types (Advanced Custom Fields). We created a test environment on other serv... | Sorted it out myself.
The problem was, server was very slow to process the import. The process was happening behind the scene but server actually went down.
When server was up, I could see all the content on the other site. |
183,005 | <p>My code theme archive.php is</p>
<pre><code><?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the... | [
{
"answer_id": 187734,
"author": "Pratik bhatt",
"author_id": 60922,
"author_profile": "https://wordpress.stackexchange.com/users/60922",
"pm_score": -1,
"selected": false,
"text": "<p>Please check your .htacess files there might be some issues in it. You may even try to rename it.Hope i... | 2015/04/02 | [
"https://wordpress.stackexchange.com/questions/183005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66796/"
] | My code theme archive.php is
```
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that w... | Sorted it out myself.
The problem was, server was very slow to process the import. The process was happening behind the scene but server actually went down.
When server was up, I could see all the content on the other site. |
183,058 | <p>I'm grabbing a remote feed in my plugin and some entries have iframe code I want to keep. However, SimplePie <code>fetch_feed</code> keeps stripping it out. Here is my code and what I've tried already:</p>
<pre><code>kses_remove_filters(); # remove kses filters but SimplePie strips codes anyway
$rss = fetch_feed( '... | [
{
"answer_id": 301259,
"author": "Cubakos",
"author_id": 107648,
"author_profile": "https://wordpress.stackexchange.com/users/107648",
"pm_score": 1,
"selected": false,
"text": "<p>From the SimplePie docs <a href=\"http://simplepie.org/wiki/reference/simplepie/strip_htmltags\" rel=\"nofo... | 2015/04/02 | [
"https://wordpress.stackexchange.com/questions/183058",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50675/"
] | I'm grabbing a remote feed in my plugin and some entries have iframe code I want to keep. However, SimplePie `fetch_feed` keeps stripping it out. Here is my code and what I've tried already:
```
kses_remove_filters(); # remove kses filters but SimplePie strips codes anyway
$rss = fetch_feed( 'http://www.someblog.com/f... | From the SimplePie docs [here](http://simplepie.org/wiki/reference/simplepie/strip_htmltags): there is a `strip_htmltags` property in the SimplePie object, which among others it has the iframe tag we want to keep.
So, apart from the wp\_kses, probably we want to remove the tag from the above property.
For instance, t... |
183,067 | <p>I have a wodpress site, and I have submitted it to google webmaster tools. When I search on google by my site name, the results come, and on clicking the searched result, I can open the website on my PC. But when doing the same thing on my mobile, i get this</p>
<pre><code>Error 406: Not accebtable
</code></pre>
<... | [
{
"answer_id": 183071,
"author": "redelschaap",
"author_id": 69725,
"author_profile": "https://wordpress.stackexchange.com/users/69725",
"pm_score": 1,
"selected": false,
"text": "<p>A <code>406 Not Acceptable</code> HTTP error usually indicates that the content type of your webpage is n... | 2015/04/02 | [
"https://wordpress.stackexchange.com/questions/183067",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70049/"
] | I have a wodpress site, and I have submitted it to google webmaster tools. When I search on google by my site name, the results come, and on clicking the searched result, I can open the website on my PC. But when doing the same thing on my mobile, i get this
```
Error 406: Not accebtable
```
How can can resolve it? | I had a similar problem recently with this 406 Not Acceptable error occurring when trying to update permalinks in WordPress. I also had the same problem when submitting any changes to the editor, etc. Google Webmaster tools would yield the same result.
The solution is to disable the mod\_security firewall within your ... |
183,075 | <p>So i've been trying to figure this out for awhile now. The following code does not seem to work for me. The javascript file will not be included in the footer ( or anywhere for that matter )</p>
<pre><code>function add_scripts_plz(){
wp_enqueue_script( 'wowjs', get_template_directory_uri() . '/js/wow.min.js', ... | [
{
"answer_id": 183071,
"author": "redelschaap",
"author_id": 69725,
"author_profile": "https://wordpress.stackexchange.com/users/69725",
"pm_score": 1,
"selected": false,
"text": "<p>A <code>406 Not Acceptable</code> HTTP error usually indicates that the content type of your webpage is n... | 2015/04/02 | [
"https://wordpress.stackexchange.com/questions/183075",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16334/"
] | So i've been trying to figure this out for awhile now. The following code does not seem to work for me. The javascript file will not be included in the footer ( or anywhere for that matter )
```
function add_scripts_plz(){
wp_enqueue_script( 'wowjs', get_template_directory_uri() . '/js/wow.min.js', array('jquery'... | I had a similar problem recently with this 406 Not Acceptable error occurring when trying to update permalinks in WordPress. I also had the same problem when submitting any changes to the editor, etc. Google Webmaster tools would yield the same result.
The solution is to disable the mod\_security firewall within your ... |
183,114 | <p>After switching from the homepage displaying latest blog posts on urls /page/1/ /page/2/ etc to a static front page with the posts displayed on /blog/page/1/ we would like to redirect the original /page/#/ to the new url /blog/page/#/</p>
<p>Is there a best way to do this? Perhaps a plugin, though searching has yie... | [
{
"answer_id": 183071,
"author": "redelschaap",
"author_id": 69725,
"author_profile": "https://wordpress.stackexchange.com/users/69725",
"pm_score": 1,
"selected": false,
"text": "<p>A <code>406 Not Acceptable</code> HTTP error usually indicates that the content type of your webpage is n... | 2015/04/03 | [
"https://wordpress.stackexchange.com/questions/183114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70073/"
] | After switching from the homepage displaying latest blog posts on urls /page/1/ /page/2/ etc to a static front page with the posts displayed on /blog/page/1/ we would like to redirect the original /page/#/ to the new url /blog/page/#/
Is there a best way to do this? Perhaps a plugin, though searching has yielded littl... | I had a similar problem recently with this 406 Not Acceptable error occurring when trying to update permalinks in WordPress. I also had the same problem when submitting any changes to the editor, etc. Google Webmaster tools would yield the same result.
The solution is to disable the mod\_security firewall within your ... |
183,154 | <p>Can items have multiple permalinks?</p>
<p>I am currently struggling to setup routing for a custom taxonomy that I have setup. </p>
<p>I have a custom post type, say hotels.</p>
<p>A standard URL for one of these posts might be /hotels/the-marriot-hotel</p>
<p>But I also have a custom taxonomy, Locations.</p>
<... | [
{
"answer_id": 183071,
"author": "redelschaap",
"author_id": 69725,
"author_profile": "https://wordpress.stackexchange.com/users/69725",
"pm_score": 1,
"selected": false,
"text": "<p>A <code>406 Not Acceptable</code> HTTP error usually indicates that the content type of your webpage is n... | 2015/04/03 | [
"https://wordpress.stackexchange.com/questions/183154",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70099/"
] | Can items have multiple permalinks?
I am currently struggling to setup routing for a custom taxonomy that I have setup.
I have a custom post type, say hotels.
A standard URL for one of these posts might be /hotels/the-marriot-hotel
But I also have a custom taxonomy, Locations.
I want to be able to access each hot... | I had a similar problem recently with this 406 Not Acceptable error occurring when trying to update permalinks in WordPress. I also had the same problem when submitting any changes to the editor, etc. Google Webmaster tools would yield the same result.
The solution is to disable the mod\_security firewall within your ... |
183,178 | <p>I think I'm missing a step here, but for the life of me I can't see it. I'm trying to display a simple list of users who all have the same role and have the same meta data value for a certain key - namely, teachers associated with a school. </p>
<p>Here is my code: </p>
<pre><code> <div class="teachers-list"... | [
{
"answer_id": 183071,
"author": "redelschaap",
"author_id": 69725,
"author_profile": "https://wordpress.stackexchange.com/users/69725",
"pm_score": 1,
"selected": false,
"text": "<p>A <code>406 Not Acceptable</code> HTTP error usually indicates that the content type of your webpage is n... | 2015/04/03 | [
"https://wordpress.stackexchange.com/questions/183178",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70112/"
] | I think I'm missing a step here, but for the life of me I can't see it. I'm trying to display a simple list of users who all have the same role and have the same meta data value for a certain key - namely, teachers associated with a school.
Here is my code:
```
<div class="teachers-list">
<h3>Your S... | I had a similar problem recently with this 406 Not Acceptable error occurring when trying to update permalinks in WordPress. I also had the same problem when submitting any changes to the editor, etc. Google Webmaster tools would yield the same result.
The solution is to disable the mod\_security firewall within your ... |
183,182 | <p>First of all, I know it's a duplicate, but none of the older answers were helpful.</p>
<p>I'm searching in posts through <code>post_meta</code>. Here's my code, which currently returns nothing.</p>
<pre><code>$args = array(
'numberposts' => -1,
'post_type' => 'post',
'meta_query' =&g... | [
{
"answer_id": 183188,
"author": "Jen",
"author_id": 13810,
"author_profile": "https://wordpress.stackexchange.com/users/13810",
"pm_score": 5,
"selected": true,
"text": "<p>There's no easy way to search serialized values in a meta query. If the list of values isn't crazy long, potential... | 2015/04/03 | [
"https://wordpress.stackexchange.com/questions/183182",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56815/"
] | First of all, I know it's a duplicate, but none of the older answers were helpful.
I'm searching in posts through `post_meta`. Here's my code, which currently returns nothing.
```
$args = array(
'numberposts' => -1,
'post_type' => 'post',
'meta_query' => array(
array(
'key... | There's no easy way to search serialized values in a meta query. If the list of values isn't crazy long, potentially you could set up multiple meta queries:
```
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'system_power_supply',
'value' => 'single',
'compare' ... |
183,196 | <p>I am trying to get the value of the 'new-post-slug' (the bit that you can edit to customize your slug for a post, but bizarrely doesn't have a 'name' attribute as you'd expect a form field to have ... the update must be done in ajax in the background)</p>
<p>What I am stuck on is 2 things:</p>
<ul>
<li><p>Why do p... | [
{
"answer_id": 185077,
"author": "user28206",
"author_id": 28206,
"author_profile": "https://wordpress.stackexchange.com/users/28206",
"pm_score": -1,
"selected": false,
"text": "<p>When a new post is created (regardless of status) <code>post_name</code> which is the slug is saved to the... | 2015/04/04 | [
"https://wordpress.stackexchange.com/questions/183196",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51271/"
] | I am trying to get the value of the 'new-post-slug' (the bit that you can edit to customize your slug for a post, but bizarrely doesn't have a 'name' attribute as you'd expect a form field to have ... the update must be done in ajax in the background)
What I am stuck on is 2 things:
* Why do posts not get their post\... | I run into a similar issue. I had to remove `remove_meta_box('slugdiv', ['post', 'page'], 'normal');` from my code. When you remove the *slugdiv* meta box the slug edit box for WP does stops working. |
183,197 | <p>I have a 'single' page for individual workshop events and i'm tying to create an 'add to calendar' functionality. Right now i have a link setup, which passes the current post ID in a query string to the PHP file that generates the iCal file. I'm pretty sure I should be able to generate such a file from a wp_query,... | [
{
"answer_id": 185077,
"author": "user28206",
"author_id": 28206,
"author_profile": "https://wordpress.stackexchange.com/users/28206",
"pm_score": -1,
"selected": false,
"text": "<p>When a new post is created (regardless of status) <code>post_name</code> which is the slug is saved to the... | 2015/04/04 | [
"https://wordpress.stackexchange.com/questions/183197",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70117/"
] | I have a 'single' page for individual workshop events and i'm tying to create an 'add to calendar' functionality. Right now i have a link setup, which passes the current post ID in a query string to the PHP file that generates the iCal file. I'm pretty sure I should be able to generate such a file from a wp\_query, but... | I run into a similar issue. I had to remove `remove_meta_box('slugdiv', ['post', 'page'], 'normal');` from my code. When you remove the *slugdiv* meta box the slug edit box for WP does stops working. |
183,227 | <p>I'm building a Wordpress site in which an admin can upload a video file from post metabox. </p>
<p>After that post is saved and the video file is attached to the post, I used ffmpeg to get the screenshot at the first second of video, then save this screenshot as a JPG file in 'tmp' directory in theme directory.</p>... | [
{
"answer_id": 185077,
"author": "user28206",
"author_id": 28206,
"author_profile": "https://wordpress.stackexchange.com/users/28206",
"pm_score": -1,
"selected": false,
"text": "<p>When a new post is created (regardless of status) <code>post_name</code> which is the slug is saved to the... | 2015/04/04 | [
"https://wordpress.stackexchange.com/questions/183227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70137/"
] | I'm building a Wordpress site in which an admin can upload a video file from post metabox.
After that post is saved and the video file is attached to the post, I used ffmpeg to get the screenshot at the first second of video, then save this screenshot as a JPG file in 'tmp' directory in theme directory.
Finally, I w... | I run into a similar issue. I had to remove `remove_meta_box('slugdiv', ['post', 'page'], 'normal');` from my code. When you remove the *slugdiv* meta box the slug edit box for WP does stops working. |
183,240 | <p>I use this code to create the dropdown and then save the dropdown chosen values:</p>
<pre><code><?php
// Display Fields
add_action( 'show_user_profile', 'add_multiple_choice_dropdown ' );
add_action( 'edit_user_profile', 'add_multiple_choice_dropdown ' );
function add_multiple_choice_dropdown ( $user ) {
?>... | [
{
"answer_id": 183334,
"author": "Mike",
"author_id": 69112,
"author_profile": "https://wordpress.stackexchange.com/users/69112",
"pm_score": 2,
"selected": true,
"text": "<p>You will need an opening select tag that tells PHP it is an array. Something along the lines of the following sho... | 2015/04/04 | [
"https://wordpress.stackexchange.com/questions/183240",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70145/"
] | I use this code to create the dropdown and then save the dropdown chosen values:
```
<?php
// Display Fields
add_action( 'show_user_profile', 'add_multiple_choice_dropdown ' );
add_action( 'edit_user_profile', 'add_multiple_choice_dropdown ' );
function add_multiple_choice_dropdown ( $user ) {
?>
<h3>Extra profile ... | You will need an opening select tag that tells PHP it is an array. Something along the lines of the following should get you on your way...
```
<?php
// Display Fields
add_action( 'show_user_profile', 'add_multiple_choice_dropdown ' );
add_action( 'edit_user_profile', 'add_multiple_choice_dropdown ' );
function add_... |
183,248 | <p>I am currently in the middle of developing the front page for a online store. I am trying to resize the width of the image to expand it across the full width of the page, however the image will not expand any further than 960px I need to expand it 1440px. I have tried using both the CSS and HTML to correct this but ... | [
{
"answer_id": 183281,
"author": "Jay",
"author_id": 70162,
"author_profile": "https://wordpress.stackexchange.com/users/70162",
"pm_score": -1,
"selected": false,
"text": "<p>Did you try <code>width:100%;</code> in your css?</p>\n"
},
{
"answer_id": 183303,
"author": "Pieter... | 2015/04/04 | [
"https://wordpress.stackexchange.com/questions/183248",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70150/"
] | I am currently in the middle of developing the front page for a online store. I am trying to resize the width of the image to expand it across the full width of the page, however the image will not expand any further than 960px I need to expand it 1440px. I have tried using both the CSS and HTML to correct this but I a... | The maximum width of an image displayed in content is not just determined by the image sizes you set or CSS settings, it is also determined by the content width set in functions.php through code similar to the following
```
if ( ! isset( $content_width ) ) {
$content_width = 960;
}
```
You need to set this to yo... |