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 |
|---|---|---|---|---|---|---|
194,326 | <p>I'm trying to import a database and wonder how I can stop getting the following error?</p>
<blockquote>
<p>"#1075 - Incorrect table definition; there can be only one auto column
and it must be defined as a key "</p>
</blockquote>
<p>Here's the result when importing using PHPMyAdmin.</p>
<p>SQL query:</p>
<pr... | [
{
"answer_id": 194340,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>I am not sure where you got that export code but I don't see the <code>PRIMARY KEY</code> defined as it shou... | 2015/07/13 | [
"https://wordpress.stackexchange.com/questions/194326",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76109/"
] | I'm trying to import a database and wonder how I can stop getting the following error?
>
> "#1075 - Incorrect table definition; there can be only one auto column
> and it must be defined as a key "
>
>
>
Here's the result when importing using PHPMyAdmin.
SQL query:
```
--
-- Database: `db_factorypattern`
--
-... | I am not sure where you got that export code but I don't see the `PRIMARY KEY` defined as it should be. Take a look at the [code from Core that creates the table](https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/schema.php#L87):
```
87 CREATE TABLE $wpdb->commentmeta (
88 meta_id bigint(20) unsi... |
194,348 | <p>I'd like to intercept 404 errors and do some things before to show the 404 error page.</p>
<p>How can intercept the 404 error?</p>
| [
{
"answer_id": 194384,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 6,
"selected": true,
"text": "<p>As was mentioned in a comment, <code>template_redirect</code> would be an appropriate hook for intercepting a 404 b... | 2015/07/13 | [
"https://wordpress.stackexchange.com/questions/194348",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57145/"
] | I'd like to intercept 404 errors and do some things before to show the 404 error page.
How can intercept the 404 error? | As was mentioned in a comment, `template_redirect` would be an appropriate hook for intercepting a 404 before the template is loaded.
```
function wpd_do_stuff_on_404(){
if( is_404() ){
// do stuff
}
}
add_action( 'template_redirect', 'wpd_do_stuff_on_404' );
```
Refer to the [Action Reference](http:... |
194,352 | <p>All I'm trying to do here is a simple custom loop using WP_Query to display posts if they are published in the last 24 hours; otherwise, a message appears telling the user to check back soon for fresh posts. I'm trying to use the date_query parameter in my arguments but I'm getting unexpected results...at first it w... | [
{
"answer_id": 194365,
"author": "terminator",
"author_id": 55034,
"author_profile": "https://wordpress.stackexchange.com/users/55034",
"pm_score": 4,
"selected": true,
"text": "<p>As birgire said date query is an array of arrays \nMay be this solves your problemo. </p>\n\n<pre><code>$ar... | 2015/07/13 | [
"https://wordpress.stackexchange.com/questions/194352",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55073/"
] | All I'm trying to do here is a simple custom loop using WP\_Query to display posts if they are published in the last 24 hours; otherwise, a message appears telling the user to check back soon for fresh posts. I'm trying to use the date\_query parameter in my arguments but I'm getting unexpected results...at first it wi... | As birgire said date query is an array of arrays
May be this solves your problemo.
```
$args = array(
'post_type' => 'surf_reports',
'posts_per_page' => '1',
'category_name' => $cat (this is pulled dynamically in my template),
'date_query' => array(
array(
'after' => '24 hours ago'
... |
194,363 | <p>I have more than 500 posts and I want to limit only 100 posts with pagination. So, 10 pages with 10 posts in each.
Presenting you the code:</p>
<pre><code>$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$posts = get_posts(
array(
'numberposts' => 10,
'paged' => $pa... | [
{
"answer_id": 194368,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>Before I start, do not use <code>get_posts</code> for paginated queries. <code>get_posts</code> legally ... | 2015/07/13 | [
"https://wordpress.stackexchange.com/questions/194363",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36035/"
] | I have more than 500 posts and I want to limit only 100 posts with pagination. So, 10 pages with 10 posts in each.
Presenting you the code:
```
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$posts = get_posts(
array(
'numberposts' => 10,
'paged' => $paged,
'meta_k... | Before I start, do not use `get_posts` for paginated queries. `get_posts` legally breaks pagination, and does not return the query object. If you need to paginate queries, use `WP_Query`
As for your issue, I really don't think limiting the total overall amount of posts to only 100 is possible when you involve paginati... |
194,374 | <h2>History:</h2>
<p>I'm working on a project for a client that involves building 27 unique websites that are built on wordpress. I say unique, because (for reasons that are not worth going into here) they aren't and can't be installed in a multi-site environment. Each of these sites will have the same theme installed... | [
{
"answer_id": 194368,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>Before I start, do not use <code>get_posts</code> for paginated queries. <code>get_posts</code> legally ... | 2015/07/13 | [
"https://wordpress.stackexchange.com/questions/194374",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15404/"
] | History:
--------
I'm working on a project for a client that involves building 27 unique websites that are built on wordpress. I say unique, because (for reasons that are not worth going into here) they aren't and can't be installed in a multi-site environment. Each of these sites will have the same theme installed an... | Before I start, do not use `get_posts` for paginated queries. `get_posts` legally breaks pagination, and does not return the query object. If you need to paginate queries, use `WP_Query`
As for your issue, I really don't think limiting the total overall amount of posts to only 100 is possible when you involve paginati... |
194,385 | <p>I'm working on a plugin that seems to be fine in Chrome, but is not firing the PHP script via Ajax in Firefox. It is driving me to distraction. Here are the code blocks that relate to it.</p>
<p>First, the JavaScript enqueue:</p>
<pre><code>wp_enqueue_script ( 'jquery' );
$script_url = plugins_url ( '/js/seamless... | [
{
"answer_id": 194488,
"author": "voldemortensen",
"author_id": 76192,
"author_profile": "https://wordpress.stackexchange.com/users/76192",
"pm_score": 0,
"selected": false,
"text": "<p>You need\n <code>type: 'POST'</code>\nin your jQuery.ajax call. The default is GET, and this requir... | 2015/07/13 | [
"https://wordpress.stackexchange.com/questions/194385",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75753/"
] | I'm working on a plugin that seems to be fine in Chrome, but is not firing the PHP script via Ajax in Firefox. It is driving me to distraction. Here are the code blocks that relate to it.
First, the JavaScript enqueue:
```
wp_enqueue_script ( 'jquery' );
$script_url = plugins_url ( '/js/seamless-donations.js', __FIL... | This is the barebones for an AJAX call and response. Take a look and make sure this is working on Chrome and Firefox for you -- works for me.
```
<?php
// Some function for data we'll pass
function dgx_donate_get_countries_requiring_postal_code()
{
return "cc postal code stuff...";
}
// Register everything
add... |
194,417 | <p>I have created a custom post types in function.php file.</p>
<p>I has created 4 categories on Service menu section, aa, bb, cc and dd, I try to get a latest 5 post for specific category but I can archive this.</p>
<p>this is my query post:</p>
<pre><code>query_posts(array('showposts' => 5, 'post_type' => ar... | [
{
"answer_id": 194420,
"author": "Brad Dalton",
"author_id": 9884,
"author_profile": "https://wordpress.stackexchange.com/users/9884",
"pm_score": 0,
"selected": false,
"text": "<p>Don't use <a href=\"https://wordpress.stackexchange.com/questions/50761/when-to-use-wp-query-query-posts-an... | 2015/07/14 | [
"https://wordpress.stackexchange.com/questions/194417",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75093/"
] | I have created a custom post types in function.php file.
I has created 4 categories on Service menu section, aa, bb, cc and dd, I try to get a latest 5 post for specific category but I can archive this.
this is my query post:
```
query_posts(array('showposts' => 5, 'post_type' => array('servicios'), 'cat' => 14));
... | After two days with this problem have resolved the problem, I fix it adding tax\_query parameter with my taxonomy name and slug of the category requested:
```
$args = array(
'post_type' => array (
'servicios' => 'servicios',
),
'tax_query' => array(
array(
'... |
194,439 | <p>I have posts with very different post lengths. </p>
<p>Sometimes there are very long posts, sometimes a very short comment on a book. </p>
<p>I have set my excerpt length to 50 words, but when a post is 25 words long, the "Read more" link doesn't show up. </p>
<p>Any ideas?</p>
| [
{
"answer_id": 194452,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": false,
"text": "<p>The reason is the <a href=\"https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/formatting.php... | 2015/07/14 | [
"https://wordpress.stackexchange.com/questions/194439",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76166/"
] | I have posts with very different post lengths.
Sometimes there are very long posts, sometimes a very short comment on a book.
I have set my excerpt length to 50 words, but when a post is 25 words long, the "Read more" link doesn't show up.
Any ideas? | The reason is the [following check](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/formatting.php#L2676-L2682) in the `wp_trim_words()` function:
```
if ( count( $words_array ) > $num_words ) {
array_pop( $words_array );
$text = implode( $sep, $words_array );
$text = $text . $more;
} el... |
194,444 | <p>I have custom field in posts called <em>hex_colors</em> which contains hex color codes separated with white space, custom field value is like this:</p>
<pre><code>"000000 f0f0f0 c0c0c0 202020 404040 "
</code></pre>
<p>I can change function which create it to separate with ", " or " | " or anything else, if it help... | [
{
"answer_id": 194452,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": false,
"text": "<p>The reason is the <a href=\"https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/formatting.php... | 2015/07/14 | [
"https://wordpress.stackexchange.com/questions/194444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25053/"
] | I have custom field in posts called *hex\_colors* which contains hex color codes separated with white space, custom field value is like this:
```
"000000 f0f0f0 c0c0c0 202020 404040 "
```
I can change function which create it to separate with ", " or " | " or anything else, if it helps.
I can show it like this:
``... | The reason is the [following check](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/formatting.php#L2676-L2682) in the `wp_trim_words()` function:
```
if ( count( $words_array ) > $num_words ) {
array_pop( $words_array );
$text = implode( $sep, $words_array );
$text = $text . $more;
} el... |
194,446 | <p>I have a running Wordpress site (3.9.6). Now a new theme should be used and for this theme also some customizations have to be made (content, some WP files like page.php and so on). Additionally, I have to update to Wordpress 4. All changes shouldn't be noticed by visitors or at least as small as possible. Before th... | [
{
"answer_id": 194461,
"author": "emilushi",
"author_id": 63983,
"author_profile": "https://wordpress.stackexchange.com/users/63983",
"pm_score": 2,
"selected": false,
"text": "<p>In this case i will do:</p>\n\n<ul>\n<li>create a new folder inside website root folder (ex: mynewsite)</li>... | 2015/07/14 | [
"https://wordpress.stackexchange.com/questions/194446",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13921/"
] | I have a running Wordpress site (3.9.6). Now a new theme should be used and for this theme also some customizations have to be made (content, some WP files like page.php and so on). Additionally, I have to update to Wordpress 4. All changes shouldn't be noticed by visitors or at least as small as possible. Before the s... | In this case i will do:
* create a new folder inside website root folder (ex: mynewsite)
* create a new db and import the old website db to it
* copy old website files and folders to the new directory (mynewsite)
* change db name, user etc in wp-config on mynewsite folder
* define site url by adding to wp-config.php
... |
194,494 | <p>I have entered a form element into the page contents editor in wordpress.</p>
<p>form action="/home4/stevekeo/public_html/wp-includes/testforms.php" method="post"> ...</p>
<p>I want to use the selected value, and have created a php script in the /home4/stevekeo/public_html/wp-includes folder to access the user cho... | [
{
"answer_id": 194461,
"author": "emilushi",
"author_id": 63983,
"author_profile": "https://wordpress.stackexchange.com/users/63983",
"pm_score": 2,
"selected": false,
"text": "<p>In this case i will do:</p>\n\n<ul>\n<li>create a new folder inside website root folder (ex: mynewsite)</li>... | 2015/07/14 | [
"https://wordpress.stackexchange.com/questions/194494",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76194/"
] | I have entered a form element into the page contents editor in wordpress.
form action="/home4/stevekeo/public\_html/wp-includes/testforms.php" method="post"> ...
I want to use the selected value, and have created a php script in the /home4/stevekeo/public\_html/wp-includes folder to access the user choice.
```
<?php... | In this case i will do:
* create a new folder inside website root folder (ex: mynewsite)
* create a new db and import the old website db to it
* copy old website files and folders to the new directory (mynewsite)
* change db name, user etc in wp-config on mynewsite folder
* define site url by adding to wp-config.php
... |
194,516 | <p>Having an issue where I have a client who wants his Google Analytics code on just one page. I'm using the following is_page code but in the <strong><code>footer.php</code></strong> of my child theme, but it's not appearing on the page. Is this code correct?</p>
<pre><code><?php if ( is_page( 'contact' )) {
e... | [
{
"answer_id": 194502,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 2,
"selected": false,
"text": "<p>In menu editor add <strong>Custom Link</strong> for each language with <strong>URL</strong> po... | 2015/07/14 | [
"https://wordpress.stackexchange.com/questions/194516",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64741/"
] | Having an issue where I have a client who wants his Google Analytics code on just one page. I'm using the following is\_page code but in the **`footer.php`** of my child theme, but it's not appearing on the page. Is this code correct?
```
<?php if ( is_page( 'contact' )) {
echo '<script type="text/javascript">/* <... | In menu editor add **Custom Link** for each language with **URL** pointing to the site of your language and **Link Text** - `<img src="url of your flag picture" alt="your language">` |
194,571 | <p>One of <a href="http://www.michalzucker.com" rel="nofollow">my client's sites</a> are in Hebrew which is a right-to-left language. </p>
<p>I'm using the <a href="https://wordpress.org/themes/mh-newsdesk-lite/" rel="nofollow">MH Newsdesk Lite theme</a> found on <a href="https://codex.wordpress.org/CSS#WordPress_Gene... | [
{
"answer_id": 194578,
"author": "Vee",
"author_id": 44979,
"author_profile": "https://wordpress.stackexchange.com/users/44979",
"pm_score": 1,
"selected": true,
"text": "<p>It is due to css:</p>\n\n<p>Check this(Line # 314 style.css):</p>\n\n<pre><code>.search-form .screen-reader-text {... | 2015/07/15 | [
"https://wordpress.stackexchange.com/questions/194571",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75345/"
] | One of [my client's sites](http://www.michalzucker.com) are in Hebrew which is a right-to-left language.
I'm using the [MH Newsdesk Lite theme](https://wordpress.org/themes/mh-newsdesk-lite/) found on [wordpress.org](https://codex.wordpress.org/CSS#WordPress_Generated_Classes) . The theme is using a **[core](https://... | It is due to css:
Check this(Line # 314 style.css):
```
.search-form .screen-reader-text {
left: -9999px;
overflow: hidden;
position: absolute;
}
```
Remove the left margin then it works fine. It is on sidebar search form. Sorry for English.
Thanks |
194,581 | <p>I've got a <code>staff_member</code> custom post type, with <code>'has_archive' => true</code>. I've got an <code>archive-staff_member.php</code> template, with <code>/* Template Name: Staff */
</code></p>
<p>In backoffice, to add it to the nav menu, I created a page and assigned the template Staff, then added i... | [
{
"answer_id": 194589,
"author": "Trang",
"author_id": 70868,
"author_profile": "https://wordpress.stackexchange.com/users/70868",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, the function is_post_type_archive only works in archive.php\nTo have an item on nav menu links to your sta... | 2015/07/15 | [
"https://wordpress.stackexchange.com/questions/194581",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10381/"
] | I've got a `staff_member` custom post type, with `'has_archive' => true`. I've got an `archive-staff_member.php` template, with `/* Template Name: Staff */`
In backoffice, to add it to the nav menu, I created a page and assigned the template Staff, then added it to the main menu.
Till here, all fine. The problem is t... | Ok, an answer to all. First, thank you for you help.
Anyway, none of your solutions really address my issue. I don't like custom links on nav menus, at all. And that's because they're not dynamic, you cannot build them dynamically. So when you move the site and change url (for example, from staging to production) you... |
194,612 | <p>How do I change the position of the Products menu? I created it by hard coding, using the code below.</p>
<p><img src="https://i.stack.imgur.com/84PVu.png" alt="enter image description here"></p>
<pre><code>add_filter( 'the_content', 'filter_ptags_on_images' );
add_filter( 'wp_nav_menu_items', 'add_my_terms', 10, ... | [
{
"answer_id": 194589,
"author": "Trang",
"author_id": 70868,
"author_profile": "https://wordpress.stackexchange.com/users/70868",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, the function is_post_type_archive only works in archive.php\nTo have an item on nav menu links to your sta... | 2015/07/15 | [
"https://wordpress.stackexchange.com/questions/194612",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76247/"
] | How do I change the position of the Products menu? I created it by hard coding, using the code below.

```
add_filter( 'the_content', 'filter_ptags_on_images' );
add_filter( 'wp_nav_menu_items', 'add_my_terms', 10, 2 );
function add_my_terms( $items... | Ok, an answer to all. First, thank you for you help.
Anyway, none of your solutions really address my issue. I don't like custom links on nav menus, at all. And that's because they're not dynamic, you cannot build them dynamically. So when you move the site and change url (for example, from staging to production) you... |
194,618 | <p>I am including a pure PHP library (nothing to do with WordPress) into a few of my page templates. This library calls PHP session_start() function and references the $_SESSION["cart"] global variable. Because of the session_start I include the library at the top of my template.</p>
<p>When I am logged in the library... | [
{
"answer_id": 194621,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 4,
"selected": true,
"text": "<p>WordPress doesn't use PHP sessions, so WordPress itself can not be related with your sessions working or not r... | 2015/07/15 | [
"https://wordpress.stackexchange.com/questions/194618",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/71479/"
] | I am including a pure PHP library (nothing to do with WordPress) into a few of my page templates. This library calls PHP session\_start() function and references the $\_SESSION["cart"] global variable. Because of the session\_start I include the library at the top of my template.
When I am logged in the library functi... | WordPress doesn't use PHP sessions, so WordPress itself can not be related with your sessions working or not regarding if you are logged in or not (I think).
Try to call `session_start()` on `init` action instead of doing it in a template file and be sure it is called before your custom library is loaded. Also, it can... |
194,634 | <p>I just not only want to override a <code>pluggable function</code> (<code>wp_new_user_notification</code>) but I want to make sure that if any other plugin is overriding the same function, so my function , override that too or I want my overridden function to work instead of other plugin that is overriding the same ... | [
{
"answer_id": 194638,
"author": "TheGentleman",
"author_id": 68563,
"author_profile": "https://wordpress.stackexchange.com/users/68563",
"pm_score": 2,
"selected": false,
"text": "<p>The short answer to your question is yes; however, the methods to do this are a little bit hacky and gen... | 2015/07/15 | [
"https://wordpress.stackexchange.com/questions/194634",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75547/"
] | I just not only want to override a `pluggable function` (`wp_new_user_notification`) but I want to make sure that if any other plugin is overriding the same function, so my function , override that too or I want my overridden function to work instead of other plugin that is overriding the same function (`wp_new_user_no... | The short answer to your question is yes; however, the methods to do this are a little bit hacky and generally I would recommend against all of them unless absolutely necessary.
Since `pluggable functions` actually replace the stock function by way of `function_exists()` whichever plugin that "plugs" the function firs... |
194,635 | <p>I have a simple loop but it returns it in any order. What I'm looking for is to alphabetize the loop. I've tried a few different things but Can't seem to get it to work.</p>
<pre><code><?php
// Start the loop.
while ( have_posts() ) : the_post();
// Include the page content template.
get_template_par... | [
{
"answer_id": 194642,
"author": "leendertvb",
"author_id": 27308,
"author_profile": "https://wordpress.stackexchange.com/users/27308",
"pm_score": 2,
"selected": false,
"text": "<p>You have to alter the query and add the <code>orderby</code> argument specified as <code>name</code>. I wo... | 2015/07/15 | [
"https://wordpress.stackexchange.com/questions/194635",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54451/"
] | I have a simple loop but it returns it in any order. What I'm looking for is to alphabetize the loop. I've tried a few different things but Can't seem to get it to work.
```
<?php
// Start the loop.
while ( have_posts() ) : the_post();
// Include the page content template.
get_template_part( 'content', 'gri... | this is what worked for me. works a treat.
```
$child_pages = new WP_Query( array(
'orderby' => 'name',
'order' => 'ASC',
'cat' => '41'
) );
while ( $child_pages->have_posts() ) : $child_pages->the_post();
get_template_part( 'content', 'grid-projects' );
endwhile;
wp_reset_postdata();
``` |
194,706 | <p>I need to display max 5 latest sticky posts that have a thumbnail. And I need to have accurate counting of the displayed posts. I've tried to exclude sticky posts without a thumbnail with meta_query, but with no luck.</p>
<pre><code>$sticky = get_option('sticky_posts');
if (empty($sticky)) {
return;
}
$counte... | [
{
"answer_id": 194709,
"author": "Puni",
"author_id": 75322,
"author_profile": "https://wordpress.stackexchange.com/users/75322",
"pm_score": 0,
"selected": false,
"text": "<p>What you are doing is right except that you are careless or you just copied code from somewhere else and pasted ... | 2015/07/16 | [
"https://wordpress.stackexchange.com/questions/194706",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31277/"
] | I need to display max 5 latest sticky posts that have a thumbnail. And I need to have accurate counting of the displayed posts. I've tried to exclude sticky posts without a thumbnail with meta\_query, but with no luck.
```
$sticky = get_option('sticky_posts');
if (empty($sticky)) {
return;
}
$counter = 1;
$r = ... | You need to set `ignore_sticky_posts` to `true` in your query arguments. This way you exclude sticky posts and only focus on the post ID's array being passed to `post_in`
```
'ignore_sticky_posts' => true,
```
EDIT
----
If this does not make much sense, please see [my answer here](https://wordpress.stackexchange.co... |
194,792 | <p>In the media tab, upload of a valid image file results in display of "HTTP error".</p>
<p>Reload of the media tab shows that the image did upload and resize, though.</p>
<p>Browser debug tools show that on upload, browser is making a POST to wp-admin/async-upload.php. The server responds with a 500 error. The bo... | [
{
"answer_id": 195108,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 1,
"selected": false,
"text": "<p>This likely isn't exactly an issue caused by WordPress, but due to server configurations and/or set... | 2015/07/17 | [
"https://wordpress.stackexchange.com/questions/194792",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76335/"
] | In the media tab, upload of a valid image file results in display of "HTTP error".
Reload of the media tab shows that the image did upload and resize, though.
Browser debug tools show that on upload, browser is making a POST to wp-admin/async-upload.php. The server responds with a 500 error. The body of the response,... | I had the same issue and did not find any information in my debug output.
It worked out, that `DOING_AJAX` was not defined (I don't know why).
Changing the beginning of `async-upload.php` from
```
if ( isset( $_REQUEST['action'] ) && 'upload-attachment' === $_REQUEST['action'] ) {
define( 'DOING_AJAX', true );
}... |
194,812 | <p>Ive got the following code for a WordPRess plugin that essentially add two custom inputs on each page/post edit screen. The values are then saved and output in the header of the frontend page.</p>
<p>The code works fine if it is located inside a .php file and dropped straight into 'wp-content/plugins'. However, if ... | [
{
"answer_id": 195592,
"author": "Subharanjan",
"author_id": 13615,
"author_profile": "https://wordpress.stackexchange.com/users/13615",
"pm_score": 2,
"selected": false,
"text": "<p>Here is the fixed and modified code which was having the nonce action issue.</p>\n\n<pre><code><?php\n... | 2015/07/17 | [
"https://wordpress.stackexchange.com/questions/194812",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55152/"
] | Ive got the following code for a WordPRess plugin that essentially add two custom inputs on each page/post edit screen. The values are then saved and output in the header of the frontend page.
The code works fine if it is located inside a .php file and dropped straight into 'wp-content/plugins'. However, if I put it i... | Here is the fixed and modified code which was having the nonce action issue.
```
<?php
/*
Plugin Name: Test Plugin
Plugin URI: Test
Description: Test
Author: Test
Version: 007
Author URI:
*/
// add all post types
$clinical_post_types = array();
$post_types = get_post_types();
foreach ( $post_types as $post_t... |
194,840 | <p>I have created a page where user can see his favourite post which has been bookmarked by him </p>
<pre><code>get_user_favorites($user_id);
</code></pre>
<p>This function is responsible for returning me all the favourite posts bookmarked by user in an array.</p>
<p>I am using this approach to get the data from the... | [
{
"answer_id": 194850,
"author": "terminator",
"author_id": 55034,
"author_profile": "https://wordpress.stackexchange.com/users/55034",
"pm_score": 1,
"selected": false,
"text": "<p>Harman, don't use <code>get_posts()</code> when <code>pagination is required</code>. You may also accompli... | 2015/07/17 | [
"https://wordpress.stackexchange.com/questions/194840",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56650/"
] | I have created a page where user can see his favourite post which has been bookmarked by him
```
get_user_favorites($user_id);
```
This function is responsible for returning me all the favourite posts bookmarked by user in an array.
I am using this approach to get the data from the database and make it work inside... | My approach was also correct but the only problem was we were missing is that resetting the query before the post navigation links.
Here is the updated answer.
```
<?php $user_fav = get_user_favorites($user_id);
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'p... |
194,844 | <p>I recently created a website at www.volatileinterface.com, using WordPress. I am using the cyanotype theme and I wanted to create a custom 404 error page for when a webpage could not be found. I edited 404.php to look like this.</p>
<pre><code> <?php
get_header(); ?>
<div id="primary" class="conte... | [
{
"answer_id": 194845,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": true,
"text": "<p>WordPress doesn't receive those requests, so the server 404 displays. If you want WordPress to handle all 404s, use... | 2015/07/17 | [
"https://wordpress.stackexchange.com/questions/194844",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76345/"
] | I recently created a website at www.volatileinterface.com, using WordPress. I am using the cyanotype theme and I wanted to create a custom 404 error page for when a webpage could not be found. I edited 404.php to look like this.
```
<?php
get_header(); ?>
<div id="primary" class="content-area">
<div i... | WordPress doesn't receive those requests, so the server 404 displays. If you want WordPress to handle all 404s, use `mod_rewrite` Pretty Permalinks rather than `PATHINFO` permalinks. The requirements are detailed in [Using Permalinks](https://codex.wordpress.org/Using_Permalinks). |
194,849 | <p>I am trying to add avatars to my wordpress web site and I activated them through the settings - discussion as you would normally do. But because I have a very customised theme, I guess, it is not working.</p>
<p>That is the code in my functions.php, where it shows the author and the comment, but not the avatar/grav... | [
{
"answer_id": 194852,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": true,
"text": "<p>You're looking for the <code>get_avatar</code> function, <a href=\"https://codex.wordpress.org/Function_Refer... | 2015/07/17 | [
"https://wordpress.stackexchange.com/questions/194849",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50311/"
] | I am trying to add avatars to my wordpress web site and I activated them through the settings - discussion as you would normally do. But because I have a very customised theme, I guess, it is not working.
That is the code in my functions.php, where it shows the author and the comment, but not the avatar/gravatar:
```... | You're looking for the `get_avatar` function, [documented here](https://codex.wordpress.org/Function_Reference/get_avatar)
```
get_avatar( $id_or_email, $size, $default, $alt )
```
You'll need either a user ID, or an email to use it, something like this should do the trick:
```
echo get_avatar( get_comment_author_e... |
194,861 | <p>I'm trying to fix an error with pagination of WP page Navi plugin. After I've added posts_per_page parameter to the query I'm getting 404 error when clicking on link page3,4 etc (there are 10 records totally) and after page 8 (where there around 60 records totally). Without this parameter it works fine but I want to... | [
{
"answer_id": 194862,
"author": "EHerman",
"author_id": 43000,
"author_profile": "https://wordpress.stackexchange.com/users/43000",
"pm_score": 0,
"selected": false,
"text": "<p>You may want to take a look at this related issue:\n<a href=\"https://wordpress.stackexchange.com/questions/3... | 2015/07/17 | [
"https://wordpress.stackexchange.com/questions/194861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76363/"
] | I'm trying to fix an error with pagination of WP page Navi plugin. After I've added posts\_per\_page parameter to the query I'm getting 404 error when clicking on link page3,4 etc (there are 10 records totally) and after page 8 (where there around 60 records totally). Without this parameter it works fine but I want to ... | Finally, I've found an answer. Not sure if it's specific in my case or it's a general WP issue but default value for posts per page set up in WP admin (General > Reading > Maximum number of posts per page) should be less than value for posts\_per\_page parameter for custom query. In my case, I've changed in WP options ... |
194,868 | <p>In functions.php is it possible to dynamically set the static home page?</p>
<p>The condition could be anything, but for example by domain:</p>
<pre><code>if ( $_SERVER['HTTP_HOST'] == 'domain-one.com' )
set_front_page_slug('domain-one-home');
else if ( $_SERVER['HTTP_HOST'] == 'domain-two.com' )
set_front_pag... | [
{
"answer_id": 194884,
"author": "Harman Preet",
"author_id": 56650,
"author_profile": "https://wordpress.stackexchange.com/users/56650",
"pm_score": 0,
"selected": false,
"text": "<p>It's better that you should contact the plugin author for the problem you are facing. There is another a... | 2015/07/18 | [
"https://wordpress.stackexchange.com/questions/194868",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/71270/"
] | In functions.php is it possible to dynamically set the static home page?
The condition could be anything, but for example by domain:
```
if ( $_SERVER['HTTP_HOST'] == 'domain-one.com' )
set_front_page_slug('domain-one-home');
else if ( $_SERVER['HTTP_HOST'] == 'domain-two.com' )
set_front_page_slug('domain-two-ho... | After reading more about the google analytic site, I found that it can take a while for analytics to start working. After waiting a full night, analytics is now working perfectly. |
194,878 | <p>I am already logged in (with role administrator). If I try to login again with wp-login.php the form just shakes - the error message above the form remains empty. Following a suggestion on this forum I added the following code to my theme's function.php - it works:
/* Create error message for new login attempt i... | [
{
"answer_id": 194890,
"author": "Ihor Vorotnov",
"author_id": 47359,
"author_profile": "https://wordpress.stackexchange.com/users/47359",
"pm_score": 0,
"selected": false,
"text": "<p>Instead of working around the error message I would suggest checking if user is already logged in on wp... | 2015/07/18 | [
"https://wordpress.stackexchange.com/questions/194878",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76375/"
] | I am already logged in (with role administrator). If I try to login again with wp-login.php the form just shakes - the error message above the form remains empty. Following a suggestion on this forum I added the following code to my theme's function.php - it works:
/\* Create error message for new login attempt if use... | Instead of working around the error message I would suggest checking if user is already logged in on wp-login.php load. If user is logged in - redirect him/her to wp-admin. You can even add another check and, for example, redirect only administrators to wp-admin, redirect subscribers to site homepage etc.
```
add_acti... |
194,896 | <p>How can I add the following HTML code into one of my web pages? It's a web form that relies on css and a few java script.</p>
<p>Below is the raw HTML code.</p>
<pre><code><head>
<link href="css/style.css" rel="stylesheet">
<script src="js/jquery.min.js"></script>
<script sr... | [
{
"answer_id": 194902,
"author": "David in Mississippi",
"author_id": 76383,
"author_profile": "https://wordpress.stackexchange.com/users/76383",
"pm_score": 0,
"selected": false,
"text": "<p>Toodarday,</p>\n\n<p>For the code you want to put in your <head> section, you should do th... | 2015/07/18 | [
"https://wordpress.stackexchange.com/questions/194896",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76382/"
] | How can I add the following HTML code into one of my web pages? It's a web form that relies on css and a few java script.
Below is the raw HTML code.
```
<head>
<link href="css/style.css" rel="stylesheet">
<script src="js/jquery.min.js"></script>
<script src="js/slider.js"></script>
<script src="js/r... | Add CSS and JS Particular Page. Put this code in your current active theme function.php file
```
<?php
function function_name() {
is_page( 'about-me' ) //is_page( 'PAGE_SLUG_NAME' )
{
wp_enqueue_style( 'stylecss', get_template_directory_uri() .'/css/style.css','', '3.3.1' );
... |
194,898 | <p>I would like to display the other paths/pages which are before the current site, plus the current site as you can see here.</p>
<blockquote>
<p><a href="https://i.stack.imgur.com/rLOco.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rLOco.png" alt="screenshot"></a></p>
</blockquote>
<p>I searc... | [
{
"answer_id": 194902,
"author": "David in Mississippi",
"author_id": 76383,
"author_profile": "https://wordpress.stackexchange.com/users/76383",
"pm_score": 0,
"selected": false,
"text": "<p>Toodarday,</p>\n\n<p>For the code you want to put in your <head> section, you should do th... | 2015/07/18 | [
"https://wordpress.stackexchange.com/questions/194898",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I would like to display the other paths/pages which are before the current site, plus the current site as you can see here.
>
> [](https://i.stack.imgur.com/rLOco.png)
>
>
>
I searched the web and I couldn't found something. It may also be that I do not know what ... | Add CSS and JS Particular Page. Put this code in your current active theme function.php file
```
<?php
function function_name() {
is_page( 'about-me' ) //is_page( 'PAGE_SLUG_NAME' )
{
wp_enqueue_style( 'stylecss', get_template_directory_uri() .'/css/style.css','', '3.3.1' );
... |
194,906 | <p>I need help to finish this last bit of php code. I'm trying to create an admin options page similar to in admin>settings>discussions like how a user can select an avatar, but instead of selecting an avatar, the user selects a style option that makes a change to the theme (by enqueueing a CSS file on the frontend).</... | [
{
"answer_id": 194912,
"author": "Mahavar Hitesh",
"author_id": 75414,
"author_profile": "https://wordpress.stackexchange.com/users/75414",
"pm_score": 0,
"selected": false,
"text": "<p>Hay In wordpress theme you can add option panel you can not registre script or wp_enqueue_scripts you ... | 2015/07/18 | [
"https://wordpress.stackexchange.com/questions/194906",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50534/"
] | I need help to finish this last bit of php code. I'm trying to create an admin options page similar to in admin>settings>discussions like how a user can select an avatar, but instead of selecting an avatar, the user selects a style option that makes a change to the theme (by enqueueing a CSS file on the frontend).
My ... | I finally got it to work after a long time of trying to figure this out!
Credit to Samuel Elh for helping me, <http://sam.elegance-style.com/>
This is useful if anyone wants to allow users to make small style changes to a theme. Rather than create many child themes, if you just need some stylesheet overrules to make ... |
194,934 | <p>Is there an easy method of adding the last few words of the posts, added to the trimmed excerpt that is automatically generated for post displayed on category pages?</p>
<p>Currently it will only show the first given number of words, and I would like it to have the first few words and the last few words, something ... | [
{
"answer_id": 194937,
"author": "terminator",
"author_id": 55034,
"author_profile": "https://wordpress.stackexchange.com/users/55034",
"pm_score": 3,
"selected": true,
"text": "<p>You can achieve this by using the_excerpt filter. You can read further on the codex. Just paste this code ... | 2015/07/19 | [
"https://wordpress.stackexchange.com/questions/194934",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16198/"
] | Is there an easy method of adding the last few words of the posts, added to the trimmed excerpt that is automatically generated for post displayed on category pages?
Currently it will only show the first given number of words, and I would like it to have the first few words and the last few words, something like follo... | You can achieve this by using the\_excerpt filter. You can read further on the codex. Just paste this code in functions.php and set the value of $i = no of words from the end you want.
```
add_filter('the_excerpt','my_excerpt');
function my_excerpt(){
global $post;
$excerpt=get_the_exc... |
194,965 | <p>I am using the Plugin Visual Composer with in a new Theme I develop. My question is about mapping shortcodes to Visual Composer arrays.</p>
<p>The problem I get, when I try to make a custom element for an image. So here is what I did:</p>
<p>I created an php file <code>vc_shortcodes.php</code> for my arrays of par... | [
{
"answer_id": 203601,
"author": "Raffael Lima",
"author_id": 80907,
"author_profile": "https://wordpress.stackexchange.com/users/80907",
"pm_score": 2,
"selected": false,
"text": "<p>Visual Composer adds the image ID to the generated shortcode. This gives you more flexibility with image... | 2015/07/19 | [
"https://wordpress.stackexchange.com/questions/194965",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76425/"
] | I am using the Plugin Visual Composer with in a new Theme I develop. My question is about mapping shortcodes to Visual Composer arrays.
The problem I get, when I try to make a custom element for an image. So here is what I did:
I created an php file `vc_shortcodes.php` for my arrays of params. The matching shortcodes... | Visual Composer adds the image ID to the generated shortcode. This gives you more flexibility with image sizes. You can use it like this:
```
$imageSrc = wp_get_attachment_image_src($image_url, 'thumbnail');
if( $imageSrc ) {
echo '<img src="' . $imageSrc[0] . '" />';
}
```
The `thumbnail` param could be replace... |
194,983 | <p>I need to add a custom parameter/segment to the post URL. </p>
<p>For example, when I have a post at <code>example.com/post-name</code>, I need to add another segment like <code>example.com/post-name/places</code>. After that, I need to add a dynamic segment like <code>example.com/post-name/places/dynamic-value</co... | [
{
"answer_id": 203601,
"author": "Raffael Lima",
"author_id": 80907,
"author_profile": "https://wordpress.stackexchange.com/users/80907",
"pm_score": 2,
"selected": false,
"text": "<p>Visual Composer adds the image ID to the generated shortcode. This gives you more flexibility with image... | 2015/07/19 | [
"https://wordpress.stackexchange.com/questions/194983",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76437/"
] | I need to add a custom parameter/segment to the post URL.
For example, when I have a post at `example.com/post-name`, I need to add another segment like `example.com/post-name/places`. After that, I need to add a dynamic segment like `example.com/post-name/places/dynamic-value`.
I can't use `?key=value` parameters, ... | Visual Composer adds the image ID to the generated shortcode. This gives you more flexibility with image sizes. You can use it like this:
```
$imageSrc = wp_get_attachment_image_src($image_url, 'thumbnail');
if( $imageSrc ) {
echo '<img src="' . $imageSrc[0] . '" />';
}
```
The `thumbnail` param could be replace... |
194,987 | <p>I have woocommerce page for my products that is treated like an archive page. I need to get the ID for the archive page but obviously if I use <code>$post->ID</code> or <code>get_the_id()</code>, etc. I get the id for the most recent post on that page.</p>
| [
{
"answer_id": 194988,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": false,
"text": "<p>If this is a true page, then you can get the ID of that specific page with <code>get_queried_object_id(... | 2015/07/20 | [
"https://wordpress.stackexchange.com/questions/194987",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8278/"
] | I have woocommerce page for my products that is treated like an archive page. I need to get the ID for the archive page but obviously if I use `$post->ID` or `get_the_id()`, etc. I get the id for the most recent post on that page. | If this is a true page, then you can get the ID of that specific page with `get_queried_object_id()`. This works and will return the ID on the specific pages, single, category, taxonomy, tag and author pages where it is used. True date and time archives and the homepage will **not** have ID's
You can do the following
... |
194,997 | <p>Recently clean-installed (with exception of themes and content/upload folders) an old wordpress to the latest Wordpress 4.2.2.</p>
<p>I continue to get this error below whenever I load files such as style.css in the web browser manually. </p>
<p>I've tried:</p>
<ul>
<li>changing this file's permission to 644, 755... | [
{
"answer_id": 194988,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": false,
"text": "<p>If this is a true page, then you can get the ID of that specific page with <code>get_queried_object_id(... | 2015/07/20 | [
"https://wordpress.stackexchange.com/questions/194997",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76447/"
] | Recently clean-installed (with exception of themes and content/upload folders) an old wordpress to the latest Wordpress 4.2.2.
I continue to get this error below whenever I load files such as style.css in the web browser manually.
I've tried:
* changing this file's permission to 644, 755, and 777
* changing .c to .... | If this is a true page, then you can get the ID of that specific page with `get_queried_object_id()`. This works and will return the ID on the specific pages, single, category, taxonomy, tag and author pages where it is used. True date and time archives and the homepage will **not** have ID's
You can do the following
... |
195,000 | <p>I'm running a WordPress site and wanna setup a mobile site based on it. </p>
<p>I've tried some plugins like Mobile Themes which allows me to implement a different theme for mobile. The problem is when I use memcached, the main theme and mobile theme is confusing very often(e.g. access the site by mobile but meet a... | [
{
"answer_id": 194988,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": false,
"text": "<p>If this is a true page, then you can get the ID of that specific page with <code>get_queried_object_id(... | 2015/07/20 | [
"https://wordpress.stackexchange.com/questions/195000",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75850/"
] | I'm running a WordPress site and wanna setup a mobile site based on it.
I've tried some plugins like Mobile Themes which allows me to implement a different theme for mobile. The problem is when I use memcached, the main theme and mobile theme is confusing very often(e.g. access the site by mobile but meet a main them... | If this is a true page, then you can get the ID of that specific page with `get_queried_object_id()`. This works and will return the ID on the specific pages, single, category, taxonomy, tag and author pages where it is used. True date and time archives and the homepage will **not** have ID's
You can do the following
... |
195,025 | <p>I have a post and payment page
each posts contain a payment form</p>
<p>I want to know how I can retrieve the data to I can execute and publish where the post payment came from</p>
<p>on payment form submit</p>
<pre><code> $return = array('success' => true, 'msg' => 'Payment Successful',
'curren... | [
{
"answer_id": 194988,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": false,
"text": "<p>If this is a true page, then you can get the ID of that specific page with <code>get_queried_object_id(... | 2015/07/20 | [
"https://wordpress.stackexchange.com/questions/195025",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44422/"
] | I have a post and payment page
each posts contain a payment form
I want to know how I can retrieve the data to I can execute and publish where the post payment came from
on payment form submit
```
$return = array('success' => true, 'msg' => 'Payment Successful',
'current_post_id' => get_the_ID(),'paymen... | If this is a true page, then you can get the ID of that specific page with `get_queried_object_id()`. This works and will return the ID on the specific pages, single, category, taxonomy, tag and author pages where it is used. True date and time archives and the homepage will **not** have ID's
You can do the following
... |
195,032 | <p>Im having an issue if i want to login to the dashboard, it needs a "Database Update Required"</p>
<p>I'd like to disable it, because once it update the Database, if I go to any post of single-pages, it display all my post in loop . .. . If i recover my database before this update - everything is working correctly... | [
{
"answer_id": 195058,
"author": "xyulex",
"author_id": 76474,
"author_profile": "https://wordpress.stackexchange.com/users/76474",
"pm_score": 1,
"selected": false,
"text": "<p>If you get that Database update message, looks like WordPress may have updated.</p>\n\n<p>Probably you want to... | 2015/07/20 | [
"https://wordpress.stackexchange.com/questions/195032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54146/"
] | Im having an issue if i want to login to the dashboard, it needs a "Database Update Required"
I'd like to disable it, because once it update the Database, if I go to any post of single-pages, it display all my post in loop . .. . If i recover my database before this update - everything is working correctly.
Any Idea ... | If you get that Database update message, looks like WordPress may have updated.
Probably you want to turn automatic updates off.
Simply do:
----------
1 - Restore your db where it works ok
2 - Add this to your `wp-config.php`:
```
define( 'AUTOMATIC_UPDATER_DISABLED', true );
```
3 - Enjoy! |
195,053 | <p>I am using <a href="https://wordpress.org/plugins/wp-pagenavi/" rel="nofollow">WP-PageNavi</a> pagination and because of certain reasons I have "Blog pages show at most" set to 100 and I can't reduce it. </p>
<p>I have a total of 30 posts in a category. I want to display 10 posts on each page but it doesn't display... | [
{
"answer_id": 195060,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>Do not run custom queries in place of the main query on the home page and any type of archive page. This... | 2015/07/20 | [
"https://wordpress.stackexchange.com/questions/195053",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36035/"
] | I am using [WP-PageNavi](https://wordpress.org/plugins/wp-pagenavi/) pagination and because of certain reasons I have "Blog pages show at most" set to 100 and I can't reduce it.
I have a total of 30 posts in a category. I want to display 10 posts on each page but it doesn't display pagination; it displays only if a c... | Do not run custom queries in place of the main query on the home page and any type of archive page. This will always cause an issue. If you need to alter the main query, use `pre_get_posts` to do so.
To solve this issue, you need remove your code from your category page and go back to the default loop. You should onl... |
195,067 | <p>Version 4.2.1 of WordPress removed the link text from the Insert/edit link box. </p>
<p>How can i add it back?</p>
| [
{
"answer_id": 195060,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>Do not run custom queries in place of the main query on the home page and any type of archive page. This... | 2015/07/20 | [
"https://wordpress.stackexchange.com/questions/195067",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76479/"
] | Version 4.2.1 of WordPress removed the link text from the Insert/edit link box.
How can i add it back? | Do not run custom queries in place of the main query on the home page and any type of archive page. This will always cause an issue. If you need to alter the main query, use `pre_get_posts` to do so.
To solve this issue, you need remove your code from your category page and go back to the default loop. You should onl... |
195,087 | <p>I'm using WordPress 4.2.2 and every time I add an image to the wysiwyg it wraps the outputed image in a paragraph tag. I need to strip out these tags. Everything I seem to find online is from 2011 plus it doesn't seem to work.</p>
<p>I have tried putting things in the functions.php like:</p>
<pre><code>function fi... | [
{
"answer_id": 195097,
"author": "Bryan Willis",
"author_id": 38123,
"author_profile": "https://wordpress.stackexchange.com/users/38123",
"pm_score": 4,
"selected": true,
"text": "<p><strong>1) Filter wpautop() with ACF:</strong></p>\n\n<pre><code>function filter_ptags_on_images($content... | 2015/07/20 | [
"https://wordpress.stackexchange.com/questions/195087",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56854/"
] | I'm using WordPress 4.2.2 and every time I add an image to the wysiwyg it wraps the outputed image in a paragraph tag. I need to strip out these tags. Everything I seem to find online is from 2011 plus it doesn't seem to work.
I have tried putting things in the functions.php like:
```
function filter_ptags_on_images(... | **1) Filter wpautop() with ACF:**
```
function filter_ptags_on_images($content) {
$content = preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
return preg_replace('/<p>\s*(<iframe .*>*.<\/iframe>)\s*<\/p>/iU', '\1', $content);
}
add_filter('acf_the_content', 'filter_pt... |
195,196 | <p>I am trying to change default Gravatar size. Since I am using WP-generated comments template (using comments_template() function), I turned to filters and this is my custom code:</p>
<pre><code>function change_avatar_size ( $id_or_email, $size = 100, $default = '', $alt = '', $args = null ) {
$args['size'] ... | [
{
"answer_id": 195268,
"author": "Bruno Kos",
"author_id": 19499,
"author_profile": "https://wordpress.stackexchange.com/users/19499",
"pm_score": 0,
"selected": false,
"text": "<p>Found it - no need to bother with filters, given that there is avatar_size parameter within wp_list_comment... | 2015/07/21 | [
"https://wordpress.stackexchange.com/questions/195196",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19499/"
] | I am trying to change default Gravatar size. Since I am using WP-generated comments template (using comments\_template() function), I turned to filters and this is my custom code:
```
function change_avatar_size ( $id_or_email, $size = 100, $default = '', $alt = '', $args = null ) {
$args['size'] = (int) $size... | Here's how to do it using the method Bruno went with (for others wondering this):
```
wp_list_comments( array(
'avatar_size' => 32
) );
```
You can also do it [this way](https://wordpress.stackexchange.com/a/210633/43806) depending on your use case:
```
global $comment;
echo get_avatar($comment, 64)
``` |
195,221 | <p>This seems to be common issue, and there exist a lot of posts about this issue but none of them works for me.</p>
<p>I have a custom post type (portfolio) with a page pagination.</p>
<pre><code>$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
echo '<a href="'.get_pagenum_link($paged+1).'">Next... | [
{
"answer_id": 196671,
"author": "Jose Andres Cordova",
"author_id": 77309,
"author_profile": "https://wordpress.stackexchange.com/users/77309",
"pm_score": 0,
"selected": false,
"text": "<p>I had the same case and I was going crazy and tested\nDisable canonical redirection for this case... | 2015/07/22 | [
"https://wordpress.stackexchange.com/questions/195221",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28159/"
] | This seems to be common issue, and there exist a lot of posts about this issue but none of them works for me.
I have a custom post type (portfolio) with a page pagination.
```
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
echo '<a href="'.get_pagenum_link($paged+1).'">Next Page</a>';
```
When Set ... | Paste this function to your `functions.php` file
```
if ( ! function_exists( 'custom_pagination' ) ) {
function custom_pagination( $query_args ) {
$big = 999999999; // need an unlikely integer
$pages = paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_page... |
195,318 | <p>To include new functions we can write them in the theme's functions.php. But I have to write my own functions in a new file rather altering the theme's function.php. I can write any custom js action in footer.php, but I need to write it in other file. How can I do this? Is there any correct way to do this? </p>
| [
{
"answer_id": 195320,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 2,
"selected": true,
"text": "<p>You can simply use <code>require</code>, <code>require_once</code>, <code>include</code> or <code>include_o... | 2015/07/23 | [
"https://wordpress.stackexchange.com/questions/195318",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70398/"
] | To include new functions we can write them in the theme's functions.php. But I have to write my own functions in a new file rather altering the theme's function.php. I can write any custom js action in footer.php, but I need to write it in other file. How can I do this? Is there any correct way to do this? | You can simply use `require`, `require_once`, `include` or `include_once` functions to include custom PHP files in your theme.
```
require( 'folder/custom.php' );
```
Usually you should keep your custom PHP files in a folder.
Developers [vote against using](https://stackoverflow.com/questions/186338/why-is-require-... |
195,335 | <p>This is the resulting html I want to produce with a shortcode - when editing page content in WordPress:</p>
<pre><code><div class="shadow-wrapper half-shadow im-centered">
<div class="box-shadow shadow-effect-2">
<div class="servive-block servive-block-bluemed">
Lorem ... | [
{
"answer_id": 195320,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 2,
"selected": true,
"text": "<p>You can simply use <code>require</code>, <code>require_once</code>, <code>include</code> or <code>include_o... | 2015/07/23 | [
"https://wordpress.stackexchange.com/questions/195335",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68052/"
] | This is the resulting html I want to produce with a shortcode - when editing page content in WordPress:
```
<div class="shadow-wrapper half-shadow im-centered">
<div class="box-shadow shadow-effect-2">
<div class="servive-block servive-block-bluemed">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec nec ... | You can simply use `require`, `require_once`, `include` or `include_once` functions to include custom PHP files in your theme.
```
require( 'folder/custom.php' );
```
Usually you should keep your custom PHP files in a folder.
Developers [vote against using](https://stackoverflow.com/questions/186338/why-is-require-... |
195,353 | <p>I am using wordpress 4.2.2 and i am using buddypress latest version. I want all my users customize their profile at buddypress profile page. So i want to disable profile.php for the users. I hide the profile link from dashboard by the WP admin UI customize plugin.But when anyone type url mysite/wp-admin/profile.php ... | [
{
"answer_id": 195357,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 2,
"selected": false,
"text": "<p>The following code* will redirect non-admin to a custom profile page in the front end, because instead... | 2015/07/23 | [
"https://wordpress.stackexchange.com/questions/195353",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75682/"
] | I am using wordpress 4.2.2 and i am using buddypress latest version. I want all my users customize their profile at buddypress profile page. So i want to disable profile.php for the users. I hide the profile link from dashboard by the WP admin UI customize plugin.But when anyone type url mysite/wp-admin/profile.php it'... | Redirect from `profile.php` to the dashboard
--------------------------------------------
Here's one way to do it:
```
add_action( 'load-profile.php', function() {
if( ! current_user_can( 'manage_options' ) )
exit( wp_safe_redirect( admin_url() ) );
} );
```
where we redirect to the dashboard instead, i... |
195,356 | <p>I know that WordPress has a faux cron that is called like so when a user visits the page. </p>
<pre><code>register_activation_hook(__FILE__, 'my_activation');
add_action('my_hourly_event', 'do_this_hourly');
function my_activation() {
wp_schedule_event(time(), 'hourly', 'my_hourly_event');
}
function do_this_... | [
{
"answer_id": 195357,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 2,
"selected": false,
"text": "<p>The following code* will redirect non-admin to a custom profile page in the front end, because instead... | 2015/07/23 | [
"https://wordpress.stackexchange.com/questions/195356",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48204/"
] | I know that WordPress has a faux cron that is called like so when a user visits the page.
```
register_activation_hook(__FILE__, 'my_activation');
add_action('my_hourly_event', 'do_this_hourly');
function my_activation() {
wp_schedule_event(time(), 'hourly', 'my_hourly_event');
}
function do_this_hourly() {
... | Redirect from `profile.php` to the dashboard
--------------------------------------------
Here's one way to do it:
```
add_action( 'load-profile.php', function() {
if( ! current_user_can( 'manage_options' ) )
exit( wp_safe_redirect( admin_url() ) );
} );
```
where we redirect to the dashboard instead, i... |
195,362 | <p>I've got a realy hair pulling problem here.</p>
<p>I've started cleaning up a plugin i've made and sort some of the functions in diffrent files.</p>
<p>but i've got a problem with wp_enqueue_scripts.</p>
<p>when i place the function where i register and enqueue in the main php file and try to enqueue my script fr... | [
{
"answer_id": 195380,
"author": "Harry",
"author_id": 76642,
"author_profile": "https://wordpress.stackexchange.com/users/76642",
"pm_score": 0,
"selected": false,
"text": "<p>You have to place the enqueue code with in a function and use add_action to call the function where you registe... | 2015/07/23 | [
"https://wordpress.stackexchange.com/questions/195362",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69346/"
] | I've got a realy hair pulling problem here.
I've started cleaning up a plugin i've made and sort some of the functions in diffrent files.
but i've got a problem with wp\_enqueue\_scripts.
when i place the function where i register and enqueue in the main php file and try to enqueue my script from there it works as i... | I found the problem....
I ran main.php like:
```
function run_this(){
include'path/to/other.php';
}
add_shortcode('shortcode', 'run_this');
```
And most of the content of other.php came up exept the hooks did'nt work
then i tried using `add_action('init', 'run_this');` and then it worked....
exept that i get a fat... |
195,377 | <p>With the release of Chrome Version 44.0.2403.89 m, I've noticed that our site is now completely broken. All of the HTTP URLs are being redirected to HTTPS URLs, which is a problem because our site does <strong>not</strong> support HTTPS. </p>
<p>Please note, this is not happening in any other browser, and was worki... | [
{
"answer_id": 195397,
"author": "Stepan",
"author_id": 76656,
"author_profile": "https://wordpress.stackexchange.com/users/76656",
"pm_score": 4,
"selected": true,
"text": "<p><strong>Solution 1:</strong> \nEnable mod_header on the server and added this rule to my appache2.conf file:</p... | 2015/07/23 | [
"https://wordpress.stackexchange.com/questions/195377",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64518/"
] | With the release of Chrome Version 44.0.2403.89 m, I've noticed that our site is now completely broken. All of the HTTP URLs are being redirected to HTTPS URLs, which is a problem because our site does **not** support HTTPS.
Please note, this is not happening in any other browser, and was working on the previous Chro... | **Solution 1:**
Enable mod\_header on the server and added this rule to my appache2.conf file:
```
<IfModule mod_headers.c>
RequestHeader unset HTTPS
</IfModule>
```
**Solution 2:**
Or you need to add the code to fonction.php file of your current theme:
```
function https_chrome44fix() {
$_SERVER['HTTPS'] = fa... |
195,425 | <p>I would like to display 6 featured products from my woocommerce store on my home-page.php template. After some researched I found that the right way to do this was through a custom loop,( I do not wish to use shortcodes because I would like to add additional classes for styling etc. ) I also found that the key that ... | [
{
"answer_id": 202739,
"author": "Hooman Askari",
"author_id": 31189,
"author_profile": "https://wordpress.stackexchange.com/users/31189",
"pm_score": 5,
"selected": true,
"text": "<p>Change your args to be like this:</p>\n\n<pre><code>$meta_query = WC()->query->get_meta_query();... | 2015/07/23 | [
"https://wordpress.stackexchange.com/questions/195425",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67512/"
] | I would like to display 6 featured products from my woocommerce store on my home-page.php template. After some researched I found that the right way to do this was through a custom loop,( I do not wish to use shortcodes because I would like to add additional classes for styling etc. ) I also found that the key that woo... | Change your args to be like this:
```
$meta_query = WC()->query->get_meta_query();
$meta_query[] = array(
'key' => '_featured',
'value' => 'yes'
);
$args = array(
'post_type' => 'product',
'stock' => 1,
'showposts' => 6,
'orderby' => 'date',
'order' => 'DESC',
... |
195,434 | <p>I want to update my old website with WordPress but I got some problems...
Is it possible to create a website without domain name (before publish) and replace it with my old website domain name as soon as i finish building the new one?
Basically, I want to keep my old website (not built by WordPress) while I am worki... | [
{
"answer_id": 202739,
"author": "Hooman Askari",
"author_id": 31189,
"author_profile": "https://wordpress.stackexchange.com/users/31189",
"pm_score": 5,
"selected": true,
"text": "<p>Change your args to be like this:</p>\n\n<pre><code>$meta_query = WC()->query->get_meta_query();... | 2015/07/24 | [
"https://wordpress.stackexchange.com/questions/195434",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76680/"
] | I want to update my old website with WordPress but I got some problems...
Is it possible to create a website without domain name (before publish) and replace it with my old website domain name as soon as i finish building the new one?
Basically, I want to keep my old website (not built by WordPress) while I am working ... | Change your args to be like this:
```
$meta_query = WC()->query->get_meta_query();
$meta_query[] = array(
'key' => '_featured',
'value' => 'yes'
);
$args = array(
'post_type' => 'product',
'stock' => 1,
'showposts' => 6,
'orderby' => 'date',
'order' => 'DESC',
... |
195,452 | <p>I am using wp_schedule_event for Insert data every 1 Minutes in a teble. But here is some confusion where i have to add code for Insert.
Here is my code which add in functions.php in my theme. </p>
<pre><code>register_activation_hook(__FILE__, 'my_activation');
add_action('my_hourly_event', 'do_this_hourly');
func... | [
{
"answer_id": 202739,
"author": "Hooman Askari",
"author_id": 31189,
"author_profile": "https://wordpress.stackexchange.com/users/31189",
"pm_score": 5,
"selected": true,
"text": "<p>Change your args to be like this:</p>\n\n<pre><code>$meta_query = WC()->query->get_meta_query();... | 2015/07/24 | [
"https://wordpress.stackexchange.com/questions/195452",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68882/"
] | I am using wp\_schedule\_event for Insert data every 1 Minutes in a teble. But here is some confusion where i have to add code for Insert.
Here is my code which add in functions.php in my theme.
```
register_activation_hook(__FILE__, 'my_activation');
add_action('my_hourly_event', 'do_this_hourly');
function my_acti... | Change your args to be like this:
```
$meta_query = WC()->query->get_meta_query();
$meta_query[] = array(
'key' => '_featured',
'value' => 'yes'
);
$args = array(
'post_type' => 'product',
'stock' => 1,
'showposts' => 6,
'orderby' => 'date',
'order' => 'DESC',
... |
195,465 | <p>I am trying to get the categories of my custom post type in functions.php But it not return any value, when i run this query in any theme file it work fine. Here is my code</p>
<pre><code>function get_destinations(){
$args = array(
'type' => 'accomodation',
'child_of' ... | [
{
"answer_id": 195481,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>You are using third party code to generate those meta boxes, and I am not familiar with how that code works.... | 2015/07/24 | [
"https://wordpress.stackexchange.com/questions/195465",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55372/"
] | I am trying to get the categories of my custom post type in functions.php But it not return any value, when i run this query in any theme file it work fine. Here is my code
```
function get_destinations(){
$args = array(
'type' => 'accomodation',
'child_of' => 0,
'par... | You are using third party code to generate those meta boxes, and I am not familiar with how that code works. In fact, based on your question I am not even sure exactly where the code fails. Your description of the problem is inadequate. I can point out that your code is overly complex. It can be simplified considerably... |
195,557 | <p>I've created a custom child theme of parent theme Cordillera.</p>
<p>This is my child theme's header.php (<code><head></code>): </p>
<pre><code><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
... | [
{
"answer_id": 196512,
"author": "Syed Priom",
"author_id": 48577,
"author_profile": "https://wordpress.stackexchange.com/users/48577",
"pm_score": -1,
"selected": false,
"text": "<p>What I'd try to do is applying <code>!important</code> to wp-admin native styles. But that would be costl... | 2015/07/25 | [
"https://wordpress.stackexchange.com/questions/195557",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | I've created a custom child theme of parent theme Cordillera.
This is my child theme's header.php (`<head>`):
```
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<?php wp_head... | Restructure your CSS files and remove `!important` rules from your `.css` files and use proper markup (classes, IDs and etc.).
e.g.
```
a, .entry-summary a, .entry-content a {
color: #06F !important;
font-weight: 400;
}
```
Judging from the test WS which was found with site: search in Google using the URL in yo... |
195,565 | <p>I've been trying for hours if not a day to try and get my custom <code>search.php</code> and <code>searchform.php</code> to work and still no success. I've read a lot on these two templates and still no success.</p>
<p>Here is my <code>search.php</code>:</p>
<pre><code><div class="post-wrap">
<... | [
{
"answer_id": 196512,
"author": "Syed Priom",
"author_id": 48577,
"author_profile": "https://wordpress.stackexchange.com/users/48577",
"pm_score": -1,
"selected": false,
"text": "<p>What I'd try to do is applying <code>!important</code> to wp-admin native styles. But that would be costl... | 2015/07/25 | [
"https://wordpress.stackexchange.com/questions/195565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55212/"
] | I've been trying for hours if not a day to try and get my custom `search.php` and `searchform.php` to work and still no success. I've read a lot on these two templates and still no success.
Here is my `search.php`:
```
<div class="post-wrap">
<?php if ( have_posts() ) : while (have_posts()) : the_post(); ?>
... | Restructure your CSS files and remove `!important` rules from your `.css` files and use proper markup (classes, IDs and etc.).
e.g.
```
a, .entry-summary a, .entry-content a {
color: #06F !important;
font-weight: 400;
}
```
Judging from the test WS which was found with site: search in Google using the URL in yo... |
195,576 | <p>I have been trying to make my Wordpress Gallery responsive with the help from another post:
<a href="https://wordpress.stackexchange.com/questions/185961/making-wordpress-gallery-gallery-item-responsive/185965#185965">Making WordPress Gallery (.gallery-item) Responsive?</a></p>
<p>I would also like the original 5-c... | [
{
"answer_id": 196512,
"author": "Syed Priom",
"author_id": 48577,
"author_profile": "https://wordpress.stackexchange.com/users/48577",
"pm_score": -1,
"selected": false,
"text": "<p>What I'd try to do is applying <code>!important</code> to wp-admin native styles. But that would be costl... | 2015/07/25 | [
"https://wordpress.stackexchange.com/questions/195576",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76769/"
] | I have been trying to make my Wordpress Gallery responsive with the help from another post:
[Making WordPress Gallery (.gallery-item) Responsive?](https://wordpress.stackexchange.com/questions/185961/making-wordpress-gallery-gallery-item-responsive/185965#185965)
I would also like the original 5-column gallery to disp... | Restructure your CSS files and remove `!important` rules from your `.css` files and use proper markup (classes, IDs and etc.).
e.g.
```
a, .entry-summary a, .entry-content a {
color: #06F !important;
font-weight: 400;
}
```
Judging from the test WS which was found with site: search in Google using the URL in yo... |
195,603 | <p>How to add users roles dropdown in registration in wordpress</p>
<pre><code> function myplugin_register_form() {
global $wp_roles;
echo '<select name="role">';
foreach ( $wp_roles->roles as $key=>$value ):
echo '<option value="'.$key.'">'.$value['name'].'</option>';
endforeach;
echo '&... | [
{
"answer_id": 195604,
"author": "sohan",
"author_id": 69017,
"author_profile": "https://wordpress.stackexchange.com/users/69017",
"pm_score": -1,
"selected": false,
"text": "<pre><code><?php global $wp_roles; ?>\n\n<select name=\"role\">\n<?php foreach ( $wp_roles->rol... | 2015/07/26 | [
"https://wordpress.stackexchange.com/questions/195603",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76780/"
] | How to add users roles dropdown in registration in wordpress
```
function myplugin_register_form() {
global $wp_roles;
echo '<select name="role">';
foreach ( $wp_roles->roles as $key=>$value ):
echo '<option value="'.$key.'">'.$value['name'].'</option>';
endforeach;
echo '</select>';
}
add_action( 'register_for... | 1. <https://codex.wordpress.org/Customizing_the_Registration_Form>
2. <https://codex.wordpress.org/Function_Reference/wp_update_user>
Instead of **update\_user\_meta** function in user\_register hook use **wp\_update\_user**
Following is the working example:
```
//1. Add a new form element...
add_action( 'register_f... |
195,631 | <p>Hello all i am struggling for days now, and i hope one of you can help me
i have a custom post type called events and i like to show only events that date is today and upcoming but i couldnt get it to work , what am i doing wrong ?</p>
<p>here is my code so far: </p>
<pre><code><?php
$paged = ( get_query_var('... | [
{
"answer_id": 195604,
"author": "sohan",
"author_id": 69017,
"author_profile": "https://wordpress.stackexchange.com/users/69017",
"pm_score": -1,
"selected": false,
"text": "<pre><code><?php global $wp_roles; ?>\n\n<select name=\"role\">\n<?php foreach ( $wp_roles->rol... | 2015/07/26 | [
"https://wordpress.stackexchange.com/questions/195631",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20808/"
] | Hello all i am struggling for days now, and i hope one of you can help me
i have a custom post type called events and i like to show only events that date is today and upcoming but i couldnt get it to work , what am i doing wrong ?
here is my code so far:
```
<?php
$paged = ( get_query_var('paged') ) ?get_query_var(... | 1. <https://codex.wordpress.org/Customizing_the_Registration_Form>
2. <https://codex.wordpress.org/Function_Reference/wp_update_user>
Instead of **update\_user\_meta** function in user\_register hook use **wp\_update\_user**
Following is the working example:
```
//1. Add a new form element...
add_action( 'register_f... |
195,634 | <p>I am using <a href="http://ultimate%20member%20plugin" rel="nofollow">UltimateMember</a> and I have the settings configured that admin must approve registered users first. I now want to display the approved users meta information like faculty, email, etc. in the theme. So in this page template I've the following blo... | [
{
"answer_id": 195647,
"author": "Webloper",
"author_id": 29035,
"author_profile": "https://wordpress.stackexchange.com/users/29035",
"pm_score": 3,
"selected": true,
"text": "<p>I assume your WP settings is <br/></p>\n\n<ol>\n<li>New User Default Role = contributor</li>\n</ol>\n\n<p>... | 2015/07/26 | [
"https://wordpress.stackexchange.com/questions/195634",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62794/"
] | I am using [UltimateMember](http://ultimate%20member%20plugin) and I have the settings configured that admin must approve registered users first. I now want to display the approved users meta information like faculty, email, etc. in the theme. So in this page template I've the following block of code to get all registe... | I assume your WP settings is
1. New User Default Role = contributor
If yes, so this block of code shows all the contributor's with account\_status = approved;
```
$args = array(
'role' => 'contributor',
'meta_key' => 'account_status',
'meta_value' => 'approved'
);
$users = get_use... |
195,641 | <p><strong>Clarification</strong>: My default header image will not <strong>RE-display</strong> (by clicking suggested image) after it has been removed using theme customizer "Hide Image" option.</p>
<ol>
<li><p>I added theme support for Custom Header Image</p>
<pre><code>// Add Theme Support for Custom Header Image
... | [
{
"answer_id": 196485,
"author": "dewd",
"author_id": 73424,
"author_profile": "https://wordpress.stackexchange.com/users/73424",
"pm_score": 0,
"selected": false,
"text": "<p>Try this where you need to get the url of the header image and you have set the default:</p>\n\n<pre><code> $... | 2015/07/26 | [
"https://wordpress.stackexchange.com/questions/195641",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12116/"
] | **Clarification**: My default header image will not **RE-display** (by clicking suggested image) after it has been removed using theme customizer "Hide Image" option.
1. I added theme support for Custom Header Image
```
// Add Theme Support for Custom Header Image
add_theme_support( 'custom-header',
array(
... | You should register the default headers using `register_defaults_headers` - e.g.
```
register_default_headers( array(
'default-image' => array(
'url' => get_stylesheet_directory_uri() . '/assets/img/default-header.jpg',
'thumbnail_url' => get_stylesheet_directory_uri() . '/assets/img/defa... |
195,665 | <p>This is on Vanilla installation. I've made a shortcode:-</p>
<pre><code>/**
* Creates a shortcode for shortcode_use_here
* @author Omar Tariq <XXXXXX@gmail.com>
*/
function callback_banana_abc( $args ){
/* Don't echo! Always return */
return 'yay!';
}
add_shortcode( 'banana_abc', 'callback_banana... | [
{
"answer_id": 195666,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>I cannot reproduce your problem but the way you are using the shortcode to construct small pieces of that st... | 2015/07/27 | [
"https://wordpress.stackexchange.com/questions/195665",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36718/"
] | This is on Vanilla installation. I've made a shortcode:-
```
/**
* Creates a shortcode for shortcode_use_here
* @author Omar Tariq <XXXXXX@gmail.com>
*/
function callback_banana_abc( $args ){
/* Don't echo! Always return */
return 'yay!';
}
add_shortcode( 'banana_abc', 'callback_banana_abc' );
```
And I... | `do_shortcodes_in_html_tags()` runs attributes through `wp_kses_one_attr()` which checks them against `wp_kses_allowed_html( 'post' )` which by default only accepts standard non-data attributes, so you'd have to add your attribute:
```
add_filter( 'wp_kses_allowed_html', function ( $allowedposttags, $context ) {
i... |
195,682 | <p>I have <code>nav_menu_options</code> in my Wordpress database as below.</p>
<pre><code>284,'nav_menu_options','a:2:{i:0;b:0;s:8:\"auto_add\";a:0:{}}'
</code></pre>
<p>I tried to deserialize this value but the result is empty string - I put a code snippet in <code><my theme>/function.php</code> as below</p>
... | [
{
"answer_id": 195716,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>Your problem is that serialized strings contains escape slashes that are not evaluated as such, because the <e... | 2015/07/27 | [
"https://wordpress.stackexchange.com/questions/195682",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/992/"
] | I have `nav_menu_options` in my Wordpress database as below.
```
284,'nav_menu_options','a:2:{i:0;b:0;s:8:\"auto_add\";a:0:{}}'
```
I tried to deserialize this value but the result is empty string - I put a code snippet in `<my theme>/function.php` as below
```
echo 'TRY #1'.'<br>';
$v = 'a:2:{i:0;b:0;s:8:\"auto_ad... | Your problem is that serialized strings contains escape slashes that are not evaluated as such, because the *wrapping* quote is a single quote.
You are using:
```
$v = 'a:2:{i:0;b:0;s:8:\"auto_add\";a:0:{}}'; // wrong
```
You have to use either
```
$v = "a:2:{i:0;b:0;s:8:\"auto_add\";a:0:{}}"; // ok
```
or
```
... |
195,688 | <p>I've written a code in a WP_Query to converting a string (the_content) to an array (choices). But it seems wrong! In fact, the choices array is empty after each loop. However str string is notnull. How can i handle this array to be nutnull?
Any help would be appreciated.</p>
<pre><code>$first_query = new WP_Query( ... | [
{
"answer_id": 195690,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>You have a couple of issues here</p>\n\n<ul>\n<li><p><code>the_content()</code> echos the content to scr... | 2015/07/27 | [
"https://wordpress.stackexchange.com/questions/195688",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/71448/"
] | I've written a code in a WP\_Query to converting a string (the\_content) to an array (choices). But it seems wrong! In fact, the choices array is empty after each loop. However str string is notnull. How can i handle this array to be nutnull?
Any help would be appreciated.
```
$first_query = new WP_Query( $args );
... | You have a couple of issues here
* `the_content()` echos the content to screen. You should be using `get_the_content()` which returns the content. Just remember, `get_the_content()` is unfiltered, so if you need filtered content, use `apply_filters( 'the_content', get_the_content() )` which will return filtered conten... |
195,736 | <p>I want to work with html form but i cant understand the Action method and when we need to use it.
For example found this code on w3schools:</p>
<pre><code><form action="action_page.php">
First name:<br>
<input type="text" value="Mickey">
<br>
Last name:<br>
<input type="text" name=... | [
{
"answer_id": 195690,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>You have a couple of issues here</p>\n\n<ul>\n<li><p><code>the_content()</code> echos the content to scr... | 2015/07/27 | [
"https://wordpress.stackexchange.com/questions/195736",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/71455/"
] | I want to work with html form but i cant understand the Action method and when we need to use it.
For example found this code on w3schools:
```
<form action="action_page.php">
First name:<br>
<input type="text" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="... | You have a couple of issues here
* `the_content()` echos the content to screen. You should be using `get_the_content()` which returns the content. Just remember, `get_the_content()` is unfiltered, so if you need filtered content, use `apply_filters( 'the_content', get_the_content() )` which will return filtered conten... |
195,743 | <p>I am sturggling with how authentication works in my scenario.</p>
<p>I have Wordpress site which provides set of custom APIs secured behind <code>oAuth2 Authentication</code> using <a href="https://wordpress.org/plugins/oauth2-provider/" rel="nofollow">Wp OAuth Server</a> plugin. </p>
<p>I started with building si... | [
{
"answer_id": 198867,
"author": "Justin P Greer",
"author_id": 77908,
"author_profile": "https://wordpress.stackexchange.com/users/77908",
"pm_score": 1,
"selected": false,
"text": "<p>You will have to follow the details from the developers website located <a href=\"https://wp-oauth.com... | 2015/07/27 | [
"https://wordpress.stackexchange.com/questions/195743",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22857/"
] | I am sturggling with how authentication works in my scenario.
I have Wordpress site which provides set of custom APIs secured behind `oAuth2 Authentication` using [Wp OAuth Server](https://wordpress.org/plugins/oauth2-provider/) plugin.
I started with building simple custom endpoint by extending [WP REST API (WP API... | You will have to follow the details from the developers website located [here](https://wp-oauth.com/knowledge-base/authenticating-with-wp-rest-api/). (FYI, I am one lead on the project). Basically, what is boils down to, is that you are going to create a client in WP OAuth Server and give the details to your authentica... |
195,753 | <p>I've got a 'downloads' custom post, with his custom taxonomy. The taxonomy has 2 main terms. One of the 2, has 4 sub-terms. I'm currently using the wp templating system to get a standard wpquery of the parent term into a <code>taxonomy-taxonomyname-termname.php</code> page. Till here, all fine.</p>
<p>Now what I'd ... | [
{
"answer_id": 195757,
"author": "Mike",
"author_id": 45704,
"author_profile": "https://wordpress.stackexchange.com/users/45704",
"pm_score": 2,
"selected": false,
"text": "<p>If I understand the question correctly, you want to produce something like this:</p>\n\n<h3>Sub-Item 1</h3>\n\n<... | 2015/07/27 | [
"https://wordpress.stackexchange.com/questions/195753",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10381/"
] | I've got a 'downloads' custom post, with his custom taxonomy. The taxonomy has 2 main terms. One of the 2, has 4 sub-terms. I'm currently using the wp templating system to get a standard wpquery of the parent term into a `taxonomy-taxonomyname-termname.php` page. Till here, all fine.
Now what I'd like to do is to show... | Ok, thank you all for your good answers. Anyway, I need more flexibility, so I ended up not using the wp template auto-sugars...
This answer is therefore not strictly related to my own original question, but I think it can help people too.
I built a custom function that retrieves a set of custom posts form a specifi... |
195,787 | <p>Can please anyone help? I created custom meta boxes, two of them are in textarea.
This is what i have:</p>
<pre><code>array(
'label'=> 'Ingredients',
'desc' => 'List of ingrediends',
'id' => $prefix.'ingrediends',
'type' => 'textarea'
),
array(
'l... | [
{
"answer_id": 198115,
"author": "aaron.cimolini",
"author_id": 67495,
"author_profile": "https://wordpress.stackexchange.com/users/67495",
"pm_score": 2,
"selected": false,
"text": "<p>To use wp_editor() you'll need to replace your textarea tag with the output from wp_editor() like so:<... | 2015/07/27 | [
"https://wordpress.stackexchange.com/questions/195787",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76850/"
] | Can please anyone help? I created custom meta boxes, two of them are in textarea.
This is what i have:
```
array(
'label'=> 'Ingredients',
'desc' => 'List of ingrediends',
'id' => $prefix.'ingrediends',
'type' => 'textarea'
),
array(
'label'=> 'Directions',
... | ```
case 'textarea':
wp_editor($meta, $field['id']);
echo '<br /><span class="description">'.$field['desc'].'</span>';
break;
```
This is the way to fix it. |
195,797 | <p>I am creating a section on my site that will display the last five categories created. How could I do that?</p>
<p>UPDATE:
The code below is what I want, just like to know how to apply in order, if the latest published categories.</p>
<pre><code><?php
$cat = get_query_var('cat');
$categories=get_categories('chi... | [
{
"answer_id": 195800,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 2,
"selected": false,
"text": "<p>the id of the categories is autoincrement so you can sort by id to find the last one : </p>\n\n<pre><code>$args =... | 2015/07/27 | [
"https://wordpress.stackexchange.com/questions/195797",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68649/"
] | I am creating a section on my site that will display the last five categories created. How could I do that?
UPDATE:
The code below is what I want, just like to know how to apply in order, if the latest published categories.
```
<?php
$cat = get_query_var('cat');
$categories=get_categories('child_of='.$cat);
if ($cate... | the id of the categories is autoincrement so you can sort by id to find the last one :
```
$args = array(
"type" => "post",
"orderby" => "id",
"order" => "DESC",
"number" => "5",
"taxonomy" => "category",
"hide_empty" => FALSE, // TRUE or FALSE depending what you want
);
$categories = get_cat... |
195,810 | <p>I have a new website and it's loading extremely slowly. It happens both in admin area and frontend, so I'm guessing is not a plugin or theme issue. In fact, I've tried deactivating all plugins and activating one by one and found no difference. I've tried switching the theme too and it didn't solve the problem.</p>
... | [
{
"answer_id": 195800,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 2,
"selected": false,
"text": "<p>the id of the categories is autoincrement so you can sort by id to find the last one : </p>\n\n<pre><code>$args =... | 2015/07/28 | [
"https://wordpress.stackexchange.com/questions/195810",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/72739/"
] | I have a new website and it's loading extremely slowly. It happens both in admin area and frontend, so I'm guessing is not a plugin or theme issue. In fact, I've tried deactivating all plugins and activating one by one and found no difference. I've tried switching the theme too and it didn't solve the problem.
I have ... | the id of the categories is autoincrement so you can sort by id to find the last one :
```
$args = array(
"type" => "post",
"orderby" => "id",
"order" => "DESC",
"number" => "5",
"taxonomy" => "category",
"hide_empty" => FALSE, // TRUE or FALSE depending what you want
);
$categories = get_cat... |
195,827 | <p>I'm trying to test wp_mail() in my local.
When I var dump wp_mail,I get Boolean false.This is my code</p>
<pre><code> $to = "abcd@gmail.com";
$subject = 'my subject';
$message = 'I would like to work with you';
$headers = '';
$sent_message = wp_mail( $to, $subject, $message, $headers);
var_... | [
{
"answer_id": 195830,
"author": "David",
"author_id": 31323,
"author_profile": "https://wordpress.stackexchange.com/users/31323",
"pm_score": 3,
"selected": false,
"text": "<p><code>wp_mail()</code> falls back to php's <code>mail()</code> function which requires a configured MTA (Messag... | 2015/07/28 | [
"https://wordpress.stackexchange.com/questions/195827",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/69020/"
] | I'm trying to test wp\_mail() in my local.
When I var dump wp\_mail,I get Boolean false.This is my code
```
$to = "abcd@gmail.com";
$subject = 'my subject';
$message = 'I would like to work with you';
$headers = '';
$sent_message = wp_mail( $to, $subject, $message, $headers);
var_dump($sent_me... | `wp_mail()` falls back to php's `mail()` function which requires a configured MTA (Message Transfer Agent) on your host. So either you install and configure such a MTA. If you're running a Linux like OS, [SSMTP](https://wiki.archlinux.org/index.php/SSMTP) is an easy solution on which you can use any mail-provider to se... |
195,850 | <p>I need to work with date function but I want to get day and month numerical and separate and pass it to a function.</p>
<p>For example, I want work for this function. </p>
<pre><code>function(day,month)
</code></pre>
<p>How can I get date of today on pass it to a function aside?</p>
| [
{
"answer_id": 195852,
"author": "denis.stoyanov",
"author_id": 76287,
"author_profile": "https://wordpress.stackexchange.com/users/76287",
"pm_score": 1,
"selected": true,
"text": "<p>I think this will work for you (tried it and it works):</p>\n\n<pre><code>date('m', strtotime('0 month'... | 2015/07/28 | [
"https://wordpress.stackexchange.com/questions/195850",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/71455/"
] | I need to work with date function but I want to get day and month numerical and separate and pass it to a function.
For example, I want work for this function.
```
function(day,month)
```
How can I get date of today on pass it to a function aside? | I think this will work for you (tried it and it works):
```
date('m', strtotime('0 month'));
date('d', strtotime('0 day'));
```
[Here is a discussion](https://stackoverflow.com/questions/5733636/trying-to-get-the-number-of-the-month-before-of-the-current-month) on the topic. |
195,864 | <p>I wonder is there a way of running wp_register_script and enqueue with the help of foreach loop to manage label and dir?</p>
<p>For example, </p>
<pre><code>function wbs_app_components(){
$scripts_list=array(
'jquery' => ToDir('/jquery/jquery.js', $LIBRARY_DIR),
'bootstrap-jquery' => ... | [
{
"answer_id": 195871,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 4,
"selected": true,
"text": "<p>You need to enqueue the scripts as well, not only register them. You can, however, just simply enqueue a... | 2015/07/28 | [
"https://wordpress.stackexchange.com/questions/195864",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38535/"
] | I wonder is there a way of running wp\_register\_script and enqueue with the help of foreach loop to manage label and dir?
For example,
```
function wbs_app_components(){
$scripts_list=array(
'jquery' => ToDir('/jquery/jquery.js', $LIBRARY_DIR),
'bootstrap-jquery' => ToDir('/bootstrap/js/boot... | You need to enqueue the scripts as well, not only register them. You can, however, just simply enqueue a script without registering it if you are not going to enqueue it conditionally.
I would try something like this: (*Untested and requires PHP5.4+*)
```
add_action( 'wp_enqueue_scripts', enqueue_scripts, 11 );
funct... |
195,945 | <p>I am using an image as my site logo, and the image displays fine on the site. However, while the image is inside of an 'a' tag, its not clickable. Here's my code:</p>
<pre><code><div class="site-branding">
<a href="<?php echo bloginfo('url'); ?>">
<img class="site-logo img-responsive" ... | [
{
"answer_id": 195957,
"author": "Sereyboth Yorn",
"author_id": 76938,
"author_profile": "https://wordpress.stackexchange.com/users/76938",
"pm_score": 2,
"selected": false,
"text": "<p>Can you try with this code? Because <code>bloginfo()</code> <a href=\"https://core.trac.wordpress.org/... | 2015/07/29 | [
"https://wordpress.stackexchange.com/questions/195945",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14578/"
] | I am using an image as my site logo, and the image displays fine on the site. However, while the image is inside of an 'a' tag, its not clickable. Here's my code:
```
<div class="site-branding">
<a href="<?php echo bloginfo('url'); ?>">
<img class="site-logo img-responsive" src="<?php echo bloginfo('url'); ?>... | Can you try with this code? Because `bloginfo()` [does already `echo`](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/general-template.php#L578), you need to remove the `echo`.
```
<div class="site-branding">
<a href="<?php bloginfo('url'); ?>">
<img class="site-logo img-responsive" src="<... |
195,960 |
<p>How can I show child categories under there parent category in the wordpress admin? On a post the format of the category box would look like this:</p>
<p>Category 1</p>
<ul>
<li>Sub-Category 1.1</li>
<li>Sub-Category 1.2</li>
</ul>
<p>Category 2</p>
| [
{
"answer_id": 195963,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": 1,
"selected": true,
"text": "<p>EDIT:</p>\n\n<p>On a post page, the categories are already seen in hierarchical manner but with checkboxes. So,... | 2015/07/29 | [
"https://wordpress.stackexchange.com/questions/195960",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45945/"
] | How can I show child categories under there parent category in the wordpress admin? On a post the format of the category box would look like this:
Category 1
* Sub-Category 1.1
* Sub-Category 1.2
Category 2 | EDIT:
On a post page, the categories are already seen in hierarchical manner but with checkboxes. So, I have assumed that you have to show list of all the categories/subcategories somewhere in the admin panel in following format.
* Category 1
+ Sub-Category 1.1
+ Sub-Category 1.2
* Category 2
So, presentation is u... |
195,962 | <p>I have installed html5 blank template and I have created sub theme too by creating <code>style.css</code> and <code>functions.php</code>. But how should I get rid off default CSS styles that come from parent theme?</p>
| [
{
"answer_id": 195977,
"author": "Tejas",
"author_id": 66047,
"author_profile": "https://wordpress.stackexchange.com/users/66047",
"pm_score": -1,
"selected": false,
"text": "<p>Go to the parent theme's functions.php and remove any enqueued styles you don't want.</p>\n"
},
{
"ans... | 2015/07/29 | [
"https://wordpress.stackexchange.com/questions/195962",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76941/"
] | I have installed html5 blank template and I have created sub theme too by creating `style.css` and `functions.php`. But how should I get rid off default CSS styles that come from parent theme? | there are two ways,
first: if you want to remove default style, just dequeue them using `wp_dequeue_style( 'style_file_name_here' )`.
second: you can rename the existing file and create a new one with the same name, just place style hook info into new style file, like:
```
/*
Theme Name: Theme name
Author: Author nam... |
195,981 | <p>with the support of ACF team I created a page where I list the values from a Taxonomy Custom Field (custom field named cognome_nome) alphabetically.
I explain:</p>
<p>Term 1</p>
<ul>
<li>Name: Elena P</li>
<li>slug: elena_p</li>
<li>cognome_nome: P Elena</li>
</ul>
<p>Term 2</p>
<ul>
<li>Name: Andrea B</li>
<li>... | [
{
"answer_id": 195993,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": true,
"text": "<p>I do not know how ACF works or how its data is stored, but in general, I would just use <code>usort()</c... | 2015/07/29 | [
"https://wordpress.stackexchange.com/questions/195981",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76249/"
] | with the support of ACF team I created a page where I list the values from a Taxonomy Custom Field (custom field named cognome\_nome) alphabetically.
I explain:
Term 1
* Name: Elena P
* slug: elena\_p
* cognome\_nome: P Elena
Term 2
* Name: Andrea B
* slug: andrea\_b
* cognome\_nome: B Andrea
The list will be:
* ... | I do not know how ACF works or how its data is stored, but in general, I would just use `usort()` to sort the returned array of terms via the ACF value of `cognome_nome`. Note that `array_push` is a bit expensive to use, so try to avoid that ;-)
As I stated in comments, your code does not make much sense to me. You ha... |
196,026 | <p>I want to modify a function in a plugin. It is declared in the plugin's main file like this:</p>
<pre><code>class WCPGSK_Main {
...
public function wcpgsk_email_after_order_table($order) {
...
}
}
</code></pre>
<p>Add called from there like this:</p>
<pre><code>add_action( 'woocommerce_email_after_order... | [
{
"answer_id": 196029,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": 4,
"selected": true,
"text": "<p>This should work:</p>\n\n<pre><code>add_action( 'woocommerce_init', 'remove_wcpgsk_email_order_table' );\nfunct... | 2015/07/29 | [
"https://wordpress.stackexchange.com/questions/196026",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73366/"
] | I want to modify a function in a plugin. It is declared in the plugin's main file like this:
```
class WCPGSK_Main {
...
public function wcpgsk_email_after_order_table($order) {
...
}
}
```
Add called from there like this:
```
add_action( 'woocommerce_email_after_order_table', array($this, 'wcpgsk_email_a... | This should work:
```
add_action( 'woocommerce_init', 'remove_wcpgsk_email_order_table' );
function remove_wcpgsk_email_order_table() {
global $wcpgsk;
remove_action( 'woocommerce_email_after_order_table', array( $wcpgsk, 'wcpgsk_email_after_order_table' ) );
}
``` |
196,050 | <p>Contributors on our wordpress site can't preview posts. I'd like them to be able to preview any post (not just theirs) and this should include custom post types.</p>
<p>I can't find a specific capability to add to the contributor role like I've done with other capabilities.</p>
| [
{
"answer_id": 196209,
"author": "John Blackbourn",
"author_id": 27051,
"author_profile": "https://wordpress.stackexchange.com/users/27051",
"pm_score": 2,
"selected": false,
"text": "<p>Unfortunately, WordPress doesn't use a separate capability for previewing posts. A user needs the abi... | 2015/07/29 | [
"https://wordpress.stackexchange.com/questions/196050",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48623/"
] | Contributors on our wordpress site can't preview posts. I'd like them to be able to preview any post (not just theirs) and this should include custom post types.
I can't find a specific capability to add to the contributor role like I've done with other capabilities. | Unfortunately, WordPress doesn't use a separate capability for previewing posts. A user needs the ability to *edit* a post in order to preview it. As seen in [the WP\_Query::get\_posts() method](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/query.php#L3549):
```
// User must have edit permissions ... |
196,055 | <p>I have a list of products in WooCommerce that have titles like so:</p>
<p><strong><em>Please note: The "groups" are just for myself, they are not categories etc. All products are the same type of product, just two types of products have different codes (Z and UK)</em></strong></p>
<p><strong>"Group 1" -</strong> U... | [
{
"answer_id": 196209,
"author": "John Blackbourn",
"author_id": 27051,
"author_profile": "https://wordpress.stackexchange.com/users/27051",
"pm_score": 2,
"selected": false,
"text": "<p>Unfortunately, WordPress doesn't use a separate capability for previewing posts. A user needs the abi... | 2015/07/29 | [
"https://wordpress.stackexchange.com/questions/196055",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18051/"
] | I have a list of products in WooCommerce that have titles like so:
***Please note: The "groups" are just for myself, they are not categories etc. All products are the same type of product, just two types of products have different codes (Z and UK)***
**"Group 1" -** Unique numbers
* 5000
* 4999
* 4998
* 4997
* 4996
... | Unfortunately, WordPress doesn't use a separate capability for previewing posts. A user needs the ability to *edit* a post in order to preview it. As seen in [the WP\_Query::get\_posts() method](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/query.php#L3549):
```
// User must have edit permissions ... |
196,061 | <p>I am using WooCommerce in WordPress. I have few categories of products like these, </p>
<p><strong>Example:</strong> </p>
<pre><code>Product 1 Category (//parent)
-- Category 1
-- Category 2
-- Category 3
-- Category 4
Product 2 Category (//parent)
-- Category 10
-- Category 11
-- Category 12
-- Category 13
</code... | [
{
"answer_id": 196209,
"author": "John Blackbourn",
"author_id": 27051,
"author_profile": "https://wordpress.stackexchange.com/users/27051",
"pm_score": 2,
"selected": false,
"text": "<p>Unfortunately, WordPress doesn't use a separate capability for previewing posts. A user needs the abi... | 2015/07/29 | [
"https://wordpress.stackexchange.com/questions/196061",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74748/"
] | I am using WooCommerce in WordPress. I have few categories of products like these,
**Example:**
```
Product 1 Category (//parent)
-- Category 1
-- Category 2
-- Category 3
-- Category 4
Product 2 Category (//parent)
-- Category 10
-- Category 11
-- Category 12
-- Category 13
```
If I am in a archive page for Cate... | Unfortunately, WordPress doesn't use a separate capability for previewing posts. A user needs the ability to *edit* a post in order to preview it. As seen in [the WP\_Query::get\_posts() method](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/query.php#L3549):
```
// User must have edit permissions ... |
196,109 | <p>I added custom post type and I have first problem. </p>
<p>I don't know why but if I use <code>$post->ID</code>, independently of post ID it always gave me the same value. I'm using this function <code><?php the_post(); ?></code> to display content of post. What can I do with it?</p>
| [
{
"answer_id": 196114,
"author": "inverted_index",
"author_id": 71448,
"author_profile": "https://wordpress.stackexchange.com/users/71448",
"pm_score": 1,
"selected": false,
"text": "<p>Use the following before <code>$post->ID</code> in your code:</p>\n\n<pre><code>global $post\n</cod... | 2015/07/30 | [
"https://wordpress.stackexchange.com/questions/196109",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77009/"
] | I added custom post type and I have first problem.
I don't know why but if I use `$post->ID`, independently of post ID it always gave me the same value. I'm using this function `<?php the_post(); ?>` to display content of post. What can I do with it? | Use the following before `$post->ID` in your code:
```
global $post
``` |
196,126 | <p>I've figured out how to do something BEFORE sending the mail, but I also need an action to happen AFTER it's been send.</p>
<p>I tried <code>wpcf7_after_send_mail</code> but with no success...</p>
<p>Any help on the matter would be much appreciated.</p>
| [
{
"answer_id": 196132,
"author": "Menno van der Krift",
"author_id": 76984,
"author_profile": "https://wordpress.stackexchange.com/users/76984",
"pm_score": 4,
"selected": true,
"text": "<p><strong>EDIT:</strong> </p>\n\n<p>Please note that as of 2017 <a href=\"https://contactform7.com/2... | 2015/07/30 | [
"https://wordpress.stackexchange.com/questions/196126",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76984/"
] | I've figured out how to do something BEFORE sending the mail, but I also need an action to happen AFTER it's been send.
I tried `wpcf7_after_send_mail` but with no success...
Any help on the matter would be much appreciated. | **EDIT:**
Please note that as of 2017 ['on\_sent\_ok' is deprecated](https://contactform7.com/2017/06/07/on-sent-ok-is-deprecated/). This means that your code will stop working at some point in the future (likely by the end of 2017). The recommended solution is using DOM event listeners directly. For example, if you ... |
196,147 | <p>When I make click at any file from my website, the URL displays like: </p>
<p><strong>www.mywebsite.com/index.php/about-me</strong> OR <strong>www.mywebsite.com/index.php/references</strong> </p>
<p>I just want to know if it is normal that index.php gets always displayed before any other file (something like <stro... | [
{
"answer_id": 196174,
"author": "feelinferrety",
"author_id": 48824,
"author_profile": "https://wordpress.stackexchange.com/users/48824",
"pm_score": 2,
"selected": true,
"text": "<p>First, check if you have an .htaccess file with the following:</p>\n\n<pre><code># BEGIN WordPress\n<... | 2015/07/30 | [
"https://wordpress.stackexchange.com/questions/196147",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76652/"
] | When I make click at any file from my website, the URL displays like:
**www.mywebsite.com/index.php/about-me** OR **www.mywebsite.com/index.php/references**
I just want to know if it is normal that index.php gets always displayed before any other file (something like **www.mywebsite.com/about-me** would be more com... | First, check if you have an .htaccess file with the following:
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
```
If this file... |
196,159 | <p>I've got a Category Archive page with name <code>category-slugb.php</code>.</p>
<p>I have a sidebar with some Widget Logic that uses <code>in_category('category-sluga')</code>.</p>
<p>What's odd is that on this Category Archive page (i.e. for all Posts of <code>category-slugb.php</code>) the <code>in_category('cat... | [
{
"answer_id": 196174,
"author": "feelinferrety",
"author_id": 48824,
"author_profile": "https://wordpress.stackexchange.com/users/48824",
"pm_score": 2,
"selected": true,
"text": "<p>First, check if you have an .htaccess file with the following:</p>\n\n<pre><code># BEGIN WordPress\n<... | 2015/07/30 | [
"https://wordpress.stackexchange.com/questions/196159",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48904/"
] | I've got a Category Archive page with name `category-slugb.php`.
I have a sidebar with some Widget Logic that uses `in_category('category-sluga')`.
What's odd is that on this Category Archive page (i.e. for all Posts of `category-slugb.php`) the `in_category('category-sluga')` condition is being triggered as `true`.
... | First, check if you have an .htaccess file with the following:
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
```
If this file... |
196,186 | <p>Does anyone know how to display the <a href="https://codex.wordpress.org/Template_Tags/wp_list_categories" rel="nofollow"><code>wp_list_categories()</code></a> on a <code>div</code> instead of the <code>li</code>?</p>
<p>I basically want to wrap main categories and its children in a bootstrap column.</p>
<pre><cod... | [
{
"answer_id": 196204,
"author": "John Blackbourn",
"author_id": 27051,
"author_profile": "https://wordpress.stackexchange.com/users/27051",
"pm_score": 3,
"selected": false,
"text": "<p>You can specify the <code>style</code> argument as something other than the default (which is <code>l... | 2015/07/30 | [
"https://wordpress.stackexchange.com/questions/196186",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77053/"
] | Does anyone know how to display the [`wp_list_categories()`](https://codex.wordpress.org/Template_Tags/wp_list_categories) on a `div` instead of the `li`?
I basically want to wrap main categories and its children in a bootstrap column.
```
$args = array(
'taxonomy' => 'product_category',
'hide_empty... | You can specify the `style` argument as something other than the default (which is `list`) and it won't wrap the output in a `<li>`. You can then wrap it in a `<div>` yourself.
Combine it with the `echo` argument if you need to check that the list isn't empty. Example:
```
$args = array(
'taxonomy' => '... |
196,191 | <p>I have code like this:</p>
<pre><code><?php echo '<div class="class-name">' . __( 'Text','text-domain' ) . '</div>'; ?>
</code></pre>
<p>in a plugin of mine.</p>
<p>Do i have to escape this? (esc_html or similiar)?</p>
| [
{
"answer_id": 196200,
"author": "jdm2112",
"author_id": 45202,
"author_profile": "https://wordpress.stackexchange.com/users/45202",
"pm_score": -1,
"selected": false,
"text": "<p>No. The contents of your <code>echo</code> statement will be output to the browser with no problems.</p>\n"... | 2015/07/30 | [
"https://wordpress.stackexchange.com/questions/196191",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77057/"
] | I have code like this:
```
<?php echo '<div class="class-name">' . __( 'Text','text-domain' ) . '</div>'; ?>
```
in a plugin of mine.
Do i have to escape this? (esc\_html or similiar)? | The answer typically depends on where your translations come from. WordPress core doesn't usually escape strings such as this, but you may wish to do so in your plugin.
A translation might come from an "untrusted" source and could, in theory, contain malicious JavaScript, and escaping would protect you from this. In r... |
196,231 | <p>I have errors in WordPress:</p>
<blockquote>
<p>PHP Notice: Undefined offset: 0 in
/home/userpro/public_html/wp-content/themes/hoon/inc/tweaks.php on
line 602</p>
<p>PHP Notice: Trying to get property of non-object in
/home/userpro/public_html/wp-content/themes/hoon/inc/tweaks.php on
line 602</p>
</b... | [
{
"answer_id": 196236,
"author": "websupporter",
"author_id": 48693,
"author_profile": "https://wordpress.stackexchange.com/users/48693",
"pm_score": 1,
"selected": false,
"text": "<p>If <code>$wp_query->post_count == 0</code> I cant see how <code>$wpdb->get_results( $wp_query->... | 2015/07/31 | [
"https://wordpress.stackexchange.com/questions/196231",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77073/"
] | I have errors in WordPress:
>
> PHP Notice: Undefined offset: 0 in
> /home/userpro/public\_html/wp-content/themes/hoon/inc/tweaks.php on
> line 602
>
>
> PHP Notice: Trying to get property of non-object in
> /home/userpro/public\_html/wp-content/themes/hoon/inc/tweaks.php on
> line 602
>
>
>
Code:
```
/**
... | If `$wp_query->post_count == 0` I cant see how `$wpdb->get_results( $wp_query->request )` would return any posts. So basically
```
$request = $wpdb->get_results( $wp_query->request );
```
contains nothing and `$request[0]` doesn't exist.
Ergo
```
PHP Notice: Undefined offset: 0
```
It would be interesting to kno... |
196,232 | <p>I have a very simple function to create a shortcode to get the name of my page. I was using this shortcode in a form, but WordPress changed the Shortcode API and that no longer works. So I was wondering if I could use a second function to make a shortcode that would put in the HTML plus the result of the first short... | [
{
"answer_id": 196236,
"author": "websupporter",
"author_id": 48693,
"author_profile": "https://wordpress.stackexchange.com/users/48693",
"pm_score": 1,
"selected": false,
"text": "<p>If <code>$wp_query->post_count == 0</code> I cant see how <code>$wpdb->get_results( $wp_query->... | 2015/07/31 | [
"https://wordpress.stackexchange.com/questions/196232",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77075/"
] | I have a very simple function to create a shortcode to get the name of my page. I was using this shortcode in a form, but WordPress changed the Shortcode API and that no longer works. So I was wondering if I could use a second function to make a shortcode that would put in the HTML plus the result of the first shortcod... | If `$wp_query->post_count == 0` I cant see how `$wpdb->get_results( $wp_query->request )` would return any posts. So basically
```
$request = $wpdb->get_results( $wp_query->request );
```
contains nothing and `$request[0]` doesn't exist.
Ergo
```
PHP Notice: Undefined offset: 0
```
It would be interesting to kno... |
196,289 | <p>Click on "Pages" -> Click on "Add New"</p>
<p>In the add new page screen. The default page template selected is "Default Template". Is there a way to change the default option to, let's say "My Other Template". So that when I click on "Add New", "My Other Tem... | [
{
"answer_id": 196297,
"author": "czerspalace",
"author_id": 47406,
"author_profile": "https://wordpress.stackexchange.com/users/47406",
"pm_score": 1,
"selected": false,
"text": "<p>I have not tested this, but it may work. The template is chosen based on a value in the global post objec... | 2015/07/31 | [
"https://wordpress.stackexchange.com/questions/196289",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30984/"
] | Click on "Pages" -> Click on "Add New"
In the add new page screen. The default page template selected is "Default Template". Is there a way to change the default option to, let's say "My Other Template". So that when I click on "Add New", "My Other Template" will always be selected by default? This needs to be done be... | Using `template_include` (as suggested by Brad Dalton) only changes the page template on the front end, not in the admin when editing a page.
On the other hand, changing the value in the post object before the metabox is rendered, as suggested by czerspalace, works! I added a check to only apply this when `$post->pag... |
196,304 | <p>In the example below, <code>$shortcodes</code> is a multidimensional array with shortcode data. </p>
<pre><code>foreach( $shortcodes as $shortcode ) {
// Here we have the shortcode name, could be 'custom_person_john'.
$shortcode_name = $shortcode['slug'];
// Anonymous function should be referred to as... | [
{
"answer_id": 196333,
"author": "Mohammad Mursaleen",
"author_id": 35899,
"author_profile": "https://wordpress.stackexchange.com/users/35899",
"pm_score": 1,
"selected": false,
"text": "<p>Few months ago I was working on a similar thing where I had to generate <a href=\"https://codex.wo... | 2015/07/31 | [
"https://wordpress.stackexchange.com/questions/196304",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62241/"
] | In the example below, `$shortcodes` is a multidimensional array with shortcode data.
```
foreach( $shortcodes as $shortcode ) {
// Here we have the shortcode name, could be 'custom_person_john'.
$shortcode_name = $shortcode['slug'];
// Anonymous function should be referred to as 'custom_person_john'.
... | the shortcodes doesn't shop up in the liste because it's not a valid declaration with a valid function callback on the 2nd argument
try this to see what append :
```
// shortcode data
add_filter("shortcode_list", function ($shortcode_list) {
$shortcode_list["slugA"] = array(
"html" => "test html 1",
... |
196,339 | <p>I am currently using the Minnow theme on Wordpress. I have set my site to show latest posts from my blog, but I have also create a page called 'About'. This page doesn't show up on my site or in the navigation menu and I'm not quite sure how to get this to display. </p>
<p>Would appreciate any help I can get. </p>
... | [
{
"answer_id": 196333,
"author": "Mohammad Mursaleen",
"author_id": 35899,
"author_profile": "https://wordpress.stackexchange.com/users/35899",
"pm_score": 1,
"selected": false,
"text": "<p>Few months ago I was working on a similar thing where I had to generate <a href=\"https://codex.wo... | 2015/08/01 | [
"https://wordpress.stackexchange.com/questions/196339",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77128/"
] | I am currently using the Minnow theme on Wordpress. I have set my site to show latest posts from my blog, but I have also create a page called 'About'. This page doesn't show up on my site or in the navigation menu and I'm not quite sure how to get this to display.
Would appreciate any help I can get.
Thank you. | the shortcodes doesn't shop up in the liste because it's not a valid declaration with a valid function callback on the 2nd argument
try this to see what append :
```
// shortcode data
add_filter("shortcode_list", function ($shortcode_list) {
$shortcode_list["slugA"] = array(
"html" => "test html 1",
... |
196,344 | <p>I'm getting a post by id with get_post();</p>
<pre><code>$post = get_post(17);
$page = get_post_meta(17);
setup_postdata( $post );
include($page['_wp_page_template'][0]);
</code></pre>
<p>After getting the post I include a pagetemplate wich contains a:</p>
<pre><code>while ( have_posts() ) : the_post();
</co... | [
{
"answer_id": 196350,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>There are multiple ways to handle these things and your question is a little light on detail <em>why</em> you need.... | 2015/08/01 | [
"https://wordpress.stackexchange.com/questions/196344",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31706/"
] | I'm getting a post by id with get\_post();
```
$post = get_post(17);
$page = get_post_meta(17);
setup_postdata( $post );
include($page['_wp_page_template'][0]);
```
After getting the post I include a pagetemplate wich contains a:
```
while ( have_posts() ) : the_post();
```
If I call `the_title()` from outsi... | If you are using `setup_postdata( $post )` you need to use the global `$post` as for some reason it does not work without that specific variable. Once you manually set `$post` to a new value, you are altering the `$post` global, so you will need to reset it back to the current post of the main query.
Apart from that,... |
196,347 | <p>I have read through a lot of responses on this site and am unable to find the issue with my code. </p>
<p>The form is : </p>
<pre><code><?php while (have_posts()) : the_post()?>
<form method='post' id="dav-international" >
<label for="dav-address">Address:</label><... | [
{
"answer_id": 196350,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>There are multiple ways to handle these things and your question is a little light on detail <em>why</em> you need.... | 2015/08/01 | [
"https://wordpress.stackexchange.com/questions/196347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77130/"
] | I have read through a lot of responses on this site and am unable to find the issue with my code.
The form is :
```
<?php while (have_posts()) : the_post()?>
<form method='post' id="dav-international" >
<label for="dav-address">Address:</label><input type="text" name="dav-address" id="dav-addr... | If you are using `setup_postdata( $post )` you need to use the global `$post` as for some reason it does not work without that specific variable. Once you manually set `$post` to a new value, you are altering the `$post` global, so you will need to reset it back to the current post of the main query.
Apart from that,... |
196,365 | <p>Assuming I have a custom thumbnail size, as defined by the following...</p>
<pre><code>add_image_size( $name, $dim_x, $dim_y, true );
</code></pre>
<p>...how can I get the defined image dimensions programatically, using only $name ?</p>
| [
{
"answer_id": 196350,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>There are multiple ways to handle these things and your question is a little light on detail <em>why</em> you need.... | 2015/08/01 | [
"https://wordpress.stackexchange.com/questions/196365",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77143/"
] | Assuming I have a custom thumbnail size, as defined by the following...
```
add_image_size( $name, $dim_x, $dim_y, true );
```
...how can I get the defined image dimensions programatically, using only $name ? | If you are using `setup_postdata( $post )` you need to use the global `$post` as for some reason it does not work without that specific variable. Once you manually set `$post` to a new value, you are altering the `$post` global, so you will need to reset it back to the current post of the main query.
Apart from that,... |
196,368 | <p>Does anyone know how to ad an item to the menu on the right side of the page.
Please see the photo attached.<a href="https://i.stack.imgur.com/hA229.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hA229.jpg" alt="enter image description here"></a></p>
<p>I basically want to add "ISSUES" as a menu... | [
{
"answer_id": 196350,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>There are multiple ways to handle these things and your question is a little light on detail <em>why</em> you need.... | 2015/08/02 | [
"https://wordpress.stackexchange.com/questions/196368",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77145/"
] | Does anyone know how to ad an item to the menu on the right side of the page.
Please see the photo attached.[](https://i.stack.imgur.com/hA229.jpg)
I basically want to add "ISSUES" as a menu item on the left side of page. Just like ARTIST is listed. I... | If you are using `setup_postdata( $post )` you need to use the global `$post` as for some reason it does not work without that specific variable. Once you manually set `$post` to a new value, you are altering the `$post` global, so you will need to reset it back to the current post of the main query.
Apart from that,... |
196,376 | <p><a href="https://wordpress.stackexchange.com/questions/180005/include-sticky-post-in-page-posts-count">This link</a> solves the problem but it's only for the main query. What if you are using a custom query? How can you <a href="https://wordpress.stackexchange.com/a/76639/73579">modify the answer</a> below:</p>
<pr... | [
{
"answer_id": 196350,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>There are multiple ways to handle these things and your question is a little light on detail <em>why</em> you need.... | 2015/08/02 | [
"https://wordpress.stackexchange.com/questions/196376",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | [This link](https://wordpress.stackexchange.com/questions/180005/include-sticky-post-in-page-posts-count) solves the problem but it's only for the main query. What if you are using a custom query? How can you [modify the answer](https://wordpress.stackexchange.com/a/76639/73579) below:
```
add_action('pre_get_posts', ... | If you are using `setup_postdata( $post )` you need to use the global `$post` as for some reason it does not work without that specific variable. Once you manually set `$post` to a new value, you are altering the `$post` global, so you will need to reset it back to the current post of the main query.
Apart from that,... |
196,394 | <p>Is it possible, with <code>WP_Query</code>, to get all posts which have at least one category or custom taxonomy term set?</p>
| [
{
"answer_id": 196409,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>Yes, totally possible. </p>\n\n<h2>SCENARIO 1</h2>\n\n<p>If you need only one taxonomy, all you need to ... | 2015/08/02 | [
"https://wordpress.stackexchange.com/questions/196394",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13205/"
] | Is it possible, with `WP_Query`, to get all posts which have at least one category or custom taxonomy term set? | Yes, totally possible.
SCENARIO 1
----------
If you need only one taxonomy, all you need to do is to get all the term ID's of all terms assigned to the taxonomy and then pass that array of term ID's to a `tax_query`
(*Requires PHP5.4+*)
```
$term_ids = get_terms(
'TAXONOMY_NAME',
[ // Array of arguments,... |
196,412 | <p>I'm currently developing a non-trivial theme right now, most of the time I'm not using <a href="https://developer.wordpress.org/reference/functions/__/" rel="nofollow">a <code>__($str)</code> translate function</a> when there's an HTML tag therein the text. Is it good to always use the translate functions such <code... | [
{
"answer_id": 196409,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>Yes, totally possible. </p>\n\n<h2>SCENARIO 1</h2>\n\n<p>If you need only one taxonomy, all you need to ... | 2015/08/02 | [
"https://wordpress.stackexchange.com/questions/196412",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73330/"
] | I'm currently developing a non-trivial theme right now, most of the time I'm not using [a `__($str)` translate function](https://developer.wordpress.org/reference/functions/__/) when there's an HTML tag therein the text. Is it good to always use the translate functions such `__($str)` and `_e($str)` whenever there's a ... | Yes, totally possible.
SCENARIO 1
----------
If you need only one taxonomy, all you need to do is to get all the term ID's of all terms assigned to the taxonomy and then pass that array of term ID's to a `tax_query`
(*Requires PHP5.4+*)
```
$term_ids = get_terms(
'TAXONOMY_NAME',
[ // Array of arguments,... |
196,449 | <p>I am currently building a wordpress plugin to send email notification to list of users roles who comments on a post.</p>
<p><strong>For Example:</strong></p>
<p>If a user with "subscriber" role comments on a post all the other users who have "subscriber" role gets email alert.Currently i have achieved this through... | [
{
"answer_id": 196451,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": -1,
"selected": false,
"text": "<p>Following should works for you:- </p>\n\n<pre><code> if( current_user_can('read')) { \n $exclude_user = ... | 2015/08/03 | [
"https://wordpress.stackexchange.com/questions/196449",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74004/"
] | I am currently building a wordpress plugin to send email notification to list of users roles who comments on a post.
**For Example:**
If a user with "subscriber" role comments on a post all the other users who have "subscriber" role gets email alert.Currently i have achieved this through the following code
```
if( c... | First, you should know that [`current_user_can()`](https://codex.wordpress.org/Function_Reference/current_user_can) only accepts capabilities, not roles, so you are using it wrong and you can end up with unexpected results.
That being said, to exlude users form `WP_User_Query` you can use the [exclude parameter](https... |
196,453 | <p>I'm using Wordpress with UserPro, and want my menu to display the logged-in user's first name, linked to the user profile page.</p>
<p>The problem is that in my menu structure, the "Profile" menu option is supposed to have a sub-menu containing "edit profile", "submit", and "logout".</p>
<p>This is the code I'm cu... | [
{
"answer_id": 196467,
"author": "Akash kapur",
"author_id": 76819,
"author_profile": "https://wordpress.stackexchange.com/users/76819",
"pm_score": 4,
"selected": true,
"text": "<p>Okay, I found a solution (and it can be used for any theme, with any plugin as it only uses core WordPress... | 2015/08/03 | [
"https://wordpress.stackexchange.com/questions/196453",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76819/"
] | I'm using Wordpress with UserPro, and want my menu to display the logged-in user's first name, linked to the user profile page.
The problem is that in my menu structure, the "Profile" menu option is supposed to have a sub-menu containing "edit profile", "submit", and "logout".
This is the code I'm currently using:
`... | Okay, I found a solution (and it can be used for any theme, with any plugin as it only uses core WordPress functions).
In the menu, name the menu item where you want the user's name to appear with a place-holder (see screenshot below). Example: #profile\_name#, #user#, #random#
[![enter image description here](https... |