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 |
|---|---|---|---|---|---|---|
272,021 | <p>I use wordpress theme in my website. Question is simple, i want to add inside my articles as an inline note, caution, warning quote like picture. How can i do that? Is there any plugin or way to do that? </p>
<p><a href="https://i.stack.imgur.com/KuF4z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.... | [
{
"answer_id": 272034,
"author": "BenB",
"author_id": 62909,
"author_profile": "https://wordpress.stackexchange.com/users/62909",
"pm_score": 0,
"selected": false,
"text": "<p>Run in your theme the CSS of admin dashboard. </p>\n\n<pre><code>wp_enqueue_style( 'wp-admin' );\n</code></pre>\... | 2017/07/02 | [
"https://wordpress.stackexchange.com/questions/272021",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122986/"
] | I use wordpress theme in my website. Question is simple, i want to add inside my articles as an inline note, caution, warning quote like picture. How can i do that? Is there any plugin or way to do that?
[](https://i.stack.imgur.com/KuF4z.png) | You can hook into [`the_content`](https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content) filter and add your note after every post. Then you can style it to have a nice quote.
```
add_filter('the_content','add_my_note');
function add_my_note($content){
// Write your note here
$note = '
<d... |
272,053 | <p>I am currently using a <code>WP_Query</code> that'll trigger from an AJAX call when a button is pressed. The post meta fields <code>lat</code> <code>lng</code> will be used as location data for a google map. The query outputs fine without AJAX but cannot seem to get it to return the results with it. </p>
<p>The res... | [
{
"answer_id": 272065,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 4,
"selected": true,
"text": "<p>Admin-AJAX is not optimized for JSON. If you need your answer to be in JSON, use the REST-API instead. This ... | 2017/07/02 | [
"https://wordpress.stackexchange.com/questions/272053",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/87036/"
] | I am currently using a `WP_Query` that'll trigger from an AJAX call when a button is pressed. The post meta fields `lat` `lng` will be used as location data for a google map. The query outputs fine without AJAX but cannot seem to get it to return the results with it.
The response I receive - `[{name: "", lng: null, l... | Admin-AJAX is not optimized for JSON. If you need your answer to be in JSON, use the REST-API instead. This API generates JSON response by default.
All you have to do is to register a rest route, and access the URL:
```
add_action( 'rest_api_init', function () {
//Path to REST route and the callback function
... |
272,075 | <p>Apologies, for the very long title.</p>
<p>I'd really appreciate any help that anyone can offer with a situation I have currently before I go for the plugin option.</p>
<p>About a month ago I moved my site from:</p>
<p><code>http</code> to <code>https</code></p>
<p>I did the move myself and all went well.</p>
<... | [
{
"answer_id": 272058,
"author": "wplearner",
"author_id": 120693,
"author_profile": "https://wordpress.stackexchange.com/users/120693",
"pm_score": 2,
"selected": true,
"text": "<p>I am able to locate that file in my theme.\nFor categories woocommerce.php in root directory of my theme i... | 2017/07/02 | [
"https://wordpress.stackexchange.com/questions/272075",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123028/"
] | Apologies, for the very long title.
I'd really appreciate any help that anyone can offer with a situation I have currently before I go for the plugin option.
About a month ago I moved my site from:
`http` to `https`
I did the move myself and all went well.
Last night I decided to update the Permalink Structure fro... | I am able to locate that file in my theme.
For categories woocommerce.php in root directory of my theme is working and i am able to complete my task.
Thank you! |
272,106 | <p>I'm having a little problem getting an information. In my plugin, I got a situation where I have to throw, in a very specific situation, a 403 error. But I can't find in the documentation if there is a recommended way to throw a 403, because WP LOVES wrap everything it's own way.</p>
<p>So! Do you know a way to tri... | [
{
"answer_id": 272107,
"author": "Junaid",
"author_id": 66571,
"author_profile": "https://wordpress.stackexchange.com/users/66571",
"pm_score": 2,
"selected": false,
"text": "<p>Is there any limitation/issue setting/thowing <code>403</code> the usual PHP way?</p>\n\n<pre><code>header('HT... | 2017/07/03 | [
"https://wordpress.stackexchange.com/questions/272106",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94823/"
] | I'm having a little problem getting an information. In my plugin, I got a situation where I have to throw, in a very specific situation, a 403 error. But I can't find in the documentation if there is a recommended way to throw a 403, because WP LOVES wrap everything it's own way.
So! Do you know a way to trigger a 403... | Is there any limitation/issue setting/thowing `403` the usual PHP way?
```
header('HTTP/1.0 403 Forbidden');
die('You are not allowed to access this file.');
``` |
272,108 | <p>I'm trying to add a login/register button to my home page only when a user is logged out. I've tried using the do_shortcode call into the relevant template: (I know there is currently no conditional to check if logged in but I just want to ensure that the shortcode actually works first of all)
<pre><code>add_s... | [
{
"answer_id": 272107,
"author": "Junaid",
"author_id": 66571,
"author_profile": "https://wordpress.stackexchange.com/users/66571",
"pm_score": 2,
"selected": false,
"text": "<p>Is there any limitation/issue setting/thowing <code>403</code> the usual PHP way?</p>\n\n<pre><code>header('HT... | 2017/07/03 | [
"https://wordpress.stackexchange.com/questions/272108",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123044/"
] | I'm trying to add a login/register button to my home page only when a user is logged out. I've tried using the do\_shortcode call into the relevant template: (I know there is currently no conditional to check if logged in but I just want to ensure that the shortcode actually works first of all)
```
add_shortcode('logi... | Is there any limitation/issue setting/thowing `403` the usual PHP way?
```
header('HTTP/1.0 403 Forbidden');
die('You are not allowed to access this file.');
``` |
272,111 | <p>I'm using <code>get_pages()</code> to create a custom navigation that lists pages with a link, title and thumbnail for each page.
How can I add a "current-item" class to the item corresponding to the current page?</p>
<p>I'm using the following code:</p>
<pre><code><?php
$our_pages = get_pages( array( 'sor... | [
{
"answer_id": 272107,
"author": "Junaid",
"author_id": 66571,
"author_profile": "https://wordpress.stackexchange.com/users/66571",
"pm_score": 2,
"selected": false,
"text": "<p>Is there any limitation/issue setting/thowing <code>403</code> the usual PHP way?</p>\n\n<pre><code>header('HT... | 2017/07/03 | [
"https://wordpress.stackexchange.com/questions/272111",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113555/"
] | I'm using `get_pages()` to create a custom navigation that lists pages with a link, title and thumbnail for each page.
How can I add a "current-item" class to the item corresponding to the current page?
I'm using the following code:
```
<?php
$our_pages = get_pages( array( 'sort_column' => 'menu_order' ) );
... | Is there any limitation/issue setting/thowing `403` the usual PHP way?
```
header('HTTP/1.0 403 Forbidden');
die('You are not allowed to access this file.');
``` |
272,128 | <p>I did little tweak for date archive permalink.</p>
<pre><code>function my_rewrite_rules($wp_rewrite){
$rules = array();
$rules['news/([0-9]{4})/?$'] = 'index.php?year=$matches[1]';
$wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
add_action('generate_rewrite_rules', 'my_rewrite_rules');
</code... | [
{
"answer_id": 276819,
"author": "Luca Reghellin",
"author_id": 10381,
"author_profile": "https://wordpress.stackexchange.com/users/10381",
"pm_score": 1,
"selected": false,
"text": "<p>Yes norixxx, your comment above is the right answer:</p>\n\n<pre><code>add_filter('year_link', 'change... | 2017/07/03 | [
"https://wordpress.stackexchange.com/questions/272128",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37130/"
] | I did little tweak for date archive permalink.
```
function my_rewrite_rules($wp_rewrite){
$rules = array();
$rules['news/([0-9]{4})/?$'] = 'index.php?year=$matches[1]';
$wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
add_action('generate_rewrite_rules', 'my_rewrite_rules');
```
Then hit the url bel... | You can change the date links by directly modifying the `date_structure`:
```
function wpd_change_date_structure(){
global $wp_rewrite;
$wp_rewrite->date_structure = 'news/%year%/%monthnum%/%day%';
}
add_action( 'init', 'wpd_change_date_structure' );
```
Don't forget to flush rewrite rules after the change.
... |
272,130 | <p>I have already tried about 20 different methods to get this working with no solution.</p>
<p>I am trying to change the classes of the buttons in the WooCommerce mini cart widget as shown below.</p>
<p><a href="https://i.stack.imgur.com/XO8L9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XO8L9.... | [
{
"answer_id": 281853,
"author": "Mat",
"author_id": 37985,
"author_profile": "https://wordpress.stackexchange.com/users/37985",
"pm_score": 2,
"selected": false,
"text": "<p>Not sure if you still need help with this but this might help others in your situation.</p>\n\n<p>If you want to ... | 2017/07/03 | [
"https://wordpress.stackexchange.com/questions/272130",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/118673/"
] | I have already tried about 20 different methods to get this working with no solution.
I am trying to change the classes of the buttons in the WooCommerce mini cart widget as shown below.
[](https://i.stack.imgur.com/XO8L9.png)
The mark up for those ... | Not sure if you still need help with this but this might help others in your situation.
If you want to change the class of the `<p>` tag in your example, the file you need to edit can be found in `/wp-content/plugins/woocommerce/templates/cart/mini-cart.php`
Obviously, don't directly edit the file. Copy it in to your... |
272,135 | <p>I have created a page on one of our sites which has a few snippets of custom CSS to make it display in a very modern, 100% width style <a href="http://www.hotrs.co.uk/" rel="nofollow noreferrer">like this</a>, as opposed to the standard, more constrained style of pages the site's theme allows. </p>
<p>This style of... | [
{
"answer_id": 281853,
"author": "Mat",
"author_id": 37985,
"author_profile": "https://wordpress.stackexchange.com/users/37985",
"pm_score": 2,
"selected": false,
"text": "<p>Not sure if you still need help with this but this might help others in your situation.</p>\n\n<p>If you want to ... | 2017/07/03 | [
"https://wordpress.stackexchange.com/questions/272135",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/120427/"
] | I have created a page on one of our sites which has a few snippets of custom CSS to make it display in a very modern, 100% width style [like this](http://www.hotrs.co.uk/), as opposed to the standard, more constrained style of pages the site's theme allows.
This style of page, however, is not going to be used site-wi... | Not sure if you still need help with this but this might help others in your situation.
If you want to change the class of the `<p>` tag in your example, the file you need to edit can be found in `/wp-content/plugins/woocommerce/templates/cart/mini-cart.php`
Obviously, don't directly edit the file. Copy it in to your... |
272,158 | <p>I have a custom post type called <code>vacancies</code> and another called <code>our_homes</code></p>
<p>How do I get the google map coordinates from <code>our_homes</code> and display inside the <code>vacancies</code> single post template?</p>
<p>My attempt below shows my tragic attempt at code inside the single-... | [
{
"answer_id": 272164,
"author": "Cesar Henrique Damascena",
"author_id": 109804,
"author_profile": "https://wordpress.stackexchange.com/users/109804",
"pm_score": -1,
"selected": false,
"text": "<p>Try to do this inside the loop</p>\n\n<pre><code>$location = get_field('google_map_coordi... | 2017/07/03 | [
"https://wordpress.stackexchange.com/questions/272158",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63480/"
] | I have a custom post type called `vacancies` and another called `our_homes`
How do I get the google map coordinates from `our_homes` and display inside the `vacancies` single post template?
My attempt below shows my tragic attempt at code inside the single-vacancies.php file:
```
<?php
//Query custom post type... | Although your question is confusing, but based on your attempts, I can say that you are using a loop inside another loop. You should store an array of main loop's titles in an array, and then write another loop **outside** the original loop and check the array.
So, this is what your main query would look like (I summa... |
272,161 | <p>I am customizing a theme that has the following code to display comments:</p>
<pre><code>if ( have_comments() ) : ?>
<h2 class="comments-title">
<?php
printf( // WPCS: XSS OK.
esc_html( _nx( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo... | [
{
"answer_id": 272178,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>From quick look at the source there seems to be three possibilities:</p>\n\n<ol>\n<li><code>get_post()</code> retur... | 2017/07/03 | [
"https://wordpress.stackexchange.com/questions/272161",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/103046/"
] | I am customizing a theme that has the following code to display comments:
```
if ( have_comments() ) : ?>
<h2 class="comments-title">
<?php
printf( // WPCS: XSS OK.
esc_html( _nx( 'One thought on “%2$s”', '%1$s thoughts on “%2$s”', get_comments_number(), ... | From quick look at the source there seems to be three possibilities:
1. `get_post()` returned *falsy* value, so current post context is invalid in some way.
2. `$post->comment_count` is `0`.
3. `get_comments_number` filter is being used to adjust the output.
Most commonly it would be case 1/2 with something interferi... |
272,163 | <p>I create a new db connection with: $mydb = new wpdb (<em>db info</em>)</p>
<p>I know it connects but for some reason I am unable to get any data from: </p>
<pre><code>$pulled = $mydb->get_results($mydb->prepare($query), "ARRAY_A").
</code></pre>
<p>I know the query it self is written correctly but for some... | [
{
"answer_id": 272178,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>From quick look at the source there seems to be three possibilities:</p>\n\n<ol>\n<li><code>get_post()</code> retur... | 2017/07/03 | [
"https://wordpress.stackexchange.com/questions/272163",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123061/"
] | I create a new db connection with: $mydb = new wpdb (*db info*)
I know it connects but for some reason I am unable to get any data from:
```
$pulled = $mydb->get_results($mydb->prepare($query), "ARRAY_A").
```
I know the query it self is written correctly but for some reason $pulled contains no data. Anyone have ... | From quick look at the source there seems to be three possibilities:
1. `get_post()` returned *falsy* value, so current post context is invalid in some way.
2. `$post->comment_count` is `0`.
3. `get_comments_number` filter is being used to adjust the output.
Most commonly it would be case 1/2 with something interferi... |
272,179 | <p>I know this has been covered in different ways a thousand times (I read all the posts), but it seems not specifically for my case. I can't really get it to work myself, being a big development noobie. </p>
<p>I have a template which shows the last posts on the front page. I changed the type of posts shown to <code>... | [
{
"answer_id": 272178,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>From quick look at the source there seems to be three possibilities:</p>\n\n<ol>\n<li><code>get_post()</code> retur... | 2017/07/03 | [
"https://wordpress.stackexchange.com/questions/272179",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107594/"
] | I know this has been covered in different ways a thousand times (I read all the posts), but it seems not specifically for my case. I can't really get it to work myself, being a big development noobie.
I have a template which shows the last posts on the front page. I changed the type of posts shown to `question` (my w... | From quick look at the source there seems to be three possibilities:
1. `get_post()` returned *falsy* value, so current post context is invalid in some way.
2. `$post->comment_count` is `0`.
3. `get_comments_number` filter is being used to adjust the output.
Most commonly it would be case 1/2 with something interferi... |
272,236 | <p>I am trying to load several scripts and stylesheets into a plugin I am creating. I want to load scripts into multiple CPTs within admin. I have got this far:</p>
<pre><code>function fhaac_admin_enqueue_scripts(){
global $pagenow, $typenow;
if ( ($pagenow == 'post.php' || $pagenow == 'post-new.php') &&a... | [
{
"answer_id": 272241,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": true,
"text": "<p>There is a built-in function that you can use, instead of globals. The <a href=\"https://codex.wordpress.org... | 2017/07/04 | [
"https://wordpress.stackexchange.com/questions/272236",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58313/"
] | I am trying to load several scripts and stylesheets into a plugin I am creating. I want to load scripts into multiple CPTs within admin. I have got this far:
```
function fhaac_admin_enqueue_scripts(){
global $pagenow, $typenow;
if ( ($pagenow == 'post.php' || $pagenow == 'post-new.php') && $typenow == 'fhaac... | There is a built-in function that you can use, instead of globals. The [`get_current_screen()`](https://codex.wordpress.org/Function_Reference/get_current_screen) function allows you to get the information associated with the current page.
One of its return values is `post_type`. So you can check against an array of p... |
272,249 | <p>I honestly did expect to get here...<br />
I tried every tool in the book...<br />
<code>Save changes</code> on the <code>permalinks</code> page...<br />
I installed <code>debug this</code> to see what going on with the <code>query</code>...<br />
I repeated other operations and changes to configurations but of no a... | [
{
"answer_id": 272258,
"author": "Mandu",
"author_id": 74623,
"author_profile": "https://wordpress.stackexchange.com/users/74623",
"pm_score": 0,
"selected": false,
"text": "<p>You might try <code>flush_rewrite_rules( $hard );</code>\nBe sure to remove the function aftewards though. </p>... | 2017/07/04 | [
"https://wordpress.stackexchange.com/questions/272249",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52581/"
] | I honestly did expect to get here...
I tried every tool in the book...
`Save changes` on the `permalinks` page...
I installed `debug this` to see what going on with the `query`...
I repeated other operations and changes to configurations but of no avail.
I've spent hours reading on `.htaccess` params as ... | I've ran into that trouble before with some of my sites when I transferred them to another server.
Here's what I did. edit your `apache2.conf` at `/etc/apache2/` folder.
Run the following command:
```
nano /etc/apache2/apache2.conf
```
Scroll down and look for this section with a comment:
```
# your system is ser... |
272,261 | <p>Quite difficult to explain this one but I will do my best.</p>
<p>Let's assume we have the theme <strong>T</strong> and plugin <strong>P</strong>.</p>
<p><strong>T</strong> has a bunch of custom taxonomies and so does <strong>P</strong>, the plugin.</p>
<p>What I am trying to achieve is display content from the c... | [
{
"answer_id": 272258,
"author": "Mandu",
"author_id": 74623,
"author_profile": "https://wordpress.stackexchange.com/users/74623",
"pm_score": 0,
"selected": false,
"text": "<p>You might try <code>flush_rewrite_rules( $hard );</code>\nBe sure to remove the function aftewards though. </p>... | 2017/07/04 | [
"https://wordpress.stackexchange.com/questions/272261",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123147/"
] | Quite difficult to explain this one but I will do my best.
Let's assume we have the theme **T** and plugin **P**.
**T** has a bunch of custom taxonomies and so does **P**, the plugin.
What I am trying to achieve is display content from the custom taxonomies in **P** in the **T** template/single files, without modify... | I've ran into that trouble before with some of my sites when I transferred them to another server.
Here's what I did. edit your `apache2.conf` at `/etc/apache2/` folder.
Run the following command:
```
nano /etc/apache2/apache2.conf
```
Scroll down and look for this section with a comment:
```
# your system is ser... |
272,276 | <p>I have created a custom map view page on my classified ads website and I seem to be having issues with the page loading, here is the code for the page.</p>
<pre><code> <?php
$featured_query = '';
if(!empty($stm_listing_filter['featured'])) {
... | [
{
"answer_id": 272277,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>This loop:</p>\n\n<pre><code>while($listing->have_posts()):\n get_template_part( 'partials/listing-cars/list... | 2017/07/04 | [
"https://wordpress.stackexchange.com/questions/272276",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123084/"
] | I have created a custom map view page on my classified ads website and I seem to be having issues with the page loading, here is the code for the page.
```
<?php
$featured_query = '';
if(!empty($stm_listing_filter['featured'])) {
... | This loop:
```
while($listing->have_posts()):
get_template_part( 'partials/listing-cars/listing-list', 'loop' );
endwhile;
```
will never terminate, because `$listing->have_posts()` will never be false. You need `$listing->the_post()` to advance the loop to the next post in each iteration. Then, when the last po... |
272,291 | <p>I developed a site in WordPress where you can click on the featured image and title of the featured image and it should take you to the corresponding page same as if you would click on the nav item:</p>
<p><a href="https://i.stack.imgur.com/VwD9y.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vw... | [
{
"answer_id": 272303,
"author": "Regolith",
"author_id": 103884,
"author_profile": "https://wordpress.stackexchange.com/users/103884",
"pm_score": 0,
"selected": false,
"text": "<p>first off you are using <code>echo the_permalink()</code></p>\n\n<pre><code><a href=\"<?php echo the... | 2017/07/04 | [
"https://wordpress.stackexchange.com/questions/272291",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109760/"
] | I developed a site in WordPress where you can click on the featured image and title of the featured image and it should take you to the corresponding page same as if you would click on the nav item:
[](https://i.stack.imgur.com/VwD9y.jpg)
This was do... | I learned that in the WP Query I had to specify page instead of quick\_links which was the custom post type. In fact I completely removed the Custom Post Type UI and the plugin. It was all completely unnecessary.
I did not want every single page, just the news, about us and get involved so I researched if there was a ... |
272,324 | <p>I accidentally deleted about 20 blog posts and they were in my trash folder for over a month and now have permanently deleted. I was wondering if there's a way to recover these? For example I have seen mention of MySql database and phpMyAdmin, and was wondering if these would be applicable in my case and, if so, how... | [
{
"answer_id": 272303,
"author": "Regolith",
"author_id": 103884,
"author_profile": "https://wordpress.stackexchange.com/users/103884",
"pm_score": 0,
"selected": false,
"text": "<p>first off you are using <code>echo the_permalink()</code></p>\n\n<pre><code><a href=\"<?php echo the... | 2017/07/05 | [
"https://wordpress.stackexchange.com/questions/272324",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123197/"
] | I accidentally deleted about 20 blog posts and they were in my trash folder for over a month and now have permanently deleted. I was wondering if there's a way to recover these? For example I have seen mention of MySql database and phpMyAdmin, and was wondering if these would be applicable in my case and, if so, how do... | I learned that in the WP Query I had to specify page instead of quick\_links which was the custom post type. In fact I completely removed the Custom Post Type UI and the plugin. It was all completely unnecessary.
I did not want every single page, just the news, about us and get involved so I researched if there was a ... |
272,331 | <p>Hi I just switched woocomerce version from 3.0.9 to 3.1.0. And I received this mesage "WooCommerce data update – We need to update your store database to the latest version"</p>
<p>So can I udpate safely woocommerce data?</p>
<p>Thanks</p>
| [
{
"answer_id": 272303,
"author": "Regolith",
"author_id": 103884,
"author_profile": "https://wordpress.stackexchange.com/users/103884",
"pm_score": 0,
"selected": false,
"text": "<p>first off you are using <code>echo the_permalink()</code></p>\n\n<pre><code><a href=\"<?php echo the... | 2017/07/05 | [
"https://wordpress.stackexchange.com/questions/272331",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/119118/"
] | Hi I just switched woocomerce version from 3.0.9 to 3.1.0. And I received this mesage "WooCommerce data update – We need to update your store database to the latest version"
So can I udpate safely woocommerce data?
Thanks | I learned that in the WP Query I had to specify page instead of quick\_links which was the custom post type. In fact I completely removed the Custom Post Type UI and the plugin. It was all completely unnecessary.
I did not want every single page, just the news, about us and get involved so I researched if there was a ... |
272,337 | <p>I am attempting to filter results based on what the user has inputted.</p>
<pre><code>function custom_archive() {
if ( is_post_type_archive( 'profiles' ) ) {
// if we are on a profiles archive page, edit the query according to the posted data.
$data = $_POST['networks'];
if ( isset( $da... | [
{
"answer_id": 272338,
"author": "Picard",
"author_id": 118566,
"author_profile": "https://wordpress.stackexchange.com/users/118566",
"pm_score": 0,
"selected": false,
"text": "<p>You should provide an array of id's to the tax_query - like here in the example from the <a href=\"https://c... | 2017/07/05 | [
"https://wordpress.stackexchange.com/questions/272337",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/118553/"
] | I am attempting to filter results based on what the user has inputted.
```
function custom_archive() {
if ( is_post_type_archive( 'profiles' ) ) {
// if we are on a profiles archive page, edit the query according to the posted data.
$data = $_POST['networks'];
if ( isset( $data ) ) {
... | So there's a few things wrong with the code:
1. You're not using the query object that's passed to the pre\_get\_posts hook, so you're not modifying the actual query.
2. Field is set to `id` instead of `term_id`.
3. If you're using `IN` as the operator, pass an array to terms.
4. You're not sanitizing the value of $\_... |
272,351 | <p>I have a simple control that displays a checkbox in the Customizer:</p>
<pre><code>$wp_customize->add_setting( 'display_about_text', array(
'default' => true
) );
$wp_customize->add_control( 'display_about_text', array(
'label' => __( 'Display Text', 'my_theme_name' ),
... | [
{
"answer_id": 272409,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 1,
"selected": false,
"text": "<p>The Customizer runs the label text through <code>esc_html()</code>, so HTML is not permitted in labels by d... | 2017/07/05 | [
"https://wordpress.stackexchange.com/questions/272351",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40536/"
] | I have a simple control that displays a checkbox in the Customizer:
```
$wp_customize->add_setting( 'display_about_text', array(
'default' => true
) );
$wp_customize->add_control( 'display_about_text', array(
'label' => __( 'Display Text', 'my_theme_name' ),
'type' => 'ch... | You should use CSS for this. For example:
```
#customize-control-display_about_text label {
font-weight: bold;
}
```
Enqueue the stylesheet for this at the `customize_controls_enqueue_scripts` action.
If you must use JS to modify a control, then note that I would not advise using `jQuery.ready` in the other ans... |
272,360 | <p>I need to 'soft' disable posts in a WordPress site. By that I mean I am hiding the 'Posts' menu item from admin... and not much else.</p>
<p>I would also like to disable 'posts' from appearing in the Menu admin. This can already be turned off by deselecting it from 'Screen Options', but is there a way to do this pr... | [
{
"answer_id": 272372,
"author": "Pratik bhatt",
"author_id": 60922,
"author_profile": "https://wordpress.stackexchange.com/users/60922",
"pm_score": 1,
"selected": false,
"text": "<p>Now create your own function called post_remove() and add code in functions.php as:</p>\n\n<pre><code>fu... | 2017/07/05 | [
"https://wordpress.stackexchange.com/questions/272360",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60816/"
] | I need to 'soft' disable posts in a WordPress site. By that I mean I am hiding the 'Posts' menu item from admin... and not much else.
I would also like to disable 'posts' from appearing in the Menu admin. This can already be turned off by deselecting it from 'Screen Options', but is there a way to do this programmatic... | We can use the `register_post_type_args` filter to adjust how the `post` post type is displayed in the backend with e.g.:
```
add_filter( 'register_post_type_args', function( $args, $name )
{
if( 'post' === $name )
{
// $args['show_ui'] = false; // Display the user-interface
$args['sh... |
272,375 | <p>I'm searching a lot about custom widgets, it seems that it can be displayed just in the sidebar, but I want to display it in my theme's footer
It's just a copyright custom text that I want to add into a widget to easily change it in WP admin, I was following this tutorial: <a href="http://www.wpbeginner.com/wp-tutor... | [
{
"answer_id": 272372,
"author": "Pratik bhatt",
"author_id": 60922,
"author_profile": "https://wordpress.stackexchange.com/users/60922",
"pm_score": 1,
"selected": false,
"text": "<p>Now create your own function called post_remove() and add code in functions.php as:</p>\n\n<pre><code>fu... | 2017/07/05 | [
"https://wordpress.stackexchange.com/questions/272375",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26805/"
] | I'm searching a lot about custom widgets, it seems that it can be displayed just in the sidebar, but I want to display it in my theme's footer
It's just a copyright custom text that I want to add into a widget to easily change it in WP admin, I was following this tutorial: <http://www.wpbeginner.com/wp-tutorials/how-to... | We can use the `register_post_type_args` filter to adjust how the `post` post type is displayed in the backend with e.g.:
```
add_filter( 'register_post_type_args', function( $args, $name )
{
if( 'post' === $name )
{
// $args['show_ui'] = false; // Display the user-interface
$args['sh... |
272,386 | <p>I'm trying to create a secure download plugin.</p>
<p>I found the rest api the best option for this task, but i cant change headers like <code>Content-Type:</code>. In the <code>register_rest_route</code> callback these headers already set.
If i set <code>Content-disposition: attachment, filename=asd.txt</code> i g... | [
{
"answer_id": 272389,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>It should be enough to add the content disposition field.</p>\n\n<p>But specifically it's Content-<strong>D<... | 2017/07/05 | [
"https://wordpress.stackexchange.com/questions/272386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123204/"
] | I'm trying to create a secure download plugin.
I found the rest api the best option for this task, but i cant change headers like `Content-Type:`. In the `register_rest_route` callback these headers already set.
If i set `Content-disposition: attachment, filename=asd.txt` i get `ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_D... | Here is what i found out:
The `ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION` error was the bad composition of the `Content-Disposition` header. Here is the correct one:
```
array(
'Content-Disposition' => 'attachment; filename="' . $filename . '"'
)
```
Note the **semicolon** after attachment, the **double... |
272,406 | <p>I am migrating a static site over to WP. Currently I have a header function that changes the inverted logo to full color on user scroll using JS.
<a href="https://synchronygroup.com/" rel="nofollow noreferrer">See Function on scroll</a></p>
<p><strong>Current JS for Scroll function:</strong></p>
<pre><code>$(windo... | [
{
"answer_id": 272403,
"author": "Den Isahac",
"author_id": 113233,
"author_profile": "https://wordpress.stackexchange.com/users/113233",
"pm_score": 4,
"selected": true,
"text": "<p>As stated in the official blog of <strong>jQuery</strong>. Note that <strong>WordPress</strong> is mentio... | 2017/07/05 | [
"https://wordpress.stackexchange.com/questions/272406",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/104284/"
] | I am migrating a static site over to WP. Currently I have a header function that changes the inverted logo to full color on user scroll using JS.
[See Function on scroll](https://synchronygroup.com/)
**Current JS for Scroll function:**
```
$(window).scroll(function() {
var top = $(window).scrollTop();
//Clea... | As stated in the official blog of **jQuery**. Note that **WordPress** is mentioned in the quote.
>
> jQuery Migrate 1.4.1 released, and the path to jQuery 3.0
> =========================================================
>
>
> Version 1.4.1 of the jQuery Migrate plugin has been released. It has only a few changes but... |
272,456 | <p>Hello i use woocommerce and i want to remove the field from the admin panel. How can I do it right?
<a href="https://i.stack.imgur.com/QrJvu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QrJvu.jpg" alt="enter image description here"></a></p>
| [
{
"answer_id": 272459,
"author": "tushonline",
"author_id": 15946,
"author_profile": "https://wordpress.stackexchange.com/users/15946",
"pm_score": 3,
"selected": true,
"text": "<p>You cannot remove the field using a code but you can disable using the sale price across the store. </p>\n\... | 2017/07/06 | [
"https://wordpress.stackexchange.com/questions/272456",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113939/"
] | Hello i use woocommerce and i want to remove the field from the admin panel. How can I do it right?
[](https://i.stack.imgur.com/QrJvu.jpg) | You cannot remove the field using a code but you can disable using the sale price across the store.
**To disable sale price**
```
function custom_wc_get_sale_price( $sale_price, $product ) {
return $product->get_regular_price();
return $sale_price;
}
add_filter( 'woocommerce_get_sale_price', 'custom_wc_get_sale... |
272,471 | <p>I am trying to implement a feature on our site where a user is able to join a team by clicking a button on that teams page (teams being custom roles set up in User Role Editor). However, if the user is already a member of that team, I don't want the button to be displayed for them. </p>
<p>I already have the code w... | [
{
"answer_id": 272459,
"author": "tushonline",
"author_id": 15946,
"author_profile": "https://wordpress.stackexchange.com/users/15946",
"pm_score": 3,
"selected": true,
"text": "<p>You cannot remove the field using a code but you can disable using the sale price across the store. </p>\n\... | 2017/07/06 | [
"https://wordpress.stackexchange.com/questions/272471",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123279/"
] | I am trying to implement a feature on our site where a user is able to join a team by clicking a button on that teams page (teams being custom roles set up in User Role Editor). However, if the user is already a member of that team, I don't want the button to be displayed for them.
I already have the code working to ... | You cannot remove the field using a code but you can disable using the sale price across the store.
**To disable sale price**
```
function custom_wc_get_sale_price( $sale_price, $product ) {
return $product->get_regular_price();
return $sale_price;
}
add_filter( 'woocommerce_get_sale_price', 'custom_wc_get_sale... |
272,476 | <p>I have a post-type Collection with custom-post-type categories.</p>
<p>I want the following url structure: www.baseurl.com/collection/current-category-name/postname</p>
<p>How do I accomplish this?</p>
| [
{
"answer_id": 272477,
"author": "berend",
"author_id": 120717,
"author_profile": "https://wordpress.stackexchange.com/users/120717",
"pm_score": 2,
"selected": true,
"text": "<p>Yes you can use the rewrite parameter when creating your custom post type:</p>\n\n<pre><code>register_post_ty... | 2017/07/06 | [
"https://wordpress.stackexchange.com/questions/272476",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31706/"
] | I have a post-type Collection with custom-post-type categories.
I want the following url structure: www.baseurl.com/collection/current-category-name/postname
How do I accomplish this? | Yes you can use the rewrite parameter when creating your custom post type:
```
register_post_type( 'example_type',
array(
'labels' => array(
'name' => "Example-Type",
'singular_name' => "example-type"
),
'public' => true,
'has_archive' => true,
... |
272,488 | <p>So far I have tried these three options and all 3 of them are not working.</p>
<h2>Option 1</h2>
<pre><code>$options = array(
'meta_key' => 'first_name',
'meta_value' => '',
'meta_compare' => '=',
);
$users = get_users( $options );
</code></pre>
<h2>Option 2</h2>
<pre><code>$options =... | [
{
"answer_id": 272492,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": true,
"text": "<p>It looks like you're searching for the <code>first_name</code> meta keys with <strong>empty</strong> string me... | 2017/07/06 | [
"https://wordpress.stackexchange.com/questions/272488",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24579/"
] | So far I have tried these three options and all 3 of them are not working.
Option 1
--------
```
$options = array(
'meta_key' => 'first_name',
'meta_value' => '',
'meta_compare' => '=',
);
$users = get_users( $options );
```
Option 2
--------
```
$options = array(
'meta_key' => 'first_na... | It looks like you're searching for the `first_name` meta keys with **empty** string meta values:
```
$options = array(
'meta_query' => array(
array(
'key' => 'first_name',
'value' => '',
'compare' => '=',
),
)
);
$users = get_users( $options );
```
th... |
272,515 | <p>Slowly going crazy over trying to make taxonomy admin columns sortable by a custom field number. I have a custom taxonomy called "typer" and these taxonomies have a custom field called "prioritet". </p>
<p>I managed to get my code to show the column, and make it sortable. Only issue is, that the fields are sorted a... | [
{
"answer_id": 284925,
"author": "dipak_pusti",
"author_id": 44528,
"author_profile": "https://wordpress.stackexchange.com/users/44528",
"pm_score": 2,
"selected": false,
"text": "<p>The code I am posting is a modified and simplified version of yours. I got my solution using your code.</... | 2017/07/06 | [
"https://wordpress.stackexchange.com/questions/272515",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/104160/"
] | Slowly going crazy over trying to make taxonomy admin columns sortable by a custom field number. I have a custom taxonomy called "typer" and these taxonomies have a custom field called "prioritet".
I managed to get my code to show the column, and make it sortable. Only issue is, that the fields are sorted alphabetica... | The code I am posting is a modified and simplified version of yours. I got my solution using your code.
```
/**
* Filter WP_Term_Query meta query
*
* @param object $query WP_Term_Query
* @return object
*/
function filter_terms_clauses( $pieces, $taxonomies, $args ) {
global $pagenow, $wpdb;
if(!is_... |
272,525 | <p>I have created <strong>Dynamic Add/Remove Custom Fields (Repeater Fields)</strong> in my custom Post types. It is working perfectly. I want to add a new <strong>JQuery Date Picker</strong> field. I tried hard to create code and also searched the web but found no luck.</p>
<p>Plz Help me.</p>
<p>Following is my cod... | [
{
"answer_id": 272631,
"author": "LWS-Mo",
"author_id": 88895,
"author_profile": "https://wordpress.stackexchange.com/users/88895",
"pm_score": 1,
"selected": false,
"text": "<p>Wordpress has the jQuery datepicker already included. So you can enqueue the default WP script. However, as fa... | 2017/07/06 | [
"https://wordpress.stackexchange.com/questions/272525",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113946/"
] | I have created **Dynamic Add/Remove Custom Fields (Repeater Fields)** in my custom Post types. It is working perfectly. I want to add a new **JQuery Date Picker** field. I tried hard to create code and also searched the web but found no luck.
Plz Help me.
Following is my code.
```
function project_rewards_select_opt... | Wordpress has the jQuery datepicker already included. So you can enqueue the default WP script. However, as far as I know, WP doesnt include the necessary styling for the datepicker!
So try to enqueue the WP script, and for example, styles from external source:
```
function my_datepicker_enqueue() {
wp_... |
272,526 | <p>Can anybody tell me that how to check if someone created his site using wordpress?</p>
| [
{
"answer_id": 272527,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 2,
"selected": true,
"text": "<p>Yes Probably.<br>\nJust Type <code>wp-admin</code> at the end of your domain like following:</p>\n\n<pre><code>htt... | 2017/07/06 | [
"https://wordpress.stackexchange.com/questions/272526",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Can anybody tell me that how to check if someone created his site using wordpress? | Yes Probably.
Just Type `wp-admin` at the end of your domain like following:
```
http://example.com/wp-admin
``` |
272,552 | <p>When a post is protected, its content looks like:</p>
<pre><code>// This content is password protected. To view it please enter your password below:
// Password: [_______________] [Enter]
</code></pre>
<p>How do I add a placeholder to that <code><input></code> tag?</p>
| [
{
"answer_id": 272553,
"author": "dodov",
"author_id": 122905,
"author_profile": "https://wordpress.stackexchange.com/users/122905",
"pm_score": 1,
"selected": false,
"text": "<p>This can be achieved via a hook, called <code>the_password_form</code>:</p>\n\n<pre><code>function my_theme_p... | 2017/07/06 | [
"https://wordpress.stackexchange.com/questions/272552",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122905/"
] | When a post is protected, its content looks like:
```
// This content is password protected. To view it please enter your password below:
// Password: [_______________] [Enter]
```
How do I add a placeholder to that `<input>` tag? | This can be achieved via a hook, called `the_password_form`:
```
function my_theme_password_placeholder($output) {
$placeholder = 'Hello!';
$search = 'type="password"';
return str_replace($search, $search . " placeholder=\"$placeholder\"", $output);
}
add_filter('the_password_form', 'my_theme_password_plac... |
272,573 | <p>I am setting a header image as a background image to the <code>.blog__header</code> block via inline styles in functions.php:</p>
<pre><code>$header_image = get_header_image();
if ( $header_image ) {
$header_image_css = "
.blog__header {
background-image: url({$header_image});
... | [
{
"answer_id": 272603,
"author": "Junaid",
"author_id": 66571,
"author_profile": "https://wordpress.stackexchange.com/users/66571",
"pm_score": 3,
"selected": true,
"text": "<p>You did not mention or shown in the code to which hook are you hooking the above code to, but here's what I thi... | 2017/07/06 | [
"https://wordpress.stackexchange.com/questions/272573",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/103046/"
] | I am setting a header image as a background image to the `.blog__header` block via inline styles in functions.php:
```
$header_image = get_header_image();
if ( $header_image ) {
$header_image_css = "
.blog__header {
background-image: url({$header_image});
}";
wp_add... | You did not mention or shown in the code to which hook are you hooking the above code to, but here's what I think should work. NOT TESTED
```
global $post;
$header_image = '';
// featured image is first priority, right?
if ( has_post_thumbnail( $post->ID ) ) {
$header_image = get_the_post_thumbnail_url( $post->ID... |
272,585 | <p>I have a custom post type product (wine). Each of the following is a custom taxonomy:</p>
<ul>
<li>Vintage (Year of harvesting) [only one per wine]</li>
<li>Family (Grape variety) [may be more than one]</li>
<li>Size (Bottle Size) [only one per product]</li>
</ul>
<p>In the single product view of a wine I want to ... | [
{
"answer_id": 272587,
"author": "Nick M.",
"author_id": 122778,
"author_profile": "https://wordpress.stackexchange.com/users/122778",
"pm_score": 0,
"selected": false,
"text": "<p>I believe you are checking for when a meta key does not exist. </p>\n\n<p>Please refer to this similar ques... | 2017/07/06 | [
"https://wordpress.stackexchange.com/questions/272585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12035/"
] | I have a custom post type product (wine). Each of the following is a custom taxonomy:
* Vintage (Year of harvesting) [only one per wine]
* Family (Grape variety) [may be more than one]
* Size (Bottle Size) [only one per product]
In the single product view of a wine I want to do the following queries:
1) Find all wi... | AFAIK there's no way to achieve that within a single WP\_Query, so you'll have to first get a list of term\_ids which have a **different year** than the one in question.
I think with the following you'll come quite close. (don't have a env to test right away)
```
$other_years_terms = get_terms(
'taxonomy' =... |
272,613 | <p>I'm trying to create a page on WordPress with a grid which contains al my posts. </p>
<p>The grid works well until when I add the <code>the_excerpt();</code> for my post. The grid became a mess. The rows are not correct anymore. </p>
<p>This is what I have without <code>the_excerpt();</code>:</p>
<p><a href="http... | [
{
"answer_id": 272615,
"author": "Kieran McClung",
"author_id": 52293,
"author_profile": "https://wordpress.stackexchange.com/users/52293",
"pm_score": 2,
"selected": false,
"text": "<p>The way I tackle this issue is by closing the row every <em>nth</em> column, like so. You basically co... | 2017/07/07 | [
"https://wordpress.stackexchange.com/questions/272613",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107597/"
] | I'm trying to create a page on WordPress with a grid which contains al my posts.
The grid works well until when I add the `the_excerpt();` for my post. The grid became a mess. The rows are not correct anymore.
This is what I have without `the_excerpt();`:
[.
Example: You could tweak this to `if ( $i... |
272,619 | <p>I'm trying to get a list/count of products who's has a specific attribute and value. Products are managed and setup using the WooCommerce plugin.</p>
<p>Each product has the same variation set, the product is assigned to a category, I need to retrieve only product with a specific attribute i.e "newyork" and the sto... | [
{
"answer_id": 291998,
"author": "Minh Dao",
"author_id": 135439,
"author_profile": "https://wordpress.stackexchange.com/users/135439",
"pm_score": -1,
"selected": false,
"text": "<p>I think you has a proble on 'tax_query'.\nIf you want you query array on 'tax_query', you need flown on f... | 2017/07/07 | [
"https://wordpress.stackexchange.com/questions/272619",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/120173/"
] | I'm trying to get a list/count of products who's has a specific attribute and value. Products are managed and setup using the WooCommerce plugin.
Each product has the same variation set, the product is assigned to a category, I need to retrieve only product with a specific attribute i.e "newyork" and the stock quantit... | You should use [wc\_get\_products and a custom filter](https://github.com/woocommerce/woocommerce/wiki/wc_get_products-and-WC_Product_Query#adding-custom-parameter-support) for adding your specific query.
**Example**
I want to find products containing a specific attribute value "table-filter".
```
$args = array(
... |
272,620 | <p>I want disable one specific page of the default css, and i want use my css on the specific page. I don't know it is posibble?</p>
<p>I use Blank State plugin, for create blank page, but css its on the blank pages, but i want my css use on the specific blank pages.</p>
<p><a href="https://wordpress.org/plugins/blan... | [
{
"answer_id": 291998,
"author": "Minh Dao",
"author_id": 135439,
"author_profile": "https://wordpress.stackexchange.com/users/135439",
"pm_score": -1,
"selected": false,
"text": "<p>I think you has a proble on 'tax_query'.\nIf you want you query array on 'tax_query', you need flown on f... | 2017/07/07 | [
"https://wordpress.stackexchange.com/questions/272620",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123365/"
] | I want disable one specific page of the default css, and i want use my css on the specific page. I don't know it is posibble?
I use Blank State plugin, for create blank page, but css its on the blank pages, but i want my css use on the specific blank pages.
<https://wordpress.org/plugins/blank-slate/>
So, i have one... | You should use [wc\_get\_products and a custom filter](https://github.com/woocommerce/woocommerce/wiki/wc_get_products-and-WC_Product_Query#adding-custom-parameter-support) for adding your specific query.
**Example**
I want to find products containing a specific attribute value "table-filter".
```
$args = array(
... |
272,659 | <p>I am trying to write a simple plugin that fetches some data from an API endpoint. I am planning to read the api key from a shortcode, but didn't get that far yet.</p>
<p>I wrote the following piece of code. The noob question I have is how do I even trigger the code so that I could debug it to see what happens ?</p>... | [
{
"answer_id": 291998,
"author": "Minh Dao",
"author_id": 135439,
"author_profile": "https://wordpress.stackexchange.com/users/135439",
"pm_score": -1,
"selected": false,
"text": "<p>I think you has a proble on 'tax_query'.\nIf you want you query array on 'tax_query', you need flown on f... | 2017/07/07 | [
"https://wordpress.stackexchange.com/questions/272659",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123390/"
] | I am trying to write a simple plugin that fetches some data from an API endpoint. I am planning to read the api key from a shortcode, but didn't get that far yet.
I wrote the following piece of code. The noob question I have is how do I even trigger the code so that I could debug it to see what happens ?
If that's a ... | You should use [wc\_get\_products and a custom filter](https://github.com/woocommerce/woocommerce/wiki/wc_get_products-and-WC_Product_Query#adding-custom-parameter-support) for adding your specific query.
**Example**
I want to find products containing a specific attribute value "table-filter".
```
$args = array(
... |
272,675 | <p>I am working on a WordPress theme offline in localhost It's a blog theme: <a href="http://preview.themeforest.net/item/paperback-magazine-wordpress-theme/full_screen_preview/13511026" rel="nofollow noreferrer">http://preview.themeforest.net/item/paperback-magazine-wordpress-theme/full_screen_preview/13511026</a> . I... | [
{
"answer_id": 291998,
"author": "Minh Dao",
"author_id": 135439,
"author_profile": "https://wordpress.stackexchange.com/users/135439",
"pm_score": -1,
"selected": false,
"text": "<p>I think you has a proble on 'tax_query'.\nIf you want you query array on 'tax_query', you need flown on f... | 2017/07/07 | [
"https://wordpress.stackexchange.com/questions/272675",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/119981/"
] | I am working on a WordPress theme offline in localhost It's a blog theme: <http://preview.themeforest.net/item/paperback-magazine-wordpress-theme/full_screen_preview/13511026> . I need to create a profile header in such a way that these writers would be able to put in their bio, a background picture, profile picture an... | You should use [wc\_get\_products and a custom filter](https://github.com/woocommerce/woocommerce/wiki/wc_get_products-and-WC_Product_Query#adding-custom-parameter-support) for adding your specific query.
**Example**
I want to find products containing a specific attribute value "table-filter".
```
$args = array(
... |
272,682 | <p>A client is using the WordPress REST JSON API with some WordPress data models. We need to hit the WordPress API from the frontend and retreive a few hundred custom posts.</p>
<p>Wordpress has a <a href="https://developer.wordpress.org/reference/classes/wp_rest_controller/get_collection_params/" rel="nofollow noref... | [
{
"answer_id": 272724,
"author": "kero",
"author_id": 108180,
"author_profile": "https://wordpress.stackexchange.com/users/108180",
"pm_score": 1,
"selected": false,
"text": "<p>You cannot get over that limit of 100 posts per requests in WordPress for default requests. One way to still r... | 2017/07/07 | [
"https://wordpress.stackexchange.com/questions/272682",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52128/"
] | A client is using the WordPress REST JSON API with some WordPress data models. We need to hit the WordPress API from the frontend and retreive a few hundred custom posts.
Wordpress has a [hard limit of 100 custom posts](https://developer.wordpress.org/reference/classes/wp_rest_controller/get_collection_params/).
I wo... | You cannot get over that limit of 100 posts per requests in WordPress for default requests. One way to still retrieve all posts would be to query that interface until you have all posts. Another would be a custom endpoint.
If you can, I suggest creating your own REST endpoint. This will already work and return all pos... |
272,717 | <p>I am newbie in wordpress but not very new.</p>
<p>When I came to know that wordpress have inbuilt shortcodes like audio, video, gallery, playlist.</p>
<p>I have searched for a list of inbuilt shortcodes that WordPress provides but I did not get anything except above can anybody provide me a link which has a list o... | [
{
"answer_id": 272721,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>You got almost all of them:</p>\n\n<pre><code>caption\ngallery\naudio\nvideo\nplaylist\nembed\n</code></pre>\n\n<p... | 2017/07/08 | [
"https://wordpress.stackexchange.com/questions/272717",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123366/"
] | I am newbie in wordpress but not very new.
When I came to know that wordpress have inbuilt shortcodes like audio, video, gallery, playlist.
I have searched for a list of inbuilt shortcodes that WordPress provides but I did not get anything except above can anybody provide me a link which has a list of inbuilt wp shor... | You can actually list all of the available shortcodes for your WordPress installation by using the following code:
```
<?php
global $shortcode_tags;
echo '<pre>';
print_r($shortcode_tags);
echo '</pre>';
?>
```
It will show the main WordPress shortcodes plus any shortcodes for installed plugins which can be handy ... |
272,760 | <p>I have done some weird things with a few custom theme pages. Namely, i have bypassed the wp_query and obtained data from a different db. I populate the post object with custom data and then inject this into my theme. Since the toolbar shows up fine normally, there must be some sort of trigger that i am bypassing by ... | [
{
"answer_id": 272721,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>You got almost all of them:</p>\n\n<pre><code>caption\ngallery\naudio\nvideo\nplaylist\nembed\n</code></pre>\n\n<p... | 2017/07/09 | [
"https://wordpress.stackexchange.com/questions/272760",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190834/"
] | I have done some weird things with a few custom theme pages. Namely, i have bypassed the wp\_query and obtained data from a different db. I populate the post object with custom data and then inject this into my theme. Since the toolbar shows up fine normally, there must be some sort of trigger that i am bypassing by no... | You can actually list all of the available shortcodes for your WordPress installation by using the following code:
```
<?php
global $shortcode_tags;
echo '<pre>';
print_r($shortcode_tags);
echo '</pre>';
?>
```
It will show the main WordPress shortcodes plus any shortcodes for installed plugins which can be handy ... |
272,772 | <p>I have a WP installation with 6 categories and I want 3 of them to use a custom Category Archive Page called "category-special.php" (default page is the "category.php").
I found the code below that looks to be close to my query, how can I modify and make it work for me, so categories 31,40 and 55 to load the above s... | [
{
"answer_id": 272721,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>You got almost all of them:</p>\n\n<pre><code>caption\ngallery\naudio\nvideo\nplaylist\nembed\n</code></pre>\n\n<p... | 2017/07/09 | [
"https://wordpress.stackexchange.com/questions/272772",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/117746/"
] | I have a WP installation with 6 categories and I want 3 of them to use a custom Category Archive Page called "category-special.php" (default page is the "category.php").
I found the code below that looks to be close to my query, how can I modify and make it work for me, so categories 31,40 and 55 to load the above spec... | You can actually list all of the available shortcodes for your WordPress installation by using the following code:
```
<?php
global $shortcode_tags;
echo '<pre>';
print_r($shortcode_tags);
echo '</pre>';
?>
```
It will show the main WordPress shortcodes plus any shortcodes for installed plugins which can be handy ... |
272,787 | <p>The permalink structure has changed with old entries as well as any new entry (post, object, etc) from THEN to NOW </p>
<p>THEN: </p>
<blockquote>
<p>constructstudies.com/(page slug or object label)</p>
</blockquote>
<p>NOW: </p>
<blockquote>
<p>constructstudies.com/disability-application/disability-benefits... | [
{
"answer_id": 272721,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>You got almost all of them:</p>\n\n<pre><code>caption\ngallery\naudio\nvideo\nplaylist\nembed\n</code></pre>\n\n<p... | 2017/07/09 | [
"https://wordpress.stackexchange.com/questions/272787",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123480/"
] | The permalink structure has changed with old entries as well as any new entry (post, object, etc) from THEN to NOW
THEN:
>
> constructstudies.com/(page slug or object label)
>
>
>
NOW:
>
> constructstudies.com/disability-application/disability-benefits-application/disability-application/(page
> slug or obj... | You can actually list all of the available shortcodes for your WordPress installation by using the following code:
```
<?php
global $shortcode_tags;
echo '<pre>';
print_r($shortcode_tags);
echo '</pre>';
?>
```
It will show the main WordPress shortcodes plus any shortcodes for installed plugins which can be handy ... |
272,797 | <p>I have Wordpress menus that is seems are put together in the backend somehow. I used <a href="https://developer.wordpress.org/reference/functions/wp_nav_menu/" rel="nofollow noreferrer">wp_nav_menu()</a> to customize the wrap of the menu items slightly.</p>
<p>My issue is I have found no direct access to access the... | [
{
"answer_id": 272721,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>You got almost all of them:</p>\n\n<pre><code>caption\ngallery\naudio\nvideo\nplaylist\nembed\n</code></pre>\n\n<p... | 2017/07/09 | [
"https://wordpress.stackexchange.com/questions/272797",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123346/"
] | I have Wordpress menus that is seems are put together in the backend somehow. I used [wp\_nav\_menu()](https://developer.wordpress.org/reference/functions/wp_nav_menu/) to customize the wrap of the menu items slightly.
My issue is I have found no direct access to access the menu items, and add a custom field to them. ... | You can actually list all of the available shortcodes for your WordPress installation by using the following code:
```
<?php
global $shortcode_tags;
echo '<pre>';
print_r($shortcode_tags);
echo '</pre>';
?>
```
It will show the main WordPress shortcodes plus any shortcodes for installed plugins which can be handy ... |
272,801 | <p>I come from a Laravel background which means I am used to using database migrations and seedings to keep content on dev / staging sites in sync with my local environment.</p>
<p>I'm starting my first project in WordPress and was wondering how to go about doing the same. Essentially I'm building the site on my local... | [
{
"answer_id": 272721,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>You got almost all of them:</p>\n\n<pre><code>caption\ngallery\naudio\nvideo\nplaylist\nembed\n</code></pre>\n\n<p... | 2017/07/09 | [
"https://wordpress.stackexchange.com/questions/272801",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62933/"
] | I come from a Laravel background which means I am used to using database migrations and seedings to keep content on dev / staging sites in sync with my local environment.
I'm starting my first project in WordPress and was wondering how to go about doing the same. Essentially I'm building the site on my local environme... | You can actually list all of the available shortcodes for your WordPress installation by using the following code:
```
<?php
global $shortcode_tags;
echo '<pre>';
print_r($shortcode_tags);
echo '</pre>';
?>
```
It will show the main WordPress shortcodes plus any shortcodes for installed plugins which can be handy ... |
272,844 | <p>I am clicking on the link define in the anchor tag and fetching the url. I want to pass this url in url_to_postid($_POST['url']) which returns me ID.</p>
<p>What I have done till far now is everything working except the ajax call on admin-ajax to pass url to fetch ID</p>
<p>Step 1 : Created a widget in widget() fu... | [
{
"answer_id": 272883,
"author": "Aniruddha Gawade",
"author_id": 101818,
"author_profile": "https://wordpress.stackexchange.com/users/101818",
"pm_score": 0,
"selected": false,
"text": "<p>Your <code>action</code> in JQuery and and hook action is not matching.\nIt should be:</p>\n\n<pre... | 2017/07/10 | [
"https://wordpress.stackexchange.com/questions/272844",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123508/"
] | I am clicking on the link define in the anchor tag and fetching the url. I want to pass this url in url\_to\_postid($\_POST['url']) which returns me ID.
What I have done till far now is everything working except the ajax call on admin-ajax to pass url to fetch ID
Step 1 : Created a widget in widget() function
Step 2... | the another way to get the `post_id` by clicking on the `link` is to add a `data-attribute` to the link. e.g; `data-post-id="'.get_the_ID().'"`
your html code should look like
```
<a href="#link" data-post-id="47">Link</a>
```
then in your js code above the ajax call
```
var post_id = jQuery(this).attr('data-post-... |
272,858 | <p>Can anyone help me how to add custom css file in wordpress.</p>
<p>I followed the below link,
<a href="https://wordpress.stackexchange.com/questions/258226/where-are-additional-css-files-stored">Where are Additional CSS files stored</a>.
But it shows only adding additional css, but i want to add css file and callin... | [
{
"answer_id": 272860,
"author": "Jignesh Patel",
"author_id": 111556,
"author_profile": "https://wordpress.stackexchange.com/users/111556",
"pm_score": 2,
"selected": false,
"text": "<p>Put this code in functions.php file for add new css file (more info <a href=\"https://developer.wordp... | 2017/07/10 | [
"https://wordpress.stackexchange.com/questions/272858",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122737/"
] | Can anyone help me how to add custom css file in wordpress.
I followed the below link,
[Where are Additional CSS files stored](https://wordpress.stackexchange.com/questions/258226/where-are-additional-css-files-stored).
But it shows only adding additional css, but i want to add css file and calling,
Thanks | Put this code in functions.php file for add new css file (more info [here](https://developer.wordpress.org/reference/functions/wp_enqueue_style/)).
```
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
function enqueue_my_styles() {
wp_enqueue_style( 'my-theme-ie', get_stylesheet_directory_uri() . "/css/ie.... |
272,879 | <p>I create custom field type select</p>
<p><a href="https://i.stack.imgur.com/bofha.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bofha.png" alt="enter image description here"></a> </p>
<p>Need display <code>values</code> from custom field outside <code><?php if ( have_posts() ) : while ( hav... | [
{
"answer_id": 272880,
"author": "Aniruddha Gawade",
"author_id": 101818,
"author_profile": "https://wordpress.stackexchange.com/users/101818",
"pm_score": 2,
"selected": false,
"text": "<p>You need to pass <code>$postid</code> to your <code>get_field</code> function.</p>\n\n<pre><code>&... | 2017/07/10 | [
"https://wordpress.stackexchange.com/questions/272879",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/120398/"
] | I create custom field type select
[](https://i.stack.imgur.com/bofha.png)
Need display `values` from custom field outside `<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>` like [bootstrap tabs](https://v4-alpha.getbootstrap.com/c... | I make this:
```
<ul class="nav nav-tabs d-flex justify-content-center flex-wrap team-navs">
<?php $loop = new WP_Query( array( 'post_type' => 'employee', 'post_status'=>'publish', 'posts_per_page' => -1 ) ); ?>
<?php
$counter = 0;
while ( $loop->have_pos... |
272,887 | <p>First apologies if this is a stupid question I can imagine there is an easy way to do this but would like to ask anyhow.</p>
<p>I have setup a js framework that I am trying to integrate into a WordPress plugin. Currently if works like this.</p>
<pre><code>example("div").media({
plugins: {
... | [
{
"answer_id": 272880,
"author": "Aniruddha Gawade",
"author_id": 101818,
"author_profile": "https://wordpress.stackexchange.com/users/101818",
"pm_score": 2,
"selected": false,
"text": "<p>You need to pass <code>$postid</code> to your <code>get_field</code> function.</p>\n\n<pre><code>&... | 2017/07/10 | [
"https://wordpress.stackexchange.com/questions/272887",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83641/"
] | First apologies if this is a stupid question I can imagine there is an easy way to do this but would like to ask anyhow.
I have setup a js framework that I am trying to integrate into a WordPress plugin. Currently if works like this.
```
example("div").media({
plugins: {
modal : true
... | I make this:
```
<ul class="nav nav-tabs d-flex justify-content-center flex-wrap team-navs">
<?php $loop = new WP_Query( array( 'post_type' => 'employee', 'post_status'=>'publish', 'posts_per_page' => -1 ) ); ?>
<?php
$counter = 0;
while ( $loop->have_pos... |
272,902 | <p>I am trying to upload many hundreds of images daily from a folder on the server to the media library using the following script that is scheduled via CRON:</p>
<pre><code><?php
require_once('../../../../public/wordpress/wp-load.php');
require_once('../../../../public/wordpress/wp-admin/includes/image.php');
fun... | [
{
"answer_id": 273298,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": false,
"text": "<p>There is already a built-in function created just for that purpose. You don't need to write walls of codes ... | 2017/07/10 | [
"https://wordpress.stackexchange.com/questions/272902",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/87803/"
] | I am trying to upload many hundreds of images daily from a folder on the server to the media library using the following script that is scheduled via CRON:
```
<?php
require_once('../../../../public/wordpress/wp-load.php');
require_once('../../../../public/wordpress/wp-admin/includes/image.php');
function importImage... | A few things
* Use `media_handle_sideload` so that WordPress moves the files to the right location and validates them for you, creates the attachment post etc, none of this manual stuff
* Don't run this once and expect it to do everything. You're just going to run into the same problem but further into the import. If ... |
272,925 | <p>I've read a bunch of articles about <a href="https://docs.woocommerce.com/document/template-structure/" rel="nofollow noreferrer">overriding the default /woocommerce/ templates</a> and tried implementing the following (which were the best/most relevant that I could find all to no avail):</p>
<ul>
<li><a href="https... | [
{
"answer_id": 272930,
"author": "Syed Abuthahir M",
"author_id": 112046,
"author_profile": "https://wordpress.stackexchange.com/users/112046",
"pm_score": 0,
"selected": false,
"text": "<p>In this scenario you can use the following filter wc_get_template_part.</p>\n\n<p>Hook reference l... | 2017/07/10 | [
"https://wordpress.stackexchange.com/questions/272925",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47880/"
] | I've read a bunch of articles about [overriding the default /woocommerce/ templates](https://docs.woocommerce.com/document/template-structure/) and tried implementing the following (which were the best/most relevant that I could find all to no avail):
* [Load WooCommerce templates from my plugin folder first](https://... | ```
function woo_template_replace( $located, $template_name, $args, $template_path, $default_path ) {
if( file_exists( plugin_dir_path(__FILE__) . 'templates/' . $template_name ) ) {
$located = plugin_dir_path(__FILE__) . 'templates/' . $template_name;
}
return $located;
}
function woo_get_template_part( $templa... |
272,928 | <p>I've managed to get the behaviour I want by modifying some plugin code. However, I would like to move my modifications outside of the plugin code using the provided hook, but I can't seem make it work. The hook uses do_action_ref_array.</p>
<p>The situation is not helped by the fact that the only way I can find to ... | [
{
"answer_id": 272934,
"author": "Syed Abuthahir M",
"author_id": 112046,
"author_profile": "https://wordpress.stackexchange.com/users/112046",
"pm_score": 0,
"selected": false,
"text": "<p>You need to write custom function in functions.php with name of <code>bookly_validate_custom_field... | 2017/07/10 | [
"https://wordpress.stackexchange.com/questions/272928",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98276/"
] | I've managed to get the behaviour I want by modifying some plugin code. However, I would like to move my modifications outside of the plugin code using the provided hook, but I can't seem make it work. The hook uses do\_action\_ref\_array.
The situation is not helped by the fact that the only way I can find to access ... | That feature exists because I bugged them to implement it :)
* <https://support.booking-wp-plugin.com/hc/en-us/community/posts/207263389-Add-a-WordPress-hook-for-custom-validators-on-the-custom-fields?page=1#community_comment_115001021885>
Using it confused me as well but somebody finally replied to this just the oth... |
272,936 | <p>To avoid image caching issues, I would like to get WordPress to reference my jpeg images with a URL parameter. I know in javascript I can do this: </p>
<pre><code><img id="idSigma" src="#" class="classSigma">
<script>
$(document).ready(function() {
var d = new Date();
$("#idSigma").attr("src", "imag... | [
{
"answer_id": 272934,
"author": "Syed Abuthahir M",
"author_id": 112046,
"author_profile": "https://wordpress.stackexchange.com/users/112046",
"pm_score": 0,
"selected": false,
"text": "<p>You need to write custom function in functions.php with name of <code>bookly_validate_custom_field... | 2017/07/10 | [
"https://wordpress.stackexchange.com/questions/272936",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123537/"
] | To avoid image caching issues, I would like to get WordPress to reference my jpeg images with a URL parameter. I know in javascript I can do this:
```
<img id="idSigma" src="#" class="classSigma">
<script>
$(document).ready(function() {
var d = new Date();
$("#idSigma").attr("src", "images/Sigma.jpeg?t=" + d.getT... | That feature exists because I bugged them to implement it :)
* <https://support.booking-wp-plugin.com/hc/en-us/community/posts/207263389-Add-a-WordPress-hook-for-custom-validators-on-the-custom-fields?page=1#community_comment_115001021885>
Using it confused me as well but somebody finally replied to this just the oth... |
272,962 | <p>I can't find any information anywhere about what data I need to give exactly. When I try to read the data from one of my posts with a thumbnail already I get this but there's not way you have to enter all this info just to add a featured image:</p>
<pre><code> thumbnail:
{ attachment_id: '360',
da... | [
{
"answer_id": 273086,
"author": "cooldude101",
"author_id": 123580,
"author_profile": "https://wordpress.stackexchange.com/users/123580",
"pm_score": 1,
"selected": false,
"text": "<p>I found my problem and just passing it on in case someone googles this.</p>\n\n<p>You need to pass the ... | 2017/07/11 | [
"https://wordpress.stackexchange.com/questions/272962",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123580/"
] | I can't find any information anywhere about what data I need to give exactly. When I try to read the data from one of my posts with a thumbnail already I get this but there's not way you have to enter all this info just to add a featured image:
```
thumbnail:
{ attachment_id: '360',
date_created_gmt... | In order to have your post have a default image, you need to set your post thumbnail. In doing this you need to set the ID of the media, which isn't readily apparent.
I do most of my work in Python, so for me, the following helps:
**Step 1.** Get the list of all your media so you know the IDs
```
##
## Retrieve a li... |
272,968 | <p>I am running some calculations on custom field data using wp_query on a large number of posts and it is taking a long time to load the result. I was advised by a user here to take advantage of wp cron to run these calculations once daily.</p>
<p>What I've been unable to wrap my head around is - if I create an actio... | [
{
"answer_id": 273086,
"author": "cooldude101",
"author_id": 123580,
"author_profile": "https://wordpress.stackexchange.com/users/123580",
"pm_score": 1,
"selected": false,
"text": "<p>I found my problem and just passing it on in case someone googles this.</p>\n\n<p>You need to pass the ... | 2017/07/11 | [
"https://wordpress.stackexchange.com/questions/272968",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105873/"
] | I am running some calculations on custom field data using wp\_query on a large number of posts and it is taking a long time to load the result. I was advised by a user here to take advantage of wp cron to run these calculations once daily.
What I've been unable to wrap my head around is - if I create an action which c... | In order to have your post have a default image, you need to set your post thumbnail. In doing this you need to set the ID of the media, which isn't readily apparent.
I do most of my work in Python, so for me, the following helps:
**Step 1.** Get the list of all your media so you know the IDs
```
##
## Retrieve a li... |
272,997 | <p>I'm trying to achieve simple result. Run main loop 2 times, but first time for the one post with different layout, and second time for the rest posts with different layout. I found that condition <strong>1 > $wp_query->current_post</strong> can show only the first post in my loop. But when I run loop again it starts... | [
{
"answer_id": 273086,
"author": "cooldude101",
"author_id": 123580,
"author_profile": "https://wordpress.stackexchange.com/users/123580",
"pm_score": 1,
"selected": false,
"text": "<p>I found my problem and just passing it on in case someone googles this.</p>\n\n<p>You need to pass the ... | 2017/07/11 | [
"https://wordpress.stackexchange.com/questions/272997",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112255/"
] | I'm trying to achieve simple result. Run main loop 2 times, but first time for the one post with different layout, and second time for the rest posts with different layout. I found that condition **1 > $wp\_query->current\_post** can show only the first post in my loop. But when I run loop again it starts with 3rd post... | In order to have your post have a default image, you need to set your post thumbnail. In doing this you need to set the ID of the media, which isn't readily apparent.
I do most of my work in Python, so for me, the following helps:
**Step 1.** Get the list of all your media so you know the IDs
```
##
## Retrieve a li... |
273,063 | <p>I don't know exactly how is the correct name, but i want to create my own table like the default wordpress table : </p>
<p><a href="https://i.stack.imgur.com/WCgaY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WCgaY.png" alt="enter image description here"></a></p>
<p>I wanted to ask, does the ... | [
{
"answer_id": 273068,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 0,
"selected": false,
"text": "<p>Did you already create your custom post type? Or were you trying to modify what appears on that page? </p>\n\n... | 2017/07/11 | [
"https://wordpress.stackexchange.com/questions/273063",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121651/"
] | I don't know exactly how is the correct name, but i want to create my own table like the default wordpress table :
[](https://i.stack.imgur.com/WCgaY.png)
I wanted to ask, does the WordPress provide some API to create it? | I'm not an expert on this but I did get into it a little recently. Take a look at this tutorial: <http://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/>
Basically, you'll want to create a class that extends `WP_List_Table`:
```
class My_List_Table extends WP_List_Table {
// what your table is all about
}
... |
273,078 | <p>I'm trying to add a link to each item of the Users table in the WP Admin area and use that link to send that specific user an email. I'm most of the way there but I'm having some odd behavior that I can't figure out. Here's my code: (I describe my issues below that)</p>
<pre><code>// Adds "Send rejection email" act... | [
{
"answer_id": 273068,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 0,
"selected": false,
"text": "<p>Did you already create your custom post type? Or were you trying to modify what appears on that page? </p>\n\n... | 2017/07/11 | [
"https://wordpress.stackexchange.com/questions/273078",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/117675/"
] | I'm trying to add a link to each item of the Users table in the WP Admin area and use that link to send that specific user an email. I'm most of the way there but I'm having some odd behavior that I can't figure out. Here's my code: (I describe my issues below that)
```
// Adds "Send rejection email" action to Users p... | I'm not an expert on this but I did get into it a little recently. Take a look at this tutorial: <http://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/>
Basically, you'll want to create a class that extends `WP_List_Table`:
```
class My_List_Table extends WP_List_Table {
// what your table is all about
}
... |
273,084 | <p>I have a situation where my search is working but the client just came with a request I hadn't considered. If you search by first name (eg. john) or last name (eg. doe), this will absolutely bring your result. But if you search for their full name (eg. john doe), you get 0 results.</p>
<p>I've looked around but I c... | [
{
"answer_id": 273173,
"author": "dbeja",
"author_id": 9585,
"author_profile": "https://wordpress.stackexchange.com/users/9585",
"pm_score": 3,
"selected": true,
"text": "<p>What if you use IN operator and split the search term in a words array:</p>\n\n<pre><code>$args = array(\n 'rol... | 2017/07/11 | [
"https://wordpress.stackexchange.com/questions/273084",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76600/"
] | I have a situation where my search is working but the client just came with a request I hadn't considered. If you search by first name (eg. john) or last name (eg. doe), this will absolutely bring your result. But if you search for their full name (eg. john doe), you get 0 results.
I've looked around but I can't seem ... | What if you use IN operator and split the search term in a words array:
```
$args = array(
'role' => 'Subscriber',
'meta_query' => array(
array(
'key' => 'membership_class',
'value' => 'Full',
'compare' => '=',
'type' ... |
273,094 | <p>I'm trying to register a new shortcode on my custom theme. </p>
<p>In functions.php I have created a basic test function as follows</p>
<pre><code>function get_second_image($atts) {
echo ‘test’;
}
</code></pre>
<p>And registered it right underneath</p>
<pre><code>add_shortcode( ‘case_study_second_image_sc’, ... | [
{
"answer_id": 273096,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>See the documentation here <a href=\"https://codex.wordpress.org/Shortcode_API\" rel=\"nofollow norefe... | 2017/07/12 | [
"https://wordpress.stackexchange.com/questions/273094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123673/"
] | I'm trying to register a new shortcode on my custom theme.
In functions.php I have created a basic test function as follows
```
function get_second_image($atts) {
echo ‘test’;
}
```
And registered it right underneath
```
add_shortcode( ‘case_study_second_image_sc’, ‘get_second_image’ );
```
Using the WYSIWY... | Make sure to use straight quotes, e.g. `'` or `"` and not curly quotes `‘`, `’`, `“`, or `”` for strings.
Also, shortcodes should return their output, not echo it.
When WordPress finds a shortcode without a callback, it displays the shortcode tag just as it was entered e.g. `[case_study_second_image_sc]`.
The shortc... |
273,112 | <p>I have been working on trying to get data to store and display on a CPT field. The code I have is here:</p>
<pre><code>function fhaac_subject_box_callback( $post ){
wp_nonce_field( basename(__FILE__ ), 'fhacc_subject_nounce');
$fhaac_stored_subject_meta = get_post_meta( '$post->ID' );
?>
<div>... | [
{
"answer_id": 273096,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>See the documentation here <a href=\"https://codex.wordpress.org/Shortcode_API\" rel=\"nofollow norefe... | 2017/07/12 | [
"https://wordpress.stackexchange.com/questions/273112",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58313/"
] | I have been working on trying to get data to store and display on a CPT field. The code I have is here:
```
function fhaac_subject_box_callback( $post ){
wp_nonce_field( basename(__FILE__ ), 'fhacc_subject_nounce');
$fhaac_stored_subject_meta = get_post_meta( '$post->ID' );
?>
<div>Subject name: <input type... | Make sure to use straight quotes, e.g. `'` or `"` and not curly quotes `‘`, `’`, `“`, or `”` for strings.
Also, shortcodes should return their output, not echo it.
When WordPress finds a shortcode without a callback, it displays the shortcode tag just as it was entered e.g. `[case_study_second_image_sc]`.
The shortc... |
273,144 | <p>Recently all of my REST-API requests suddenly turned to return a 404 error, Every request (no matter custom endpoint or built-in).</p>
<p>Then I figured it's because of permalink's structure. <code>/wp-json/</code> is not accessible under plain permalink, since there is simply no redirect rule available at the mome... | [
{
"answer_id": 273147,
"author": "kraftner",
"author_id": 47733,
"author_profile": "https://wordpress.stackexchange.com/users/47733",
"pm_score": 5,
"selected": true,
"text": "<p>Yes you can. Just add the <code>rest_route</code> query parameter.</p>\n\n<p>So</p>\n\n<p><a href=\"https://w... | 2017/07/12 | [
"https://wordpress.stackexchange.com/questions/273144",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94498/"
] | Recently all of my REST-API requests suddenly turned to return a 404 error, Every request (no matter custom endpoint or built-in).
Then I figured it's because of permalink's structure. `/wp-json/` is not accessible under plain permalink, since there is simply no redirect rule available at the moment.
Is it possible t... | Yes you can. Just add the `rest_route` query parameter.
So
<https://wordpress.org/wp-json/>
would become
<https://wordpress.org/?rest_route=/>
Or `https://wordpress.org/wp-json/wp/v2/` would become `https://wordpress.org/?rest_route=/wp/v2` to give you a more complete example.
So you're wondering how to decide w... |
273,165 | <p>I am trying to display a taxonomy term's image and need the term's ID. For some reason I am having trouble getting the ID. If I hard-code the ID in place of <code>$term_id</code> everything works as expected, but of course that doesn't help in a template.</p>
<p>For reference, my taxonomy is <code>Organizations</co... | [
{
"answer_id": 273168,
"author": "dbeja",
"author_id": 9585,
"author_profile": "https://wordpress.stackexchange.com/users/9585",
"pm_score": 0,
"selected": false,
"text": "<p>Are you using this on an archive page?</p>\n\n<p>Try to get the term ID with this instead:</p>\n\n<pre><code>$que... | 2017/07/12 | [
"https://wordpress.stackexchange.com/questions/273165",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123721/"
] | I am trying to display a taxonomy term's image and need the term's ID. For some reason I am having trouble getting the ID. If I hard-code the ID in place of `$term_id` everything works as expected, but of course that doesn't help in a template.
For reference, my taxonomy is `Organizations` and each entry is the name o... | The term ID is contained within the term object you are already using in your loop:
```
echo z_taxonomy_image_url( $term->term_id, 'thumbnail' );
``` |
273,194 | <p>I want to prevent posts that dont have thumbnails from showing on the homepage, category page, archive, etc.</p>
<p>Using something like </p>
<pre><code>if (get_the_post_thumbnail_url() != "") {
//don't insert post
}
</code></pre>
<p>What filter / hook should I use?</p>
| [
{
"answer_id": 273206,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 0,
"selected": false,
"text": "<p>What you asked for can be expensive. You can not check if a post has thumbnail or not unless the query is r... | 2017/07/12 | [
"https://wordpress.stackexchange.com/questions/273194",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123742/"
] | I want to prevent posts that dont have thumbnails from showing on the homepage, category page, archive, etc.
Using something like
```
if (get_the_post_thumbnail_url() != "") {
//don't insert post
}
```
What filter / hook should I use? | >
> What filter / hook should I use?
>
>
>
You can use the `pre_get_posts` action hook.
Following [Tom's](https://wordpress.stackexchange.com/users/736/tom-j-nowell) comment on the question about querying for what you want, maybe set `meta_query` to `_thumbnail_id`.
I would also `(` group `)` the conditionals to... |
273,239 | <p><strong>Set-up</strong></p>
<p>I have the following standard Adsense script inserted in my <code>header.php</code> file, </p>
<pre><code><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
</script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_... | [
{
"answer_id": 273247,
"author": "SleepyAsh",
"author_id": 123718,
"author_profile": "https://wordpress.stackexchange.com/users/123718",
"pm_score": 3,
"selected": true,
"text": "<p>You can use <a href=\"https://developer.wordpress.org/reference/functions/is_page/\" rel=\"nofollow norefe... | 2017/07/13 | [
"https://wordpress.stackexchange.com/questions/273239",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123057/"
] | **Set-up**
I have the following standard Adsense script inserted in my `header.php` file,
```
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
</script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-********",
enable_page_level_ads: true
}... | You can use [this](https://developer.wordpress.org/reference/functions/is_page/ "this") function:
```
<?php if(is_page('your-page-slug')): ?>
//do nothing on selected pages
<?php else: ?>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" />
<script>
(adsbygoogle = windo... |
273,242 | <p>So im currently developing a plugin, this plugin has a new CPT that i would like to exclude its menu from the admin page of the first site. Im using a multi-site installation. The menu has to only be visible to the other site admins but not the first one.</p>
<p>The Link where i want to remove the menu from is www.... | [
{
"answer_id": 273245,
"author": "TMA",
"author_id": 91044,
"author_profile": "https://wordpress.stackexchange.com/users/91044",
"pm_score": 0,
"selected": false,
"text": "<p>Wordpress <a href=\"https://codex.wordpress.org/WPMU_Functions/switch_to_blog\" rel=\"nofollow noreferrer\"><code... | 2017/07/13 | [
"https://wordpress.stackexchange.com/questions/273242",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121367/"
] | So im currently developing a plugin, this plugin has a new CPT that i would like to exclude its menu from the admin page of the first site. Im using a multi-site installation. The menu has to only be visible to the other site admins but not the first one.
The Link where i want to remove the menu from is www.example.co... | When you register the custom post type, you can control whether the menu item appears with the `show_in_menu` arg. You could do something like the following ( this has not been tested ):
```
// create a constant to store the ID of the blog where the menu should be hidden.
define('HIDDEN_MENU_BLOG_ID', 1 );
function c... |
273,264 | <p>I am developing theme to sell on themefores. I want to get option values in the head. but as the checkoptions would not be called yet i need to call wp-load.php. but the reviewer from themeforest said wp-load.php should not be called in any case. so can you please guide me how can i do the same without requiring wp... | [
{
"answer_id": 273252,
"author": "satibel",
"author_id": 123782,
"author_profile": "https://wordpress.stackexchange.com/users/123782",
"pm_score": 2,
"selected": false,
"text": "<p>Disclaimer: I haven't used this, but from the description it looks like a good fit.</p>\n\n<hr>\n\n<p>The <... | 2017/07/13 | [
"https://wordpress.stackexchange.com/questions/273264",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123788/"
] | I am developing theme to sell on themefores. I want to get option values in the head. but as the checkoptions would not be called yet i need to call wp-load.php. but the reviewer from themeforest said wp-load.php should not be called in any case. so can you please guide me how can i do the same without requiring wp-loa... | There is actually a plugin that offers this exact functionality: [Polylang User Manager](http://wooexperts.com/plugins/polylang-user-manager/):
>
> Polylang User Manager will work with Polylang WordPress multilingual Plugin, it will allow you to restrict access for editors/shop\_manager or other user role based on la... |
273,289 | <p>Using the plugin "Advanced Custom Fields":
<a href="https://wordpress.org/plugins/advanced-custom-fields/" rel="nofollow noreferrer">https://wordpress.org/plugins/advanced-custom-fields/</a>
I am able to add my custom fields to profile.php.</p>
<p><strong>But how do I remove the default elements from profile.php (P... | [
{
"answer_id": 273304,
"author": "Charles",
"author_id": 15605,
"author_profile": "https://wordpress.stackexchange.com/users/15605",
"pm_score": 2,
"selected": true,
"text": "<p>There are probably several options to achieve your goal, below is one of the options shown by me.<br />\n<em>(... | 2017/07/13 | [
"https://wordpress.stackexchange.com/questions/273289",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123624/"
] | Using the plugin "Advanced Custom Fields":
<https://wordpress.org/plugins/advanced-custom-fields/>
I am able to add my custom fields to profile.php.
**But how do I remove the default elements from profile.php (Personal Options, Name, etc.)?**
I know I can create new template files in my child theme to override how pa... | There are probably several options to achieve your goal, below is one of the options shown by me.
*(these 2 functions belong to each other)*
>
> Please make always a copy of `functions.php` before you start to edit/add a plugin or other code snippet.
>
>
>
```
/**
* Remove fields from an user profile page for... |
273,302 | <p>I'm getting an error on the admin screen for the custom post type. I've searched lots of other answers but see nothing in my code that could be causing it. Here's my code. Any help would be greatly appreciated.</p>
<pre><code>// Register the post types and taxonomys
add_action('init', 'register_post_types');
functi... | [
{
"answer_id": 273325,
"author": "Sddarter",
"author_id": 62082,
"author_profile": "https://wordpress.stackexchange.com/users/62082",
"pm_score": 1,
"selected": false,
"text": "<p>I've removed the custom_meta_boxes. I don't have to have them and it solves the problem. I still don't under... | 2017/07/13 | [
"https://wordpress.stackexchange.com/questions/273302",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62082/"
] | I'm getting an error on the admin screen for the custom post type. I've searched lots of other answers but see nothing in my code that could be causing it. Here's my code. Any help would be greatly appreciated.
```
// Register the post types and taxonomys
add_action('init', 'register_post_types');
function register_po... | I've removed the custom\_meta\_boxes. I don't have to have them and it solves the problem. I still don't understand why they were a problem, but if I can do without them I will.
I appreciate everyone's efforts.
Note: rolling back to 4.7 made no difference. |
273,322 | <p>Right now I've got future posts displayed on my site, and I was using this code on each post to show when it was published.</p>
<pre><code><?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
</code></pre>
<p>Naturally it shows a post 2 days from now as 2 days ago. How mig... | [
{
"answer_id": 273326,
"author": "mwz",
"author_id": 121004,
"author_profile": "https://wordpress.stackexchange.com/users/121004",
"pm_score": 1,
"selected": true,
"text": "<p>I managed to figure it out</p>\n\n<pre><code><?php\n if ( get_post_status ( $ID ) == 'future' ) { \necho huma... | 2017/07/13 | [
"https://wordpress.stackexchange.com/questions/273322",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121004/"
] | Right now I've got future posts displayed on my site, and I was using this code on each post to show when it was published.
```
<?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
```
Naturally it shows a post 2 days from now as 2 days ago. How might I fix it so it says "ago" and ... | I managed to figure it out
```
<?php
if ( get_post_status ( $ID ) == 'future' ) {
echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' from
now';
} else {
echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
``` |
273,333 | <p>The Admin Bar has a menu with shortcuts for adding new content.</p>
<p>By default, it shows "Post", "Media", "Page" and "User".</p>
<p><a href="https://i.stack.imgur.com/0ydcC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0ydcC.png" alt="enter image description here"></a></p>
<p>I'm using <co... | [
{
"answer_id": 273388,
"author": "Kudratullah",
"author_id": 62726,
"author_profile": "https://wordpress.stackexchange.com/users/62726",
"pm_score": 0,
"selected": false,
"text": "<p>This section rendered via <code>wp_admin_bar_new_content_menu</code> (admin-bar.php <a href=\"https://cor... | 2017/07/13 | [
"https://wordpress.stackexchange.com/questions/273333",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22510/"
] | The Admin Bar has a menu with shortcuts for adding new content.
By default, it shows "Post", "Media", "Page" and "User".
[](https://i.stack.imgur.com/0ydcC.png)
I'm using `register_post_type` to register a new custom post type. I can use its `menu_p... | I had a similar situation. My custom post type showed up under the Admin Bar as **Artifact**, but my clients preferred it to be at the top of the list. Plus, the items for **Media** and **User** were not really needed.
[](https://i.stack.imgur.com/pI5kR.... |
273,367 | <p>Im trying to remove the editor from the homepage using the following functions however I am struggling to achieve this?</p>
<pre><code>function hide_homepage_editor() {
if ( is_admin() ) {
if (is_front_page()) {
remove_post_type_support('page', 'editor');
}
}
}
add_action( 'admin... | [
{
"answer_id": 273371,
"author": "Andrew M",
"author_id": 89356,
"author_profile": "https://wordpress.stackexchange.com/users/89356",
"pm_score": 5,
"selected": true,
"text": "<p>There are a couple of issues with your approach</p>\n\n<p>By using the <strong>admin_init</strong> hook you w... | 2017/07/14 | [
"https://wordpress.stackexchange.com/questions/273367",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102937/"
] | Im trying to remove the editor from the homepage using the following functions however I am struggling to achieve this?
```
function hide_homepage_editor() {
if ( is_admin() ) {
if (is_front_page()) {
remove_post_type_support('page', 'editor');
}
}
}
add_action( 'admin_init', 'hide_... | There are a couple of issues with your approach
By using the **admin\_init** hook you won't have any reference to the post object. This means you won't be able to get the post ID or use anything like get\_the\_ID because the post won't actually be loaded. You can see that in the order here <https://codex.wordpress.org... |
273,394 | <p>I'm trying to make simple about me widget with WordPress media uploader. When I click the button <strong>Upload</strong> it opens media uploader, but after I hit <strong>save</strong>, the button doesn't work anymore, the same behavior if I have one active widget and then I add another, media upload button doesn't w... | [
{
"answer_id": 273371,
"author": "Andrew M",
"author_id": 89356,
"author_profile": "https://wordpress.stackexchange.com/users/89356",
"pm_score": 5,
"selected": true,
"text": "<p>There are a couple of issues with your approach</p>\n\n<p>By using the <strong>admin_init</strong> hook you w... | 2017/07/14 | [
"https://wordpress.stackexchange.com/questions/273394",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112255/"
] | I'm trying to make simple about me widget with WordPress media uploader. When I click the button **Upload** it opens media uploader, but after I hit **save**, the button doesn't work anymore, the same behavior if I have one active widget and then I add another, media upload button doesn't work in second widget. No JS e... | There are a couple of issues with your approach
By using the **admin\_init** hook you won't have any reference to the post object. This means you won't be able to get the post ID or use anything like get\_the\_ID because the post won't actually be loaded. You can see that in the order here <https://codex.wordpress.org... |
273,403 | <p>I've been pulling my hair over this strange issue for several hours now and need some help figuring out what's going on. Allow me to explain my setup followed by the behavior and question.</p>
<p>Setup:</p>
<ol>
<li><p>I've set my 'posts page' to domain.com/search/ where I intend to list all my posts. </p></li>
<l... | [
{
"answer_id": 273371,
"author": "Andrew M",
"author_id": 89356,
"author_profile": "https://wordpress.stackexchange.com/users/89356",
"pm_score": 5,
"selected": true,
"text": "<p>There are a couple of issues with your approach</p>\n\n<p>By using the <strong>admin_init</strong> hook you w... | 2017/07/14 | [
"https://wordpress.stackexchange.com/questions/273403",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21100/"
] | I've been pulling my hair over this strange issue for several hours now and need some help figuring out what's going on. Allow me to explain my setup followed by the behavior and question.
Setup:
1. I've set my 'posts page' to domain.com/search/ where I intend to list all my posts.
2. Since I need a custom layout for... | There are a couple of issues with your approach
By using the **admin\_init** hook you won't have any reference to the post object. This means you won't be able to get the post ID or use anything like get\_the\_ID because the post won't actually be loaded. You can see that in the order here <https://codex.wordpress.org... |
273,419 | <p>The following bit of code was used in my fictitious plugin to redirect the non-logged-in users from page <code>173</code> (ID) to <code>sample-page</code> (slug). The code's working well. But just today, I figured out that the code is causing Notices <del>in Firefox</del>.</p>
<p>The issue happened when I tried sett... | [
{
"answer_id": 344086,
"author": "Tom",
"author_id": 172789,
"author_profile": "https://wordpress.stackexchange.com/users/172789",
"pm_score": 0,
"selected": false,
"text": "<p>Turn off debug mode and it will be gone, at least worked for me. \nI know it's an old post but just want to hel... | 2017/07/14 | [
"https://wordpress.stackexchange.com/questions/273419",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | The following bit of code was used in my fictitious plugin to redirect the non-logged-in users from page `173` (ID) to `sample-page` (slug). The code's working well. But just today, I figured out that the code is causing Notices ~~in Firefox~~.
The issue happened when I tried setting a Static Page as the front page fr... | `pre_get_posts` is innapropriate for this use, instead you should use the `template_redirect` filter, e.g.
```php
add_action( 'template_redirect', funnction() {
if ( ! is_user_logged_in() && is_page( 123 ) ) {
wp_safe_redirect( home_url( '/sample-page' ) );
exit;
}
} );
``` |
273,438 | <p>I want to show random posts from a custom post type in my page. For example, I have 10 posts, but I want to show 5 post in page which will change randomly.</p>
<p>How can I do this?</p>
<p>Regards.</p>
| [
{
"answer_id": 273439,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>A quick 'googles' turns up several possibilities (the googles are your friend to get answers for most ... | 2017/07/14 | [
"https://wordpress.stackexchange.com/questions/273438",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123903/"
] | I want to show random posts from a custom post type in my page. For example, I have 10 posts, but I want to show 5 post in page which will change randomly.
How can I do this?
Regards. | You can write a custom query to get some random posts for your template. The simplest possible solution will be this query:
```
<?php
// Set the post type here, and sort them randomly
$args = array(
'post_type' => 'YOUR-POST-TYPE',
'posts_per_page'=> 5,
'order_by' => 'rand',
);
// Initiate a custom query
... |
273,442 | <p>I will post the entire plugin code below.. here is the problem that I am having with it. I am using the values that are imported to custom fields in a custom post type to construct the URLs. On the edit post page it shows the permalink as I wish it to be..</p>
<blockquote>
<p>site.com/real-estate/%postname%-%fi... | [
{
"answer_id": 273439,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>A quick 'googles' turns up several possibilities (the googles are your friend to get answers for most ... | 2017/07/14 | [
"https://wordpress.stackexchange.com/questions/273442",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123857/"
] | I will post the entire plugin code below.. here is the problem that I am having with it. I am using the values that are imported to custom fields in a custom post type to construct the URLs. On the edit post page it shows the permalink as I wish it to be..
>
> site.com/real-estate/%postname%-%field\_City%-%field\_Sta... | You can write a custom query to get some random posts for your template. The simplest possible solution will be this query:
```
<?php
// Set the post type here, and sort them randomly
$args = array(
'post_type' => 'YOUR-POST-TYPE',
'posts_per_page'=> 5,
'order_by' => 'rand',
);
// Initiate a custom query
... |
273,459 | <p>In the navigation menu creation page, when you are trying to add a category to the menu, if the category is empty, it won't show up in the search results. However, if the category itself is empty but has a child that is not empty, it will still be shown.</p>
<p>I have a blog with over 500 categories, and I'm trying... | [
{
"answer_id": 273812,
"author": "Worduoso",
"author_id": 101425,
"author_profile": "https://wordpress.stackexchange.com/users/101425",
"pm_score": 2,
"selected": true,
"text": "<p>You can modify this behaviour by adding a custom filter to your functions.php or as a plugin:</p>\n\n<pre><... | 2017/07/15 | [
"https://wordpress.stackexchange.com/questions/273459",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94498/"
] | In the navigation menu creation page, when you are trying to add a category to the menu, if the category is empty, it won't show up in the search results. However, if the category itself is empty but has a child that is not empty, it will still be shown.
I have a blog with over 500 categories, and I'm trying to add so... | You can modify this behaviour by adding a custom filter to your functions.php or as a plugin:
```
add_filter('get_terms_args', 'wodruoso_terms_args', 10, 1);
function wodruoso_terms_args($args) {
/* note: I am checking here that we are in WP Admin area and that it's
* search by category name to minimize impa... |
273,500 | <p>I have just followed <a href="http://www.wpbeginner.com/wp-tutorials/how-to-move-live-wordpress-site-to-local-server/" rel="nofollow noreferrer">this guide</a> on manually migrating a WordPress site to localhost.</p>
<p>I have followed all of the steps: downloading files using FTP, exporting database, importing to ... | [
{
"answer_id": 273496,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>You can't find it because it doesn't exist. There is no page at that location.</p>\n\n<p>In WordPress everyt... | 2017/07/15 | [
"https://wordpress.stackexchange.com/questions/273500",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123633/"
] | I have just followed [this guide](http://www.wpbeginner.com/wp-tutorials/how-to-move-live-wordpress-site-to-local-server/) on manually migrating a WordPress site to localhost.
I have followed all of the steps: downloading files using FTP, exporting database, importing to localhost database, changing URL links to local... | You can't find it because it doesn't exist. There is no page at that location.
In WordPress everything is either an archive of posts or a post of some type. Pages are posts of type `page` etc. Date archives are archives of posts
So if you went to `/category` what would it show? For this reason there is nothing there ... |
273,523 | <p>I cannot successfully filter posts from some categories and exclude at the same time from others. The code is working perfectly when used to include only posts from a given category. Categories to be included are subcategories and the excluded categories are main categories (they're not parents to the included subca... | [
{
"answer_id": 273496,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>You can't find it because it doesn't exist. There is no page at that location.</p>\n\n<p>In WordPress everyt... | 2017/07/16 | [
"https://wordpress.stackexchange.com/questions/273523",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1210/"
] | I cannot successfully filter posts from some categories and exclude at the same time from others. The code is working perfectly when used to include only posts from a given category. Categories to be included are subcategories and the excluded categories are main categories (they're not parents to the included subcateg... | You can't find it because it doesn't exist. There is no page at that location.
In WordPress everything is either an archive of posts or a post of some type. Pages are posts of type `page` etc. Date archives are archives of posts
So if you went to `/category` what would it show? For this reason there is nothing there ... |
273,545 | <p>I am attempting to import several users, who each should have a connection with a term in a taxonomy named "firm" - but I don't know how to make the connection...</p>
<p><strong>Background:</strong></p>
<p>FYI, I have already enabled WordPress taxonomy support for Users using plugin <a href="https://wordpress.org/... | [
{
"answer_id": 273590,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>users are humans (or extensions of humans) that have some level of admin access, taxonomies are for \"cat... | 2017/07/16 | [
"https://wordpress.stackexchange.com/questions/273545",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39300/"
] | I am attempting to import several users, who each should have a connection with a term in a taxonomy named "firm" - but I don't know how to make the connection...
**Background:**
FYI, I have already enabled WordPress taxonomy support for Users using plugin [LH User Taxonomies](https://wordpress.org/plugins/lh-user-ta... | The function wp\_set\_object\_terms relates to objects (posts, page, etc).
You better use usermeta - update\_usermeta.
E.g
`update_usermeta( $user_id, 'company', $company_id );`
Wordpress is built by two major database tables (wp\_posts and wp\_users) and two (meta tables wp\_postmeta and wp\_usermeta). It seems that... |
273,558 | <p>So I made a couple of custom taxonomies to add multiple categories to a page/project. (single-work.php) The default one (built in category) being <code>project type</code>, and the two new ones being <code>client</code> and <code>agency</code>.</p>
<p>Basically I use the same code for all three, but I just noticed ... | [
{
"answer_id": 273561,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 0,
"selected": false,
"text": "<p>You can set the post status to <code>trash</code>.</p>\n\n<pre><code>$post_id = 1; // change this to your p... | 2017/07/16 | [
"https://wordpress.stackexchange.com/questions/273558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123968/"
] | So I made a couple of custom taxonomies to add multiple categories to a page/project. (single-work.php) The default one (built in category) being `project type`, and the two new ones being `client` and `agency`.
Basically I use the same code for all three, but I just noticed that what it's doing for the two custom cat... | You can move the post to Trash before you save it or publish:
[](https://i.stack.imgur.com/olHzC.png)
Or you can do it later, from the post list:
[](https://i.stack.imgur.com/Ng1mh.... |
273,572 | <p>I am using WordPress to develop a picture gallery website. I have albums and galleries, with different permalinks...<code>http://url.com/albums</code> and <code>http://url.com/gallery</code>, but only the albums appear in the main navigation.</p>
<p>The code for my navigation looks like:</p>
<pre><code><div id=... | [
{
"answer_id": 273653,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>The <a href=\"https://developer.wordpress.org/reference/hooks/page_css_class/\" rel=\"nofollow noreferrer\"><code>p... | 2017/07/17 | [
"https://wordpress.stackexchange.com/questions/273572",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9820/"
] | I am using WordPress to develop a picture gallery website. I have albums and galleries, with different permalinks...`http://url.com/albums` and `http://url.com/gallery`, but only the albums appear in the main navigation.
The code for my navigation looks like:
```
<div id="nav">
<ul>
<?php wp_list_pages("t... | The [`page_css_class` filter](https://developer.wordpress.org/reference/hooks/page_css_class/) lets you modify the classes each menu item gets.
Here we check if we are currently viewing a singular `envira` post type and the menu item slug is `gallery`. In that case we add a class to the array of default classes passed... |
273,582 | <p>Let suppose I have made a file in my theme folder (with the name c.php) and I want it to link it with a custom button (that I have made in post/page) in admin using GET action. How can I achieve that</p>
| [
{
"answer_id": 273623,
"author": "lky",
"author_id": 102937,
"author_profile": "https://wordpress.stackexchange.com/users/102937",
"pm_score": 0,
"selected": false,
"text": "<p>Im a little unsure what you are trying to achieve but can't you link the button like:</p>\n\n<pre><code>href=\"... | 2017/07/17 | [
"https://wordpress.stackexchange.com/questions/273582",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/108146/"
] | Let suppose I have made a file in my theme folder (with the name c.php) and I want it to link it with a custom button (that I have made in post/page) in admin using GET action. How can I achieve that | Finally, I make it, the way without losing the access to WordPress environment:
```
add_action( 'edit_form_after_title', 'custom_button' );
function custom_button() {
$button = sprintf('<a href="%1$s" class="button button-primary button-large">%2$s</a>', esc_url( add_query_arg( 'link' , true, get_the_permalink() ) ), ... |
273,597 | <p>I need an extra pair of eyes on this. I have customized a block of code in a function of a commercial theme, which is the following code: </p>
<pre><code> <div class="author-description">
<h5><span class="fn"><?php the_author_link(); ?></span></h5>
<p class=... | [
{
"answer_id": 273623,
"author": "lky",
"author_id": 102937,
"author_profile": "https://wordpress.stackexchange.com/users/102937",
"pm_score": 0,
"selected": false,
"text": "<p>Im a little unsure what you are trying to achieve but can't you link the button like:</p>\n\n<pre><code>href=\"... | 2017/07/17 | [
"https://wordpress.stackexchange.com/questions/273597",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60297/"
] | I need an extra pair of eyes on this. I have customized a block of code in a function of a commercial theme, which is the following code:
```
<div class="author-description">
<h5><span class="fn"><?php the_author_link(); ?></span></h5>
<p class="note"><?php the_author_meta( 'description', $id ); ?... | Finally, I make it, the way without losing the access to WordPress environment:
```
add_action( 'edit_form_after_title', 'custom_button' );
function custom_button() {
$button = sprintf('<a href="%1$s" class="button button-primary button-large">%2$s</a>', esc_url( add_query_arg( 'link' , true, get_the_permalink() ) ), ... |
273,654 | <p>I can't access the dashboard of the second site. When I go to the second site, I only see the HTML page without the style (css).</p>
<p>When I try to access the dashboard (from Safari), I get this message from the browser: "too many redirects occurred trying to open".</p>
<p>Subsite set-up</p>
<p>example.com (wor... | [
{
"answer_id": 273619,
"author": "Chris Cox",
"author_id": 1718,
"author_profile": "https://wordpress.stackexchange.com/users/1718",
"pm_score": 1,
"selected": false,
"text": "<p>It's in the filename. single-$posttype.php, archive-$posttype.php</p>\n"
},
{
"answer_id": 273622,
... | 2017/07/17 | [
"https://wordpress.stackexchange.com/questions/273654",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123998/"
] | I can't access the dashboard of the second site. When I go to the second site, I only see the HTML page without the style (css).
When I try to access the dashboard (from Safari), I get this message from the browser: "too many redirects occurred trying to open".
Subsite set-up
example.com (works)
example.com/seconda... | You need to create the template files within your theme using the correct naming.
Please see:
<https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-page-templates-for-specific-post-types> |
273,678 | <p>I am sending php array using serialise but the response is different. Here is my attempt</p>
<pre><code>$array = serialize($out);
var_dump(serialize($array));
//string(58) "s:50:"a:2:{s:9:"sidebar-1";i:5;s:12:"footer-insta";i:2;}";"
</code></pre>
<p>The way I am sending this value, </p>
<pre><code>echo '<div d... | [
{
"answer_id": 273680,
"author": "CodeMascot",
"author_id": 44192,
"author_profile": "https://wordpress.stackexchange.com/users/44192",
"pm_score": 0,
"selected": false,
"text": "<p>Well, this <code>\\</code> is getting added to escape the <code>\"</code>. For example you are storing the... | 2017/07/17 | [
"https://wordpress.stackexchange.com/questions/273678",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48294/"
] | I am sending php array using serialise but the response is different. Here is my attempt
```
$array = serialize($out);
var_dump(serialize($array));
//string(58) "s:50:"a:2:{s:9:"sidebar-1";i:5;s:12:"footer-insta";i:2;}";"
```
The way I am sending this value,
```
echo '<div data-ad = '.$array.' class="ash_loadmore"... | Well it seems @JacobPeattie mentioned to use json, I just echoing that.
1. First json encode the variable `$array = json_encode($out);`
2. Then send this value `echo '<div data-ad = '.$array.' class="ash_loadmore"><span>LOAD MORE</span></div>';`
3. To get that `echo json_encode($_POST['ad'])`
I think that's it.BTW y... |
273,695 | <p>I have two meta_keys on a custom post type. I want to be able to query all of these posts, and order them by the two <code>meta_key</code>, one taking precedence over the other.</p>
<p>I.e. I have one <code>meta_key</code> called <code>stickied</code>, these should always appear first. The second <code>meta_key</co... | [
{
"answer_id": 273697,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 0,
"selected": false,
"text": "<p>As I understand, you are trying to sort the post by meta values. In such cases, you can use <code>'orderby ... | 2017/07/18 | [
"https://wordpress.stackexchange.com/questions/273695",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124056/"
] | I have two meta\_keys on a custom post type. I want to be able to query all of these posts, and order them by the two `meta_key`, one taking precedence over the other.
I.e. I have one `meta_key` called `stickied`, these should always appear first. The second `meta_key` is `popularity`, which is a basic hit count for t... | I had a similar issue but couldn't solved with the snippets on this thread.
I had to order a query by:
1. all 'featured' posts first (***is\_it\_a\_featured\_etf***) and
2. by a numeric field (***etf\_aum***) in DESC order after the featured ones.
My solution:
```
'meta_query' => [
'relation' => 'OR',
'et... |
273,704 | <p>Since some updates of WooCommerce, Wordpress, Theme etc. on our product pages in the product-tab "additional information" some attributes are now linkable (to some automatic created pages). I cant find the setting how to disable it and even so no php solution for functions.php. I neither want that automatic pages th... | [
{
"answer_id": 276255,
"author": "Krystian",
"author_id": 122426,
"author_profile": "https://wordpress.stackexchange.com/users/122426",
"pm_score": 1,
"selected": true,
"text": "<p>I couldnt find a real Solution, but I used CSS to visually hide the link, but actually the link still exist... | 2017/07/18 | [
"https://wordpress.stackexchange.com/questions/273704",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122426/"
] | Since some updates of WooCommerce, Wordpress, Theme etc. on our product pages in the product-tab "additional information" some attributes are now linkable (to some automatic created pages). I cant find the setting how to disable it and even so no php solution for functions.php. I neither want that automatic pages then ... | I couldnt find a real Solution, but I used CSS to visually hide the link, but actually the link still exists, but its not clickable anymore. Note: change this CSS to your font-color:
```
.shop_attributes a[rel="tag"] {
pointer-events: none;
cursor: default;
color: #888;
}
``` |
273,720 | <p>I want to apply my valid custom admin bar color scheme to front-end toolbar.</p>
<p>I am using this code to do it:</p>
<pre><code>add_action(
'wp_enqueue_scripts',
function () {
wp_enqueue_style(
'color-admin-bar',
PATH_TO_CSS,
array( 'admin-bar' )
);
} );
</code></pre>
<p>However ... | [
{
"answer_id": 273724,
"author": "Chris Cox",
"author_id": 1718,
"author_profile": "https://wordpress.stackexchange.com/users/1718",
"pm_score": -1,
"selected": false,
"text": "<p><a href=\"https://css-tricks.com/forums/topic/styling-wordpress-admin-bar/\" rel=\"nofollow noreferrer\">Thi... | 2017/07/18 | [
"https://wordpress.stackexchange.com/questions/273720",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109919/"
] | I want to apply my valid custom admin bar color scheme to front-end toolbar.
I am using this code to do it:
```
add_action(
'wp_enqueue_scripts',
function () {
wp_enqueue_style(
'color-admin-bar',
PATH_TO_CSS,
array( 'admin-bar' )
);
} );
```
However it causes some strange bugs.
For... | You make it the wrong way.
First, you do double work. Enqueue inside enqueue. You don't need `wp_enqueue_scripts()`:
```
wp_enqueue_style(
'color-admin-bar',
PATH_TO_CSS,
array( 'admin-bar' )
);
```
Second. Don't use anonymous functions with WordPress Actions. Once-for-all-time is OK, but while the proj... |
273,734 | <p>When I change <code>WP_PLUGIN_DIR</code> example:</p>
<pre><code>define( 'WP_PLUGIN_DIR', $_SERVER['DOCUMENT_ROOT'] . '/../wp-content/renamefolder' );
</code></pre>
<p>All plugins are shown and I can activate them.
<a href="https://i.stack.imgur.com/z4naU.png" rel="nofollow noreferrer"><img src="https://i.stack.im... | [
{
"answer_id": 273751,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": true,
"text": "<p><code>WP_PLUGIN_DIR</code> customizes the location of files in filesystem.</p>\n\n<p>Most likely you <em>also</em> n... | 2017/07/18 | [
"https://wordpress.stackexchange.com/questions/273734",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123978/"
] | When I change `WP_PLUGIN_DIR` example:
```
define( 'WP_PLUGIN_DIR', $_SERVER['DOCUMENT_ROOT'] . '/../wp-content/renamefolder' );
```
All plugins are shown and I can activate them.
[](https://i.stack.imgur.com/z4naU.png)
But with TinyMCE Advanced w... | `WP_PLUGIN_DIR` customizes the location of files in filesystem.
Most likely you *also* need to customize `WP_PLUGIN_URL`, which customizes client–facing URL location. If you omit this one, WP will decide it based on `WP_CONTENT_URL`, which might not at all point to your new location.
Another possibility is that plugi... |
273,765 | <p>I made a large-scale research. But there are no anything what I want. I want to style my options page in a static style file. How can I do that?</p>
<p><strong>Sources</strong></p>
<pre><code>/*
*Create A Simple Theme Options Panel
*Exit if accessed directly
*/
if (!defined('ABSPATH')){
exit;
}
// Start Class... | [
{
"answer_id": 273767,
"author": "Chris Cox",
"author_id": 1718,
"author_profile": "https://wordpress.stackexchange.com/users/1718",
"pm_score": -1,
"selected": false,
"text": "<p>Give your HTML elements existing classes from the WP admin CSS and they'll inherit styles consistent with th... | 2017/07/18 | [
"https://wordpress.stackexchange.com/questions/273765",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124103/"
] | I made a large-scale research. But there are no anything what I want. I want to style my options page in a static style file. How can I do that?
**Sources**
```
/*
*Create A Simple Theme Options Panel
*Exit if accessed directly
*/
if (!defined('ABSPATH')){
exit;
}
// Start Class
if ( ! class_exists('Azura_Theme_... | In your construct function you also need to enqueue a custom stylesheet that will house the CSS to style up your theme options.
A simplified example would look like this:
```
function admin_style() {
wp_enqueue_style( 'theme-options-style', get_template_directory_uri().'styles/theme-options-style.css');
}
add_act... |
273,773 | <p>How add, update and retrieve user meta fields with the wp api? I added a function to add a meta field phonenumber to a user. Is a function like this necessary to add meta values to the meta object? The function doesn't add the field to the meta object in the API response but adds it as a new field.</p>
<p>The funct... | [
{
"answer_id": 273875,
"author": "Maarten Heideman",
"author_id": 54693,
"author_profile": "https://wordpress.stackexchange.com/users/54693",
"pm_score": 2,
"selected": true,
"text": "<p>found it, first yes for meta data on a user you'll need a custom function like this:</p>\n\n<pre><cod... | 2017/07/18 | [
"https://wordpress.stackexchange.com/questions/273773",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54693/"
] | How add, update and retrieve user meta fields with the wp api? I added a function to add a meta field phonenumber to a user. Is a function like this necessary to add meta values to the meta object? The function doesn't add the field to the meta object in the API response but adds it as a new field.
The function i have... | found it, first yes for meta data on a user you'll need a custom function like this:
```
<?php
function portal_add_user_field() {
register_rest_field( 'user', 'userfields',
array(
'get_callback' => function( $user, $field_name, $request ) {
return get_user_meta( $user[ 'id'... |
273,790 | <p>I am trying to use $wpdb object to get results from a custom table and I get an error when I echo the result:</p>
<pre><code>Notice: Undefined property: stdClass::$category in...
</code></pre>
<p>Here is the PHP code:</p>
<pre><code>global $wpdb;
$prodCat = $wpdb->get_results(
"SELECT * FROM product_category"... | [
{
"answer_id": 273875,
"author": "Maarten Heideman",
"author_id": 54693,
"author_profile": "https://wordpress.stackexchange.com/users/54693",
"pm_score": 2,
"selected": true,
"text": "<p>found it, first yes for meta data on a user you'll need a custom function like this:</p>\n\n<pre><cod... | 2017/07/18 | [
"https://wordpress.stackexchange.com/questions/273790",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45250/"
] | I am trying to use $wpdb object to get results from a custom table and I get an error when I echo the result:
```
Notice: Undefined property: stdClass::$category in...
```
Here is the PHP code:
```
global $wpdb;
$prodCat = $wpdb->get_results(
"SELECT * FROM product_category" , OBJECT_K);
foreach ( $prodCat as ... | found it, first yes for meta data on a user you'll need a custom function like this:
```
<?php
function portal_add_user_field() {
register_rest_field( 'user', 'userfields',
array(
'get_callback' => function( $user, $field_name, $request ) {
return get_user_meta( $user[ 'id'... |
273,801 | <p>I've got a local install of WP and I've copied my live site's uploads dir to the proper spot in wp-content, but Media Library isn't showing a single image.</p>
<p>I've recursively set uploads and subsequent dirs to 755, that didn't fix it. I checked the upload_path in wp_options and it's blank like it is on the liv... | [
{
"answer_id": 273875,
"author": "Maarten Heideman",
"author_id": 54693,
"author_profile": "https://wordpress.stackexchange.com/users/54693",
"pm_score": 2,
"selected": true,
"text": "<p>found it, first yes for meta data on a user you'll need a custom function like this:</p>\n\n<pre><cod... | 2017/07/18 | [
"https://wordpress.stackexchange.com/questions/273801",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124126/"
] | I've got a local install of WP and I've copied my live site's uploads dir to the proper spot in wp-content, but Media Library isn't showing a single image.
I've recursively set uploads and subsequent dirs to 755, that didn't fix it. I checked the upload\_path in wp\_options and it's blank like it is on the live server... | found it, first yes for meta data on a user you'll need a custom function like this:
```
<?php
function portal_add_user_field() {
register_rest_field( 'user', 'userfields',
array(
'get_callback' => function( $user, $field_name, $request ) {
return get_user_meta( $user[ 'id'... |
273,805 | <p>When I write answers for questions on WPSE, or when I want to try a piece of short and simple code, I need a place to quickly test the results without actually doing permanent change to any file. </p>
<p>For example, let's say I want to test this:</p>
<pre><code><?php echo get_post_meta(); ?>
</code></pre>
... | [
{
"answer_id": 273807,
"author": "kero",
"author_id": 108180,
"author_profile": "https://wordpress.stackexchange.com/users/108180",
"pm_score": 1,
"selected": false,
"text": "<p>The answer is quite simple: test your code in WordPress environment.</p>\n\n<p>I have a standard WordPress ins... | 2017/07/18 | [
"https://wordpress.stackexchange.com/questions/273805",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94498/"
] | When I write answers for questions on WPSE, or when I want to try a piece of short and simple code, I need a place to quickly test the results without actually doing permanent change to any file.
For example, let's say I want to test this:
```
<?php echo get_post_meta(); ?>
```
I can put this at the end of my `sin... | I actually use free online development environments to test, such as [c9](http://c9.io). It allows very quick installation and setup of wordpress. You can easily try different plugins/codes without endangering your files.
Moreover, if you mess any thing up you can always delete that installation and create a new one. ... |
273,806 | <p>In my WordPress site, I created a <code>Singleton</code> inside a custom plugin I have, like this:</p>
<pre><code>class VBWpdb {
private $trace = array();
public static function get_instance() {
static $instance = null;
if(null === $instance) {
$instance = new static();
... | [
{
"answer_id": 273828,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 0,
"selected": false,
"text": "<p>Your function <code>get_instance</code> will never create an instance of the class because of ... | 2017/07/18 | [
"https://wordpress.stackexchange.com/questions/273806",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77513/"
] | In my WordPress site, I created a `Singleton` inside a custom plugin I have, like this:
```
class VBWpdb {
private $trace = array();
public static function get_instance() {
static $instance = null;
if(null === $instance) {
$instance = new static();
}
return $instanc... | You are just doing it wrong. The problem starts with using a singleton, just never do it.
You have a class of loggers which logs into some internal buffer. All loggers log into the same buffer, therefor the buffer (`trace` in your case) a static array in the class.
No more `get_intance`, just instantiate a new logger ... |