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 |
|---|---|---|---|---|---|---|
277,558 | <p><a href="https://i.stack.imgur.com/bvUt0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bvUt0.png" alt="this is the directory"></a>I am trying to integrate an animation in my Wordpress home page, for this I am trying to load scripts from "skrollr" library, but my styles and scripts don't load.</p... | [
{
"answer_id": 277548,
"author": "Aniruddha Gawade",
"author_id": 101818,
"author_profile": "https://wordpress.stackexchange.com/users/101818",
"pm_score": 1,
"selected": false,
"text": "<p>You can fix this by changes <code>site_url</code> and <code>home_url</code> in your database.</p>\... | 2017/08/21 | [
"https://wordpress.stackexchange.com/questions/277558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126245/"
] | [](https://i.stack.imgur.com/bvUt0.png)I am trying to integrate an animation in my Wordpress home page, for this I am trying to load scripts from "skrollr" library, but my styles and scripts don't load.
this is the code I added is function.php in the child t... | You can fix this by changes `site_url` and `home_url` in your database.
If you have access to your database(phpmyadmin) go to `options` table and change `site_url` and `home_url` from HTTPS to HTTP.
You can also change it through `wp-config` file.
```
define('WP_HOME','http://www.example.com');
define('WP_SITEURL',... |
277,559 | <p>I want to redirect every user, depending on its user role, who wants to access home page (its my welcome login page).</p>
<p>I don't want to redirect users just after they log in, but after they are logged in and if they maybe again access home page incidentally.</p>
<p>Thanks</p>
| [
{
"answer_id": 277548,
"author": "Aniruddha Gawade",
"author_id": 101818,
"author_profile": "https://wordpress.stackexchange.com/users/101818",
"pm_score": 1,
"selected": false,
"text": "<p>You can fix this by changes <code>site_url</code> and <code>home_url</code> in your database.</p>\... | 2017/08/21 | [
"https://wordpress.stackexchange.com/questions/277559",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126244/"
] | I want to redirect every user, depending on its user role, who wants to access home page (its my welcome login page).
I don't want to redirect users just after they log in, but after they are logged in and if they maybe again access home page incidentally.
Thanks | You can fix this by changes `site_url` and `home_url` in your database.
If you have access to your database(phpmyadmin) go to `options` table and change `site_url` and `home_url` from HTTPS to HTTP.
You can also change it through `wp-config` file.
```
define('WP_HOME','http://www.example.com');
define('WP_SITEURL',... |
277,575 | <p>media file has <code>//example.com/wp-content/uploads/2015/08/logo.png</code> without <code>http:</code>.</p>
<p>How to change it?</p>
<p><a href="https://i.stack.imgur.com/MxJmC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MxJmC.jpg" alt="picture URL without http://"></a></p>
<p>I need full... | [
{
"answer_id": 277580,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 0,
"selected": false,
"text": "<p>The URLs in your media library are protocol-relative. This means, no matter if you are on a secure protocol... | 2017/08/21 | [
"https://wordpress.stackexchange.com/questions/277575",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126260/"
] | media file has `//example.com/wp-content/uploads/2015/08/logo.png` without `http:`.
How to change it?
[](https://i.stack.imgur.com/MxJmC.jpg)
I need full `http://` address in my posts | I'm sure some plugin or your theme modifies your attachment url.
Try to find `wp_get_attachment_url` hook in your code or simply create your own with high priority this way:
```
add_filter('wp_get_attachment_url', function($url) {
return preg_replace("~^//(.+)$~", "https://$1", $url);
}, 999);
```
or better:
```
... |
277,599 | <p>I need to capture a value displayed on the website to the user, and then store it in a variable. Ideally, I'd like to do this in functions.php. </p>
<p>More specifically, we use dynamic phone number replacement on the sites, and we’d like to know which phone number is displayed to the user when they are submitting... | [
{
"answer_id": 277580,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 0,
"selected": false,
"text": "<p>The URLs in your media library are protocol-relative. This means, no matter if you are on a secure protocol... | 2017/08/21 | [
"https://wordpress.stackexchange.com/questions/277599",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126276/"
] | I need to capture a value displayed on the website to the user, and then store it in a variable. Ideally, I'd like to do this in functions.php.
More specifically, we use dynamic phone number replacement on the sites, and we’d like to know which phone number is displayed to the user when they are submitting a contact ... | I'm sure some plugin or your theme modifies your attachment url.
Try to find `wp_get_attachment_url` hook in your code or simply create your own with high priority this way:
```
add_filter('wp_get_attachment_url', function($url) {
return preg_replace("~^//(.+)$~", "https://$1", $url);
}, 999);
```
or better:
```
... |
277,602 | <p>I recently migrated a live wordpress site, watershedgeo.com, over to a development site using the temp url, <a href="http://vps3813.inmotionhosting.com/~watershedgeo/dev.watershedgeo.com/" rel="nofollow noreferrer">http://vps3813.inmotionhosting.com/~watershedgeo/dev.watershedgeo.com/</a>.</p>
<p>I finally got it l... | [
{
"answer_id": 277580,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 0,
"selected": false,
"text": "<p>The URLs in your media library are protocol-relative. This means, no matter if you are on a secure protocol... | 2017/08/21 | [
"https://wordpress.stackexchange.com/questions/277602",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115321/"
] | I recently migrated a live wordpress site, watershedgeo.com, over to a development site using the temp url, <http://vps3813.inmotionhosting.com/~watershedgeo/dev.watershedgeo.com/>.
I finally got it launched but the images and links don't show, they're all broken, but a lot of the images are showing their alt text. He... | I'm sure some plugin or your theme modifies your attachment url.
Try to find `wp_get_attachment_url` hook in your code or simply create your own with high priority this way:
```
add_filter('wp_get_attachment_url', function($url) {
return preg_replace("~^//(.+)$~", "https://$1", $url);
}, 999);
```
or better:
```
... |
277,617 | <p>How can I redirect users if they want to visit any other pages, but login page and password reset page?</p>
<p>My login page is actually my homepage and I want to redirect all of them to login page if they are not logged in. Also to allow them to reset password if they have forgotten them.</p>
<p>Thanks</p>
| [
{
"answer_id": 277623,
"author": "Fabio Marzocca",
"author_id": 65278,
"author_profile": "https://wordpress.stackexchange.com/users/65278",
"pm_score": 0,
"selected": false,
"text": "<p>You can add a rewrite rule into your .htaccess, checking for not-logged users, and redirect them to ho... | 2017/08/21 | [
"https://wordpress.stackexchange.com/questions/277617",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126244/"
] | How can I redirect users if they want to visit any other pages, but login page and password reset page?
My login page is actually my homepage and I want to redirect all of them to login page if they are not logged in. Also to allow them to reset password if they have forgotten them.
Thanks | You indicated that your login page is your home page. If you want all non-logged in users to then be directed to the home page to log in, you need to check a couple of things:
1. Is the user logged in?
2. Is the current page the home page?
You can do these things with `is_user_logged_in()` and is\_front\_page(). If t... |
277,618 | <p>I have a page that contain all my servers data, it really sensitive information.
Is there any strong way to hide it from google spiders and non login users.</p>
<p>I found small solutions that's hide the page, but not secured at all, if someone search in the website directory he will get access to that page easily.... | [
{
"answer_id": 277620,
"author": "Anton Lukin",
"author_id": 126253,
"author_profile": "https://wordpress.stackexchange.com/users/126253",
"pm_score": 3,
"selected": true,
"text": "<p>Use <a href=\"https://codex.wordpress.org/Using_Password_Protection\" rel=\"nofollow noreferrer\">passwo... | 2017/08/21 | [
"https://wordpress.stackexchange.com/questions/277618",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124400/"
] | I have a page that contain all my servers data, it really sensitive information.
Is there any strong way to hide it from google spiders and non login users.
I found small solutions that's hide the page, but not secured at all, if someone search in the website directory he will get access to that page easily.
Any hints... | Use [password protection mechanism](https://codex.wordpress.org/Using_Password_Protection)
Alterative you can use wordpress hook in your theme to show your post/page only for administrators this way:
```
add_action('wp', function() {
if(is_page('my-data') && !current_user_can('manage_options'))
die("123")
});... |
277,649 | <p>I submitted my site to Google and now the author page is showing up in the search results. </p>
<pre><code>http://www.domain.com/author/myusername
</code></pre>
<p>How do I prevent my and others author names from showing up in search results? </p>
<p>It would be best to disable completely the path "/author/" all ... | [
{
"answer_id": 315604,
"author": "Cbinger",
"author_id": 144946,
"author_profile": "https://wordpress.stackexchange.com/users/144946",
"pm_score": 2,
"selected": false,
"text": "<p>You can disable the access to author pages by adding this snippet to functions.php:</p>\n\n<pre><code>// D... | 2017/08/22 | [
"https://wordpress.stackexchange.com/questions/277649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29247/"
] | I submitted my site to Google and now the author page is showing up in the search results.
```
http://www.domain.com/author/myusername
```
How do I prevent my and others author names from showing up in search results?
It would be best to disable completely the path "/author/" all together because it's not a blog ... | The above answer is good, but if redirecting to home page, it should specify a 301 status and exit after.
```
add_action('template_redirect', 'my_custom_disable_author_page');
function my_custom_disable_author_page() {
global $wp_query;
if ( is_author() ) {
// Redirect to homepage, set status to 301 ... |
277,670 | <p>I'm currently using the Hemingway theme as seen here: </p>
<p>gamingprofessors.com</p>
<p>Currently this theme provides a pleasing tag when generated, however I can't change what the tag reads as. At least individually. I know I can go into the functions.php and change the $more_link_text:</p>
<pre><code>// Cust... | [
{
"answer_id": 277676,
"author": "deflime",
"author_id": 18907,
"author_profile": "https://wordpress.stackexchange.com/users/18907",
"pm_score": 2,
"selected": true,
"text": "<p>WordPress has the functionality <a href=\"https://codex.wordpress.org/Customizing_the_Read_More\" rel=\"nofoll... | 2017/08/22 | [
"https://wordpress.stackexchange.com/questions/277670",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126310/"
] | I'm currently using the Hemingway theme as seen here:
gamingprofessors.com
Currently this theme provides a pleasing tag when generated, however I can't change what the tag reads as. At least individually. I know I can go into the functions.php and change the $more\_link\_text:
```
// Custom more-link text
add_filte... | WordPress has the functionality [built-in](https://codex.wordpress.org/Customizing_the_Read_More) natively.
Try updating the read more tag in the `Text` editor. Examples:
```
<!--more Episode Summary and Extras -->
<!--more Regular Blog Post -->
<!--more Read More About My Cats -->
```
This only works with `the_con... |
277,677 | <p>i created website in local using word press theme, then uploaded on server but in server database have table like <strong>wp_2xxfpfb5qn_options</strong> and local have tables like "doc_options" so its not taking value from proper table, hence my theme not showing as i did changes in local theme. so what i ... | [
{
"answer_id": 277676,
"author": "deflime",
"author_id": 18907,
"author_profile": "https://wordpress.stackexchange.com/users/18907",
"pm_score": 2,
"selected": true,
"text": "<p>WordPress has the functionality <a href=\"https://codex.wordpress.org/Customizing_the_Read_More\" rel=\"nofoll... | 2017/08/22 | [
"https://wordpress.stackexchange.com/questions/277677",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126317/"
] | i created website in local using word press theme, then uploaded on server but in server database have table like **wp\_2xxfpfb5qn\_options** and local have tables like "doc\_options" so its not taking value from proper table, hence my theme not showing as i did changes in local theme. so what i have do for it?
Now, i... | WordPress has the functionality [built-in](https://codex.wordpress.org/Customizing_the_Read_More) natively.
Try updating the read more tag in the `Text` editor. Examples:
```
<!--more Episode Summary and Extras -->
<!--more Regular Blog Post -->
<!--more Read More About My Cats -->
```
This only works with `the_con... |
277,718 | <p>I am having problem when I want to display my taxonomy template.<br>
I have created one custom taxonomy 'Location' for my custom post type 'Project'. Moreover, I have created templates for it as :</p>
<pre><code>taxonomy-{taxonomy_name}-{term}.php
taxonomy-{taxonomy_name}.php
taxonomy.php
</code></pre>
<p>None of ... | [
{
"answer_id": 278029,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 1,
"selected": false,
"text": "<p>There are a couple of different solutions if you want to have only the /holliday/project-location/ URL an... | 2017/08/22 | [
"https://wordpress.stackexchange.com/questions/277718",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116160/"
] | I am having problem when I want to display my taxonomy template.
I have created one custom taxonomy 'Location' for my custom post type 'Project'. Moreover, I have created templates for it as :
```
taxonomy-{taxonomy_name}-{term}.php
taxonomy-{taxonomy_name}.php
taxonomy.php
```
None of them work... I just get my ... | Thank you WebElaine for your help ! I figured out a way to solve it.
It looks a bit as you proposed in **Option 2**. Except that I used the filter **`parse_query`** to change my CPT `'has_archive'` to false when accessing my taxonomy.
Here is the code :
```
function check_taxonomy_query( $query ) {
if ($query-... |
277,724 | <p><a href="https://i.stack.imgur.com/Md1Uq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Md1Uq.png" alt="HTTPS ERROR"></a></p>
<p>How to fix Mixed content for wordpress plugin and themes, my images already served with https</p>
<p>i also test with <a href="https://www.whynopadlock.com/" rel="nof... | [
{
"answer_id": 278029,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 1,
"selected": false,
"text": "<p>There are a couple of different solutions if you want to have only the /holliday/project-location/ URL an... | 2017/08/22 | [
"https://wordpress.stackexchange.com/questions/277724",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/117129/"
] | [](https://i.stack.imgur.com/Md1Uq.png)
How to fix Mixed content for wordpress plugin and themes, my images already served with https
i also test with <https://www.whynopadlock.com/> | Thank you WebElaine for your help ! I figured out a way to solve it.
It looks a bit as you proposed in **Option 2**. Except that I used the filter **`parse_query`** to change my CPT `'has_archive'` to false when accessing my taxonomy.
Here is the code :
```
function check_taxonomy_query( $query ) {
if ($query-... |
277,725 | <p>I've a Custom Post Type called clock and a taxonomy called clock_category on my website.
It is working well and All the clocks can be accessed from the REST endpoint
<a href="https://myapp.dev/wp-json/wp/v2/clock" rel="noreferrer">https://myapp.dev/wp-json/wp/v2/clock</a></p>
<p>But I don't know how to filter them ... | [
{
"answer_id": 277744,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>We can check out the <code>/wp/v2/clock</code> endpoint's arguments here:</p>\n\n<pre><code>https://myapp.dev... | 2017/08/22 | [
"https://wordpress.stackexchange.com/questions/277725",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126346/"
] | I've a Custom Post Type called clock and a taxonomy called clock\_category on my website.
It is working well and All the clocks can be accessed from the REST endpoint
<https://myapp.dev/wp-json/wp/v2/clock>
But I don't know how to filter them by the Clock category, say I want to get all the clocks which are made of wo... | We can check out the `/wp/v2/clock` endpoint's arguments here:
```
https://myapp.dev/wp-json/wp/v2/
```
If we add the `'show_in_rest' => true,` argument, when registering the custom `clock_category` taxonomy, it will add a support for this GET/POST argument:
```
clock_category: {
required: false,
default: [... |
277,731 | <p>I'm creating a custom php/js pages querying and displaying results from a separate non-wordpress DB on a 2nd page. The header and footer will be the same as my theme so I'm calling the theme's footer and header but I haven't figured out why my hook to customize the pages' title aren't working and am asking which hoo... | [
{
"answer_id": 277735,
"author": "Anton Lukin",
"author_id": 126253,
"author_profile": "https://wordpress.stackexchange.com/users/126253",
"pm_score": -1,
"selected": false,
"text": "<p>It doesn't work this way.\nYou should load all wordpress environment, than with <code>template_include... | 2017/08/22 | [
"https://wordpress.stackexchange.com/questions/277731",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48698/"
] | I'm creating a custom php/js pages querying and displaying results from a separate non-wordpress DB on a 2nd page. The header and footer will be the same as my theme so I'm calling the theme's footer and header but I haven't figured out why my hook to customize the pages' title aren't working and am asking which hook t... | I ended up making a page template anyways and inserting the page title when making the post. |
277,740 | <p>I'm using Types plugin to create user metaboxes but it doesn't save. My HTML:</p>
<pre><code><form id="new-user" action="" method="POST" name="new-user" novalidate="" enctype="multipart/form-data">
<div class="form-group">
<input type="text" name="wpcf-nombre-u" id="nombre" placeholder="<... | [
{
"answer_id": 277735,
"author": "Anton Lukin",
"author_id": 126253,
"author_profile": "https://wordpress.stackexchange.com/users/126253",
"pm_score": -1,
"selected": false,
"text": "<p>It doesn't work this way.\nYou should load all wordpress environment, than with <code>template_include... | 2017/08/22 | [
"https://wordpress.stackexchange.com/questions/277740",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126358/"
] | I'm using Types plugin to create user metaboxes but it doesn't save. My HTML:
```
<form id="new-user" action="" method="POST" name="new-user" novalidate="" enctype="multipart/form-data">
<div class="form-group">
<input type="text" name="wpcf-nombre-u" id="nombre" placeholder="<?php _e('Nombre', 'wm'); ?>" >
... | I ended up making a page template anyways and inserting the page title when making the post. |
277,763 | <p>I could see previous –next image option in the default Twenty Sixteen theme even without installation any plugins.</p>
<p>But I would like to use Big Blue theme instead of default one and I could not see previous –next image option regardless that I’ve installed different plugins related gallery like Gallery Por... | [
{
"answer_id": 277735,
"author": "Anton Lukin",
"author_id": 126253,
"author_profile": "https://wordpress.stackexchange.com/users/126253",
"pm_score": -1,
"selected": false,
"text": "<p>It doesn't work this way.\nYou should load all wordpress environment, than with <code>template_include... | 2017/08/22 | [
"https://wordpress.stackexchange.com/questions/277763",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126051/"
] | I could see previous –next image option in the default Twenty Sixteen theme even without installation any plugins.
But I would like to use Big Blue theme instead of default one and I could not see previous –next image option regardless that I’ve installed different plugins related gallery like Gallery Portfolio, NextG... | I ended up making a page template anyways and inserting the page title when making the post. |
277,786 | <p>I want to try calling the pre-defined functions from the <a href="https://wordpress.org/plugins/front-end-pm/" rel="nofollow noreferrer">front end private messages plugin</a> in my custom template. But It shows that the function does not exist. But that function is working fine in the plugin.</p>
<p>What should I d... | [
{
"answer_id": 277794,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": -1,
"selected": true,
"text": "<p>There can be various reason for the undefined function error:</p>\n\n<ul>\n<li><p>The plugin might load its function ... | 2017/08/23 | [
"https://wordpress.stackexchange.com/questions/277786",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126392/"
] | I want to try calling the pre-defined functions from the [front end private messages plugin](https://wordpress.org/plugins/front-end-pm/) in my custom template. But It shows that the function does not exist. But that function is working fine in the plugin.
What should I do? | There can be various reason for the undefined function error:
* The plugin might load its function definitions later than `template_include` or in the admin backend only.
* You might have made a syntax error, for example if the plugin is using a [namespace](http://php.net/manual/en/language.namespaces.php), but you ar... |
277,787 | <p>I'm trying to Show User List in WordPress Admin in Descending order by "ID" column.</p>
<p>I tried below code</p>
<pre><code>add_action('pre_user_search', 'change_user_order');
function change_user_order($query)
{
$query->query_orderby = ' ORDER BY ID DESC';
}
</code></pre>
<p>But its not working.</p>
| [
{
"answer_id": 277789,
"author": "Bhagchandani",
"author_id": 101627,
"author_profile": "https://wordpress.stackexchange.com/users/101627",
"pm_score": 0,
"selected": false,
"text": "<p>As per user @toni_lehtimaki <strong>pre_user_search</strong> is deprecated. Below code is working.</p>... | 2017/08/23 | [
"https://wordpress.stackexchange.com/questions/277787",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124611/"
] | I'm trying to Show User List in WordPress Admin in Descending order by "ID" column.
I tried below code
```
add_action('pre_user_search', 'change_user_order');
function change_user_order($query)
{
$query->query_orderby = ' ORDER BY ID DESC';
}
```
But its not working. | I first thought that `pre_user_query` would be that hook for the job. But I think using the equivalent of `pre_get_posts`, which is [`pre_get_users`](https://developer.wordpress.org/reference/hooks/pre_get_users/), would be suitable here.
You also said you wanted to run this in admin. So we will check that before run... |
277,804 | <p>sorry for my english...
So I want to get my data from a https live site back to localhost. Using duplicator plugin works fine exept that I run (especially in Chrome) to a problem with absolute setted image links, wich refer to <a href="https://localhost" rel="nofollow noreferrer">https://localhost</a> ... .</p>
<p... | [
{
"answer_id": 277789,
"author": "Bhagchandani",
"author_id": 101627,
"author_profile": "https://wordpress.stackexchange.com/users/101627",
"pm_score": 0,
"selected": false,
"text": "<p>As per user @toni_lehtimaki <strong>pre_user_search</strong> is deprecated. Below code is working.</p>... | 2017/08/23 | [
"https://wordpress.stackexchange.com/questions/277804",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107825/"
] | sorry for my english...
So I want to get my data from a https live site back to localhost. Using duplicator plugin works fine exept that I run (especially in Chrome) to a problem with absolute setted image links, wich refer to <https://localhost> ... .
I wonder if someone is out there who knows a solution for this is... | I first thought that `pre_user_query` would be that hook for the job. But I think using the equivalent of `pre_get_posts`, which is [`pre_get_users`](https://developer.wordpress.org/reference/hooks/pre_get_users/), would be suitable here.
You also said you wanted to run this in admin. So we will check that before run... |
277,828 | <p>This is a rather simple question, so I'll keep it short.</p>
<p>Update1: In this context <code>{page-structure}</code> means just that: <code>page1/page1-1/page1-1-1/{...}</code>.</p>
<p>Update2: For further clarification, I want to do about the same <a href="https://www.advancedcustomfields.com/resources/post-obj... | [
{
"answer_id": 277830,
"author": "Mostafa Soufi",
"author_id": 106877,
"author_profile": "https://wordpress.stackexchange.com/users/106877",
"pm_score": 0,
"selected": false,
"text": "<p>Use the <code>$global</code> in before your <code>$post</code></p>\n\n<p>For example:</p>\n\n<pre><co... | 2017/08/23 | [
"https://wordpress.stackexchange.com/questions/277828",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59140/"
] | This is a rather simple question, so I'll keep it short.
Update1: In this context `{page-structure}` means just that: `page1/page1-1/page1-1-1/{...}`.
Update2: For further clarification, I want to do about the same [the ACF Post Object field](https://www.advancedcustomfields.com/resources/post-object/) is doing, exce... | This is how you can get the post object of a page with a matching path, minus the `/en` part:
```
$page_path = get_page_uri( get_queried_object_id() ); // en/page/child-page
$target_page_path = str_replace( 'en/', '', $page_path ); // page/child-page
$target_page = get_page_by_path( $target_page_path ); // WP_Post of ... |
277,836 | <p>I'm trying to make a code to display a image at the end of each post, but i need to show a specific image for each post category.
I'm using the code below:</p>
<pre><code><?php
if (in_category('category1')||){
echo '<img src="https://example.com/category1">';
}
elseif (in_category('cat... | [
{
"answer_id": 277830,
"author": "Mostafa Soufi",
"author_id": 106877,
"author_profile": "https://wordpress.stackexchange.com/users/106877",
"pm_score": 0,
"selected": false,
"text": "<p>Use the <code>$global</code> in before your <code>$post</code></p>\n\n<p>For example:</p>\n\n<pre><co... | 2017/08/23 | [
"https://wordpress.stackexchange.com/questions/277836",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126419/"
] | I'm trying to make a code to display a image at the end of each post, but i need to show a specific image for each post category.
I'm using the code below:
```
<?php
if (in_category('category1')||){
echo '<img src="https://example.com/category1">';
}
elseif (in_category('category2')){
echo... | This is how you can get the post object of a page with a matching path, minus the `/en` part:
```
$page_path = get_page_uri( get_queried_object_id() ); // en/page/child-page
$target_page_path = str_replace( 'en/', '', $page_path ); // page/child-page
$target_page = get_page_by_path( $target_page_path ); // WP_Post of ... |
277,837 | <p><code>$wpdb->insert()</code> returns <code>false</code> which I've learned means that the insert failed. Now, I would like to know why it fails with the insert.</p>
<p>According to this ticket <a href="https://core.trac.wordpress.org/ticket/32315" rel="noreferrer">https://core.trac.wordpress.org/ticket/32315</a>... | [
{
"answer_id": 326322,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 4,
"selected": false,
"text": "<p><code>$wpdb->insert()</code> method returns <code>false</code> if the row could not be inserted. O... | 2017/08/23 | [
"https://wordpress.stackexchange.com/questions/277837",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3216/"
] | `$wpdb->insert()` returns `false` which I've learned means that the insert failed. Now, I would like to know why it fails with the insert.
According to this ticket <https://core.trac.wordpress.org/ticket/32315> the problem could be that the value is either too long or contains bad characters.
Here is the insert query... | `$wpdb->insert()` method returns `false` if the row could not be inserted. Otherwise, it returns the number of affected rows (which will always be 1).
You can turn error echoing on and off with the `show_errors` and `hide_errors`, respectively.
```
<?php $wpdb->show_errors(); ?>
<?php $wpdb->hide_errors(); ?>
```
... |
277,841 | <p>I want to show all posts like <code>mywebsite.com/postname/1/</code>, <code>mywebsite.com/postname/2/</code> ...... <code>mywebsite.com/postname/7/</code> .. </p>
<p>Below code works perfectly for me, the only problem is that it shows only first posts <code>mywebsite.com/postname/</code>... </p>
<p>How can I do th... | [
{
"answer_id": 277844,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 0,
"selected": false,
"text": "<p>You don't need to redirect the user to the random post page, and you can't even if you want, because you ca... | 2017/08/23 | [
"https://wordpress.stackexchange.com/questions/277841",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126422/"
] | I want to show all posts like `mywebsite.com/postname/1/`, `mywebsite.com/postname/2/` ...... `mywebsite.com/postname/7/` ..
Below code works perfectly for me, the only problem is that it shows only first posts `mywebsite.com/postname/`...
How can I do this?
```
<?php
/**
* Template Name: Random Post
* This tem... | Only 1 post is displaying on your side because of you are using `exit()` in your loop. In your code when WP\_Query start and loop exit after one counter.
Remove `exit()` and use this code:
```
<?php
/*
* Random Post Picker
* Use on page to send viewer to random post optionally mod query
*/
// set arguments for WP_... |
277,872 | <p>For some reason I am unable to output the custom post type content using the following code. what am I missing here? It works fine for <code>get_the_title</code> yet using <code>get_the_content</code> using same parameters yields nothing.</p>
<pre><code><?php
$query = new WP_Query( ['post_type' =>... | [
{
"answer_id": 277844,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 0,
"selected": false,
"text": "<p>You don't need to redirect the user to the random post page, and you can't even if you want, because you ca... | 2017/08/23 | [
"https://wordpress.stackexchange.com/questions/277872",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1354/"
] | For some reason I am unable to output the custom post type content using the following code. what am I missing here? It works fine for `get_the_title` yet using `get_the_content` using same parameters yields nothing.
```
<?php
$query = new WP_Query( ['post_type' => 'testimonials', 'posts_per_page' => -1 ] ... | Only 1 post is displaying on your side because of you are using `exit()` in your loop. In your code when WP\_Query start and loop exit after one counter.
Remove `exit()` and use this code:
```
<?php
/*
* Random Post Picker
* Use on page to send viewer to random post optionally mod query
*/
// set arguments for WP_... |
277,874 | <p>I have 2 menus.</p>
<ol>
<li>Main Navigation</li>
<li>Footer Navigation</li>
</ol>
<p>And 3 locations:</p>
<ol>
<li>Top Bar Navigation</li>
<li>Main Navigation</li>
<li>Footer Navigation</li>
</ol>
<p>If I try to create a new menu, wp displays <strong>error</strong></p>
<pre><code>A name is required for this te... | [
{
"answer_id": 279647,
"author": "mperrin",
"author_id": 127640,
"author_profile": "https://wordpress.stackexchange.com/users/127640",
"pm_score": 2,
"selected": true,
"text": "<p>I got the same issue and found that the plugin <code>user-activity-log</code> was at the origin of the probl... | 2017/08/23 | [
"https://wordpress.stackexchange.com/questions/277874",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52581/"
] | I have 2 menus.
1. Main Navigation
2. Footer Navigation
And 3 locations:
1. Top Bar Navigation
2. Main Navigation
3. Footer Navigation
If I try to create a new menu, wp displays **error**
```
A name is required for this term.
```
Obviously I am giving a name in `Menu Name` textbox...
Is this a bug?
Is there a... | I got the same issue and found that the plugin `user-activity-log` was at the origin of the problem.
As I reported [here](https://wordpress.org/support/topic/cant-create-new-menus-a-name-is-required-for-this-term),the problem is related to the hooks:
* ual\_shook\_created\_term
* ual\_shook\_edited\_term
* ual\_shook... |
277,883 | <p>The theme I am using has a function to embed videos from Facebook. The problem is that whenever I use it it loads the SDK in <code>uk_UA</code> for whatever reasons (Ukrainian).</p>
<p>Nothing related to my Website or Facebook is using this language. After contacting the theme developers i was told it's not their f... | [
{
"answer_id": 277955,
"author": "Anton Lukin",
"author_id": 126253,
"author_profile": "https://wordpress.stackexchange.com/users/126253",
"pm_score": 1,
"selected": false,
"text": "<p>I've found your problem.</p>\n\n<p>You've inserted video from facebook on your page with facebook init ... | 2017/08/23 | [
"https://wordpress.stackexchange.com/questions/277883",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112590/"
] | The theme I am using has a function to embed videos from Facebook. The problem is that whenever I use it it loads the SDK in `uk_UA` for whatever reasons (Ukrainian).
Nothing related to my Website or Facebook is using this language. After contacting the theme developers i was told it's not their fault and *might* be s... | The reason for this issue was given on the [wordpress core ticketing system](https://core.trac.wordpress.org/ticket/40656).
>
> This is probably something you should report to Facebook (good luck),
> as WordPress is correctly outputting the lang attribute on the html
> element. Facebook likely uses heuristics to de... |
277,894 | <p>I would like to insert a full-width DIV at the topmost location in the site I'm building. The project is in overtime. All the other work is done, but I have been asked to add a small logo and a single link on top. This would be on all pages, so it's a modification to the header. I've looked at several plugins, but t... | [
{
"answer_id": 277895,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>Take a look at this question, and the first answer: <a href=\"https://wordpress.stackexchange.com/ques... | 2017/08/23 | [
"https://wordpress.stackexchange.com/questions/277894",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121627/"
] | I would like to insert a full-width DIV at the topmost location in the site I'm building. The project is in overtime. All the other work is done, but I have been asked to add a small logo and a single link on top. This would be on all pages, so it's a modification to the header. I've looked at several plugins, but they... | As I can see in [wp-primer-theme sources](https://github.com/godaddy/wp-primer-theme/blob/develop/header.php): there are `do_action( 'primer_body' );` on the top of content and `do_action( 'primer_before_header' );` just below.
You can update your child theme functions.php with your own action
```
add_action('primer_... |
277,910 | <p>I have a single-site Wordpress installed on example.com. The DNS is configured so that www.example.com is an ALIAS of example.com. The client wants the user to see www. on their nav bar if they entered it, so this is important.</p>
<p>I hosted their website on an apache server running cpanel. The cpanel has the dom... | [
{
"answer_id": 277947,
"author": "MrWhite",
"author_id": 8259,
"author_profile": "https://wordpress.stackexchange.com/users/8259",
"pm_score": 2,
"selected": true,
"text": "<p>You need to set the canonical hostname (ie. with <code>www</code>) in the WordPress dashboard... Under Settings ... | 2017/08/24 | [
"https://wordpress.stackexchange.com/questions/277910",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126470/"
] | I have a single-site Wordpress installed on example.com. The DNS is configured so that www.example.com is an ALIAS of example.com. The client wants the user to see www. on their nav bar if they entered it, so this is important.
I hosted their website on an apache server running cpanel. The cpanel has the domain set as... | You need to set the canonical hostname (ie. with `www`) in the WordPress dashboard... Under Settings > General and set the appropriate "WordPress Address (URL)" and "Site Address (URL)" properties.
Alternatively, these values can be *hardcoded* in `wp_config.php` by defining the `WP_HOME` and `WP_SITEURL` constants re... |
277,928 | <p>I haven't been able to find this on google and I thought this was a common requirement.</p>
<p>Is there a way to add a 5 stars (or whatever rating) to my products with a single plugin or PHP code? I need to show stars in every catalog so I can test my design.</p>
| [
{
"answer_id": 277935,
"author": "Nikola Miljković",
"author_id": 111583,
"author_profile": "https://wordpress.stackexchange.com/users/111583",
"pm_score": 2,
"selected": false,
"text": "<p>Since you need it just for visual purposes, it's better if you don't save the rating value to the ... | 2017/08/24 | [
"https://wordpress.stackexchange.com/questions/277928",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126489/"
] | I haven't been able to find this on google and I thought this was a common requirement.
Is there a way to add a 5 stars (or whatever rating) to my products with a single plugin or PHP code? I need to show stars in every catalog so I can test my design. | [@Nikola](https://wordpress.stackexchange.com/users/111583/nikola-miljkovi%C4%87)'s [answer](https://wordpress.stackexchange.com/a/277935/43098) gives you what you want to need without saving anything to the database. If **you** need to save the values to the database and directly execute SQL, you can do the following.... |
277,939 | <p>I have to run a php function for around 10 minutes. Now I am sheduling the job as a wp-cron-job. But it is getting timed out after 30seconds which is the maximum execution time for php. How to get rid of this timeout issue?</p>
| [
{
"answer_id": 277935,
"author": "Nikola Miljković",
"author_id": 111583,
"author_profile": "https://wordpress.stackexchange.com/users/111583",
"pm_score": 2,
"selected": false,
"text": "<p>Since you need it just for visual purposes, it's better if you don't save the rating value to the ... | 2017/08/24 | [
"https://wordpress.stackexchange.com/questions/277939",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/119861/"
] | I have to run a php function for around 10 minutes. Now I am sheduling the job as a wp-cron-job. But it is getting timed out after 30seconds which is the maximum execution time for php. How to get rid of this timeout issue? | [@Nikola](https://wordpress.stackexchange.com/users/111583/nikola-miljkovi%C4%87)'s [answer](https://wordpress.stackexchange.com/a/277935/43098) gives you what you want to need without saving anything to the database. If **you** need to save the values to the database and directly execute SQL, you can do the following.... |
277,943 | <p>I can't get any 'category' loops to load.</p>
<p>Here is my work flow.</p>
<p>I create a page called category.php and placed the following code (exactly like this):</p>
<pre><code><?php
/*
* Template Name: Category
*/
if (!defined('ABSPATH'))
exit; // Exit if accessed directly
get_header();
?>
<?... | [
{
"answer_id": 277949,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p>You don't assign category templates to pages. They are templates that will be used <em>automatically</e... | 2017/08/24 | [
"https://wordpress.stackexchange.com/questions/277943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93691/"
] | I can't get any 'category' loops to load.
Here is my work flow.
I create a page called category.php and placed the following code (exactly like this):
```
<?php
/*
* Template Name: Category
*/
if (!defined('ABSPATH'))
exit; // Exit if accessed directly
get_header();
?>
<?php while ( have_posts() ) : the_post... | You don't assign category templates to pages. They are templates that will be used *automatically* when you view a category.
Read the [Template Hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/) documentation. You're using WordPress completely wrong. You don't create pages for archives, they... |
277,953 | <p>I'm trying to add a custom field of event_month when a post is published or saved. I'm using the save_post action and getting the contents of a custom field containing the date and trying to store this in a separate custom field with just the month. This works perfectly when saving a post that has already been cre... | [
{
"answer_id": 277954,
"author": "Anton Lukin",
"author_id": 126253,
"author_profile": "https://wordpress.stackexchange.com/users/126253",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>pre_post_update</code> instead of <code>save_post</code></p>\n\n<p>Full explanation <a href=\... | 2017/08/24 | [
"https://wordpress.stackexchange.com/questions/277953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/118170/"
] | I'm trying to add a custom field of event\_month when a post is published or saved. I'm using the save\_post action and getting the contents of a custom field containing the date and trying to store this in a separate custom field with just the month. This works perfectly when saving a post that has already been create... | You can hook into [`post_updated`](https://codex.wordpress.org/Plugin_API/Action_Reference/post_updated) action, if you want to access the post's data *after* it's been published. This hook passes the post's ID, inundated post object, and updated post object.
```
add_action( 'post_updated', 'update_event_date', 10, 3 ... |
277,956 | <p>I am using shortcode and in that I want to change the title by setting the value from the database using custom tables.I have tried using the_title filter as follows </p>
<pre><code>add_filter('the_title','set_page_title', 10, 2);
function set_page_title($title, $id){
if(in_the_loop()) {
return 'sdfds... | [
{
"answer_id": 277954,
"author": "Anton Lukin",
"author_id": 126253,
"author_profile": "https://wordpress.stackexchange.com/users/126253",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>pre_post_update</code> instead of <code>save_post</code></p>\n\n<p>Full explanation <a href=\... | 2017/08/24 | [
"https://wordpress.stackexchange.com/questions/277956",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123210/"
] | I am using shortcode and in that I want to change the title by setting the value from the database using custom tables.I have tried using the\_title filter as follows
```
add_filter('the_title','set_page_title', 10, 2);
function set_page_title($title, $id){
if(in_the_loop()) {
return 'sdfdsfdsf';
}
... | You can hook into [`post_updated`](https://codex.wordpress.org/Plugin_API/Action_Reference/post_updated) action, if you want to access the post's data *after* it's been published. This hook passes the post's ID, inundated post object, and updated post object.
```
add_action( 'post_updated', 'update_event_date', 10, 3 ... |
278,015 | <p>I am using the Zephyr theme for my site, but want to switch to a child theme as this seems to be recommended in case the theme is updated. I am worried I will lose my customization etc. </p>
<p>Are there any safeguards against this?</p>
| [
{
"answer_id": 277954,
"author": "Anton Lukin",
"author_id": 126253,
"author_profile": "https://wordpress.stackexchange.com/users/126253",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>pre_post_update</code> instead of <code>save_post</code></p>\n\n<p>Full explanation <a href=\... | 2017/08/24 | [
"https://wordpress.stackexchange.com/questions/278015",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126536/"
] | I am using the Zephyr theme for my site, but want to switch to a child theme as this seems to be recommended in case the theme is updated. I am worried I will lose my customization etc.
Are there any safeguards against this? | You can hook into [`post_updated`](https://codex.wordpress.org/Plugin_API/Action_Reference/post_updated) action, if you want to access the post's data *after* it's been published. This hook passes the post's ID, inundated post object, and updated post object.
```
add_action( 'post_updated', 'update_event_date', 10, 3 ... |
278,035 | <p>I have a quite extensive database, 30000+ items, and using this:</p>
<pre><code>$args = array(
'posts_per_page' => -1,
'post_type' => 'books',
's' => $s
);
$post_counts = count(get_posts($args));
</code></pre>
<p>seems to take forever.</p>
<pre><code>I solved this partic... | [
{
"answer_id": 278036,
"author": "Anton Lukin",
"author_id": 126253,
"author_profile": "https://wordpress.stackexchange.com/users/126253",
"pm_score": 0,
"selected": false,
"text": "<p>There is <code>$wpdb->num_rows</code> parameter. \nBut I suggest you do it with </p>\n\n<pre><code>$... | 2017/08/24 | [
"https://wordpress.stackexchange.com/questions/278035",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116224/"
] | I have a quite extensive database, 30000+ items, and using this:
```
$args = array(
'posts_per_page' => -1,
'post_type' => 'books',
's' => $s
);
$post_counts = count(get_posts($args));
```
seems to take forever.
```
I solved this particular case with:
$post_count = $wpdb->get_var(... | Here's one thing you could do. Create a WP\_Query object but only include ids:
```
$args = array(
'posts_per_page' => -1,
'post_type' => 'books',
's' => $s,
'fields' => 'ids',
);
$query = new WP_Query( $args );
$post_counts = $query->post_count;
wp_res... |
278,051 | <p>I have been trying to figure out how to add session variables to WordPress Custom Pages for the past few days but have still been unable to find a solution. From researching it seems WordPress does not allow you to move Session variables from one page to the next. I have tried removing all of the 'session_start();' ... | [
{
"answer_id": 278036,
"author": "Anton Lukin",
"author_id": 126253,
"author_profile": "https://wordpress.stackexchange.com/users/126253",
"pm_score": 0,
"selected": false,
"text": "<p>There is <code>$wpdb->num_rows</code> parameter. \nBut I suggest you do it with </p>\n\n<pre><code>$... | 2017/08/24 | [
"https://wordpress.stackexchange.com/questions/278051",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126550/"
] | I have been trying to figure out how to add session variables to WordPress Custom Pages for the past few days but have still been unable to find a solution. From researching it seems WordPress does not allow you to move Session variables from one page to the next. I have tried removing all of the 'session\_start();' fr... | Here's one thing you could do. Create a WP\_Query object but only include ids:
```
$args = array(
'posts_per_page' => -1,
'post_type' => 'books',
's' => $s,
'fields' => 'ids',
);
$query = new WP_Query( $args );
$post_counts = $query->post_count;
wp_res... |
278,076 | <p>I would like to display the last 3 articles of category 'camping-camping' with a shortcode but the function does not seem valid, an idea ?</p>
<pre><code>function derniers_articles_camping() {
// the query
$the_query = new WP_Query( array(
'category_name' => 'location-camping-var',
'posts_per_page' => 3,... | [
{
"answer_id": 278070,
"author": "Atul",
"author_id": 126565,
"author_profile": "https://wordpress.stackexchange.com/users/126565",
"pm_score": -1,
"selected": false,
"text": "<p>If there are only few images which are required for the plugin itself then store it under plugins own image f... | 2017/08/25 | [
"https://wordpress.stackexchange.com/questions/278076",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109045/"
] | I would like to display the last 3 articles of category 'camping-camping' with a shortcode but the function does not seem valid, an idea ?
```
function derniers_articles_camping() {
// the query
$the_query = new WP_Query( array(
'category_name' => 'location-camping-var',
'posts_per_page' => 3,
));
if ( $the_que... | The only directory in which you have guaranteed write access is the uploads directory. Even your plugin's directory might be write protected, the same for `wp-content` (which doesn't even have to exist). |
278,078 | <p>Probably a silly one but hopefully someone has encountered this before.</p>
<h2>The problem:</h2>
<p>I have a local copy of my Wordpress site that works fine and a copy on the server. After uploading I get <code>Call to undefined function</code> from within the child theme's <code>header.php</code> referencing a ... | [
{
"answer_id": 278070,
"author": "Atul",
"author_id": 126565,
"author_profile": "https://wordpress.stackexchange.com/users/126565",
"pm_score": -1,
"selected": false,
"text": "<p>If there are only few images which are required for the plugin itself then store it under plugins own image f... | 2017/08/25 | [
"https://wordpress.stackexchange.com/questions/278078",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122832/"
] | Probably a silly one but hopefully someone has encountered this before.
The problem:
------------
I have a local copy of my Wordpress site that works fine and a copy on the server. After uploading I get `Call to undefined function` from within the child theme's `header.php` referencing a function that should exist in... | The only directory in which you have guaranteed write access is the uploads directory. Even your plugin's directory might be write protected, the same for `wp-content` (which doesn't even have to exist). |
278,081 | <p>I have a plugin rejected by wordpress.org, one of the resasons is this:</p>
<blockquote>
<h2>Unsafe Requiring of Common Libraries Since you're using a common library, it's important that you enqueue it safely. Example(s):</h2>
<p>require_once('jsonld.php');</p>
<p>Since that is a common library, y... | [
{
"answer_id": 278082,
"author": "Fabio Marzocca",
"author_id": 65278,
"author_profile": "https://wordpress.stackexchange.com/users/65278",
"pm_score": 0,
"selected": false,
"text": "<p>You can check included files first.</p>\n\n<pre><code>$included_files = get_included_files();\n\nif (!... | 2017/08/25 | [
"https://wordpress.stackexchange.com/questions/278081",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17157/"
] | I have a plugin rejected by wordpress.org, one of the resasons is this:
>
> Unsafe Requiring of Common Libraries Since you're using a common library, it's important that you enqueue it safely. Example(s):
> ---------------------------------------------------------------------------------------------------------------... | 1. No, it just means it's used by many plugins, not that Core includes it.
2. Many of the functions in that library seem to use the `JsonLdProcessor` class that is also in that library, I'd check for that before including:
```
if ( ! class_exists( 'JsonLdProcessor' ) ) {
require_once( 'jsonld.php' )
}
``` |
278,096 | <p>I have 4 users roles on my wordpress platform (role1, role2, role3, role4)</p>
<p>I'm looking for to show front-end top bar only for Role1 Role2.</p>
<p>how can i add a condition on this code to show it only for this 2 roles?</p>
<pre><code>function wpc_show_admin_bar() {
return true;
}
add_filter('show_admin_b... | [
{
"answer_id": 278098,
"author": "Christine Cooper",
"author_id": 24875,
"author_profile": "https://wordpress.stackexchange.com/users/24875",
"pm_score": 4,
"selected": true,
"text": "<p>You can disable the admin bar via function:</p>\n\n<pre><code>show_admin_bar(false);\n</code></pre>\n... | 2017/08/25 | [
"https://wordpress.stackexchange.com/questions/278096",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/119785/"
] | I have 4 users roles on my wordpress platform (role1, role2, role3, role4)
I'm looking for to show front-end top bar only for Role1 Role2.
how can i add a condition on this code to show it only for this 2 roles?
```
function wpc_show_admin_bar() {
return true;
}
add_filter('show_admin_bar' , 'wpc_show_admin_bar');... | You can disable the admin bar via function:
```
show_admin_bar(false);
```
So with that in mind, we can hook into `after_setup_theme` and hide the admin bar for all users except `administrator` and `contributor`:
```
function cc_wpse_278096_disable_admin_bar() {
if (current_user_can('administrator') || current_u... |
278,099 | <p>I'm creating a single page app with WP REST API and AngularJS. After solving a problem with nonces on <a href="https://wordpress.stackexchange.com/questions/278011/wp-rest-api-check-if-user-is-logged-in">this question</a>, now i'm facing something else.
To test the chance of adding fields and making them protected a... | [
{
"answer_id": 278100,
"author": "bynicolas",
"author_id": 99217,
"author_profile": "https://wordpress.stackexchange.com/users/99217",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress nonces are not real nonces, they remain valid for a period of 12 to 24 hours and will return the ... | 2017/08/25 | [
"https://wordpress.stackexchange.com/questions/278099",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/119611/"
] | I'm creating a single page app with WP REST API and AngularJS. After solving a problem with nonces on [this question](https://wordpress.stackexchange.com/questions/278011/wp-rest-api-check-if-user-is-logged-in), now i'm facing something else.
To test the chance of adding fields and making them protected against non-log... | The true reason of not using nonces for non logged in users, is that it adds a pointless burden on their usage as they need to refresh the page when the nonce expire, and the only way they will know that they need to do it is when something do not work.
There is probably no reason to avoid generating it, but if you ex... |
278,109 | <p>I'm trying to exclude the latest two blog posts from a page.
I know it's possible to do this with <code>offset</code> however doing that causes a bug in which some of the blog posts are repeated on the second page so not ideal.
Currently I'm doing it manually using the post id so like this:</p>
<pre><code>$paged = ... | [
{
"answer_id": 278100,
"author": "bynicolas",
"author_id": 99217,
"author_profile": "https://wordpress.stackexchange.com/users/99217",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress nonces are not real nonces, they remain valid for a period of 12 to 24 hours and will return the ... | 2017/08/25 | [
"https://wordpress.stackexchange.com/questions/278109",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126587/"
] | I'm trying to exclude the latest two blog posts from a page.
I know it's possible to do this with `offset` however doing that causes a bug in which some of the blog posts are repeated on the second page so not ideal.
Currently I'm doing it manually using the post id so like this:
```
$paged = ( get_query_var( 'paged' ... | The true reason of not using nonces for non logged in users, is that it adds a pointless burden on their usage as they need to refresh the page when the nonce expire, and the only way they will know that they need to do it is when something do not work.
There is probably no reason to avoid generating it, but if you ex... |
278,128 | <p>I am trying to output related posts of the current post by <code>tag_ID</code>. With the current code, posts will output all posts from the <code>property</code> tag instead of specific tag.</p>
<p>How can I only return posts based on the current posts <code>tag_ID</code>?</p>
<pre><code><?php $post_tag = get_t... | [
{
"answer_id": 278130,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": true,
"text": "<p><code>get_the_tags()</code> returns an array of tags name, ID, and more. You should store only IDs in an arr... | 2017/08/25 | [
"https://wordpress.stackexchange.com/questions/278128",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/87036/"
] | I am trying to output related posts of the current post by `tag_ID`. With the current code, posts will output all posts from the `property` tag instead of specific tag.
How can I only return posts based on the current posts `tag_ID`?
```
<?php $post_tag = get_the_tags($post->ID)?>//Not sure if correct
<?php
$arg... | `get_the_tags()` returns an array of tags name, ID, and more. You should store only IDs in an array, and use it in your query.
```
$post_tag = get_the_tags ( $post->ID );
// Define an empty array
$ids = array();
// Check if the post has any tags
if ( $post_tag ) {
foreach ( $post_tag as $tag ) {
$ids[] = $... |
278,136 | <p>So, I have a plugin that uses Ajax to dynamically build the post content piece by piece for a custom post type. Once the user has build their page, they hit Update/Publish and Ajax sends the entire built page to a the main plugin PHP file where I am attempting to call <code>wp_insert_post()</code>.</p>
<p>Here is m... | [
{
"answer_id": 278139,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>Don't bother fixing your AJAX callback, there's already a REST API endpoint that's well tested and does all o... | 2017/08/25 | [
"https://wordpress.stackexchange.com/questions/278136",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/119050/"
] | So, I have a plugin that uses Ajax to dynamically build the post content piece by piece for a custom post type. Once the user has build their page, they hit Update/Publish and Ajax sends the entire built page to a the main plugin PHP file where I am attempting to call `wp_insert_post()`.
Here is my relevant code (and ... | Don't bother fixing your AJAX callback, there's already a REST API endpoint that's well tested and does all of this out of the box:
```
example.com/wp-json/wp/v2/zen_page
```
So lets enqueue a helper script to give us the URL and a security token/nonce:
```
wp_enqueue_script( 'wp-api' );
```
You will **must** ena... |
278,148 | <p>I've just converted my local development install of wordpress to a network, and everything seems to work, except the parts of the admin panel relating to network management don't have the correct links (I have the core wordpress files in a "wordpress/" subdirectory.) The network related parts get links generated wit... | [
{
"answer_id": 278139,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>Don't bother fixing your AJAX callback, there's already a REST API endpoint that's well tested and does all o... | 2017/08/25 | [
"https://wordpress.stackexchange.com/questions/278148",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84595/"
] | I've just converted my local development install of wordpress to a network, and everything seems to work, except the parts of the admin panel relating to network management don't have the correct links (I have the core wordpress files in a "wordpress/" subdirectory.) The network related parts get links generated withou... | Don't bother fixing your AJAX callback, there's already a REST API endpoint that's well tested and does all of this out of the box:
```
example.com/wp-json/wp/v2/zen_page
```
So lets enqueue a helper script to give us the URL and a security token/nonce:
```
wp_enqueue_script( 'wp-api' );
```
You will **must** ena... |
278,150 | <p>I'm currently working on my first theme and am trying to allow the user to edit some text in the customizer. </p>
<p>Basically, I've got as far as getting the text the user writes in the customizer to show on the frontend, but the default text isn't showing and I'm not sure how to get it to show.</p>
<p>Below is t... | [
{
"answer_id": 278151,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<p>Setting the default when registering the setting doesn't make it the default on output, it just makes i... | 2017/08/26 | [
"https://wordpress.stackexchange.com/questions/278150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/108692/"
] | I'm currently working on my first theme and am trying to allow the user to edit some text in the customizer.
Basically, I've got as far as getting the text the user writes in the customizer to show on the frontend, but the default text isn't showing and I'm not sure how to get it to show.
Below is the code I've put ... | Setting the default when registering the setting doesn't make it the default on output, it just makes it the default value when the customiser is opened. To provide a default before the customiser is opened/saved you pass it as a second argument to `get_theme_mod()`:
```
<?php echo get_theme_mod('home_header_title', _... |
278,156 | <p>Not sure if my assumption is correct regarding running <code>wp-cron</code> from CLI would be slightly faster than calling it via <code>wget</code> or <code>curl</code>, so either way I'm trying this:</p>
<pre><code>/usr/bin/php /var/www/mywebsite.com/wp-cron.php?import_key=<keyhere>&import_id=1&actio... | [
{
"answer_id": 278158,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>the CLI PHP interpreter is not exactly the same as the one invoke by the webserver. A lot of enviroment i... | 2017/08/26 | [
"https://wordpress.stackexchange.com/questions/278156",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16113/"
] | Not sure if my assumption is correct regarding running `wp-cron` from CLI would be slightly faster than calling it via `wget` or `curl`, so either way I'm trying this:
```
/usr/bin/php /var/www/mywebsite.com/wp-cron.php?import_key=<keyhere>&import_id=1&action=processing
```
I ensured that path to PHP and the file is... | Or, you could use [WP-CLI](http://wp-cli.org/) which was developed for scenarios like these. After a short installation like this
```
$ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
$ chmod +x wp-cli.phar
$ sudo mv wp-cli.phar /usr/local/bin/wp
```
You can run your scheduled tasks... |
278,190 | <p>I have a custom search query that return results correctly, but when i tried to paginate the results,it shows the content of the first page. when I click on 'next'or the number of the page the search page reloads and the link changes from
localhost/wordpress/search/?search_input=art&search=</p>
<p>to </p>
<p>... | [
{
"answer_id": 278198,
"author": "inarilo",
"author_id": 17923,
"author_profile": "https://wordpress.stackexchange.com/users/17923",
"pm_score": 0,
"selected": false,
"text": "<p>You need to pass more values to <a href=\"https://codex.wordpress.org/Function_Reference/paginate_links\" rel... | 2017/08/26 | [
"https://wordpress.stackexchange.com/questions/278190",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126630/"
] | I have a custom search query that return results correctly, but when i tried to paginate the results,it shows the content of the first page. when I click on 'next'or the number of the page the search page reloads and the link changes from
localhost/wordpress/search/?search\_input=art&search=
to
localhost/wordpress/... | the problem was that the get\_query\_var('paged')or 'page' couldn't read the value .. I don't know why? .. but it always returns 0; and the check sets $paged to 1 each time ... so I got around it, and got the page number from the URL >>> It worked for me on localhost, but I've no clue if it works on a host... for your ... |
278,204 | <p>Is it possible to delete a huge number of wordpress posts through SQL query using phpmyadmin by using a permalink list of posts that I want to delete ?</p>
| [
{
"answer_id": 278368,
"author": "Milan Petrovic",
"author_id": 126702,
"author_profile": "https://wordpress.stackexchange.com/users/126702",
"pm_score": 0,
"selected": false,
"text": "<p>It depends on permalinks. Permalinks can contain more then just the post name (slug). Also, post nam... | 2017/08/26 | [
"https://wordpress.stackexchange.com/questions/278204",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65292/"
] | Is it possible to delete a huge number of wordpress posts through SQL query using phpmyadmin by using a permalink list of posts that I want to delete ? | Yes you can.
To delete posts with inherit post meta, use following code:
```
DELETE
p,pm
FROM wp_posts p
JOIN wp_postmeta pm ON pm.post_id = p.id
WHERE p.post_name IN ('post-1', 'post-2', 'post-3')
```
Pass slugs array to WHERE clause.
If you want to delete only posts w/out postmeta (for some reason), use this code... |
278,251 | <p>I'm currently trying to resize all the featured images on my theme to 1140 x 500. I've placed this code in my function.php file</p>
<pre><code> if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
// Default Post thumbnail dimensions (cropped)
set_po... | [
{
"answer_id": 278262,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 2,
"selected": true,
"text": "<p>Setting the size itself does not crop the existing images. You need to regenerate the existing thumbnails to... | 2017/08/27 | [
"https://wordpress.stackexchange.com/questions/278251",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/108692/"
] | I'm currently trying to resize all the featured images on my theme to 1140 x 500. I've placed this code in my function.php file
```
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
// Default Post thumbnail dimensions (cropped)
set_post_thumbnail_s... | Setting the size itself does not crop the existing images. You need to regenerate the existing thumbnails too.
There are a couple of plugins for this, but I personally downloaded and used [Regenerate Thumbnails](https://wordpress.org/plugins/regenerate-thumbnails/). Install the plugin, and head over to `Tools > Regene... |
278,258 | <p>I have a multisite installation running in a sub-directory on the server - purely for the reason that it has become my MO to develop a new site for a client in a "WordPress" directory while their old site is live, and then when it is ready, I change the <code>index.php</code> and <code>.htaccess</code> files and voi... | [
{
"answer_id": 278281,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 1,
"selected": false,
"text": "<p>That's an error with your database credentials, as stored in wp-config.php . Check/fix those credentia... | 2017/08/27 | [
"https://wordpress.stackexchange.com/questions/278258",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126669/"
] | I have a multisite installation running in a sub-directory on the server - purely for the reason that it has become my MO to develop a new site for a client in a "WordPress" directory while their old site is live, and then when it is ready, I change the `index.php` and `.htaccess` files and voila, the site is live.
F... | That's an error with your database credentials, as stored in wp-config.php . Check/fix those credentials to let WP access the database. (As the googles would tell you if you searched on the error message....) |
278,286 | <p>I have a custom field for an image, and using it this way:</p>
<pre><code><?php $item_img = get_sub_field('image'); ?>
<img src="<?php echo $item_img ?>" />
</code></pre>
<p>But I want to use the thumbnail version of the image, as set to 150x150 in wordpress.</p>
<p>How do I do that with this ty... | [
{
"answer_id": 278271,
"author": "sakarya",
"author_id": 51376,
"author_profile": "https://wordpress.stackexchange.com/users/51376",
"pm_score": -1,
"selected": false,
"text": "<p>I can't say, how do you find out how they did it, but I can say something for security.</p>\n\n<ol>\n<li>Alw... | 2017/08/28 | [
"https://wordpress.stackexchange.com/questions/278286",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123346/"
] | I have a custom field for an image, and using it this way:
```
<?php $item_img = get_sub_field('image'); ?>
<img src="<?php echo $item_img ?>" />
```
But I want to use the thumbnail version of the image, as set to 150x150 in wordpress.
How do I do that with this type of setup?
Do I have to set a custom `add_image_... | There are many things that I do to check a possible hack on the site. Changing FTP users/passwords, reinstalling WP, reinstalling themes/plugins, changing user account passwords (especially admin level), change hosting credentials.
I wrote an entry on my own site to remind me (most of the stuff there is my own 'notes'... |
278,293 | <p>One of my WordPress templates is <strong>completely different</strong> and requires different css and js (but still needs needs the core JQuery as well as the bootstrap 3 css/js).</p>
<p>So, how would I go about removing the generic style.css and also a few other css files (and js files) that are site wide? I think... | [
{
"answer_id": 278271,
"author": "sakarya",
"author_id": 51376,
"author_profile": "https://wordpress.stackexchange.com/users/51376",
"pm_score": -1,
"selected": false,
"text": "<p>I can't say, how do you find out how they did it, but I can say something for security.</p>\n\n<ol>\n<li>Alw... | 2017/08/28 | [
"https://wordpress.stackexchange.com/questions/278293",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93691/"
] | One of my WordPress templates is **completely different** and requires different css and js (but still needs needs the core JQuery as well as the bootstrap 3 css/js).
So, how would I go about removing the generic style.css and also a few other css files (and js files) that are site wide? I think that it is a variation... | There are many things that I do to check a possible hack on the site. Changing FTP users/passwords, reinstalling WP, reinstalling themes/plugins, changing user account passwords (especially admin level), change hosting credentials.
I wrote an entry on my own site to remind me (most of the stuff there is my own 'notes'... |
278,296 | <p>I'm bulk deleting posts from my WordPress site using the function <code>wp_delete_post</code> and categories using <code>wp_delete_category</code>. That are about 100.000 posts and 4.000 categories, and after a while I get a PHP Error </p>
<p><code>PHP Fatal error: Allowed memory size of ... bytes exhausted</code>... | [
{
"answer_id": 278313,
"author": "Milan Petrovic",
"author_id": 126702,
"author_profile": "https://wordpress.stackexchange.com/users/126702",
"pm_score": 2,
"selected": false,
"text": "<p>The code you use also uses WordPress functions that will first load posts (and other relevant data) ... | 2017/08/28 | [
"https://wordpress.stackexchange.com/questions/278296",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126097/"
] | I'm bulk deleting posts from my WordPress site using the function `wp_delete_post` and categories using `wp_delete_category`. That are about 100.000 posts and 4.000 categories, and after a while I get a PHP Error
`PHP Fatal error: Allowed memory size of ... bytes exhausted`
That's what I do inside my code:
```
// g... | The code you use also uses WordPress functions that will first load posts (and other relevant data) in memory first and cache them using object cache. So, to delete 100.000 posts, your code will try to load each post in memory and that can take a lot of memory. I am not sure how high PHP memory is set in your case, but... |
278,354 | <p>I have a wordpress site in a language that aligns RTL, but some pages are in English. These pages look terrible, however, because the English text is aligned with the RTL language, and punctuation, etc. appear on the wrong the side.</p>
<p>How can I set the language for a single page or several individual pages?</p... | [
{
"answer_id": 278355,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": false,
"text": "<p>The <a href=\"https://codex.wordpress.org/Plugin_API/Filter_Reference/locale\" rel=\"noreferrer\"><code>loc... | 2017/08/28 | [
"https://wordpress.stackexchange.com/questions/278354",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126536/"
] | I have a wordpress site in a language that aligns RTL, but some pages are in English. These pages look terrible, however, because the English text is aligned with the RTL language, and punctuation, etc. appear on the wrong the side.
How can I set the language for a single page or several individual pages? | The [`locale`](https://codex.wordpress.org/Plugin_API/Filter_Reference/locale) filter that allows you to set the locale specifically. You can check the current page, and alter the value based on that.
```
add_filter('locale', 'change_my_locale');
function change_my_locale( $locale ) {
if ( is_page('slug-here') ) {... |
278,385 | <p>I migrated my WordPress install and DB to another server (same domain).
And I am getting this:</p>
<p><a href="https://i.stack.imgur.com/KhPai.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KhPai.png" alt="enter image description here"></a></p>
<p>Also everything is where it should be (includin... | [
{
"answer_id": 278403,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>I always find it easiest to use the WP Clone plugin <a href=\"https://wordpress.org/plugins/wp-clone-b... | 2017/08/28 | [
"https://wordpress.stackexchange.com/questions/278385",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126738/"
] | I migrated my WordPress install and DB to another server (same domain).
And I am getting this:
[](https://i.stack.imgur.com/KhPai.png)
Also everything is where it should be (including file and db permissions and other specific settings):
[![enter im... | You didn't mention what have you done so far to migrate your installation, but I'm going to write the full procedure.
Backing Up the Old Database
---------------------------
You need to create an exact duplicate of your database, to transfer it to your new server. There might be an encoding issue here, so to do this,... |
278,393 | <p>I need to enqueue a style sheet in my plugin to work on the front end of Wordpress. Here is what I have. Will someone please tell me what I am doing wrong?</p>
<pre><code>function add_my_stylesheet1() {
wp_enqueue_style( 'myStyles', plugins_url( 'css/styles.css', __FILE__ ) );
}
add_action('admin_print_sty... | [
{
"answer_id": 278394,
"author": "Cedon",
"author_id": 80069,
"author_profile": "https://wordpress.stackexchange.com/users/80069",
"pm_score": 0,
"selected": false,
"text": "<p>You need to use the <code>admin_enqueue_scripts</code> hook. So your function would be like this...</p>\n\n<pre... | 2017/08/29 | [
"https://wordpress.stackexchange.com/questions/278393",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/117793/"
] | I need to enqueue a style sheet in my plugin to work on the front end of Wordpress. Here is what I have. Will someone please tell me what I am doing wrong?
```
function add_my_stylesheet1() {
wp_enqueue_style( 'myStyles', plugins_url( 'css/styles.css', __FILE__ ) );
}
add_action('admin_print_styles', 'add_my_st... | You're enquing on the **admin**\_enqueue\_scripts hook, which is why it's only showing up on admin pages
If we look at an example from the official documentation:
```
/**
* Proper way to enqueue scripts and styles
*/
function wpdocs_theme_name_scripts() {
wp_enqueue_style( 'style-name', get_stylesheet_uri() );
... |
278,399 | <p>How do I add a class <code>the_content();</code>?</p>
<pre><code><div class="csoporszoveg">
<h3 class="csoporcim"><?php
if ($settings['enable_link']) {
echo '<a href="' . get_permalink($post) . '">';
}
the_title();
if ($settings['enable_link']) ... | [
{
"answer_id": 278400,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p>You don't. You'll need to put an element around it:</p>\n\n<pre><code><?php if ( $content_source == ... | 2017/08/29 | [
"https://wordpress.stackexchange.com/questions/278399",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126748/"
] | How do I add a class `the_content();`?
```
<div class="csoporszoveg">
<h3 class="csoporcim"><?php
if ($settings['enable_link']) {
echo '<a href="' . get_permalink($post) . '">';
}
the_title();
if ($settings['enable_link']) {
echo '</a>';
}
?... | You don't. You'll need to put an element around it:
```
<?php if ( $content_source == 'excerpt' ) { ?>
<div class="excerpt">
<?php the_excerpt(); ?>
</div>
<?php } else { ?>
<div class="content">
<?php the_content(); ?>
</div>
<?php } ?>
``` |
278,408 | <p>I'm building a website where there are some posts that will be relevant only for users from a specific country, so I would like that the user select his country so that he can view all the content minus (-) the content that is specific to other countries. </p>
<p>For example:
The user can select between Argentina, ... | [
{
"answer_id": 278400,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p>You don't. You'll need to put an element around it:</p>\n\n<pre><code><?php if ( $content_source == ... | 2017/08/29 | [
"https://wordpress.stackexchange.com/questions/278408",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126752/"
] | I'm building a website where there are some posts that will be relevant only for users from a specific country, so I would like that the user select his country so that he can view all the content minus (-) the content that is specific to other countries.
For example:
The user can select between Argentina, Chile, Mex... | You don't. You'll need to put an element around it:
```
<?php if ( $content_source == 'excerpt' ) { ?>
<div class="excerpt">
<?php the_excerpt(); ?>
</div>
<?php } else { ?>
<div class="content">
<?php the_content(); ?>
</div>
<?php } ?>
``` |
278,429 | <p>I use TinyMCE Advance plugin. I've posted a question in the support forum of the the plugin but it seems that the author doesn't provide any support now. As you can see in the picture, the font size 12pt is the default font size. Every time I open the TinyMCE Advance editor, the size 12pt displays in the default sta... | [
{
"answer_id": 295988,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 2,
"selected": true,
"text": "<p>This is kind of a 2-parter. The first half will show you how to change the style inside TinyMCE when editing... | 2017/08/29 | [
"https://wordpress.stackexchange.com/questions/278429",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/125408/"
] | I use TinyMCE Advance plugin. I've posted a question in the support forum of the the plugin but it seems that the author doesn't provide any support now. As you can see in the picture, the font size 12pt is the default font size. Every time I open the TinyMCE Advance editor, the size 12pt displays in the default state.... | This is kind of a 2-parter. The first half will show you how to change the style inside TinyMCE when editing. The second half will show you how to remove things from the toolbar.
Style TinyMCE
=============
WordPress give us a neat little function called [`add_editor_style()`](https://developer.wordpress.org/referenc... |
278,450 | <p>I want to import into the media library, all the images & videos referenced in my blog posts.</p>
<ol>
<li>Can I use <a href="https://developer.wordpress.org/reference/functions/get_attached_media/" rel="nofollow noreferrer"><code>get_attached_media()</code></a> to get the images <em>referenced</em> on a page, ... | [
{
"answer_id": 295988,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 2,
"selected": true,
"text": "<p>This is kind of a 2-parter. The first half will show you how to change the style inside TinyMCE when editing... | 2017/08/29 | [
"https://wordpress.stackexchange.com/questions/278450",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/81576/"
] | I want to import into the media library, all the images & videos referenced in my blog posts.
1. Can I use [`get_attached_media()`](https://developer.wordpress.org/reference/functions/get_attached_media/) to get the images *referenced* on a page, even if they're not formally attached?
2. Should I use [`media_handle_si... | This is kind of a 2-parter. The first half will show you how to change the style inside TinyMCE when editing. The second half will show you how to remove things from the toolbar.
Style TinyMCE
=============
WordPress give us a neat little function called [`add_editor_style()`](https://developer.wordpress.org/referenc... |
278,452 | <p>The error is:</p>
<blockquote>
<p>Warning: Cannot modify header information - headers already sent by (output started at
C:\wamp64444\www\demoplugin\wp-includes\class.wp-styles.php:237) in
C:\wamp64444\www\demoplugin\wp-includes\pluggable.php on line 914</p>
</blockquote>
<p>code of my plugin that create for... | [
{
"answer_id": 295988,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 2,
"selected": true,
"text": "<p>This is kind of a 2-parter. The first half will show you how to change the style inside TinyMCE when editing... | 2017/08/29 | [
"https://wordpress.stackexchange.com/questions/278452",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126783/"
] | The error is:
>
> Warning: Cannot modify header information - headers already sent by (output started at
> C:\wamp64444\www\demoplugin\wp-includes\class.wp-styles.php:237) in
> C:\wamp64444\www\demoplugin\wp-includes\pluggable.php on line 914
>
>
>
code of my plugin that create form for registration and form lo... | This is kind of a 2-parter. The first half will show you how to change the style inside TinyMCE when editing. The second half will show you how to remove things from the toolbar.
Style TinyMCE
=============
WordPress give us a neat little function called [`add_editor_style()`](https://developer.wordpress.org/referenc... |
278,476 | <p>I am currently trying to change <strong>Woocommerce redirect url</strong> for login only when users logged from a specific page. So first I tried that way in my template page:</p>
<pre><code><?php woocommerce_login_form(array('redirect'=>$_SERVER['REQUEST_URI'])); ?>
</code></pre>
<p>Then, I saw user is s... | [
{
"answer_id": 278478,
"author": "Jeff Mattson",
"author_id": 93714,
"author_profile": "https://wordpress.stackexchange.com/users/93714",
"pm_score": 2,
"selected": false,
"text": "<p>Try changing <code>strtr</code> to <code>strpos</code>. However, you can not give it an array for needl... | 2017/08/29 | [
"https://wordpress.stackexchange.com/questions/278476",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96315/"
] | I am currently trying to change **Woocommerce redirect url** for login only when users logged from a specific page. So first I tried that way in my template page:
```
<?php woocommerce_login_form(array('redirect'=>$_SERVER['REQUEST_URI'])); ?>
```
Then, I saw user is still redirected to default (my-account) so I use... | I found what was my problem is priority. Some other plugin was using a 1000 priority, so I had to boost my priority when declaring the hook. That way:
```
add_filter( 'woocommerce_login_redirect', 'share_login_redirect', 1100, 2 );
```
instead of
```
add_filter( 'woocommerce_login_redirect', 'share_login_redirect'... |
278,504 | <p>Trying to run a custom script on a single page using is_page in functions.php not working at all. I have a function called load_gh_boards that would enquque a script, only on a certain page (79): </p>
<pre><code>function load_gh_boards() {
if( is_page(79) ){
wp_register_script( 'gh-jobs-board', get_bloginfo( 't... | [
{
"answer_id": 278505,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 0,
"selected": false,
"text": "<p>First of all, there is a mistype in your code. It's <code>wp_enqueue_scripts</code>, not <code>wp_enqueue_s... | 2017/08/29 | [
"https://wordpress.stackexchange.com/questions/278504",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114585/"
] | Trying to run a custom script on a single page using is\_page in functions.php not working at all. I have a function called load\_gh\_boards that would enquque a script, only on a certain page (79):
```
function load_gh_boards() {
if( is_page(79) ){
wp_register_script( 'gh-jobs-board', get_bloginfo( 'template_dir... | `is_page(79)` is asking if the current main query is a page, specifically page 79
**But the main query hasn't happened yet**
This function has to be called inside the main loop or at the very least inside the template, but the `init` hook is way too early for this.
Instead, make sure you use the body class, and load... |
278,527 | <p>-I am running a woo commencers shop</p>
<p>-Users have the ability to add products using wp insert post</p>
<p>-The product gallery multiple image upload will only add the last image to the post but in media they are all attached to the correct post</p>
<p>This is my code</p>
<p>function.php</p>
<pre><code>func... | [
{
"answer_id": 330163,
"author": "Tcmxc",
"author_id": 63922,
"author_profile": "https://wordpress.stackexchange.com/users/63922",
"pm_score": 1,
"selected": true,
"text": "<pre><code>if ( ! empty( $_FILES['muti_files'] ) ) {\n $files = $_FILES['muti_files'];\n for... | 2017/08/29 | [
"https://wordpress.stackexchange.com/questions/278527",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63922/"
] | -I am running a woo commencers shop
-Users have the ability to add products using wp insert post
-The product gallery multiple image upload will only add the last image to the post but in media they are all attached to the correct post
This is my code
function.php
```
function my_handle_attachment($file_handler,$p... | ```
if ( ! empty( $_FILES['muti_files'] ) ) {
$files = $_FILES['muti_files'];
foreach ($files['name'] as $key => $value){
if ($files['name'][$key]){
$file = array(
'name' => $files['name'][$key],
'type' => $files['type'... |
278,533 | <p>When Users create custom post types, the author field does not seem to be passed back to WP posts functions.</p>
<p>As the title says, I'm creating a user account programatically, and having that user log-in and write a post of custom post_type = 'job'.</p>
<p>This all LOOKS good in the database - the user, and po... | [
{
"answer_id": 330163,
"author": "Tcmxc",
"author_id": 63922,
"author_profile": "https://wordpress.stackexchange.com/users/63922",
"pm_score": 1,
"selected": true,
"text": "<pre><code>if ( ! empty( $_FILES['muti_files'] ) ) {\n $files = $_FILES['muti_files'];\n for... | 2017/08/30 | [
"https://wordpress.stackexchange.com/questions/278533",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122711/"
] | When Users create custom post types, the author field does not seem to be passed back to WP posts functions.
As the title says, I'm creating a user account programatically, and having that user log-in and write a post of custom post\_type = 'job'.
This all LOOKS good in the database - the user, and post are inserted.... | ```
if ( ! empty( $_FILES['muti_files'] ) ) {
$files = $_FILES['muti_files'];
foreach ($files['name'] as $key => $value){
if ($files['name'][$key]){
$file = array(
'name' => $files['name'][$key],
'type' => $files['type'... |
278,541 | <p>I use the bellow template to display the first event from an ascendent list of custom post type events, created by a third party plugin. What I want is to exclude old events, displaying only the one actual, if we have one today, or the nearest. The event start date is saved in a <code>meta_key</code> with a value in... | [
{
"answer_id": 278545,
"author": "Abdul Awal Uzzal",
"author_id": 31449,
"author_profile": "https://wordpress.stackexchange.com/users/31449",
"pm_score": 2,
"selected": false,
"text": "<p>You need something like the following:</p>\n\n<pre><code>$args = array(\n 'post_type' =&g... | 2017/08/30 | [
"https://wordpress.stackexchange.com/questions/278541",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | I use the bellow template to display the first event from an ascendent list of custom post type events, created by a third party plugin. What I want is to exclude old events, displaying only the one actual, if we have one today, or the nearest. The event start date is saved in a `meta_key` with a value in the "Y-m-d" f... | OK, with some help from [@jonathan-wold](https://wordpress.stackexchange.com/a/12305/25187), I figured out how to solve my problem. In my initial code I just replaced the `$args` part, accordingly to mentioned author, and this worked like a charm. This is the code:
```
$args = array(
'post_type' => 'events', // Te... |
278,555 | <p>How can I submit pull request to other's plugin, which is hosted at <strong>wordpress.org</strong>?</p>
| [
{
"answer_id": 278545,
"author": "Abdul Awal Uzzal",
"author_id": 31449,
"author_profile": "https://wordpress.stackexchange.com/users/31449",
"pm_score": 2,
"selected": false,
"text": "<p>You need something like the following:</p>\n\n<pre><code>$args = array(\n 'post_type' =&g... | 2017/08/30 | [
"https://wordpress.stackexchange.com/questions/278555",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33667/"
] | How can I submit pull request to other's plugin, which is hosted at **wordpress.org**? | OK, with some help from [@jonathan-wold](https://wordpress.stackexchange.com/a/12305/25187), I figured out how to solve my problem. In my initial code I just replaced the `$args` part, accordingly to mentioned author, and this worked like a charm. This is the code:
```
$args = array(
'post_type' => 'events', // Te... |
278,561 | <p>Should I able to change URL structure of WordPress blog? (Free WordPress hosted blog) </p>
<p>Right now I have this way: (see URL structure)</p>
<pre><code>helloworld.wordpress.com/london
</code></pre>
<p>But I want to use as this way:</p>
<pre><code>helloworld.wordpress.com/carhire/uk/london
</code></pre>
<p>I... | [
{
"answer_id": 278562,
"author": "kero",
"author_id": 108180,
"author_profile": "https://wordpress.stackexchange.com/users/108180",
"pm_score": 2,
"selected": true,
"text": "<p>Yes, this is achievable and quite simple to do so. Go to <strong>Settings</strong> > <strong>Permalinks</strong... | 2017/08/30 | [
"https://wordpress.stackexchange.com/questions/278561",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126838/"
] | Should I able to change URL structure of WordPress blog? (Free WordPress hosted blog)
Right now I have this way: (see URL structure)
```
helloworld.wordpress.com/london
```
But I want to use as this way:
```
helloworld.wordpress.com/carhire/uk/london
```
Is this achievable? | Yes, this is achievable and quite simple to do so. Go to **Settings** > **Permalinks** in your admin area.
There you should be able to select **Custom** and use a value like (if you want all URLs to start with /carhire/uk/)
```
/carhire/uk/%postname%/
```
If your logic is more complex, I suggest using a plugin such... |
278,580 | <p>I can't get this line of code translation ready.</p>
<pre><code><?php
comment_form(array ('title_reply' => 'Leave a comment'));
?>
</code></pre>
<p>Thank you very much! Best wishes,
Pierre</p>
| [
{
"answer_id": 278562,
"author": "kero",
"author_id": 108180,
"author_profile": "https://wordpress.stackexchange.com/users/108180",
"pm_score": 2,
"selected": true,
"text": "<p>Yes, this is achievable and quite simple to do so. Go to <strong>Settings</strong> > <strong>Permalinks</strong... | 2017/08/30 | [
"https://wordpress.stackexchange.com/questions/278580",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126835/"
] | I can't get this line of code translation ready.
```
<?php
comment_form(array ('title_reply' => 'Leave a comment'));
?>
```
Thank you very much! Best wishes,
Pierre | Yes, this is achievable and quite simple to do so. Go to **Settings** > **Permalinks** in your admin area.
There you should be able to select **Custom** and use a value like (if you want all URLs to start with /carhire/uk/)
```
/carhire/uk/%postname%/
```
If your logic is more complex, I suggest using a plugin such... |
278,612 | <p>I´am creating a Plugin. For this I wrote my own templates. Now I want to have the templeates files in my Plugin directory. </p>
<p>But that doenst work fine. Since I used the Plugin directory, wordpress doesent know that are my templates are wp templeates. What is the best way to let WP know, that these files are a... | [
{
"answer_id": 278562,
"author": "kero",
"author_id": 108180,
"author_profile": "https://wordpress.stackexchange.com/users/108180",
"pm_score": 2,
"selected": true,
"text": "<p>Yes, this is achievable and quite simple to do so. Go to <strong>Settings</strong> > <strong>Permalinks</strong... | 2017/08/30 | [
"https://wordpress.stackexchange.com/questions/278612",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126872/"
] | I´am creating a Plugin. For this I wrote my own templates. Now I want to have the templeates files in my Plugin directory.
But that doenst work fine. Since I used the Plugin directory, wordpress doesent know that are my templates are wp templeates. What is the best way to let WP know, that these files are a wordpress... | Yes, this is achievable and quite simple to do so. Go to **Settings** > **Permalinks** in your admin area.
There you should be able to select **Custom** and use a value like (if you want all URLs to start with /carhire/uk/)
```
/carhire/uk/%postname%/
```
If your logic is more complex, I suggest using a plugin such... |
278,613 | <p>I have the following args array</p>
<pre><code>{
"ordreby":"meta_value_num",
"meta_key":"_price",
"posts_per_page":10,
"offset":0,
"post_type":"product",
"post_status":"publish",
"order":"asc",
"suppress_filters":false,
}
</code></pre>
<p>when i do </p>
<pre><code> $myposts = get_posts... | [
{
"answer_id": 278617,
"author": "Z. Zlatev",
"author_id": 4192,
"author_profile": "https://wordpress.stackexchange.com/users/4192",
"pm_score": 1,
"selected": false,
"text": "<p><code>meta_query</code> should be an array of arrays like:</p>\n\n<pre><code>...\n'meta_query' => [\n [... | 2017/08/30 | [
"https://wordpress.stackexchange.com/questions/278613",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122895/"
] | I have the following args array
```
{
"ordreby":"meta_value_num",
"meta_key":"_price",
"posts_per_page":10,
"offset":0,
"post_type":"product",
"post_status":"publish",
"order":"asc",
"suppress_filters":false,
}
```
when i do
```
$myposts = get_posts($args);
```
the order by **\_price... | Change
`"ordreby":"meta_value_num"`
for
```
"orderby":"meta_value_num"
```
a dyslexic error xD |
278,628 | <p>I have created the <strong>Read more</strong> in my posts, but when I add the php tag </p>
<pre><code><?php the_content(); ?>
</code></pre>
<p>...it shows the post content with <strong>read more</strong> button. I only want to display the button, with no post content.</p>
<p>Here is a picture of my design .... | [
{
"answer_id": 278638,
"author": "Osama Elzero",
"author_id": 126781,
"author_profile": "https://wordpress.stackexchange.com/users/126781",
"pm_score": 2,
"selected": false,
"text": "<p>You can achieve this with many ways. First thing you need to use </p>\n\n<pre><code>the_excerpt() \n</... | 2017/08/30 | [
"https://wordpress.stackexchange.com/questions/278628",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126889/"
] | I have created the **Read more** in my posts, but when I add the php tag
```
<?php the_content(); ?>
```
...it shows the post content with **read more** button. I only want to display the button, with no post content.
Here is a picture of my design .
In the pi... | You can achieve this with many ways. First thing you need to use
```
the_excerpt()
```
instead of
```
the_content()
```
and in your functions.php file you can add this function to return 0 text from post text.
```
function custom_excerpt_length($length) {
if (is_home()) {
return 0;
}
}
add_fi... |
278,631 | <p>I am trying to get a child theme to work. At first it didn't load because it didn't recognise it as a child theme. Now it does work but when I activate it, it loads a version of my page seemingly without any css or something. There's only text and images there, but no styling. Is it that it isn't using the parent th... | [
{
"answer_id": 278638,
"author": "Osama Elzero",
"author_id": 126781,
"author_profile": "https://wordpress.stackexchange.com/users/126781",
"pm_score": 2,
"selected": false,
"text": "<p>You can achieve this with many ways. First thing you need to use </p>\n\n<pre><code>the_excerpt() \n</... | 2017/08/30 | [
"https://wordpress.stackexchange.com/questions/278631",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126890/"
] | I am trying to get a child theme to work. At first it didn't load because it didn't recognise it as a child theme. Now it does work but when I activate it, it loads a version of my page seemingly without any css or something. There's only text and images there, but no styling. Is it that it isn't using the parent theme... | You can achieve this with many ways. First thing you need to use
```
the_excerpt()
```
instead of
```
the_content()
```
and in your functions.php file you can add this function to return 0 text from post text.
```
function custom_excerpt_length($length) {
if (is_home()) {
return 0;
}
}
add_fi... |
278,647 | <p>I have tried adding this to <code>style.css</code>:</p>
<pre><code>.sidebar, .widget-area, .secondary {
position: absolute
margin-left: 120px;
max-width: 250px;
}
</code></pre>
<p>But it won't move. If I remove <code>position:absolute</code>, it is pushed down, getting under all the other content.</p>
| [
{
"answer_id": 279137,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 0,
"selected": false,
"text": "<p>there are 2 pieces of code in the css:</p>\n\n<pre><code>.has-sidebar #secondary {\n float: right;\n pad... | 2017/08/30 | [
"https://wordpress.stackexchange.com/questions/278647",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126901/"
] | I have tried adding this to `style.css`:
```
.sidebar, .widget-area, .secondary {
position: absolute
margin-left: 120px;
max-width: 250px;
}
```
But it won't move. If I remove `position:absolute`, it is pushed down, getting under all the other content. | You have 2 options:
**Option 1.**
Just add negative margin to the sidebar CSS like this:
```
@media screen and (min-width: 48em){
#secondary{
margin-right:-150px;
}
}
```
**Option 2.**
Add more max-width to the wrapper:
```
@media screen and (min-width: 48em){
.wrap{
max-width: 1340px;... |
278,655 | <p>HTML:</p>
<pre><code><header>
<!-- I want to add html code here -->
</header>
</code></pre>
<p>Function:</p>
<pre><code> function add_html_to_header {
<b> Hello World </b>
}
add_action('','add_html_to_header')
</code></pre>
<p>Expected Html results:</p>
<pre><code><heade... | [
{
"answer_id": 278656,
"author": "Monkey Puzzle",
"author_id": 48568,
"author_profile": "https://wordpress.stackexchange.com/users/48568",
"pm_score": 2,
"selected": false,
"text": "<p>You can add html to the site head using this function:</p>\n\n<pre><code>// Add scripts to wp_head()\nf... | 2017/08/31 | [
"https://wordpress.stackexchange.com/questions/278655",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96537/"
] | HTML:
```
<header>
<!-- I want to add html code here -->
</header>
```
Function:
```
function add_html_to_header {
<b> Hello World </b>
}
add_action('','add_html_to_header')
```
Expected Html results:
```
<header id="header">
<b> Hello World </b>
</header>
```
**EDIT:** Is it possible without usin... | You can add html to the site head using this function:
```
// Add scripts to wp_head()
function add_head_html() { ?>
<!-- html goes here -->
<?php }
add_action( 'wp_head', 'add_head_html' );
```
But if you're talking about the html element `<header>` (as it sounds like from your edits) it sounds like ove... |
278,662 | <p>I'm trying to enqueue a JavaScript file in the header of my website.</p>
<p>If I add the following in my main plugin file the JS is included in the header:</p>
<pre><code>function wpdocs_theme_name_scripts() {
wp_register_script('googlesearch', 'https://maps.googleapis.com/maps/api/js');
wp_enqueue_script... | [
{
"answer_id": 278666,
"author": "KAGG Design",
"author_id": 108721,
"author_profile": "https://wordpress.stackexchange.com/users/108721",
"pm_score": 2,
"selected": false,
"text": "<p>Page is created and output in the following order: header, content, footer. Shorcode is executed during... | 2017/08/31 | [
"https://wordpress.stackexchange.com/questions/278662",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/81594/"
] | I'm trying to enqueue a JavaScript file in the header of my website.
If I add the following in my main plugin file the JS is included in the header:
```
function wpdocs_theme_name_scripts() {
wp_register_script('googlesearch', 'https://maps.googleapis.com/maps/api/js');
wp_enqueue_script('googlesearch');
}
... | Page is created and output in the following order: header, content, footer. Shorcode is executed during the construction of the page content, when header is already output on the page. So, it is impossible to add any script to header on this stage: it is too late. |
278,696 | <p>I've been trying to change the title in a dynamic page without any luck.</p>
<p>What I did is I created two page-templates from where I load items (occasions) from an external database.
In one page-template I load the single-page occasion:</p>
<pre><code><?php include 'Occasions-files/single.php';?>
</code><... | [
{
"answer_id": 278724,
"author": "James",
"author_id": 34484,
"author_profile": "https://wordpress.stackexchange.com/users/34484",
"pm_score": 1,
"selected": false,
"text": "<p>Just to make sure, does the title tag in your <code><head></code> area (presumably in header.php) look li... | 2017/08/31 | [
"https://wordpress.stackexchange.com/questions/278696",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126415/"
] | I've been trying to change the title in a dynamic page without any luck.
What I did is I created two page-templates from where I load items (occasions) from an external database.
In one page-template I load the single-page occasion:
```
<?php include 'Occasions-files/single.php';?>
```
And the second page-template ... | Just to make sure, does the title tag in your `<head>` area (presumably in header.php) look like this?
```
<title><?php wp_title(); ?></title>
```
It has to be like that for Yoast to work with it, and be able to override titles.
Anyway if you add this to your single.php (or at least before `get_header()` is run for... |
278,701 | <p>this is my jscript</p>
<pre><code> <script>
jQuery(document).ready(function($){
$("button").on('click', function(event) {
event.preventDefault();
$('html, body').stop().animate({
scrollTop: $("#button").offset().top
}, 1000);
... | [
{
"answer_id": 278724,
"author": "James",
"author_id": 34484,
"author_profile": "https://wordpress.stackexchange.com/users/34484",
"pm_score": 1,
"selected": false,
"text": "<p>Just to make sure, does the title tag in your <code><head></code> area (presumably in header.php) look li... | 2017/08/31 | [
"https://wordpress.stackexchange.com/questions/278701",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124829/"
] | this is my jscript
```
<script>
jQuery(document).ready(function($){
$("button").on('click', function(event) {
event.preventDefault();
$('html, body').stop().animate({
scrollTop: $("#button").offset().top
}, 1000);
});
});
</... | Just to make sure, does the title tag in your `<head>` area (presumably in header.php) look like this?
```
<title><?php wp_title(); ?></title>
```
It has to be like that for Yoast to work with it, and be able to override titles.
Anyway if you add this to your single.php (or at least before `get_header()` is run for... |
278,706 | <p>I wanted to set value of <strong>WP option</strong> (more specifically - 'admin_email') by using plugin, <strong>its option</strong> (plugin option) and update_option().</p>
<p>I tried using lines like below, but when plugin code contains them - it gets disabled. Any ideas why?</p>
<pre><code>$helper = (get_option... | [
{
"answer_id": 278707,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": -1,
"selected": false,
"text": "<p>You've got an extra bracket:</p>\n\n<pre><code>$helper = (get_option('plugin-option');\n</code></pre>\... | 2017/08/31 | [
"https://wordpress.stackexchange.com/questions/278706",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126863/"
] | I wanted to set value of **WP option** (more specifically - 'admin\_email') by using plugin, **its option** (plugin option) and update\_option().
I tried using lines like below, but when plugin code contains them - it gets disabled. Any ideas why?
```
$helper = (get_option('plugin-option');
update_option('admin_email... | That option is special in that WordPress has code to intercept your call for security reasons:
<https://codex.wordpress.org/Function_Reference/update_option_new_admin_email>
>
> This function intercepts changes to the administrator's email address. It keeps the address from being updated and instead sends the user a... |
278,714 | <p>I add my custom fields in genearal settings page. One of them using Wordpress Editor - there i insert my HTML content. I creeated it using simple snippet: </p>
<pre><code>add_action( 'admin_init', 'register_settings_wpse_57647' );
function register_settings_wpse_57647()
{
register_setting(
'genera... | [
{
"answer_id": 278715,
"author": "Patryk Patryk",
"author_id": 120726,
"author_profile": "https://wordpress.stackexchange.com/users/120726",
"pm_score": -1,
"selected": false,
"text": "<p>Ok. i was solved it right now! When i display it i put it wit html_entity_decode()</p>\n\n<pre><code... | 2017/08/31 | [
"https://wordpress.stackexchange.com/questions/278714",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/120726/"
] | I add my custom fields in genearal settings page. One of them using Wordpress Editor - there i insert my HTML content. I creeated it using simple snippet:
```
add_action( 'admin_init', 'register_settings_wpse_57647' );
function register_settings_wpse_57647()
{
register_setting(
'general',
'opi... | It's because you're using `esc_html` to sanitize the setting, which converts all the `<`,`>` etc. into HTML entities, like `>`, which *render* as `<` but aren't treated as those characters in terms of HTML, which is why tags aren't rendering correctly. `esc_html` is supposed to be use for outputting HTML so that the... |
278,754 | <p>I wrote some custom code which I've stuck into the media upload panel using a filter. It does a couple of things. First, it changes the text for the "submit" button for users who add things through the uploader. Second, it makes it so that the contents of the File URL field automatically enters the image upload inpu... | [
{
"answer_id": 278725,
"author": "Abhilash Narayan",
"author_id": 123210,
"author_profile": "https://wordpress.stackexchange.com/users/123210",
"pm_score": -1,
"selected": false,
"text": "<p>I fixed this by changing the permission of uploads folder to 745 and its working.</p>\n"
},
{... | 2017/08/31 | [
"https://wordpress.stackexchange.com/questions/278754",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114210/"
] | I wrote some custom code which I've stuck into the media upload panel using a filter. It does a couple of things. First, it changes the text for the "submit" button for users who add things through the uploader. Second, it makes it so that the contents of the File URL field automatically enters the image upload input f... | For the permission please read this
<https://codex.wordpress.org/Changing_File_Permissions>
>
> All directories should be 755 or 750.
>
>
> |
278,772 | <p>I do not have coding experience only what I've learned to be able to modify my WP themes. I am stuck on the following issue. I'd like to add text and a call to action button to the featured image on my static homepage. </p>
<p>I'm fine using the page title as the text but I need to be able to add the call to act... | [
{
"answer_id": 278784,
"author": "Dexter0015",
"author_id": 62134,
"author_profile": "https://wordpress.stackexchange.com/users/62134",
"pm_score": 1,
"selected": false,
"text": "<p>If your theme allow you to edit the text displayed on your home page, when you just need to add a a link.<... | 2017/09/01 | [
"https://wordpress.stackexchange.com/questions/278772",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/126986/"
] | I do not have coding experience only what I've learned to be able to modify my WP themes. I am stuck on the following issue. I'd like to add text and a call to action button to the featured image on my static homepage.
I'm fine using the page title as the text but I need to be able to add the call to action button bu... | If your theme allow you to edit the text displayed on your home page, when you just need to add a a link.
A click to call link is a simple HTML link, except that the value of the `href` attribute needs to refer to the "tel" protocol:
```
<a href="tel:XXXXXXXXXXXXX">Call Us</a>
```
Where "XXXXXXXXXXXXX" is your phon... |
278,780 | <p>I have a custom post type functionality defined on my website for a certain action. In order to achieve a specific type of url structure. I removed the constant slug from it and replaced it with category and brand name. </p>
<p>The previous url was</p>
<p>www.website.com/product/name</p>
<p>The new url is</p>
<p... | [
{
"answer_id": 278784,
"author": "Dexter0015",
"author_id": 62134,
"author_profile": "https://wordpress.stackexchange.com/users/62134",
"pm_score": 1,
"selected": false,
"text": "<p>If your theme allow you to edit the text displayed on your home page, when you just need to add a a link.<... | 2017/09/01 | [
"https://wordpress.stackexchange.com/questions/278780",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24020/"
] | I have a custom post type functionality defined on my website for a certain action. In order to achieve a specific type of url structure. I removed the constant slug from it and replaced it with category and brand name.
The previous url was
www.website.com/product/name
The new url is
www.website.com/category/brand... | If your theme allow you to edit the text displayed on your home page, when you just need to add a a link.
A click to call link is a simple HTML link, except that the value of the `href` attribute needs to refer to the "tel" protocol:
```
<a href="tel:XXXXXXXXXXXXX">Call Us</a>
```
Where "XXXXXXXXXXXXX" is your phon... |
278,813 | <p>i have in all of my posts an additional custom field (acf user field) in case the post has a co-author. </p>
<p>All users have their own author-page where all their posts are displayed. No problem so far.</p>
<p>But what i now want is a query where i get all posts where the author is the actual author and all post... | [
{
"answer_id": 278842,
"author": "James",
"author_id": 34484,
"author_profile": "https://wordpress.stackexchange.com/users/34484",
"pm_score": 0,
"selected": false,
"text": "<p>Real quick, are you sure you spelled the name of the meta_key correctly? It says \"authorfeld\" in your example... | 2017/09/01 | [
"https://wordpress.stackexchange.com/questions/278813",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92874/"
] | i have in all of my posts an additional custom field (acf user field) in case the post has a co-author.
All users have their own author-page where all their posts are displayed. No problem so far.
But what i now want is a query where i get all posts where the author is the actual author and all posts where he/she is... | I found some hints here: [Can i merge 2 new WP\_Query($variable) 's?](https://wordpress.stackexchange.com/questions/55519/can-i-merge-2-new-wp-queryvariable-s)
So i created two separate queries and merged them into a new array:
```
$wp_query = new WP_Query();
$wp_query->posts = array_merge( $query1->posts, $query2->p... |
278,882 | <p>How can I get the email adress from the users by using the REST API?
I'm authenticating with nonce, and it seems to be working since I can do POST requests and change stuff. Do I have to add something to make it return all the user info?</p>
<p>This is my JS:</p>
<pre><code>(function($) {
var nonce = WP... | [
{
"answer_id": 278883,
"author": "Mostafa Soufi",
"author_id": 106877,
"author_profile": "https://wordpress.stackexchange.com/users/106877",
"pm_score": 4,
"selected": true,
"text": "<p>To add the user's email address in the REST API response, register an additional field to the <code>us... | 2017/09/02 | [
"https://wordpress.stackexchange.com/questions/278882",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5079/"
] | How can I get the email adress from the users by using the REST API?
I'm authenticating with nonce, and it seems to be working since I can do POST requests and change stuff. Do I have to add something to make it return all the user info?
This is my JS:
```
(function($) {
var nonce = WPsettings.nonce;
v... | To add the user's email address in the REST API response, register an additional field to the `user` object and add the email address:
```
register_rest_field(
'user',
'user_email',
[
'get_callback' => static function (array $user): string {
return get_userdata($user['id'])->user_email;... |
278,954 | <p>I'm currently trying to download a blob archive file saved in the database</p>
<pre><code>$fid = $_GET['fid'];
$sel = $wpdb->get_results( "SELECT * FROM uploads WHERE id = $fid" );
foreach( $sel as $head )
{
$name = $head->name;
$type = $head->type;
$size = $head->size;
$content = $head... | [
{
"answer_id": 278993,
"author": "Sebastian Kurzynowski",
"author_id": 108925,
"author_profile": "https://wordpress.stackexchange.com/users/108925",
"pm_score": 2,
"selected": false,
"text": "<p>There are some security issues. \nPlease sanitize your input because someone can download fro... | 2017/09/03 | [
"https://wordpress.stackexchange.com/questions/278954",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127113/"
] | I'm currently trying to download a blob archive file saved in the database
```
$fid = $_GET['fid'];
$sel = $wpdb->get_results( "SELECT * FROM uploads WHERE id = $fid" );
foreach( $sel as $head )
{
$name = $head->name;
$type = $head->type;
$size = $head->size;
$content = $head->content;
header("Co... | There are some security issues.
Please sanitize your input because someone can download from Your database something different than archive, or simply drop Your database.
`$fid = sanitize_text_field( $_GET['fid'] );` |
278,986 | <p>I am trying to get the updated value of a piece of meta when a post is saved (custom post type) but when I try to grab the updated data on the save_post hook, I get the previous data instead. I tried a separate function with a higher priority, but no luck that way either (below)</p>
<p>How do I get the updated meta... | [
{
"answer_id": 278988,
"author": "Eckstein",
"author_id": 23492,
"author_profile": "https://wordpress.stackexchange.com/users/23492",
"pm_score": 3,
"selected": true,
"text": "<p>Apparently in order to get the meta value right after saving the post, you have to either get the $_REQUEST['... | 2017/09/04 | [
"https://wordpress.stackexchange.com/questions/278986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23492/"
] | I am trying to get the updated value of a piece of meta when a post is saved (custom post type) but when I try to grab the updated data on the save\_post hook, I get the previous data instead. I tried a separate function with a higher priority, but no luck that way either (below)
How do I get the updated meta value ri... | Apparently in order to get the meta value right after saving the post, you have to either get the $\_REQUEST['my\_meta\_value'] directly, or, if you need to update the database right away, you have to use update\_post\_meta() in your save\_post action. |
279,035 | <p>I am new to woo-commerce, can anyone please let me know where the cart items are stored in Database. which tables have cart details?</p>
| [
{
"answer_id": 279036,
"author": "DHL17",
"author_id": 125227,
"author_profile": "https://wordpress.stackexchange.com/users/125227",
"pm_score": 2,
"selected": false,
"text": "<p>Various information about cart are stored by woocmmerce by two ways:</p>\n\n<ol>\n<li>In $woocommerce object(... | 2017/09/04 | [
"https://wordpress.stackexchange.com/questions/279035",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127183/"
] | I am new to woo-commerce, can anyone please let me know where the cart items are stored in Database. which tables have cart details? | Various information about cart are stored by woocmmerce by two ways:
1. In $woocommerce object( About session , cart info, subtotal etc)
2. In database table named persistent\_cart which is dynamic ... it will get destroyed as soon as checkout is done.
So , now how to access all this info ...
For the 1st kind just de... |
279,204 | <p>The stock statuses from my woocommerce installation were uploaded by another plugin (square) and so all goods are in stock even if they have quantity 0. Is there a way to get the statuses to reset somehow, so that products with 0 stock, have the stock status "out of stock". </p>
<p>I have looked for this and found ... | [
{
"answer_id": 279212,
"author": "Pratik bhatt",
"author_id": 60922,
"author_profile": "https://wordpress.stackexchange.com/users/60922",
"pm_score": 1,
"selected": false,
"text": "<p>You can add the following sql command in your database using PHP my admin or anyother DB editor</p>\n\n<... | 2017/09/06 | [
"https://wordpress.stackexchange.com/questions/279204",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127261/"
] | The stock statuses from my woocommerce installation were uploaded by another plugin (square) and so all goods are in stock even if they have quantity 0. Is there a way to get the statuses to reset somehow, so that products with 0 stock, have the stock status "out of stock".
I have looked for this and found the follow... | You can add the following sql command in your database using PHP my admin or anyother DB editor
```
Update wp_postmeta Set meta_value = 'instock' Where meta_value = 'outofstock' And meta_key = '_stock_status'
``` |
279,215 | <p>I've created a custom field and selected "Filter by role" to "Subscriber" and assigned the custom field to the post type. Now when I add a new post and assigned the subscriber (ie: created a Test Post and assigned the subscriber to "grade 1") after I click on the update again I changed the subscriber "grade 1" to "g... | [
{
"answer_id": 279212,
"author": "Pratik bhatt",
"author_id": 60922,
"author_profile": "https://wordpress.stackexchange.com/users/60922",
"pm_score": 1,
"selected": false,
"text": "<p>You can add the following sql command in your database using PHP my admin or anyother DB editor</p>\n\n<... | 2017/09/06 | [
"https://wordpress.stackexchange.com/questions/279215",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80578/"
] | I've created a custom field and selected "Filter by role" to "Subscriber" and assigned the custom field to the post type. Now when I add a new post and assigned the subscriber (ie: created a Test Post and assigned the subscriber to "grade 1") after I click on the update again I changed the subscriber "grade 1" to "grad... | You can add the following sql command in your database using PHP my admin or anyother DB editor
```
Update wp_postmeta Set meta_value = 'instock' Where meta_value = 'outofstock' And meta_key = '_stock_status'
``` |
279,230 | <p>I am trying to understand how <code>add_theme_support()</code> function works, but at the section of Html5 i tried to use it with gallery and i noticed that the markup has changed for it,and here is what i did</p>
<pre><code>add_theme_support( 'html5', array('gallery') );
</code></pre>
<p>but for the others like s... | [
{
"answer_id": 279232,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>According to the documentation, you must pass an array of items where you want to enable HTML5 markup:</p>\n\n<... | 2017/09/06 | [
"https://wordpress.stackexchange.com/questions/279230",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102224/"
] | I am trying to understand how `add_theme_support()` function works, but at the section of Html5 i tried to use it with gallery and i noticed that the markup has changed for it,and here is what i did
```
add_theme_support( 'html5', array('gallery') );
```
but for the others like search-form or comment-form for exampl... | I have figured out why no changes happens, and the problem was that i am calling a custom search form file `searchform.php` and the function `add_theme_support()` affects the built in features only. So if you want to use the default search form by calling `get_search_form()` without having the `searchform.php` file, th... |
279,247 | <p>I am using twenty seventeen theme. The theme allows to have different sections on homepage based on site pages. I was wondering how I can add make it so only logged out users see a certain page in one of the sections? Basically I have a new user registration page i want to have as one of my sections but I don't want... | [
{
"answer_id": 279255,
"author": "Rafael Cavalcante",
"author_id": 68359,
"author_profile": "https://wordpress.stackexchange.com/users/68359",
"pm_score": 0,
"selected": false,
"text": "<p>You can solve your problem by using the built-in <a href=\"https://developer.wordpress.org/referenc... | 2017/09/06 | [
"https://wordpress.stackexchange.com/questions/279247",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127363/"
] | I am using twenty seventeen theme. The theme allows to have different sections on homepage based on site pages. I was wondering how I can add make it so only logged out users see a certain page in one of the sections? Basically I have a new user registration page i want to have as one of my sections but I don't want lo... | You can do this by checking if the user is logged in as stated in the first answer. You simply need to do it the other way.
For example, if you have a link in the menu that should be hidden in case the user is logged in, just add a custom css;
```
.logged_in .menu-class-here{display:none;}
```
That is to hide a men... |
279,279 | <p>I'm a newby and don't have much knowledge of programming. My website is <a href="https://www.laraellisphotography.com" rel="nofollow noreferrer">https://www.laraellisphotography.com</a> I'm using the Divina theme and I can't figure out how to remove the search bar. I tried to see if it's a widget but it appears to b... | [
{
"answer_id": 279255,
"author": "Rafael Cavalcante",
"author_id": 68359,
"author_profile": "https://wordpress.stackexchange.com/users/68359",
"pm_score": 0,
"selected": false,
"text": "<p>You can solve your problem by using the built-in <a href=\"https://developer.wordpress.org/referenc... | 2017/09/06 | [
"https://wordpress.stackexchange.com/questions/279279",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127381/"
] | I'm a newby and don't have much knowledge of programming. My website is <https://www.laraellisphotography.com> I'm using the Divina theme and I can't figure out how to remove the search bar. I tried to see if it's a widget but it appears to be hardcoded into the theme. It shows up under the menu I put in. Can somebody ... | You can do this by checking if the user is logged in as stated in the first answer. You simply need to do it the other way.
For example, if you have a link in the menu that should be hidden in case the user is logged in, just add a custom css;
```
.logged_in .menu-class-here{display:none;}
```
That is to hide a men... |
279,280 | <p>I have a few questions and I don't think the outcome I want is possible without adding a custom taxonomy and redoing a bunch of work.</p>
<p>I have registered a custom post type - gallery - with taxonomies set to post_tag and category.</p>
<p>I have the permalink structure set to /blog/%postname%/ so Posts can ha... | [
{
"answer_id": 279255,
"author": "Rafael Cavalcante",
"author_id": 68359,
"author_profile": "https://wordpress.stackexchange.com/users/68359",
"pm_score": 0,
"selected": false,
"text": "<p>You can solve your problem by using the built-in <a href=\"https://developer.wordpress.org/referenc... | 2017/09/06 | [
"https://wordpress.stackexchange.com/questions/279280",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127382/"
] | I have a few questions and I don't think the outcome I want is possible without adding a custom taxonomy and redoing a bunch of work.
I have registered a custom post type - gallery - with taxonomies set to post\_tag and category.
I have the permalink structure set to /blog/%postname%/ so Posts can have the /blog/ bas... | You can do this by checking if the user is logged in as stated in the first answer. You simply need to do it the other way.
For example, if you have a link in the menu that should be hidden in case the user is logged in, just add a custom css;
```
.logged_in .menu-class-here{display:none;}
```
That is to hide a men... |
279,294 | <p>I created an image size:</p>
<pre><code>add_image_size('slider', 1920, 1080, true);
</code></pre>
<p>Now, i thought hard cropping meant that WordPress would zoom into the picture until it obtains that size and proportion no matter what. </p>
<p>Well, if User enters a vertical image, say 784x1200, What WordPress i... | [
{
"answer_id": 279255,
"author": "Rafael Cavalcante",
"author_id": 68359,
"author_profile": "https://wordpress.stackexchange.com/users/68359",
"pm_score": 0,
"selected": false,
"text": "<p>You can solve your problem by using the built-in <a href=\"https://developer.wordpress.org/referenc... | 2017/09/07 | [
"https://wordpress.stackexchange.com/questions/279294",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124731/"
] | I created an image size:
```
add_image_size('slider', 1920, 1080, true);
```
Now, i thought hard cropping meant that WordPress would zoom into the picture until it obtains that size and proportion no matter what.
Well, if User enters a vertical image, say 784x1200, What WordPress is doing is getting me an 784x1080... | You can do this by checking if the user is logged in as stated in the first answer. You simply need to do it the other way.
For example, if you have a link in the menu that should be hidden in case the user is logged in, just add a custom css;
```
.logged_in .menu-class-here{display:none;}
```
That is to hide a men... |
279,321 | <p>For my client site, I am planning to enable link post image to post a link on blog list page, the site uses custom WordPress theme developed by the previous developer.</p>
<p>For blog post list page he created as content.php and for the single post he created <code>content-page.php</code> </p>
<p>Even if I add the... | [
{
"answer_id": 279255,
"author": "Rafael Cavalcante",
"author_id": 68359,
"author_profile": "https://wordpress.stackexchange.com/users/68359",
"pm_score": 0,
"selected": false,
"text": "<p>You can solve your problem by using the built-in <a href=\"https://developer.wordpress.org/referenc... | 2017/09/07 | [
"https://wordpress.stackexchange.com/questions/279321",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127412/"
] | For my client site, I am planning to enable link post image to post a link on blog list page, the site uses custom WordPress theme developed by the previous developer.
For blog post list page he created as content.php and for the single post he created `content-page.php`
Even if I add the featured image I can't able... | You can do this by checking if the user is logged in as stated in the first answer. You simply need to do it the other way.
For example, if you have a link in the menu that should be hidden in case the user is logged in, just add a custom css;
```
.logged_in .menu-class-here{display:none;}
```
That is to hide a men... |
279,344 | <p>I am customizing the Woocommerce Storefront theme.
In the product-list pages (category page, shop page), I would like to display the available sizes of the product when the user hover with its mouse on the image of a product.
So I need to add html/php code that will display this on hover:</p>
<p><strong>Available s... | [
{
"answer_id": 279349,
"author": "finitesource",
"author_id": 127371,
"author_profile": "https://wordpress.stackexchange.com/users/127371",
"pm_score": 0,
"selected": false,
"text": "<p>Yes. The <code>woocommerce_template_loop_product_thumbnail</code> is hooked into the <code>woocommerc... | 2017/09/07 | [
"https://wordpress.stackexchange.com/questions/279344",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121787/"
] | I am customizing the Woocommerce Storefront theme.
In the product-list pages (category page, shop page), I would like to display the available sizes of the product when the user hover with its mouse on the image of a product.
So I need to add html/php code that will display this on hover:
**Available sizes:**
**S, M,... | Here's the code I finally used for those interested:
```
/* This snippet removes the action that inserts thumbnails to products in the loop
* and re-adds the function customized with our wrapper in it.
* It applies to all archives with products.
*
* @original plugin: WooCommerce
* @author of snippet: Brian Krogsa... |
279,353 | <p>I'm trying to organize my search results page based on an ACF subfield value of a repeater field. I would like a LIKE result rather than =.</p>
<p>So far, I got the following (modified with help below, but still not working):</p>
<pre><code>// Modify meta key to allow wildcard
function add_wildcard_to_meta_key_fil... | [
{
"answer_id": 279355,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 2,
"selected": false,
"text": "<p>You need to add Wildcards to your meta_value.</p>\n\n<p>Change </p>\n\n<pre><code>$query->set('met... | 2017/09/07 | [
"https://wordpress.stackexchange.com/questions/279353",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94213/"
] | I'm trying to organize my search results page based on an ACF subfield value of a repeater field. I would like a LIKE result rather than =.
So far, I got the following (modified with help below, but still not working):
```
// Modify meta key to allow wildcard
function add_wildcard_to_meta_key_filter( $where ) {
$w... | You need to add Wildcards to your meta\_value.
Change
```
$query->set('meta_query', array(
array(
'meta_key' => 'test_repeater_%_test_sub_field',
'meta_value' => $search,
'compare' => 'LIKE',
),
));
```
To
```
$query->set('meta_query', array(
array(
'meta_key' => 'test_repeat... |
279,380 | <p>Have a custom post type, where each post is a gallery, and each has an Advanced Custom Fields Gallery field that has say 5-20 images each. Also have a custom post type post template as seen below (stripped out most of the code to focus on parts that are relevant to this.) The comments in the code explain which each ... | [
{
"answer_id": 279355,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 2,
"selected": false,
"text": "<p>You need to add Wildcards to your meta_value.</p>\n\n<p>Change </p>\n\n<pre><code>$query->set('met... | 2017/09/07 | [
"https://wordpress.stackexchange.com/questions/279380",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5465/"
] | Have a custom post type, where each post is a gallery, and each has an Advanced Custom Fields Gallery field that has say 5-20 images each. Also have a custom post type post template as seen below (stripped out most of the code to focus on parts that are relevant to this.) The comments in the code explain which each par... | You need to add Wildcards to your meta\_value.
Change
```
$query->set('meta_query', array(
array(
'meta_key' => 'test_repeater_%_test_sub_field',
'meta_value' => $search,
'compare' => 'LIKE',
),
));
```
To
```
$query->set('meta_query', array(
array(
'meta_key' => 'test_repeat... |