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 |
|---|---|---|---|---|---|---|
311,158 | <p>How do I make my single-work page show on my <code>front-page.php</code>?</p>
<p>So I want to show my <code>work</code> page on the homepage. For example, my work page link is <code>www.example.com/work</code> but I want to show the work page in <code>www.example.com</code>. Should I use gettemplate code?</p>
| [
{
"answer_id": 311159,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 1,
"selected": false,
"text": "<p>No CODE is necessary for this.</p>\n\n<p>Go to WordPress Admin Panel → <code>Settings</code> → <code>Reading<... | 2018/08/11 | [
"https://wordpress.stackexchange.com/questions/311158",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82064/"
] | How do I make my single-work page show on my `front-page.php`?
So I want to show my `work` page on the homepage. For example, my work page link is `www.example.com/work` but I want to show the work page in `www.example.com`. Should I use gettemplate code? | No CODE is necessary for this.
Go to WordPress Admin Panel → `Settings` → `Reading`.
Then from the option `Your homepage displays`, select `A static page (select below)` & then in the `Homepage:` dropdown menu, select your `Work` page & `Save Changes`.
Like the screenshot below:
[![Select a static page as home page... |
311,199 | <p>I am new in WordPress Development. How can I get <code>Menus</code> in Admin Panel like below ?</p>
<p><a href="https://i.stack.imgur.com/e68P7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e68P7.png" alt="enter image description here"></a></p>
<p>I am trying to develop a theme. But I couldn't... | [
{
"answer_id": 311200,
"author": "John Doe",
"author_id": 78806,
"author_profile": "https://wordpress.stackexchange.com/users/78806",
"pm_score": 2,
"selected": false,
"text": "<p>You can refer to <a href=\"https://codex.wordpress.org/Navigation_Menus\" rel=\"nofollow noreferrer\">this l... | 2018/08/12 | [
"https://wordpress.stackexchange.com/questions/311199",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/104698/"
] | I am new in WordPress Development. How can I get `Menus` in Admin Panel like below ?
[](https://i.stack.imgur.com/e68P7.png)
I am trying to develop a theme. But I couldn't display that.
[;
function register_my_menu() {
register_nav_menu( 'primary', __( 'Primary Me... |
311,209 | <p>I've created a custom post-type along with a custom taxonomy and everything is fine, apart from one particular thing.</p>
<p>First off, my use case: I need it to <em>act</em> like a category system, <em>however</em> <strong>not</strong> be hierarchical (one level only), so I left both to the default setting of <cod... | [
{
"answer_id": 313441,
"author": "benny-ben",
"author_id": 135157,
"author_profile": "https://wordpress.stackexchange.com/users/135157",
"pm_score": 0,
"selected": false,
"text": "<p>Given that it's a dirty option you could try this way:</p>\n\n<pre><code>function dirty_admin_customizati... | 2018/08/12 | [
"https://wordpress.stackexchange.com/questions/311209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1839/"
] | I've created a custom post-type along with a custom taxonomy and everything is fine, apart from one particular thing.
First off, my use case: I need it to *act* like a category system, *however* **not** be hierarchical (one level only), so I left both to the default setting of `false` for the `hierarchical` setting.
... | [This blog post by "Gazchap"](https://www.gazchap.com/posts/enable-checkbox-lists-non-hierarchical-taxonomies-wordpress/) deals with exactly the situation you are, and they updated it after publishing to your follow-up problem:
>
> Fortunately, version 4.4 of WordPress introduced a filter – post\_edit\_category\_pare... |
311,218 | <pre><code><?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array( 'posts_per_page' => 6, 'offset'=> 0, 'category' => 1, 'paged' => $paged );
$custom_query = new WP_Query( $args );
while($custom_query->have_posts()) :
$custom_query->the_post();
?>
</code><... | [
{
"answer_id": 313441,
"author": "benny-ben",
"author_id": 135157,
"author_profile": "https://wordpress.stackexchange.com/users/135157",
"pm_score": 0,
"selected": false,
"text": "<p>Given that it's a dirty option you could try this way:</p>\n\n<pre><code>function dirty_admin_customizati... | 2018/08/12 | [
"https://wordpress.stackexchange.com/questions/311218",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148575/"
] | ```
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array( 'posts_per_page' => 6, 'offset'=> 0, 'category' => 1, 'paged' => $paged );
$custom_query = new WP_Query( $args );
while($custom_query->have_posts()) :
$custom_query->the_post();
?>
```
My Html code
```
<?php endwhile;... | [This blog post by "Gazchap"](https://www.gazchap.com/posts/enable-checkbox-lists-non-hierarchical-taxonomies-wordpress/) deals with exactly the situation you are, and they updated it after publishing to your follow-up problem:
>
> Fortunately, version 4.4 of WordPress introduced a filter – post\_edit\_category\_pare... |
311,220 | <p>I have created a <em>custom post type</em> as well as a <em>custom taxonomy</em>, however when I added my first item and selected a category/recipient something weird happened, it automatically created an additional numeric category and changed the selection to that.</p>
<p>eg;</p>
<p><a href="https://i.stack.imgu... | [
{
"answer_id": 311224,
"author": "Alex P",
"author_id": 134728,
"author_profile": "https://wordpress.stackexchange.com/users/134728",
"pm_score": 0,
"selected": false,
"text": "<p>You are using incorrect syntax - try like this:</p>\n\n<pre><code>add_action( 'after_setup_theme', 'blm_them... | 2018/08/12 | [
"https://wordpress.stackexchange.com/questions/311220",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1839/"
] | I have created a *custom post type* as well as a *custom taxonomy*, however when I added my first item and selected a category/recipient something weird happened, it automatically created an additional numeric category and changed the selection to that.
eg;
[</li>
<li>Post 3 (<code>field_order</code>: 2)</li>
<li>Post 2 (<code>field_order</code>: 3)</li>
<li>Post 1 (<code>field_order</code>:... | [
{
"answer_id": 311241,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": -1,
"selected": false,
"text": "<p>I'm not sure if it can be done on <code>WP_Query</code>, but this should work:</p>\n\n<pre><code>global $wpdb;... | 2018/08/12 | [
"https://wordpress.stackexchange.com/questions/311227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148581/"
] | I need to order the first three posts by a custom field, and subsequent posts by `post_date` in one query - for example:
* Post 4 (`field_order`: 1)
* Post 3 (`field_order`: 2)
* Post 2 (`field_order`: 3)
* Post 1 (`field_order`: null)
* Post 0 (`field_order`: null)
`Post 1` and `Post 0` need to be ordered by `post_d... | Multiple `meta_query` arguments with `OR`
-----------------------------------------
You may use the `'relation' => 'OR'` argument in `meta_query` with two sets of `field_order` arguments: one with `meta_value >= '0'` and the other one with `NOT EXISTS` to generate the main query.
```
'meta_query' => array... |
311,244 | <p>I am getting the error: Error establishing a database connection. I go to localhost, and it brings up the wampserver homepage (I am using wamp obviously) I click on my project which is called wordpress-first and it just says this site cant be reached. if I go to localhost/wordpress-first it gives me the error establ... | [
{
"answer_id": 311241,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": -1,
"selected": false,
"text": "<p>I'm not sure if it can be done on <code>WP_Query</code>, but this should work:</p>\n\n<pre><code>global $wpdb;... | 2018/08/12 | [
"https://wordpress.stackexchange.com/questions/311244",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148592/"
] | I am getting the error: Error establishing a database connection. I go to localhost, and it brings up the wampserver homepage (I am using wamp obviously) I click on my project which is called wordpress-first and it just says this site cant be reached. if I go to localhost/wordpress-first it gives me the error establish... | Multiple `meta_query` arguments with `OR`
-----------------------------------------
You may use the `'relation' => 'OR'` argument in `meta_query` with two sets of `field_order` arguments: one with `meta_value >= '0'` and the other one with `NOT EXISTS` to generate the main query.
```
'meta_query' => array... |
311,265 | <p>Some plugins place various links under their name on the plugins page. To display these each action links for a specific plugin in a seperate line I followed <a href="https://wordpress.stackexchange.com/a/241011/25187">this</a> and <a href="https://wordpress.stackexchange.com/a/241071/25187">this</a> answers, but my... | [
{
"answer_id": 311292,
"author": "Kaperto",
"author_id": 147795,
"author_profile": "https://wordpress.stackexchange.com/users/147795",
"pm_score": 1,
"selected": false,
"text": "<p>you can customise these links with this filter :<br>\n<a href=\"https://developer.wordpress.org/reference/h... | 2018/08/13 | [
"https://wordpress.stackexchange.com/questions/311265",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | Some plugins place various links under their name on the plugins page. To display these each action links for a specific plugin in a seperate line I followed [this](https://wordpress.stackexchange.com/a/241011/25187) and [this](https://wordpress.stackexchange.com/a/241071/25187) answers, but my code doesn't work. What ... | I found a better solution by moving links in discussion from the first column to the second column of plugin admin page with these two functions:
```
/** Remove action links from the Super Socializer plugin first column **/
const PLUGIN_SLUG = "super-socializer/super_socializer.php";
add_filter("plugin_action_links_" ... |
311,282 | <p>How do I display all posts from multisite to the main site? Please help me. thanks.</p>
| [
{
"answer_id": 311319,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>That's exactly what my \"Multisite Post Reader\" plugin does. Grabs posts from any/all multisites. Has... | 2018/08/13 | [
"https://wordpress.stackexchange.com/questions/311282",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148609/"
] | How do I display all posts from multisite to the main site? Please help me. thanks. | So, actually there is two ways to do it.
The first one is using `switch_to_blog()` and `restore_current_blog()` functions, example:
```
// in this variable you can pass all the blog IDs you would like to display posts from
$blog_ids = array( 1, 3 );
foreach( $blog_ids as $id ) {
switch_to_blog( $id );
$arg... |
311,318 | <p>I am using plugin "wpdevart facebook comment" for posting comments at the end of every post. They are displaying good But now I want to shift those comments little below of pagination and ads Or at the end of the page but comments should be of the relevant post.
attached is the screenshot:
<a href="https://i.stack.i... | [
{
"answer_id": 311320,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 1,
"selected": true,
"text": "<p>From the plugin's user manual.</p>\n\n<blockquote>\n <p><strong>Curent_url</strong> - Type the page URL f... | 2018/08/13 | [
"https://wordpress.stackexchange.com/questions/311318",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/119633/"
] | I am using plugin "wpdevart facebook comment" for posting comments at the end of every post. They are displaying good But now I want to shift those comments little below of pagination and ads Or at the end of the page but comments should be of the relevant post.
attached is the screenshot:
[![enter image description he... | From the plugin's user manual.
>
> **Curent\_url** - Type the page URL from where you need to show Facebook
> comments
>
>
>
So you will have to change the current URL which is (<http://developers.facebook.com/docs/plugins/comments/>) to your real current URL.
```
global $wp;
$current_url = home_url( add_query_... |
311,340 | <p>I try to <strong>hide</strong> the "cash on pickup"-payment-gateway [cop] when I am on the checkout page of my woocommerce installation. When I echo the code it gets two times executed.
One time correctly,
the other time it truncates the end of the url:</p>
<p>functions.php</p>
<pre><code>// Disable gateway on ch... | [
{
"answer_id": 311350,
"author": "Jan",
"author_id": 129330,
"author_profile": "https://wordpress.stackexchange.com/users/129330",
"pm_score": 1,
"selected": false,
"text": "<p>This is my solution:</p>\n\n<p>I had to disable the woocommerce checkout ajax script. It's causing a reload and... | 2018/08/13 | [
"https://wordpress.stackexchange.com/questions/311340",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/129330/"
] | I try to **hide** the "cash on pickup"-payment-gateway [cop] when I am on the checkout page of my woocommerce installation. When I echo the code it gets two times executed.
One time correctly,
the other time it truncates the end of the url:
functions.php
```
// Disable gateway on checkout page
function payment_gatew... | To answer the question in this posts's title, you don't need to check for the page's URL to see if you're on the checkout page as Woocommerce has a conditional for that - [`is_checkout()`](https://docs.woocommerce.com/wc-apidocs/function-is_checkout.html) |
311,341 | <p>I have a query like this i will get the id's for product. This works fine:</p>
<pre><code>function ids(){
$args = array(
'numberposts' => -1,
'post_type' => 'product',
'meta_key' => 'wppl_is_dax',
'meta_value' => '1'
);
// query
$the_query ... | [
{
"answer_id": 311343,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 1,
"selected": true,
"text": "<p>Your function returns <code>$product->get_id();</code>, instead of that, you should save those values i... | 2018/08/13 | [
"https://wordpress.stackexchange.com/questions/311341",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have a query like this i will get the id's for product. This works fine:
```
function ids(){
$args = array(
'numberposts' => -1,
'post_type' => 'product',
'meta_key' => 'wppl_is_dax',
'meta_value' => '1'
);
// query
$the_query = new WP_Query( $args );
... | Your function returns `$product->get_id();`, instead of that, you should save those values into an array and at the end return that array.
```
function ids(){
$args = array(
'numberposts' => -1,
'post_type' => 'product',
'meta_key' => 'wppl_is_dax',
'meta_value' => '1'... |
311,361 | <p>I'm not a WordPress developer, I'm trying to help a friend who has a WordPress website. Here is the problem: </p>
<p>In the template, <code>wp_head()</code> function adds bunch of styles and scripts.</p>
<p>I want to remove some of them in some pages lets say this one: </p>
<pre><code><link rel='stylesheet' id... | [
{
"answer_id": 311366,
"author": "Futuritous",
"author_id": 122392,
"author_profile": "https://wordpress.stackexchange.com/users/122392",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>Note: the file name is <code>functions.php</code>, not <code>function.php</code> (but tha... | 2018/08/14 | [
"https://wordpress.stackexchange.com/questions/311361",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148678/"
] | I'm not a WordPress developer, I'm trying to help a friend who has a WordPress website. Here is the problem:
In the template, `wp_head()` function adds bunch of styles and scripts.
I want to remove some of them in some pages lets say this one:
```
<link rel='stylesheet' id='yasrcss-css' href='https://www.example.... | >
> Note: the file name is `functions.php`, not `function.php` (but that's probably just a typo in the question).
>
>
>
To remove a script or style, you must remove it after it was added. If you try to remove it before it was added, or even print `$GLOBALS['wp_scripts']->registered`, nothing will happen, since it ... |
311,375 | <p>when I copy my content from my WordPad and paste it into Wordpress Visual editor it shows line break on post display on the browser whenever a line is started in visual editor</p>
| [
{
"answer_id": 311366,
"author": "Futuritous",
"author_id": 122392,
"author_profile": "https://wordpress.stackexchange.com/users/122392",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>Note: the file name is <code>functions.php</code>, not <code>function.php</code> (but tha... | 2018/08/14 | [
"https://wordpress.stackexchange.com/questions/311375",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148683/"
] | when I copy my content from my WordPad and paste it into Wordpress Visual editor it shows line break on post display on the browser whenever a line is started in visual editor | >
> Note: the file name is `functions.php`, not `function.php` (but that's probably just a typo in the question).
>
>
>
To remove a script or style, you must remove it after it was added. If you try to remove it before it was added, or even print `$GLOBALS['wp_scripts']->registered`, nothing will happen, since it ... |
311,396 | <p>I want to get all post types filtered by get_post_types() arguments.</p>
<pre><code>public static function get_post_type()
{
if(!$post_type = wp_cache_get('post_type', 'dsad'))
{
$post_type = get_post_types(array(
'public' => true,
'show_ui' => true
));
... | [
{
"answer_id": 311397,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 0,
"selected": false,
"text": "<p>This answer can give you an important advice: <a href=\"https://wordpress.stackexchange.com/questions... | 2018/08/14 | [
"https://wordpress.stackexchange.com/questions/311396",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148689/"
] | I want to get all post types filtered by get\_post\_types() arguments.
```
public static function get_post_type()
{
if(!$post_type = wp_cache_get('post_type', 'dsad'))
{
$post_type = get_post_types(array(
'public' => true,
'show_ui' => true
));
wp_cache_set('post... | Build in WordPress function for fetching all registered post types: **get\_post\_types()**
```
<?php
// hook into init late, so everything is registered
// you can also use get_post_types where ever. Any time after init is usually fine.
add_action( 'init', 'wpse34410_init', 0, 99 );
function wpse... |
311,401 | <p>I have inherited an existing site and have recently been asked to make some changes.</p>
<p>They have 'renamed' the default post as 'latest-news' using this 'my_new_default_post_type':</p>
<pre><code><?php
add_action( 'init', 'my_new_default_post_type', 1 );
function my_new_default_post_type() {
re... | [
{
"answer_id": 311397,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 0,
"selected": false,
"text": "<p>This answer can give you an important advice: <a href=\"https://wordpress.stackexchange.com/questions... | 2018/08/14 | [
"https://wordpress.stackexchange.com/questions/311401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148618/"
] | I have inherited an existing site and have recently been asked to make some changes.
They have 'renamed' the default post as 'latest-news' using this 'my\_new\_default\_post\_type':
```
<?php
add_action( 'init', 'my_new_default_post_type', 1 );
function my_new_default_post_type() {
register_post_type( 'p... | Build in WordPress function for fetching all registered post types: **get\_post\_types()**
```
<?php
// hook into init late, so everything is registered
// you can also use get_post_types where ever. Any time after init is usually fine.
add_action( 'init', 'wpse34410_init', 0, 99 );
function wpse... |
311,414 | <p>How do I for instance check if there is written a new comment in the database and then make my plugin register that there have been a change? I will use this information to do something in the database afterwards with my plugin.</p>
<p>Any help appreciated. Could not find anything regarding this question.</p>
| [
{
"answer_id": 311420,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 4,
"selected": true,
"text": "<h2>By checking the <code>date</code> columns:</h2>\n\n<p>To only check for new comments, new posts etc., you may... | 2018/08/14 | [
"https://wordpress.stackexchange.com/questions/311414",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148099/"
] | How do I for instance check if there is written a new comment in the database and then make my plugin register that there have been a change? I will use this information to do something in the database afterwards with my plugin.
Any help appreciated. Could not find anything regarding this question. | By checking the `date` columns:
-------------------------------
To only check for new comments, new posts etc., you may create a cron job & then check the `comment_date`, `post_date` etc. to determine if anything new appeared in those tables. Save a last checked timestamp from the cron job, so any row with `date` grea... |
311,416 | <p>How can I configure to have two sets of URL that actually using the same content?</p>
<p>For example:</p>
<p>(set 1)</p>
<pre><code>samplesite.com
samplesite.com/about/
samplesite.com/contact/
samplesite.com/projects/
</code></pre>
<p>(set 2)</p>
<pre><code>samplesite.com/fr/
samplesite.com/fr/about/
samplesite... | [
{
"answer_id": 311421,
"author": "Serkan Algur",
"author_id": 23042,
"author_profile": "https://wordpress.stackexchange.com/users/23042",
"pm_score": 1,
"selected": false,
"text": "<p>You can create <strong>custom post type</strong> to manage your secondary content (multilanguage i suppo... | 2018/08/14 | [
"https://wordpress.stackexchange.com/questions/311416",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/89898/"
] | How can I configure to have two sets of URL that actually using the same content?
For example:
(set 1)
```
samplesite.com
samplesite.com/about/
samplesite.com/contact/
samplesite.com/projects/
```
(set 2)
```
samplesite.com/fr/
samplesite.com/fr/about/
samplesite.com/fr/contact/
samplesite.com/fr/projects/
```
... | My answer with the help from Sally CJ in this [question](https://wordpress.stackexchange.com/questions/311476/add-rewrite-rule-to-call-front-page-php):
```
/**
* Add new rewrite rule
*/
function create_new_url_querystring() {
// https://wordpress.stackexchange.com/questions/60173/rewrite-rule-for-multilingual-we... |
311,427 | <p>So, after working on a script that imports tons of data from another API, and doing lots of testing, all new posts I make have a post ID above 10,000,000.</p>
<p>Thing is, now that I'm done, all my test data is gone, and my last "real" post has the ID 88.</p>
<p>Is there a method to "reset" my post ID's, so that t... | [
{
"answer_id": 311429,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 3,
"selected": true,
"text": "<p>I also happened to me once, I only had like 10 real post, so what I did was to go to <strong>phpMyAdmin</s... | 2018/08/14 | [
"https://wordpress.stackexchange.com/questions/311427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44937/"
] | So, after working on a script that imports tons of data from another API, and doing lots of testing, all new posts I make have a post ID above 10,000,000.
Thing is, now that I'm done, all my test data is gone, and my last "real" post has the ID 88.
Is there a method to "reset" my post ID's, so that the next one I mak... | I also happened to me once, I only had like 10 real post, so what I did was to go to **phpMyAdmin**, make sure your that on my `wp_posts` and `wp_posts_meta` tables are only information about the 10 real posts IDs, from the `mysite/wp-admin/export.php` I exported all the posts (10 of them), I run the following SQL quer... |
311,431 | <p>I have this working in my plugin and all is well with the world:</p>
<pre><code>edit: withAPIData( props => {
return {
roles: '/matt-watson/secure-blocks/v1/user-roles/'
};
} )( props => {
</code></pre>
<p>....</p>
<p>However guidance here suggests that this w... | [
{
"answer_id": 311551,
"author": "Matt Watson",
"author_id": 148566,
"author_profile": "https://wordpress.stackexchange.com/users/148566",
"pm_score": 2,
"selected": false,
"text": "<p>I've cracked it! </p>\n\n<pre><code>const actions = {\n setUserRoles( userRoles ) {\n return ... | 2018/08/14 | [
"https://wordpress.stackexchange.com/questions/311431",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148566/"
] | I have this working in my plugin and all is well with the world:
```
edit: withAPIData( props => {
return {
roles: '/matt-watson/secure-blocks/v1/user-roles/'
};
} )( props => {
```
....
However guidance here suggests that this will no longer be supported going forwar... | It's worth noting that the answer above is out of date. The data store should now look like this:
```
const actions = {
setUserRoles( userRoles ) {
return {
type: 'SET_USER_ROLES',
userRoles,
};
},
receiveUserRoles( path ) {
return {
type: 'RECEIV... |
311,437 | <p>I'm having an issue selecting a page. </p>
<p>There are guides that tell you how to find the page ID and I just couldn't find it in the admin panel to figure out what the page ID is. If only there was a way to search by slug in the admin panel that would be great.</p>
<p>the other way was to look at the elements w... | [
{
"answer_id": 311439,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 1,
"selected": false,
"text": "<p>From <a href=\"https://codex.wordpress.org/Template_Tags/get_posts#Get_a_post_by_its_slug\" rel=\"nofollo... | 2018/08/14 | [
"https://wordpress.stackexchange.com/questions/311437",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147639/"
] | I'm having an issue selecting a page.
There are guides that tell you how to find the page ID and I just couldn't find it in the admin panel to figure out what the page ID is. If only there was a way to search by slug in the admin panel that would be great.
the other way was to look at the elements which worked beaut... | From [WordPress Codex Get Posts](https://codex.wordpress.org/Template_Tags/get_posts#Get_a_post_by_its_slug).
```
<?php
$the_slug = 'my_slug';
$args = array(
'name' => $the_slug,
'post_type' => 'post',
'post_status' => 'publish',
'numberposts' => 1
);
$my_posts = get_posts($args);
if( $my_posts ) :
... |
311,438 | <p>I have the following function inside an existing plugin:</p>
<pre><code>public static function init() {
add_filter( 'wcs_view_subscription_actions', __CLASS__ . '::add_edit_address_subscription_action', 10, 2 );
}
public static function add_edit_address_subscription_action( $actions, $subscription ) {
... | [
{
"answer_id": 311440,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 4,
"selected": true,
"text": "<p>You can simply use the same filter with <a href=\"https://developer.wordpress.org/reference/functions/add_filt... | 2018/08/14 | [
"https://wordpress.stackexchange.com/questions/311438",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10247/"
] | I have the following function inside an existing plugin:
```
public static function init() {
add_filter( 'wcs_view_subscription_actions', __CLASS__ . '::add_edit_address_subscription_action', 10, 2 );
}
public static function add_edit_address_subscription_action( $actions, $subscription ) {
if ( $subscr... | You can simply use the same filter with [a lower or higher priority parameter](https://developer.wordpress.org/reference/functions/add_filter/#parameters) to make the appropriate changes to the `$actions` array. That way you may create a small custom plugin (or modify the theme's `functions.php` file), without having t... |
311,451 | <p>Hi Ive uploaded a WP site onto a new server updated the DB and can get into the backend and even see the homepge. However, all the links are messed up.</p>
<p>I wasnt able to change the URL in the settings prior to moving, it was all grayed out.
Here is the error message</p>
<pre><code>Requested URL http://m... | [
{
"answer_id": 311440,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 4,
"selected": true,
"text": "<p>You can simply use the same filter with <a href=\"https://developer.wordpress.org/reference/functions/add_filt... | 2018/08/14 | [
"https://wordpress.stackexchange.com/questions/311451",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/138551/"
] | Hi Ive uploaded a WP site onto a new server updated the DB and can get into the backend and even see the homepge. However, all the links are messed up.
I wasnt able to change the URL in the settings prior to moving, it was all grayed out.
Here is the error message
```
Requested URL http://mysite-site3.itempurl.... | You can simply use the same filter with [a lower or higher priority parameter](https://developer.wordpress.org/reference/functions/add_filter/#parameters) to make the appropriate changes to the `$actions` array. That way you may create a small custom plugin (or modify the theme's `functions.php` file), without having t... |
311,468 | <p>Is it possible to edit my site's header with a page-builder plugin, such as Page Builder, Elementor, or Gutenberg? I don't want to be stuck in the constraints of the theme and/or Wordpress's idea of how a header should be structured. </p>
<p>I essentially just want to define a block section either above and/or belo... | [
{
"answer_id": 311440,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 4,
"selected": true,
"text": "<p>You can simply use the same filter with <a href=\"https://developer.wordpress.org/reference/functions/add_filt... | 2018/08/14 | [
"https://wordpress.stackexchange.com/questions/311468",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127125/"
] | Is it possible to edit my site's header with a page-builder plugin, such as Page Builder, Elementor, or Gutenberg? I don't want to be stuck in the constraints of the theme and/or Wordpress's idea of how a header should be structured.
I essentially just want to define a block section either above and/or below the menu... | You can simply use the same filter with [a lower or higher priority parameter](https://developer.wordpress.org/reference/functions/add_filter/#parameters) to make the appropriate changes to the `$actions` array. That way you may create a small custom plugin (or modify the theme's `functions.php` file), without having t... |
311,479 | <p>I've read <a href="https://wordpress.stackexchange.com/questions/120259/running-a-python-script-within-wordpress">this question</a> (and many more web pages) in order to figure out how to run a simple python script via a Wordpress plugin.</p>
<p>However, I couldn't do it: I always get a "Blank" output.</p>
<p>No e... | [
{
"answer_id": 311440,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 4,
"selected": true,
"text": "<p>You can simply use the same filter with <a href=\"https://developer.wordpress.org/reference/functions/add_filt... | 2018/08/15 | [
"https://wordpress.stackexchange.com/questions/311479",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148751/"
] | I've read [this question](https://wordpress.stackexchange.com/questions/120259/running-a-python-script-within-wordpress) (and many more web pages) in order to figure out how to run a simple python script via a Wordpress plugin.
However, I couldn't do it: I always get a "Blank" output.
No errors were displayed.
*How ... | You can simply use the same filter with [a lower or higher priority parameter](https://developer.wordpress.org/reference/functions/add_filter/#parameters) to make the appropriate changes to the `$actions` array. That way you may create a small custom plugin (or modify the theme's `functions.php` file), without having t... |
311,492 | <p>I am creating a directory and have a custom post type called "listings". </p>
<p>I want to display a grid of "Most viewed" listings as well as "Highest rated" listings on my homepage and throughout the website. </p>
<p>I am really not sure how to do this. </p>
| [
{
"answer_id": 311440,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 4,
"selected": true,
"text": "<p>You can simply use the same filter with <a href=\"https://developer.wordpress.org/reference/functions/add_filt... | 2018/08/15 | [
"https://wordpress.stackexchange.com/questions/311492",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148759/"
] | I am creating a directory and have a custom post type called "listings".
I want to display a grid of "Most viewed" listings as well as "Highest rated" listings on my homepage and throughout the website.
I am really not sure how to do this. | You can simply use the same filter with [a lower or higher priority parameter](https://developer.wordpress.org/reference/functions/add_filter/#parameters) to make the appropriate changes to the `$actions` array. That way you may create a small custom plugin (or modify the theme's `functions.php` file), without having t... |
311,547 | <p>I'm created two themes <em>(light & dark)</em> but I'm not sure how to set cookies so the theme will remain constant when the user navigates from page-to-page or comes back to the site next week. Is there a simple script I can add to my existing code?</p>
<p><b>HTML</b></p>
<pre><code><html>
<head>... | [
{
"answer_id": 311440,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 4,
"selected": true,
"text": "<p>You can simply use the same filter with <a href=\"https://developer.wordpress.org/reference/functions/add_filt... | 2018/08/15 | [
"https://wordpress.stackexchange.com/questions/311547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148791/"
] | I'm created two themes *(light & dark)* but I'm not sure how to set cookies so the theme will remain constant when the user navigates from page-to-page or comes back to the site next week. Is there a simple script I can add to my existing code?
**HTML**
```
<html>
<head>
<link id="lightTheme" rel="stylesheet" type=... | You can simply use the same filter with [a lower or higher priority parameter](https://developer.wordpress.org/reference/functions/add_filter/#parameters) to make the appropriate changes to the `$actions` array. That way you may create a small custom plugin (or modify the theme's `functions.php` file), without having t... |
311,550 | <p>I need to expand on this discussion <a href="https://wordpress.stackexchange.com/questions/76802/redirect-entire-website-to-a-single-page">Redirect entire website to a single page</a> to include two pages rather than one.</p>
<p>On this site, I need two pages to be live and all others to redirect to the home page.<... | [
{
"answer_id": 311440,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 4,
"selected": true,
"text": "<p>You can simply use the same filter with <a href=\"https://developer.wordpress.org/reference/functions/add_filt... | 2018/08/15 | [
"https://wordpress.stackexchange.com/questions/311550",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17301/"
] | I need to expand on this discussion [Redirect entire website to a single page](https://wordpress.stackexchange.com/questions/76802/redirect-entire-website-to-a-single-page) to include two pages rather than one.
On this site, I need two pages to be live and all others to redirect to the home page.
<http://prairiebrand... | You can simply use the same filter with [a lower or higher priority parameter](https://developer.wordpress.org/reference/functions/add_filter/#parameters) to make the appropriate changes to the `$actions` array. That way you may create a small custom plugin (or modify the theme's `functions.php` file), without having t... |
311,558 | <p>I got a problem with value = 0 for meta_query checkbox field:</p>
<pre><code>$args = [
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => - 1,
'meta_query' => array(
array(
... | [
{
"answer_id": 311440,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 4,
"selected": true,
"text": "<p>You can simply use the same filter with <a href=\"https://developer.wordpress.org/reference/functions/add_filt... | 2018/08/15 | [
"https://wordpress.stackexchange.com/questions/311558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148797/"
] | I got a problem with value = 0 for meta\_query checkbox field:
```
$args = [
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => - 1,
'meta_query' => array(
array(
'key' => '... | You can simply use the same filter with [a lower or higher priority parameter](https://developer.wordpress.org/reference/functions/add_filter/#parameters) to make the appropriate changes to the `$actions` array. That way you may create a small custom plugin (or modify the theme's `functions.php` file), without having t... |
311,564 | <p>how can i achieve a front end form with preview option to create custom post based on the input? I want it done without any plugin. A simple example will help a lot.
<hr>
This is not a ACF question but ACF is having a front end form functionality but does not have preview function. </p>
<p>Is it possible to get the... | [
{
"answer_id": 311783,
"author": "Serkan Algur",
"author_id": 23042,
"author_profile": "https://wordpress.stackexchange.com/users/23042",
"pm_score": 1,
"selected": false,
"text": "<p>You need to create post as draft for preview. You can use this form, function and ajax script for this. ... | 2018/08/15 | [
"https://wordpress.stackexchange.com/questions/311564",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | how can i achieve a front end form with preview option to create custom post based on the input? I want it done without any plugin. A simple example will help a lot.
---
This is not a ACF question but ACF is having a front end form functionality but does not have preview function.
Is it possible to get the id for f... | There are many ways you could use to reach your goal. Here's one...
**Steps:**
1. Create a shortcode that renders the form.
2. Create and enqueue a JavaScript file that handles the form submission.
3. Create PHP function for creating/updating Post/Custom Post.
**In your functions.php:**
```
/**
* @return string ... |
311,583 | <p>I try to add auto increment post numbering by category.
Like cat="myID" > post 1, post 2, post 3...</p>
<p><a href="https://wordpress.stackexchange.com/questions/13083/display-post-number-not-post-id-number">Display post number not post ID number</a></p>
<p>In find this solution, and use post_meta looks a good way... | [
{
"answer_id": 311585,
"author": "Tedinoz",
"author_id": 24711,
"author_profile": "https://wordpress.stackexchange.com/users/24711",
"pm_score": 0,
"selected": false,
"text": "<p>There's no field in wp_posts called \"post_cat\". </p>\n\n<p>Try \"post_category\" instead.</p>\n"
},
{... | 2018/08/16 | [
"https://wordpress.stackexchange.com/questions/311583",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148815/"
] | I try to add auto increment post numbering by category.
Like cat="myID" > post 1, post 2, post 3...
[Display post number not post ID number](https://wordpress.stackexchange.com/questions/13083/display-post-number-not-post-id-number)
In find this solution, and use post\_meta looks a good way.
But this solution work on... | Add this code to `functions.php`. It should add meta value to posts from given category.
You can use hardcoded category slug/ID, but maybe it would be better to store it in `options` table and allow to change from dashboard.
Change "ID" / "category\_slug" to your own.
```
/**
* @param int $post_ID Post ... |
311,624 | <p>(WP Post Title)Malwarebytes Anti-Malware (Custom field value)3.5.1.2522</p>
<p>How to add custome meta value in wordpress after wp post title in same hyperlink</p>
| [
{
"answer_id": 311634,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 0,
"selected": false,
"text": "<p>It's possible to change displayed title in template file (e.g. content.php):</p>\n\n<pre><code>$custom_field = ... | 2018/08/16 | [
"https://wordpress.stackexchange.com/questions/311624",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148823/"
] | (WP Post Title)Malwarebytes Anti-Malware (Custom field value)3.5.1.2522
How to add custome meta value in wordpress after wp post title in same hyperlink | It is a simple 3 step process:
1. Look for your post title markup that should look something like:
>
>
> ```
> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
>
> ```
>
>
2. Now, get your post custom meta value through:
>
>
> ```
> <?php $bannerContent = get_post_meta($post->ID, 'banne... |
311,625 | <p>I need to list all slug categories from a taxonomy portfolio_category.
Like this:</p>
<pre><code>the_terms( get_the_ID(), 'portfolio_category', '', ', ' );
</code></pre>
<p>This returns categories from a single portfolio. I want to return just slug of this. </p>
| [
{
"answer_id": 311634,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 0,
"selected": false,
"text": "<p>It's possible to change displayed title in template file (e.g. content.php):</p>\n\n<pre><code>$custom_field = ... | 2018/08/16 | [
"https://wordpress.stackexchange.com/questions/311625",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94056/"
] | I need to list all slug categories from a taxonomy portfolio\_category.
Like this:
```
the_terms( get_the_ID(), 'portfolio_category', '', ', ' );
```
This returns categories from a single portfolio. I want to return just slug of this. | It is a simple 3 step process:
1. Look for your post title markup that should look something like:
>
>
> ```
> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
>
> ```
>
>
2. Now, get your post custom meta value through:
>
>
> ```
> <?php $bannerContent = get_post_meta($post->ID, 'banne... |
311,630 | <p>I wonder if there exists a quick way to register custom background images as simple as we do with the custom headers.</p>
<pre><code>$header_images = array(
'ferrari' => array(
'url' => get_template_directory_uri() . '/img/ferrari.jpg',
'thumbnail_url' => get_template_directory_uri() . ... | [
{
"answer_id": 311635,
"author": "David Sword",
"author_id": 132362,
"author_profile": "https://wordpress.stackexchange.com/users/132362",
"pm_score": 0,
"selected": false,
"text": "<p>You're correct, all plugins from wordpress.org <a href=\"https://developer.wordpress.org/plugins/wordpr... | 2018/08/16 | [
"https://wordpress.stackexchange.com/questions/311630",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67150/"
] | I wonder if there exists a quick way to register custom background images as simple as we do with the custom headers.
```
$header_images = array(
'ferrari' => array(
'url' => get_template_directory_uri() . '/img/ferrari.jpg',
'thumbnail_url' => get_template_directory_uri() . '/img/ferrari.jpg',
... | You should ask your lawyer, never ask legal advice from random people on the net.
Regardless of the legal question, it is rarely a smart idea to fork a plugin unless you understand that from that point forward it is your plugin. You can smartly use GIT to manage synchronizing when the original code updates, but the mo... |
311,657 | <p>I'm trying to create an events page that lists events (custom post type) within the week. I'm having trouble properly selecting only the posts that have a 'start_date' that falls in the current week.</p>
<p>Here is my code:</p>
<pre><code> $day = date('w');
$week_start = date('d-m-Y', strtotime('-'. $day . ... | [
{
"answer_id": 311635,
"author": "David Sword",
"author_id": 132362,
"author_profile": "https://wordpress.stackexchange.com/users/132362",
"pm_score": 0,
"selected": false,
"text": "<p>You're correct, all plugins from wordpress.org <a href=\"https://developer.wordpress.org/plugins/wordpr... | 2018/08/16 | [
"https://wordpress.stackexchange.com/questions/311657",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148871/"
] | I'm trying to create an events page that lists events (custom post type) within the week. I'm having trouble properly selecting only the posts that have a 'start\_date' that falls in the current week.
Here is my code:
```
$day = date('w');
$week_start = date('d-m-Y', strtotime('-'. $day . ' days'));
$week... | You should ask your lawyer, never ask legal advice from random people on the net.
Regardless of the legal question, it is rarely a smart idea to fork a plugin unless you understand that from that point forward it is your plugin. You can smartly use GIT to manage synchronizing when the original code updates, but the mo... |
311,696 | <p>for a project I have to extend the core block core/cover-image. For the first basic try I came up with the following code:</p>
<p>PHP:</p>
<pre><code>add_action('enqueue_block_editor_assets', function() {
wp_enqueue_script('hephaestus-admin-script',
get_template_directory_uri() . '/dist/js/admin.js', ['wp-b... | [
{
"answer_id": 311704,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 4,
"selected": true,
"text": "<p>Not a real answer alert</p>\n\n<p>This sounds like a long term bad idea. You are modifying a core function... | 2018/08/17 | [
"https://wordpress.stackexchange.com/questions/311696",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107117/"
] | for a project I have to extend the core block core/cover-image. For the first basic try I came up with the following code:
PHP:
```
add_action('enqueue_block_editor_assets', function() {
wp_enqueue_script('hephaestus-admin-script',
get_template_directory_uri() . '/dist/js/admin.js', ['wp-blocks', 'wp-element',... | Not a real answer alert
This sounds like a long term bad idea. You are modifying a core functionality with something which do not inherit any of the generated markup of the original block. Any later processing of the block might make assumption about the markup based on the block name, but the assumptions might be wro... |
311,816 | <p>Hi I am trying to do a simple thing for my header at <a href="https://blog.madesoma.com/" rel="nofollow noreferrer">https://blog.madesoma.com/</a>, but I don't know what's wrong with it. </p>
<pre><code>.site-header {
background-color: #473C93;
}
#branding-logo {
float: left;
width: 50px;
height: auto;
}
</c... | [
{
"answer_id": 311821,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": -1,
"selected": false,
"text": "<p>In your style.css file, you should have:</p>\n\n<pre><code>.site-header { background-color: #... | 2018/08/18 | [
"https://wordpress.stackexchange.com/questions/311816",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147326/"
] | Hi I am trying to do a simple thing for my header at <https://blog.madesoma.com/>, but I don't know what's wrong with it.
```
.site-header {
background-color: #473C93;
}
#branding-logo {
float: left;
width: 50px;
height: auto;
}
```
and here is my header.php file:
```
<?php
/**
* The header for our theme
... | This is the relevant section of CSS in your stylesheet:
```
/*--------------------------------------------------------------
## Uling dini ke beten, Bapak Ngelah olah2an. Kangguang deen malu!
--------------------------------------------------------------*/
/*-----------------------------------------------------------... |
311,825 | <p>I want to login via wordpresss api. I tried with "/wp-json/wp/v2/users" . but it just returns user 1 details.</p>
<p>My goal is login via api and fetch all profile information.</p>
| [
{
"answer_id": 311826,
"author": "Mohammad Shahnewaz Sarker",
"author_id": 116711,
"author_profile": "https://wordpress.stackexchange.com/users/116711",
"pm_score": -1,
"selected": false,
"text": "<p>Solved:</p>\n\n<pre><code>add_action( 'rest_api_init', 'register_api_hooks' );\nfunction... | 2018/08/19 | [
"https://wordpress.stackexchange.com/questions/311825",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116711/"
] | I want to login via wordpresss api. I tried with "/wp-json/wp/v2/users" . but it just returns user 1 details.
My goal is login via api and fetch all profile information. | **1.** Install and activate [JWT Authentication for WP REST API plugin](https://pt.wordpress.org/plugins/jwt-authentication-for-wp-rest-api/), also install [WP REST API plugin](https://github.com/WP-API/WP-API)
**2.** Now you can run any wordpress default api from mobile app or any other source or by postman. for e... |
311,833 | <p>I am trying to create a shortcode to see if the url matches with the attribute, then return the content. So far I have:</p>
<pre><code>add_shortcode( 'ifurl', 'ifurl' );
function ifurl( $atts, $content = null ) {
$url = 'https://' . $_SERVER['SERVER_NAME'];
$current_tld = end( explode( ".", parse_url( $u... | [
{
"answer_id": 311826,
"author": "Mohammad Shahnewaz Sarker",
"author_id": 116711,
"author_profile": "https://wordpress.stackexchange.com/users/116711",
"pm_score": -1,
"selected": false,
"text": "<p>Solved:</p>\n\n<pre><code>add_action( 'rest_api_init', 'register_api_hooks' );\nfunction... | 2018/08/19 | [
"https://wordpress.stackexchange.com/questions/311833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147013/"
] | I am trying to create a shortcode to see if the url matches with the attribute, then return the content. So far I have:
```
add_shortcode( 'ifurl', 'ifurl' );
function ifurl( $atts, $content = null ) {
$url = 'https://' . $_SERVER['SERVER_NAME'];
$current_tld = end( explode( ".", parse_url( $url, PHP_URL_HO... | **1.** Install and activate [JWT Authentication for WP REST API plugin](https://pt.wordpress.org/plugins/jwt-authentication-for-wp-rest-api/), also install [WP REST API plugin](https://github.com/WP-API/WP-API)
**2.** Now you can run any wordpress default api from mobile app or any other source or by postman. for e... |
311,840 | <p>I want to enqueue the stylesheet in <code>functions.php</code>, but it's not loading. What can be problem in my code?</p>
<pre><code>function my_theme_sty() {
wp_enqueue_style( 'bootstrap', get_template_directory_uri().'/assets/css/bootstrap.css');
}
add_action( 'admin_enqueue_s', 'my_theme_sty' );
</code></pre... | [
{
"answer_id": 311841,
"author": "Clinton",
"author_id": 122375,
"author_profile": "https://wordpress.stackexchange.com/users/122375",
"pm_score": 3,
"selected": true,
"text": "<p>Your function should be:</p>\n\n<pre><code>function my_theme_sty() {\n wp_enqueue_style( 'bootstrap', get... | 2018/08/19 | [
"https://wordpress.stackexchange.com/questions/311840",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/144155/"
] | I want to enqueue the stylesheet in `functions.php`, but it's not loading. What can be problem in my code?
```
function my_theme_sty() {
wp_enqueue_style( 'bootstrap', get_template_directory_uri().'/assets/css/bootstrap.css');
}
add_action( 'admin_enqueue_s', 'my_theme_sty' );
``` | Your function should be:
```
function my_theme_sty() {
wp_enqueue_style( 'bootstrap', get_template_directory_uri().'/assets/css/bootstrap.css');
}
add_action( 'wp_enqueue_scripts', 'my_theme_sty' );
``` |
311,849 | <p>Is there any way to block disposable emails on Woocommerce registration? I used this <a href="https://wordpress.org/plugins/ban-hammer/" rel="nofollow noreferrer">plugin</a> with a list of disposable email domains, but it would only block on regular registration - not Woocommerce registration. Any ideas?</p>
| [
{
"answer_id": 338008,
"author": "ooi18",
"author_id": 166810,
"author_profile": "https://wordpress.stackexchange.com/users/166810",
"pm_score": 0,
"selected": false,
"text": "<p>If I am right, are you asking a WordPress plugin which can validate emails from Woocommerce Registration? If ... | 2018/08/19 | [
"https://wordpress.stackexchange.com/questions/311849",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78330/"
] | Is there any way to block disposable emails on Woocommerce registration? I used this [plugin](https://wordpress.org/plugins/ban-hammer/) with a list of disposable email domains, but it would only block on regular registration - not Woocommerce registration. Any ideas? | Hi just add this code in your theme functions.php
```
add_action('init', 'mydomain_plugin_checks');
function mydomain_plugin_checks(){
if ( class_exists('BanHammer') ) {
add_filter('woocommerce_registration_errors', 'woocommerce_banhammer_validation', 10, 3 );
}
}
function woocommerce_banhammer_va... |
311,858 | <p>For example, I have a category <code>/wiki/</code> <code>https://buhehe.de/wiki/</code></p>
<p>It has removed the term "category" from the URL, but please see: <code>https://buhehe.de/wiki/page/2</code></p>
<p>It doesn't show the second category page, but it actually has a second page.</p>
<p>Where is the proble... | [
{
"answer_id": 311864,
"author": "Cryptomanic",
"author_id": 148990,
"author_profile": "https://wordpress.stackexchange.com/users/148990",
"pm_score": 2,
"selected": false,
"text": "<h2>Yoast Plugin - Remove Categories</h2>\n\n<p>You could use an SEO plugin such as <a href=\"https://yoas... | 2018/08/19 | [
"https://wordpress.stackexchange.com/questions/311858",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147675/"
] | For example, I have a category `/wiki/` `https://buhehe.de/wiki/`
It has removed the term "category" from the URL, but please see: `https://buhehe.de/wiki/page/2`
It doesn't show the second category page, but it actually has a second page.
Where is the problem? | Why does the problem in pagination happens?
-------------------------------------------
Say you have a category named `wiki`.
Now, when you have a category URL like: `https://example.com/wiki` (instead of `https://example.com/category/wiki`) and say page or post URL like:
```
https://example.com/a-page
or
https://ex... |
311,932 | <p>How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts:</p>
<p>i have this code here: </p>
<pre><code>add_action( 'wp_head', 'set_featured_background', 99);
function set_featured_background() {
if ( has_post_thumbnail() ) {
$feature... | [
{
"answer_id": 311961,
"author": "nmr",
"author_id": 147428,
"author_profile": "https://wordpress.stackexchange.com/users/147428",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Or is it because im trying to add it to the css class <code>.has-post-thumbnail</code> which is... | 2018/08/20 | [
"https://wordpress.stackexchange.com/questions/311932",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149054/"
] | How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts:
i have this code here:
```
add_action( 'wp_head', 'set_featured_background', 99);
function set_featured_background() {
if ( has_post_thumbnail() ) {
$featured_img_url = get_the_p... | >
> Or is it because im trying to add it to the css class `.has-post-thumbnail` which is applied to all posts?
>
>
>
Yes, `set_featured_background()` gets first post from the loop and add `.has-post-thumbnail` to styles. All posts that have thumbnail (with class `.has-post-thumbnail`) will have the same background... |
311,956 | <p>Is it safe to use hyphen in shortcode attribute value?</p>
<p>For example:</p>
<pre><code>[foo something="fo-bar"]
</code></pre>
| [
{
"answer_id": 311957,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": -1,
"selected": true,
"text": "<p>It's safe, you won't have any problem using it, the only caution about <strong>Hyphens</strong> and <stro... | 2018/08/20 | [
"https://wordpress.stackexchange.com/questions/311956",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45321/"
] | Is it safe to use hyphen in shortcode attribute value?
For example:
```
[foo something="fo-bar"]
``` | It's safe, you won't have any problem using it, the only caution about **Hyphens** and **Shortcodes** comes from the [Codex](https://codex.wordpress.org/Shortcode_API#Hyphens).
>
> Take caution when using hyphens in the name of your shortcodes. In the
> following instance WordPress may see the second opening shortco... |
311,967 | <p>I have a multisite and I’m able to use the rest api for posts/tags/etc for specific sites but I was wondering if there’s a away to get a list of sites on the network using the rest api?</p>
<p>something like this: <a href="https://wordpress.stackexchange.com/questions/205354/rest-api-for-multisite">REST API for Mul... | [
{
"answer_id": 311957,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": -1,
"selected": true,
"text": "<p>It's safe, you won't have any problem using it, the only caution about <strong>Hyphens</strong> and <stro... | 2018/08/20 | [
"https://wordpress.stackexchange.com/questions/311967",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76667/"
] | I have a multisite and I’m able to use the rest api for posts/tags/etc for specific sites but I was wondering if there’s a away to get a list of sites on the network using the rest api?
something like this: [REST API for Multisite](https://wordpress.stackexchange.com/questions/205354/rest-api-for-multisite) but withou... | It's safe, you won't have any problem using it, the only caution about **Hyphens** and **Shortcodes** comes from the [Codex](https://codex.wordpress.org/Shortcode_API#Hyphens).
>
> Take caution when using hyphens in the name of your shortcodes. In the
> following instance WordPress may see the second opening shortco... |
311,972 | <blockquote>
<p>Notice: Undefined index: mtral_field_subscriber in
/wp-content/plugins/redirect-after-login/redirect-after-login.php
on line 54</p>
<p>Warning: Cannot modify header information - headers already sent by
(output started at
/wp-content/plugins/redirect-after-login/redirect-after-login.php:5... | [
{
"answer_id": 311973,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 3,
"selected": true,
"text": "<p>You can simply remove that plugin, and create that redirection youself.</p>\n\n<p>You can use the <code>lo... | 2018/08/20 | [
"https://wordpress.stackexchange.com/questions/311972",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48078/"
] | >
> Notice: Undefined index: mtral\_field\_subscriber in
> /wp-content/plugins/redirect-after-login/redirect-after-login.php
> on line 54
>
>
> Warning: Cannot modify header information - headers already sent by
> (output started at
> /wp-content/plugins/redirect-after-login/redirect-after-login.php:54)
> in wp... | You can simply remove that plugin, and create that redirection youself.
You can use the `login_redirect` hook, add this into your theme's `functions.php`
```
function redirect_admin( $redirect_to, $request, $user ){
//is there a user to check?
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
... |
311,976 | <p>My site is using a nav menu in my custom theme. I want to add navigation links to anchored links that points to specific sections of the site home page using a <code>Custom Link</code> in the nav menu.</p>
<p>I want to use the equivalent of:</p>
<pre><code><?php echo get_home_url(); ?>/#xxxx
</code></pre>
<... | [
{
"answer_id": 311978,
"author": "lpFranz",
"author_id": 135813,
"author_profile": "https://wordpress.stackexchange.com/users/135813",
"pm_score": -1,
"selected": false,
"text": "<p>You can add the <code>/index.php/#my-anchor</code> in your custom links, try it.</p>\n\n<p>Or, you can jus... | 2018/08/20 | [
"https://wordpress.stackexchange.com/questions/311976",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113048/"
] | My site is using a nav menu in my custom theme. I want to add navigation links to anchored links that points to specific sections of the site home page using a `Custom Link` in the nav menu.
I want to use the equivalent of:
```
<?php echo get_home_url(); ?>/#xxxx
```
in the URL field. If I use just the anchored lin... | If all you want is to go to a specific section of the home page, then the easiest way is to use the **relative URL** mark `/` and then use the anchor `#xxx`.
So the custom link for the menu will be: `/#xxx`.
>
> **Note the difference between `#xxx` and `/#xxx`** as custom link.
>
>
>
The best thing about this ap... |
312,041 | <p>I am trying to build the simplest of custom Gutenberg block by referring the handbook <a href="https://wordpress.org/gutenberg/handbook/blocks/writing-your-first-block-type/" rel="nofollow noreferrer">https://wordpress.org/gutenberg/handbook/blocks/writing-your-first-block-type/</a>.</p>
<p>The directory structure ... | [
{
"answer_id": 312037,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 1,
"selected": false,
"text": "<p>You will need <a href=\"https://codex.wordpress.org/Function_Reference/get_comment_meta\" rel=\"nofollow norefer... | 2018/08/21 | [
"https://wordpress.stackexchange.com/questions/312041",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109082/"
] | I am trying to build the simplest of custom Gutenberg block by referring the handbook <https://wordpress.org/gutenberg/handbook/blocks/writing-your-first-block-type/>.
The directory structure is as follows:
```
wp-content
plugins
gutenberg-bolierplate-block
block.js
gutenberg-boilerplate-bl... | You will need [`get_comment_meta`](https://codex.wordpress.org/Function_Reference/get_comment_meta) to pull that information from the database. You will need to know the metakey. If you don't have that, you will have to search the theme/plugin that generates the metadata for the occurence of [`add_comment_meta`](https:... |
312,103 | <p>I've read many related questions and have tried all that I could so make sure it's actually a duplicate before flagging please. </p>
<p>I've been using WordPress for about 6 years so when I say I'm stuck, I really mean it. </p>
<p>I'm trying to add custom meta boxes to a CPT, <code>boat</code>. Below is my code an... | [
{
"answer_id": 312105,
"author": "De Coder",
"author_id": 144159,
"author_profile": "https://wordpress.stackexchange.com/users/144159",
"pm_score": 0,
"selected": false,
"text": "<p>It's not even that $custom[\"boat_make\"][0], but not even $custom[\"boat_make\"] is set.</p>\n\n<p>Becaus... | 2018/08/21 | [
"https://wordpress.stackexchange.com/questions/312103",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76059/"
] | I've read many related questions and have tried all that I could so make sure it's actually a duplicate before flagging please.
I've been using WordPress for about 6 years so when I say I'm stuck, I really mean it.
I'm trying to add custom meta boxes to a CPT, `boat`. Below is my code and the error I'm getting.
Er... | Before saving your meta data, you have `if ( ! current_user_can( '' ) ) return`
I've never run current\_user\_can against and empty string of capabilities, so I'm not sure what your results are going to be, but it's very possible this returns a false, and you return at this point.
Also, be sure you sanitize your $\_P... |
312,112 | <p>I have setup my custom post's custom taxonomy's permalink structure to be:</p>
<p><strong>custom post type > custom taxonomy > post</strong> (from <a href="https://wordpress.stackexchange.com/questions/108642/permalinks-custom-post-type-custom-taxonomy-post">this helpful Q&A</a>)</p>
<p>Now I'm hoping to be ab... | [
{
"answer_id": 312113,
"author": "codeview",
"author_id": 40679,
"author_profile": "https://wordpress.stackexchange.com/users/40679",
"pm_score": 1,
"selected": false,
"text": "<p>Got it to work with:</p>\n\n<pre><code>$queried_object = get_queried_object () ;\n</code></pre>\n\n<p>and</p... | 2018/08/21 | [
"https://wordpress.stackexchange.com/questions/312112",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40679/"
] | I have setup my custom post's custom taxonomy's permalink structure to be:
**custom post type > custom taxonomy > post** (from [this helpful Q&A](https://wordpress.stackexchange.com/questions/108642/permalinks-custom-post-type-custom-taxonomy-post))
Now I'm hoping to be able to code taxonomy.php to automatically loop... | Got it to work with:
```
$queried_object = get_queried_object () ;
```
and
```
'terms' => $queried_object->slug,
```
full code now:
```
<?php
$queried_object = get_queried_object () ;
$posts = array (
'post_type' => 'writing',
'posts_per_page' => -1,
'tax_q... |
312,120 | <p>I am currently working on a plugin using WordPress. I created a register page that allow users to register, this information is then stored in custom database table called finusers.</p>
<p>This is what I have done so far:</p>
<p>The code below is used to register users into custom table called finusers. </p>
<pre... | [
{
"answer_id": 312352,
"author": "Metal Zer0",
"author_id": 149153,
"author_profile": "https://wordpress.stackexchange.com/users/149153",
"pm_score": 0,
"selected": false,
"text": "<p>After researching and looking up the WordPress Codex and support forums, this is the code that I have us... | 2018/08/22 | [
"https://wordpress.stackexchange.com/questions/312120",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149153/"
] | I am currently working on a plugin using WordPress. I created a register page that allow users to register, this information is then stored in custom database table called finusers.
This is what I have done so far:
The code below is used to register users into custom table called finusers.
```
function db_insert(... | After researching and looking up the WordPress Codex, this is the code that I have used to authenticate..
I hope this helpful to all friends .it's working fine for me :)
```
$creds = array(
'user_login' => $username,
'user_password' => $userpassword,
'remember' => true
);
if(!empty($username) ... |
312,126 | <p>I was going through the source code of Gutenberg, for e.g. <a href="https://github.com/WordPress/gutenberg/blob/master/edit-post/components/visual-editor/block-inspector-button.js" rel="nofollow noreferrer">this</a> and cannot understand how they handle translations... </p>
<p>They do import this <code>import { __ ... | [
{
"answer_id": 312127,
"author": "kero",
"author_id": 108180,
"author_profile": "https://wordpress.stackexchange.com/users/108180",
"pm_score": 4,
"selected": true,
"text": "<p>In the <a href=\"https://github.com/WordPress/gutenberg\" rel=\"noreferrer\">Gutenberg's GitHub repository</a> ... | 2018/08/22 | [
"https://wordpress.stackexchange.com/questions/312126",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149161/"
] | I was going through the source code of Gutenberg, for e.g. [this](https://github.com/WordPress/gutenberg/blob/master/edit-post/components/visual-editor/block-inspector-button.js) and cannot understand how they handle translations...
They do import this `import { __ } from '@wordpress/i18n'` and then in the source cod... | In the [Gutenberg's GitHub repository](https://github.com/WordPress/gutenberg) you can see the source of the i18n package that is used. In this source, you'll see **Jed** getting imported [(line 4 of gutenberg/packages/i18n/src/index.js)](https://github.com/WordPress/gutenberg/blob/f02064f12a148df60b8d79801858ce3699bdf... |
312,147 | <p>I am looking to enqueue this script on the header of a wordpress page</p>
<pre><code><script src="https://js.chargebee.com/v2/chargebee.js" data-cb-site="mydomainame" ></script>
</code></pre>
<p>I know how to use </p>
<pre><code>function wp_mk_scripts() {
if( is_page(11) ){
wp_enqueue_script(... | [
{
"answer_id": 312153,
"author": "Bhupen",
"author_id": 128529,
"author_profile": "https://wordpress.stackexchange.com/users/128529",
"pm_score": 4,
"selected": true,
"text": "<p>Please try code given below:</p>\n\n<pre><code>function add_data_attribute($tag, $handle) {\n if ( 'chargeb... | 2018/08/22 | [
"https://wordpress.stackexchange.com/questions/312147",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40727/"
] | I am looking to enqueue this script on the header of a wordpress page
```
<script src="https://js.chargebee.com/v2/chargebee.js" data-cb-site="mydomainame" ></script>
```
I know how to use
```
function wp_mk_scripts() {
if( is_page(11) ){
wp_enqueue_script( 'chargebee', 'https://js.chargebee.com/v2/charge... | Please try code given below:
```
function add_data_attribute($tag, $handle) {
if ( 'chargebee' !== $handle )
return $tag;
return str_replace( ' src', ' data-cb-site="mydomainame" src', $tag );
}
add_filter('script_loader_tag', 'add_data_attribute', 10, 2);
``` |
312,159 | <p>I want to move page template files like <code>page-{slug}.php</code> to a sub-directory within my theme, in a way that WordPress will recognize them automatically. If the page templates of the said form doesn't exist within the sub-directory, then WordPress should fall back to the default template loading rules. How... | [
{
"answer_id": 312611,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 5,
"selected": true,
"text": "<h2>How Page Templates are loaded:</h2>\n<p>According to the default <a href=\"https://developer.wordpress.org/th... | 2018/08/22 | [
"https://wordpress.stackexchange.com/questions/312159",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149002/"
] | I want to move page template files like `page-{slug}.php` to a sub-directory within my theme, in a way that WordPress will recognize them automatically. If the page templates of the said form doesn't exist within the sub-directory, then WordPress should fall back to the default template loading rules. How can I achieve... | How Page Templates are loaded:
------------------------------
According to the default [WordPress Template Hierarchy](https://developer.wordpress.org/themes/template-files-section/page-template-files/#page-templates-within-the-template-hierarchy), a `page` request loads a template based on the priority and naming as s... |
312,206 | <p>I built the ajax loader as follows.</p>
<p>How can I detect when it reaches the end of all posts? So that I can make the "More" button to disappear, or not clickable anymore.</p>
<p>In page template:</p>
<pre><code>WP_Query stuff...
if ($press_posts->max_num_pages > 1) :
echo '<a class="link-button"... | [
{
"answer_id": 312230,
"author": "firxworx",
"author_id": 134244,
"author_profile": "https://wordpress.stackexchange.com/users/134244",
"pm_score": 0,
"selected": false,
"text": "<p>I agree with the commenter @TomJNowell it could worth looking into the REST API. However, regarding your s... | 2018/08/22 | [
"https://wordpress.stackexchange.com/questions/312206",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9508/"
] | I built the ajax loader as follows.
How can I detect when it reaches the end of all posts? So that I can make the "More" button to disappear, or not clickable anymore.
In page template:
```
WP_Query stuff...
if ($press_posts->max_num_pages > 1) :
echo '<a class="link-button" id="load-more">More</a>';
endif;
``... | Page template:
```
<div class="entry-content">
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => '2',
'paged' => 1,
);
$my_posts = new WP_Query($args);
if ($my_posts->have_posts()) :
?>
... |
312,208 | <p>Could someone have the same error when im trying to <a href="https://codex.wordpress.org/Navigation_Menus" rel="nofollow noreferrer">register a menu</a>?</p>
<p>function.php</p>
<pre><code>function register_my_menu() {
register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'register_my_menu'... | [
{
"answer_id": 312210,
"author": "De Coder",
"author_id": 144159,
"author_profile": "https://wordpress.stackexchange.com/users/144159",
"pm_score": 0,
"selected": false,
"text": "<p>I believe you are running your action too soon.</p>\n\n<p>Don't run it at 'init', use 'after_setup_theme' ... | 2018/08/22 | [
"https://wordpress.stackexchange.com/questions/312208",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149189/"
] | Could someone have the same error when im trying to [register a menu](https://codex.wordpress.org/Navigation_Menus)?
function.php
```
function register_my_menu() {
register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'register_my_menu' );
```
error
>
> function register\_my\_menu() { regi... | ```
<?php
function register_my_menu() {
register_nav_menu( 'header-menu',__( 'Header Menu' ) );
}
add_action( 'after_setup_theme', 'register_my_menu' );
``` |
312,218 | <p>I am trying to do something but I have problem...</p>
<p>I wont show the list of my post, but from all titles I want remove text after last "-" (dash)</p>
<p>My list of posts:</p>
<blockquote>
<ol>
<li>My experience - this boy - first day - meet</li>
<li>My love - i do not know - second day</li>
<li>My fi... | [
{
"answer_id": 312223,
"author": "C C",
"author_id": 83299,
"author_profile": "https://wordpress.stackexchange.com/users/83299",
"pm_score": 3,
"selected": true,
"text": "<p>This is really a PHP question not so much a WP question -- but:</p>\n\n<pre><code>echo substr($stringx,0,strrpos($... | 2018/08/22 | [
"https://wordpress.stackexchange.com/questions/312218",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/140882/"
] | I am trying to do something but I have problem...
I wont show the list of my post, but from all titles I want remove text after last "-" (dash)
My list of posts:
>
> 1. My experience - this boy - first day - meet
> 2. My love - i do not know - second day
> 3. My first time - auuu - third time
>
>
>
I would like... | This is really a PHP question not so much a WP question -- but:
```
echo substr($stringx,0,strrpos($stringx,'-'));
```
Also I think your example #3 is wrong unless there are some cases where you want to exclude more than simply after the final dash character.
Note - if you want to exclude both that final blank spac... |
312,231 | <p>I am trying to apply discounts based on quantity amounts in the cart for each product. Each product has it's own quantity discounts set by custom fields. I'm using the action "woocommerce_before_calculate_totals" and in the foreach loop trying to apply the discount from the custom fields. However, it only works for ... | [
{
"answer_id": 312233,
"author": "Raja Mohammed",
"author_id": 97358,
"author_profile": "https://wordpress.stackexchange.com/users/97358",
"pm_score": 0,
"selected": false,
"text": "<p>In your code, you are trying to equate $qty to the number of items <code>$qty = 5</code> which should ... | 2018/08/23 | [
"https://wordpress.stackexchange.com/questions/312231",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/81422/"
] | I am trying to apply discounts based on quantity amounts in the cart for each product. Each product has it's own quantity discounts set by custom fields. I'm using the action "woocommerce\_before\_calculate\_totals" and in the foreach loop trying to apply the discount from the custom fields. However, it only works for ... | So the answer to this is instead of placing the code in your functions.php, you create a "woocommerce" folder in your theme folder, and place the "cart" folder and the "cart.php" template file from the woocommerce plugin inside of that. Then you place the same code as in the "woocommerce\_before\_calculate\_totals" act... |
312,243 | <p>In my website this characters ​​ showing up on everywhere in blog content and title, after many hours of searching and googling cant find any useful answer i tried this meta but no luck</p>
<pre><code>header("Content-Type: text/html; charset=ISO-8859-1");
<meta http-equiv="Content-Type" content="text/html;... | [
{
"answer_id": 312376,
"author": "user141080",
"author_id": 141080,
"author_profile": "https://wordpress.stackexchange.com/users/141080",
"pm_score": 1,
"selected": false,
"text": "<p>If you search your content for these characters <code>‘ â �</code> you will not find them, because the... | 2018/08/23 | [
"https://wordpress.stackexchange.com/questions/312243",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149061/"
] | In my website this characters ​​ showing up on everywhere in blog content and title, after many hours of searching and googling cant find any useful answer i tried this meta but no luck
```
header("Content-Type: text/html; charset=ISO-8859-1");
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-... | Found the answer after little bit search on google & <http://php.net/manual/en/function.htmlspecialchars-decode.php> , After a long time answered my own question thought maybe it will help someone.
```
htmlspecialchars_decode(utf8_decode(htmlentities(YOUR_STRING, ENT_COMPAT, 'utf-8', false)));
``` |
312,274 | <p>I am using a custum gutenberg block plugin for wordpress(<a href="https://neliosoftware.com/blog/how-to-create-your-first-block-for-gutenberg/" rel="noreferrer">https://neliosoftware.com/blog/how-to-create-your-first-block-for-gutenberg/</a>)</p>
<p>This block is using an image but always choosing the full size ima... | [
{
"answer_id": 314768,
"author": "Ashiquzzaman Kiron",
"author_id": 78505,
"author_profile": "https://wordpress.stackexchange.com/users/78505",
"pm_score": 0,
"selected": false,
"text": "<p>Couple of ways to manage the uploaded image size-</p>\n\n<ol>\n<li><p>Define a new attribute with ... | 2018/08/23 | [
"https://wordpress.stackexchange.com/questions/312274",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148458/"
] | I am using a custum gutenberg block plugin for wordpress(<https://neliosoftware.com/blog/how-to-create-your-first-block-for-gutenberg/>)
This block is using an image but always choosing the full size image. I would like that it chooses custom image sizes like the standard gutenberg image or gallery blocks. when browsi... | Yes, this can be done.
Are you using MediaUpload? Once an image is selected, MediaUpload returns that image object, which includes sizes: full, large, medium etc - this will include any custom sizes you've defined. Then, instead of assigned the url to the attribute, you save the url *of the size you want*.
This is de... |
312,283 | <p>I'm trying to get the alt text of our featured image and have it output on the frontend.</p>
<p>Currently my code is</p>
<pre><code><img class="vehicle-photo" src="<?php echo the_post_thumbnail_url() ?>" alt="<?php the_post_thumbnail_caption();?>" />
</code></pre>
<p>But on the frontend, it is o... | [
{
"answer_id": 312284,
"author": "Bhupen",
"author_id": 128529,
"author_profile": "https://wordpress.stackexchange.com/users/128529",
"pm_score": 1,
"selected": false,
"text": "<p>Please try code given below:</p>\n\n<pre><code><?php $image_id = get_post_thumbnail_id(get_the_ID());\n$a... | 2018/08/23 | [
"https://wordpress.stackexchange.com/questions/312283",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149246/"
] | I'm trying to get the alt text of our featured image and have it output on the frontend.
Currently my code is
```
<img class="vehicle-photo" src="<?php echo the_post_thumbnail_url() ?>" alt="<?php the_post_thumbnail_caption();?>" />
```
But on the frontend, it is outputting as
```
<img class="vehicle-photo" src="... | The alt text is stored as post meta on the attachment, and can be retrieved with `get_post_meta()` combined with `get_post_thumbnail_id()`:
```
<?php echo get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true ); ?>
```
But if you just use the [`the_post_thumbnail()`](https://developer.wordpress.or... |
312,296 | <p>I have a script that requires jQuery, and I don't know how to add it into a post correctly. I've read <a href="https://wordpress.stackexchange.com/q/45437/64282">How to include jQuery and JavaScript files correctly?</a> and <a href="https://wordpress.stackexchange.com/q/285383/64282">Using JavaScript and JQuery in P... | [
{
"answer_id": 312313,
"author": "maverick",
"author_id": 132953,
"author_profile": "https://wordpress.stackexchange.com/users/132953",
"pm_score": 2,
"selected": false,
"text": "<p>assuming you have enqueued everything ( script files and style files ) properly in your wordpress theme's... | 2018/08/23 | [
"https://wordpress.stackexchange.com/questions/312296",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64282/"
] | I have a script that requires jQuery, and I don't know how to add it into a post correctly. I've read [How to include jQuery and JavaScript files correctly?](https://wordpress.stackexchange.com/q/45437/64282) and [Using JavaScript and JQuery in Page](https://wordpress.stackexchange.com/q/285383/64282) but they are too ... | assuming you have enqueued everything ( script files and style files ) properly in your wordpress theme's folder
following would be ( just assume ) your theme files
```
wp-content/themes/your-theme-dir/
assets/
css/ ( this is directory/folder )
styles... |
312,324 | <p>I know how to query posts with my custom query var, but I am trying to rewrite the following URL from this...</p>
<p><a href="https://www.fashionavocado.com/category/healthy-living/relationships/?tag=flock" rel="nofollow noreferrer">https://www.fashionavocado.com/category/healthy-living/relationships/?tag=flock</a>... | [
{
"answer_id": 312354,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>These should work for you:</p>\n\n<pre><code>function myplugin_rewrite_tag_rule() {\n add_rewrite_rule(\n ... | 2018/08/23 | [
"https://wordpress.stackexchange.com/questions/312324",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64309/"
] | I know how to query posts with my custom query var, but I am trying to rewrite the following URL from this...
<https://www.fashionavocado.com/category/healthy-living/relationships/?tag=flock>
to this...
<https://www.fashionavocado.com/category/healthy-living/relationships/tag/flock>
I can't seem to combine the pre-... | These should work for you:
```
function myplugin_rewrite_tag_rule() {
add_rewrite_rule(
'category/(.+?)/tag/([^/]+)/?$',
'index.php?category_name=$matches[1]&tag=$matches[2]',
'top'
);
add_rewrite_rule(
'category/(.+?)/tag/([^/]+)/page/?([0-9]{1,})/?$',
'index.php?ca... |
312,327 | <p>I am copying this tutorial to make my own custom meta box <a href="https://www.sitepoint.com/adding-meta-boxes-post-types-wordpress/" rel="nofollow noreferrer">https://www.sitepoint.com/adding-meta-boxes-post-types-wordpress/</a></p>
<p>It works perfectly, however I need to be able to enter script tags into this me... | [
{
"answer_id": 312345,
"author": "De Coder",
"author_id": 144159,
"author_profile": "https://wordpress.stackexchange.com/users/144159",
"pm_score": 0,
"selected": false,
"text": "<p>You cannot just remove the line to skip sanitizing of your data.\nThe line is:\n<code>$my_data = sanitize_... | 2018/08/23 | [
"https://wordpress.stackexchange.com/questions/312327",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24617/"
] | I am copying this tutorial to make my own custom meta box <https://www.sitepoint.com/adding-meta-boxes-post-types-wordpress/>
It works perfectly, however I need to be able to enter script tags into this meta box and save the script and output it on the page.
When I enter anything like script tags or div tags, it will... | Your using "esc\_attr()" to escape the data, That is why it's being converted to plan text. If you used echo it will likely work. However, your saving the script tags into the database.
I'm still on the learning journey just like you but here is what I would do.
TO SAVE THE DATA
```
//$my_data = sanitize_text_fiel... |
312,328 | <p>I'm running localhost server on xampp. I 'm connecting properly with my host computer from other devices with IP address but once i go into wordpress directory i got redirected. Every device i was testing changed entered IP/wordpress to localhost/wordpress. </p>
<p>Strange fact is that i have 3 exact copies of word... | [
{
"answer_id": 312355,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 2,
"selected": false,
"text": "<p>Trying to change edit the <code>wp-config.php</code> file was a good idea, let's try some extra things to... | 2018/08/23 | [
"https://wordpress.stackexchange.com/questions/312328",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/140315/"
] | I'm running localhost server on xampp. I 'm connecting properly with my host computer from other devices with IP address but once i go into wordpress directory i got redirected. Every device i was testing changed entered IP/wordpress to localhost/wordpress.
Strange fact is that i have 3 exact copies of wordpress. One... | Trying to change edit the `wp-config.php` file was a good idea, let's try some extra things to see if they solve the problem. Let's add these lines to the bottom of your `functions.php`:
```
update_option( 'siteurl', 'http://LOCAL_HOST_IP/wordpress' );
update_option( 'home', 'http://LOCAL_HOST_IP/wordpress' );
```
-... |
312,329 | <p>I have local Instance of WordPress and I want to edit the code of Pages which I created using WordPress Dashboard but I can't find those pages in my local environment folders so how can I find those pages .php files?</p>
| [
{
"answer_id": 312355,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 2,
"selected": false,
"text": "<p>Trying to change edit the <code>wp-config.php</code> file was a good idea, let's try some extra things to... | 2018/08/23 | [
"https://wordpress.stackexchange.com/questions/312329",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149275/"
] | I have local Instance of WordPress and I want to edit the code of Pages which I created using WordPress Dashboard but I can't find those pages in my local environment folders so how can I find those pages .php files? | Trying to change edit the `wp-config.php` file was a good idea, let's try some extra things to see if they solve the problem. Let's add these lines to the bottom of your `functions.php`:
```
update_option( 'siteurl', 'http://LOCAL_HOST_IP/wordpress' );
update_option( 'home', 'http://LOCAL_HOST_IP/wordpress' );
```
-... |
312,391 | <p>I have added a custom field (checkbox) to product variations with the following code:</p>
<pre><code>/**
* Create new fields for variations
*
*/
function variation_settings_fields( $loop, $variation_data, $variation ) {
woocommerce_wp_checkbox(
array(
'id' => '_wholesale_checkbox[' . $variation... | [
{
"answer_id": 312909,
"author": "Out of Orbit",
"author_id": 148251,
"author_profile": "https://wordpress.stackexchange.com/users/148251",
"pm_score": 1,
"selected": false,
"text": "<p>I ultimately solved this by manipulating the $options array. See full code below for conditionally hid... | 2018/08/24 | [
"https://wordpress.stackexchange.com/questions/312391",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148251/"
] | I have added a custom field (checkbox) to product variations with the following code:
```
/**
* Create new fields for variations
*
*/
function variation_settings_fields( $loop, $variation_data, $variation ) {
woocommerce_wp_checkbox(
array(
'id' => '_wholesale_checkbox[' . $variation->ID . ']',
... | I ultimately solved this by manipulating the $options array. See full code below for conditionally hiding a product variation by a custom field, and display variations as radio buttons. Solution marked with comments
```
/**
* Convert WooCommerce variation dropdown to radio buttons.
*
* @param string $html Original dro... |
312,444 | <p>in my single.php i took a data from one $_GET[] value and i'm using this like</p>
<p><strong>domain.com/example-slug/?holder=value</strong></p>
<p>The thing i want is <strong>domain.com/example-slug/value</strong> or <strong>domain.com/example-slug/holder/value</strong></p>
<p>so, how i can to this?</p>
| [
{
"answer_id": 312450,
"author": "Pratik Patel",
"author_id": 143123,
"author_profile": "https://wordpress.stackexchange.com/users/143123",
"pm_score": 0,
"selected": false,
"text": "<p>You can rewrite your URL using Rewrite rule like this </p>\n\n<pre><code>Options +FollowSymLinks\nRewr... | 2018/08/25 | [
"https://wordpress.stackexchange.com/questions/312444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149362/"
] | in my single.php i took a data from one $\_GET[] value and i'm using this like
**domain.com/example-slug/?holder=value**
The thing i want is **domain.com/example-slug/value** or **domain.com/example-slug/holder/value**
so, how i can to this? | You don't need to do anything with rewrite rules.
Your example ("domain.com/example-slug/?holder=value") is a perfect example of "Plain" Permalinks. So your starting point is to set Permalinks (Settings > Permalinks) to something other than "Plain". This will take the "/?" component out of the URL, and generate a URL... |
312,492 | <p>I need to query all of my posts as an array in example:</p>
<pre><code>'options' => [
'Post ID' => __('Post Name'),
'Post ID' => __('Post Name'),
],
</code></pre>
<p>How can i do it? </p>
<p>tried this but it gives me only the ID's:</p>
<pre><code>function query_posts_as_array(){
$args = arra... | [
{
"answer_id": 312499,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": true,
"text": "<p>You're trying to make <code>WP_Query</code> give you everything in a single API call, but that won't work.</p... | 2018/08/26 | [
"https://wordpress.stackexchange.com/questions/312492",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149398/"
] | I need to query all of my posts as an array in example:
```
'options' => [
'Post ID' => __('Post Name'),
'Post ID' => __('Post Name'),
],
```
How can i do it?
tried this but it gives me only the ID's:
```
function query_posts_as_array(){
$args = array(
'post_status' => 'publish',
'fields'... | You're trying to make `WP_Query` give you everything in a single API call, but that won't work.
Instead, break it down into multiple steps, e.g.:
* Create an empty list
* fetch all the posts
* foreach post:
+ add its ID and name to the list
* you now have alist of ID's and names |
312,545 | <p>I just come up with this issue for a project that uses a lot of taxonomies and I need to list posts using the taxonomies itself, not only the terms.</p>
<p>I have a taxonomy called "Colors", so the terms can be "red", "blue" etc and we can see all posts using the terms visiting:</p>
<pre><code>site.com/colors/red
... | [
{
"answer_id": 312499,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": true,
"text": "<p>You're trying to make <code>WP_Query</code> give you everything in a single API call, but that won't work.</p... | 2018/08/26 | [
"https://wordpress.stackexchange.com/questions/312545",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17048/"
] | I just come up with this issue for a project that uses a lot of taxonomies and I need to list posts using the taxonomies itself, not only the terms.
I have a taxonomy called "Colors", so the terms can be "red", "blue" etc and we can see all posts using the terms visiting:
```
site.com/colors/red
site.com/colors/blue
... | You're trying to make `WP_Query` give you everything in a single API call, but that won't work.
Instead, break it down into multiple steps, e.g.:
* Create an empty list
* fetch all the posts
* foreach post:
+ add its ID and name to the list
* you now have alist of ID's and names |
312,579 | <p>i want to disable click our product image on archives product page. so, user only can click from the button.</p>
<p><a href="https://i.stack.imgur.com/RsApZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RsApZ.png" alt="enter image description here"></a></p>
| [
{
"answer_id": 312582,
"author": "Carlos Faria",
"author_id": 39047,
"author_profile": "https://wordpress.stackexchange.com/users/39047",
"pm_score": 2,
"selected": true,
"text": "<p>In your functions.php</p>\n\n<pre><code>remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_... | 2018/08/27 | [
"https://wordpress.stackexchange.com/questions/312579",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/141909/"
] | i want to disable click our product image on archives product page. so, user only can click from the button.
[](https://i.stack.imgur.com/RsApZ.png) | In your functions.php
```
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 );
``` |
312,587 | <p>I tested posting a blog post to Facebook it shows a too large pic of the header title design you made for the home page not blog image. It doesn't show the feature photo from that blog post. Also, when I share a blog post link via text, it doesn't show a thumbnail photo of that blog post's feature photo, just words.... | [
{
"answer_id": 312594,
"author": "user141080",
"author_id": 141080,
"author_profile": "https://wordpress.stackexchange.com/users/141080",
"pm_score": 0,
"selected": false,
"text": "<p>Most of the social media platforms use there own \"social media tags\" to structure the content of a web... | 2018/08/27 | [
"https://wordpress.stackexchange.com/questions/312587",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149459/"
] | I tested posting a blog post to Facebook it shows a too large pic of the header title design you made for the home page not blog image. It doesn't show the feature photo from that blog post. Also, when I share a blog post link via text, it doesn't show a thumbnail photo of that blog post's feature photo, just words. Wh... | Your pages need to have the Open Graph meta tags required for social networks to parse the needed information & display it correctly. If you're looking for a simple, straightforward solution to this, you should check out Complete Open Graph, a plugin I wrote to handle it. Much less bloat than something like Yoast, beca... |
312,592 | <p>I've added some custom fields into the user profile. It's "Date of Birth".</p>
<p>There are "<strong>month_of_birth</strong>", "<strong>day_of_birth</strong>", "<strong>year_of_birth</strong>".</p>
<p>How to store them in one meta key ('<strong>birth_date</strong>') ?</p>
<p>Here's the code for the custom field :... | [
{
"answer_id": 312600,
"author": "Baikare Sandeep",
"author_id": 99404,
"author_profile": "https://wordpress.stackexchange.com/users/99404",
"pm_score": 0,
"selected": false,
"text": "<p>You can save these fields in the single user meta field like below:</p>\n\n<pre><code>\n // SAVE EXTR... | 2018/08/27 | [
"https://wordpress.stackexchange.com/questions/312592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149236/"
] | I've added some custom fields into the user profile. It's "Date of Birth".
There are "**month\_of\_birth**", "**day\_of\_birth**", "**year\_of\_birth**".
How to store them in one meta key ('**birth\_date**') ?
Here's the code for the custom field :
```
// ADD EXTRA PROFILE FIELD - BIRTH DATE
add_action( 'show_user... | >
> There are "**month\_of\_birth**", "**day\_of\_birth**",
> "**year\_of\_birth**".
>
>
> How to store them in one meta key ('**birth\_date**') ?
>
>
>
If you mean to replace all the three meta keys with one single meta key, then you can save the `birth_date` meta as an `array`, so that the value would be some... |
312,625 | <p>I'm trying to output an SVG file in a template, and PHPCS is telling me I need to escape the output. So I tried with KSES and it doesn't seem to want to include the viewbox attribute.</p>
<pre><code> $allowed_html = array(
'svg' => array(
'xmlns' => array (),
'viewBox' => true
),
'path' =>... | [
{
"answer_id": 316943,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 5,
"selected": true,
"text": "<p>I found your question as I was searching for an answer. I tried experimenting a bit more with <code>wp_kses()</co... | 2018/08/27 | [
"https://wordpress.stackexchange.com/questions/312625",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5302/"
] | I'm trying to output an SVG file in a template, and PHPCS is telling me I need to escape the output. So I tried with KSES and it doesn't seem to want to include the viewbox attribute.
```
$allowed_html = array(
'svg' => array(
'xmlns' => array (),
'viewBox' => true
),
'path' => array(
'd'=> array(),... | I found your question as I was searching for an answer. I tried experimenting a bit more with `wp_kses()` ([code reference](https://developer.wordpress.org/reference/functions/wp_kses/)) found that lower-casing `viewBox` in the arguments seems to fix the issue. You do not have to put the actual attribute on the SVG in ... |
312,629 | <p>I have been trying desesperately and in vain to highlight the button I have for "Blog" whenever I am in the the main page (I had created a custom link with my homepage)...it is really driving nuts!</p>
<p>The only time I have been able to highlight it was when I used the ".menu-item-has-children", but then it stays... | [
{
"answer_id": 312631,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 0,
"selected": false,
"text": "<p>You have to play with this CSS selector. I don't really know what do you mean by highlight, it may be a b... | 2018/08/27 | [
"https://wordpress.stackexchange.com/questions/312629",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149490/"
] | I have been trying desesperately and in vain to highlight the button I have for "Blog" whenever I am in the the main page (I had created a custom link with my homepage)...it is really driving nuts!
The only time I have been able to highlight it was when I used the ".menu-item-has-children", but then it stays highlight... | Wordpress marks the currently displayed page in the menu with CSS classes `.current-menu-item`, `.current-menu-parent`, `.current-menu-ancestor`. Add the required styles to highlight items using these classes.
Sample Menu:
```
* Blog
* First Category
* Second Category
* About
* Contact
```
When you open **blog*... |
312,630 | <p>In my <code>home.php</code> file I have only this code:</p>
<pre><code><?php
global $post;
print_r($post->ID);
die();
?>
</code></pre>
<p>This is printing the ID of the latest blog post, but what I want is to get the ID of the current page (the page I set as the Posts Page in Settings). It see... | [
{
"answer_id": 312631,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 0,
"selected": false,
"text": "<p>You have to play with this CSS selector. I don't really know what do you mean by highlight, it may be a b... | 2018/08/27 | [
"https://wordpress.stackexchange.com/questions/312630",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63238/"
] | In my `home.php` file I have only this code:
```
<?php
global $post;
print_r($post->ID);
die();
?>
```
This is printing the ID of the latest blog post, but what I want is to get the ID of the current page (the page I set as the Posts Page in Settings). It seems that I am already in "The Loop". How can I ... | Wordpress marks the currently displayed page in the menu with CSS classes `.current-menu-item`, `.current-menu-parent`, `.current-menu-ancestor`. Add the required styles to highlight items using these classes.
Sample Menu:
```
* Blog
* First Category
* Second Category
* About
* Contact
```
When you open **blog*... |
312,653 | <p>I applied a filter to remove all theme styles, but I want this to happen only if the url ends with <b>/amp/</b>.</p>
<p>The code below is removing the .css styles on all pages, not filtering the term <b>/amp/</b> of the permalink.</p>
<p>I am using the <a href="https://wordpress.org/plugins/amp/" rel="nofollow nor... | [
{
"answer_id": 312667,
"author": "Nathan Kinkead",
"author_id": 148750,
"author_profile": "https://wordpress.stackexchange.com/users/148750",
"pm_score": 1,
"selected": false,
"text": "<p>In your example, <code>$_SERVER['REQUEST_URI']</code> would return <code>/category/post-slug/amp/</c... | 2018/08/28 | [
"https://wordpress.stackexchange.com/questions/312653",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12990/"
] | I applied a filter to remove all theme styles, but I want this to happen only if the url ends with **/amp/**.
The code below is removing the .css styles on all pages, not filtering the term **/amp/** of the permalink.
I am using the [AMP for Wordpress](https://wordpress.org/plugins/amp/ "AMP for Wordpress") plugin, w... | In your example, `$_SERVER['REQUEST_URI']` would return `/category/post-slug/amp/` which is not the same as `get_permalink($post->ID)` which would return `https://example.com/category/post-slug/`
There are lots of ways to go about this, but one easy one that comes to mind is...
`if ( strpos($_SERVER['REQUEST_URI'], '... |
312,660 | <p>I installed the Gutenberg plugin today to try it out.</p>
<p>I’m getting an error message both at the top of my WP dashboard, and when I go to view the site in a browser:</p>
<blockquote>
<p>Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘ikreativ_tinymce_fix’ not found or i... | [
{
"answer_id": 312667,
"author": "Nathan Kinkead",
"author_id": 148750,
"author_profile": "https://wordpress.stackexchange.com/users/148750",
"pm_score": 1,
"selected": false,
"text": "<p>In your example, <code>$_SERVER['REQUEST_URI']</code> would return <code>/category/post-slug/amp/</c... | 2018/08/28 | [
"https://wordpress.stackexchange.com/questions/312660",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149513/"
] | I installed the Gutenberg plugin today to try it out.
I’m getting an error message both at the top of my WP dashboard, and when I go to view the site in a browser:
>
> Warning: call\_user\_func\_array() expects parameter 1 to be a valid callback, function ‘ikreativ\_tinymce\_fix’ not found or invalid function name i... | In your example, `$_SERVER['REQUEST_URI']` would return `/category/post-slug/amp/` which is not the same as `get_permalink($post->ID)` which would return `https://example.com/category/post-slug/`
There are lots of ways to go about this, but one easy one that comes to mind is...
`if ( strpos($_SERVER['REQUEST_URI'], '... |
312,670 | <h2>The Issue With Customise:</h2>
<p>Wouldn't it be nice if WordPress made the <strong>Customise</strong> area shown in the below image resizable?</p>
<p>As it is at the moment, it can be a little tricky working in a squashed sidebar.</p>
<p>Because of this I usually do all my CSS in an external editor then copy it... | [
{
"answer_id": 312676,
"author": "Eh Jewel",
"author_id": 75264,
"author_profile": "https://wordpress.stackexchange.com/users/75264",
"pm_score": 3,
"selected": true,
"text": "<p>You can expand the WordPress customize area without plugins by applying a simple line of CSS.</p>\n\n<pre><co... | 2018/08/28 | [
"https://wordpress.stackexchange.com/questions/312670",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148986/"
] | The Issue With Customise:
-------------------------
Wouldn't it be nice if WordPress made the **Customise** area shown in the below image resizable?
As it is at the moment, it can be a little tricky working in a squashed sidebar.
Because of this I usually do all my CSS in an external editor then copy it into the sid... | You can expand the WordPress customize area without plugins by applying a simple line of CSS.
```
.wp-full-overlay-sidebar {
width: 30% !important; /* The width of the customize area */
}
.wp-full-overlay.expanded {
margin-left: 30%; /* Here would be the width as same as the customize window width you set */
}
`... |
312,694 | <p>i found many questions like this but nothing matching to my requirement.Here i need to lock a specific page named settings,not to be deleted by other admins.But it should able to edit. Is there any way to lock a specific page.</p>
| [
{
"answer_id": 312768,
"author": "Adarsh",
"author_id": 143452,
"author_profile": "https://wordpress.stackexchange.com/users/143452",
"pm_score": 0,
"selected": false,
"text": "<p>found the solution</p>\n\n<pre><code>function restrict_page_deletion($post_ID)\n{\n $restricted_pageId = 17... | 2018/08/28 | [
"https://wordpress.stackexchange.com/questions/312694",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/143452/"
] | i found many questions like this but nothing matching to my requirement.Here i need to lock a specific page named settings,not to be deleted by other admins.But it should able to edit. Is there any way to lock a specific page. | Preventing the trash post action is a crude way of approaching it. You have to kill the application and display an ugly error message, and the UI for deleting the post will still be there.
Instead I suggest using the `map_meta_cap` filter. This will allow you to change a user's [capabilities](https://developer.wordpre... |
312,706 | <p>i have a multiple meta (custom field) in posts as "cd_meta"
that it (cd_meta) have a meta as "artist", also "artist" meta maybe have one or more value in array</p>
<p>i want to getting posts that "artist" meta have specific value and number of them</p>
<p>look below picture for more info
<a href="https://i.stack.i... | [
{
"answer_id": 312708,
"author": "Dharmishtha Patel",
"author_id": 135085,
"author_profile": "https://wordpress.stackexchange.com/users/135085",
"pm_score": 0,
"selected": false,
"text": "<p>Please change your SQL Query </p>\n\n<pre><code>$args = array(\n 'meta_query' => array(\n ... | 2018/08/28 | [
"https://wordpress.stackexchange.com/questions/312706",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/141766/"
] | i have a multiple meta (custom field) in posts as "cd\_meta"
that it (cd\_meta) have a meta as "artist", also "artist" meta maybe have one or more value in array
i want to getting posts that "artist" meta have specific value and number of them
look below picture for more info
[) ? get_query_var('paged') : 1;
$args = array(
'post_type' => array('pos... | [
{
"answer_id": 312717,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 1,
"selected": false,
"text": "<p>You can try something like this:</p>\n\n<pre><code><?php\n\n$tags_array = get_tags();\n$news_query ... | 2018/08/28 | [
"https://wordpress.stackexchange.com/questions/312716",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149480/"
] | I need a query to show all posts in the site but not repeat the ones with same tag, I mean only show one post with the same tag.
My current query is
```
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => array('post'),
'posts_per_pag... | You can try something like this:
```
<?php
$tags_array = get_tags();
$news_query = new WP_Query;
foreach ( $tags_array as $tags ) :
$news_query->query( array(
'cat' => $tags->term_id,
'posts_per_page' => 1,
'no_found_rows' => true,
'ignore_sticky_post... |
312,732 | <p>I have an external html form that I would like to add to my wordpress developed site. </p>
<p>The form links to other areas in the business like the cashiers, so when customers fill the form out, the content is added to their system. </p>
<p>I have seen different ways such as adding raw html and adding as media ho... | [
{
"answer_id": 312717,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 1,
"selected": false,
"text": "<p>You can try something like this:</p>\n\n<pre><code><?php\n\n$tags_array = get_tags();\n$news_query ... | 2018/08/28 | [
"https://wordpress.stackexchange.com/questions/312732",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149547/"
] | I have an external html form that I would like to add to my wordpress developed site.
The form links to other areas in the business like the cashiers, so when customers fill the form out, the content is added to their system.
I have seen different ways such as adding raw html and adding as media however these do no... | You can try something like this:
```
<?php
$tags_array = get_tags();
$news_query = new WP_Query;
foreach ( $tags_array as $tags ) :
$news_query->query( array(
'cat' => $tags->term_id,
'posts_per_page' => 1,
'no_found_rows' => true,
'ignore_sticky_post... |
312,736 | <p>I'm trying to remove the distraction free mode button from the editor, but i can't make it disapear.</p>
<p>Here is the code im using:</p>
<pre><code> add_filter( 'wp_editor_settings', function($settings) {
$settings['teeny']=true;
$settings['media_buttons']=false;
$settings['quicktags'] = false;
... | [
{
"answer_id": 312717,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 1,
"selected": false,
"text": "<p>You can try something like this:</p>\n\n<pre><code><?php\n\n$tags_array = get_tags();\n$news_query ... | 2018/08/28 | [
"https://wordpress.stackexchange.com/questions/312736",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/131119/"
] | I'm trying to remove the distraction free mode button from the editor, but i can't make it disapear.
Here is the code im using:
```
add_filter( 'wp_editor_settings', function($settings) {
$settings['teeny']=true;
$settings['media_buttons']=false;
$settings['quicktags'] = false;
$settings['dfw'] = fa... | You can try something like this:
```
<?php
$tags_array = get_tags();
$news_query = new WP_Query;
foreach ( $tags_array as $tags ) :
$news_query->query( array(
'cat' => $tags->term_id,
'posts_per_page' => 1,
'no_found_rows' => true,
'ignore_sticky_post... |
312,741 | <p>I upload all images through the Media Library Drag and Drop Uploader with no problems.
Every time I use a CSV file with several thousand products, I enter the image url for each product, which is located in the Media Library.
Example: /wp-content/uploads/2018/08/oa901-essence-1oz.jpg</p>
<p>As a result, the product... | [
{
"answer_id": 312717,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 1,
"selected": false,
"text": "<p>You can try something like this:</p>\n\n<pre><code><?php\n\n$tags_array = get_tags();\n$news_query ... | 2018/08/28 | [
"https://wordpress.stackexchange.com/questions/312741",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112400/"
] | I upload all images through the Media Library Drag and Drop Uploader with no problems.
Every time I use a CSV file with several thousand products, I enter the image url for each product, which is located in the Media Library.
Example: /wp-content/uploads/2018/08/oa901-essence-1oz.jpg
As a result, the product page uses... | You can try something like this:
```
<?php
$tags_array = get_tags();
$news_query = new WP_Query;
foreach ( $tags_array as $tags ) :
$news_query->query( array(
'cat' => $tags->term_id,
'posts_per_page' => 1,
'no_found_rows' => true,
'ignore_sticky_post... |
312,822 | <p>I created a simple design for showing team members with there image and linked with a modal (bootstrap 4). Its shows as following:</p>
<pre><code> <div class="col-lg-4 col-sm-6 text-center mb-4">
<img class="rounded-circle img-fluid d-block mx-auto" src="<?php echo get_template_directory_uri(... | [
{
"answer_id": 312824,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 3,
"selected": true,
"text": "<p>What you can do is to use a <a href=\"https://codex.wordpress.org/Shortcode_API\" rel=\"nofollow noreferre... | 2018/08/29 | [
"https://wordpress.stackexchange.com/questions/312822",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148864/"
] | I created a simple design for showing team members with there image and linked with a modal (bootstrap 4). Its shows as following:
```
<div class="col-lg-4 col-sm-6 text-center mb-4">
<img class="rounded-circle img-fluid d-block mx-auto" src="<?php echo get_template_directory_uri(); ?>/images/bestuur/jonas... | What you can do is to use a [shortcode](https://codex.wordpress.org/Shortcode_API), for example, you can add them to your `functions.php` or `create a plugin` that does the same.
Check [this guide](https://www.elegantthemes.com/blog/tips-tricks/how-to-create-shortcodes-in-wordpress), but keep in mind there is a lot of... |
312,839 | <p>I followed this guide <a href="https://docs.woocommerce.com/document/template-structure/" rel="nofollow noreferrer">https://docs.woocommerce.com/document/template-structure/</a></p>
<p>Then I installed a Woocommerce folder inside of my theme folder and added some lines in functions.php </p>
<pre><code> function... | [
{
"answer_id": 312824,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 3,
"selected": true,
"text": "<p>What you can do is to use a <a href=\"https://codex.wordpress.org/Shortcode_API\" rel=\"nofollow noreferre... | 2018/08/30 | [
"https://wordpress.stackexchange.com/questions/312839",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149634/"
] | I followed this guide <https://docs.woocommerce.com/document/template-structure/>
Then I installed a Woocommerce folder inside of my theme folder and added some lines in functions.php
```
function mytheme_add_woocommerce_support() {
add_theme_support( 'woocommerce', array(
'thumbnail_image_wi... | What you can do is to use a [shortcode](https://codex.wordpress.org/Shortcode_API), for example, you can add them to your `functions.php` or `create a plugin` that does the same.
Check [this guide](https://www.elegantthemes.com/blog/tips-tricks/how-to-create-shortcodes-in-wordpress), but keep in mind there is a lot of... |
312,843 | <p>On my ecommerce website, I don't want customers to leave my website and be directed to PayPal when paying via credit card. Is there a good plugin that shows a PayPal credit card form on my checkout page?</p>
<p>Thanks!</p>
| [
{
"answer_id": 312824,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 3,
"selected": true,
"text": "<p>What you can do is to use a <a href=\"https://codex.wordpress.org/Shortcode_API\" rel=\"nofollow noreferre... | 2018/08/30 | [
"https://wordpress.stackexchange.com/questions/312843",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113629/"
] | On my ecommerce website, I don't want customers to leave my website and be directed to PayPal when paying via credit card. Is there a good plugin that shows a PayPal credit card form on my checkout page?
Thanks! | What you can do is to use a [shortcode](https://codex.wordpress.org/Shortcode_API), for example, you can add them to your `functions.php` or `create a plugin` that does the same.
Check [this guide](https://www.elegantthemes.com/blog/tips-tricks/how-to-create-shortcodes-in-wordpress), but keep in mind there is a lot of... |
312,845 | <p>I created a taxonomy called <code>animal</code> and a term meta field called <code>horse</code>. </p>
<p>I created a function in my functios.php file to make it easier to display the data.</p>
<p>Here is my code:</p>
<pre><code>function regular_info_page() {
$terms = get_the_terms($post->ID, 'a... | [
{
"answer_id": 312824,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 3,
"selected": true,
"text": "<p>What you can do is to use a <a href=\"https://codex.wordpress.org/Shortcode_API\" rel=\"nofollow noreferre... | 2018/08/30 | [
"https://wordpress.stackexchange.com/questions/312845",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149636/"
] | I created a taxonomy called `animal` and a term meta field called `horse`.
I created a function in my functios.php file to make it easier to display the data.
Here is my code:
```
function regular_info_page() {
$terms = get_the_terms($post->ID, 'animal');
$result = "";
... | What you can do is to use a [shortcode](https://codex.wordpress.org/Shortcode_API), for example, you can add them to your `functions.php` or `create a plugin` that does the same.
Check [this guide](https://www.elegantthemes.com/blog/tips-tricks/how-to-create-shortcodes-in-wordpress), but keep in mind there is a lot of... |
312,846 | <p>Please forgive me if my question isn't the clearest and I'm not using this exactly correct... I've never posted before. </p>
<p>I am trying to setup a query on a real estate website that I'm developing that will give precedence to the company's listings (a custom post type) before showing the other listings (of the... | [
{
"answer_id": 312824,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 3,
"selected": true,
"text": "<p>What you can do is to use a <a href=\"https://codex.wordpress.org/Shortcode_API\" rel=\"nofollow noreferre... | 2018/08/30 | [
"https://wordpress.stackexchange.com/questions/312846",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149639/"
] | Please forgive me if my question isn't the clearest and I'm not using this exactly correct... I've never posted before.
I am trying to setup a query on a real estate website that I'm developing that will give precedence to the company's listings (a custom post type) before showing the other listings (of the same cust... | What you can do is to use a [shortcode](https://codex.wordpress.org/Shortcode_API), for example, you can add them to your `functions.php` or `create a plugin` that does the same.
Check [this guide](https://www.elegantthemes.com/blog/tips-tricks/how-to-create-shortcodes-in-wordpress), but keep in mind there is a lot of... |
312,871 | <p>I need to place <strong>Add to cart</strong> button at every product on the page of certain category as shown below
<a href="https://i.stack.imgur.com/HCtd9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HCtd9.png" alt="page's screenshot"></a></p>
<p>How can I achive this?
Link to subject pa... | [
{
"answer_id": 312886,
"author": "Pratik Patel",
"author_id": 143123,
"author_profile": "https://wordpress.stackexchange.com/users/143123",
"pm_score": 0,
"selected": false,
"text": "<p>Please make sure that “Enable AJAX add to cart buttons on archives” is turned on in <strong>WooCommer... | 2018/08/30 | [
"https://wordpress.stackexchange.com/questions/312871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101659/"
] | I need to place **Add to cart** button at every product on the page of certain category as shown below
[](https://i.stack.imgur.com/HCtd9.png)
How can I achive this?
Link to subject page [oma-fintess.com.ua](https://oma-fitness.com.ua/orbitreki) | ```
<a href="<?php the_permalink(); ?>" class="more">More info</a><?php
if($available){?><a href="<?php
$add_to_cart = do_shortcode('[add_to_cart_url id="'.$post->ID.'"]');
echo $add_to_cart;
?>" class="more">Buy now</a>
<?php
}
```
This code solve ... |
312,879 | <p>I need help with this one. What I want to do is to display specific posts of the custom post type.
Everything working fine, just I can't display more than 1(one) post. doesn't matter how much posts I select it always return to me just one.
Here is a full code</p>
<pre><code><?php
$post_objects = get_sub_field('... | [
{
"answer_id": 312889,
"author": "Stefan",
"author_id": 93082,
"author_profile": "https://wordpress.stackexchange.com/users/93082",
"pm_score": -1,
"selected": false,
"text": "<p>Here is a solution, i need to returns an array of string. It's not enough to pass string in array()</p>\n\n<p... | 2018/08/30 | [
"https://wordpress.stackexchange.com/questions/312879",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93082/"
] | I need help with this one. What I want to do is to display specific posts of the custom post type.
Everything working fine, just I can't display more than 1(one) post. doesn't matter how much posts I select it always return to me just one.
Here is a full code
```
<?php
$post_objects = get_sub_field('choose_blocks');
... | now we are getting there.. you really need to try to explain, what your problem is, its not very clear in your question.
my assumption is, you tried this one, but it didn't work out:
```
foreach( $post_objects as $post_object):
get_template_part( 'includes/content', get_post_format( $post_object->ID ) );
endforeach... |
312,905 | <p>I have created a HTML website and want to shift to wordpress. I have another theme so I will be copying my content to that theme. But I want to keep my HTML website alive till I am done with the shifting to wordpress. Is there any way I can install the wordpress database and install my theme and start my word in bac... | [
{
"answer_id": 312889,
"author": "Stefan",
"author_id": 93082,
"author_profile": "https://wordpress.stackexchange.com/users/93082",
"pm_score": -1,
"selected": false,
"text": "<p>Here is a solution, i need to returns an array of string. It's not enough to pass string in array()</p>\n\n<p... | 2018/08/30 | [
"https://wordpress.stackexchange.com/questions/312905",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149678/"
] | I have created a HTML website and want to shift to wordpress. I have another theme so I will be copying my content to that theme. But I want to keep my HTML website alive till I am done with the shifting to wordpress. Is there any way I can install the wordpress database and install my theme and start my word in backen... | now we are getting there.. you really need to try to explain, what your problem is, its not very clear in your question.
my assumption is, you tried this one, but it didn't work out:
```
foreach( $post_objects as $post_object):
get_template_part( 'includes/content', get_post_format( $post_object->ID ) );
endforeach... |
312,929 | <p>I'm trying to display user info including custom fields determined by an ACF relational user field, and all contained within a flexible content field.</p>
<p><em>EDIT</em> Updated code following answers / comments, but still can't get anything to output - all my variables are empty.</p>
<p>The flexible content par... | [
{
"answer_id": 312931,
"author": "Lewis Donovan",
"author_id": 113034,
"author_profile": "https://wordpress.stackexchange.com/users/113034",
"pm_score": 1,
"selected": false,
"text": "<p>You don't actually need to call <code>get_userdata()</code>, all the data you need should be in the r... | 2018/08/30 | [
"https://wordpress.stackexchange.com/questions/312929",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111367/"
] | I'm trying to display user info including custom fields determined by an ACF relational user field, and all contained within a flexible content field.
*EDIT* Updated code following answers / comments, but still can't get anything to output - all my variables are empty.
The flexible content part is fine, and I'm just ... | The solution was only slightly different from Lewis' answer:
```
<?php
$posts = get_sub_field('who_to_show');
if( $posts ):
foreach( $posts as $post):
$userdata = get_user_by('ID',$post['ID']);
$image = get_field('author_image', 'user_'. $post['ID'] );
$role = get_field('role', 'user... |
312,973 | <h2>How Can I Manually Fix & What is The Root Cause?</h2>
<p>The <code>Site Language</code> setting in <code>Settings > General</code> for <a href="https://lbryhub.com" rel="nofollow noreferrer">my site</a>, will not update.</p>
<p>It is stuck on <code>English (United States)</code>.</p>
<p>I have done all th... | [
{
"answer_id": 312931,
"author": "Lewis Donovan",
"author_id": 113034,
"author_profile": "https://wordpress.stackexchange.com/users/113034",
"pm_score": 1,
"selected": false,
"text": "<p>You don't actually need to call <code>get_userdata()</code>, all the data you need should be in the r... | 2018/08/31 | [
"https://wordpress.stackexchange.com/questions/312973",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/148986/"
] | How Can I Manually Fix & What is The Root Cause?
------------------------------------------------
The `Site Language` setting in `Settings > General` for [my site](https://lbryhub.com), will not update.
It is stuck on `English (United States)`.
I have done all the usually debugging procedures, such as disabling all ... | The solution was only slightly different from Lewis' answer:
```
<?php
$posts = get_sub_field('who_to_show');
if( $posts ):
foreach( $posts as $post):
$userdata = get_user_by('ID',$post['ID']);
$image = get_field('author_image', 'user_'. $post['ID'] );
$role = get_field('role', 'user... |
312,975 | <p>I have a custom filed called <code>xxxx_url</code>. <code>xxxx_url</code> should be unique.</p>
<p>So, before publishing the post, I want to make sure that <code>xxxx_url</code> is unique or not? If it isn't unique, publishing the post should be reject.</p>
<p>I tried <code>publish_post</code>. But that isn't the ... | [
{
"answer_id": 313225,
"author": "Petr Cibulka",
"author_id": 28718,
"author_profile": "https://wordpress.stackexchange.com/users/28718",
"pm_score": -1,
"selected": false,
"text": "<p>The check should go to <code>wp_insert_post</code>. This hook is fired whenever post is published or ed... | 2018/08/31 | [
"https://wordpress.stackexchange.com/questions/312975",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/123092/"
] | I have a custom filed called `xxxx_url`. `xxxx_url` should be unique.
So, before publishing the post, I want to make sure that `xxxx_url` is unique or not? If it isn't unique, publishing the post should be reject.
I tried `publish_post`. But that isn't the correct one, since it triggers when we publish the post. I wa... | At the beginning of [`wp_insert_post`](https://developer.wordpress.org/reference/functions/wp_insert_post/), the function that saves/updates a post, there is a filter called [`wp_insert_post_empty_content`](https://developer.wordpress.org/reference/hooks/wp_insert_post_empty_content/). By default this filter checks whe... |
312,988 | <p>I am currently using a Hesita Child Theme.
I want to edit the copyright text in the footer. </p>
<p>I have found the text I need to edit in 'hestia/inc/views/main/class-hestia-footer.php'</p>
<p>I think know what code to edit, however, I do not know how to make that change in the child theme. I have changed it bef... | [
{
"answer_id": 312990,
"author": "Quang Hoang",
"author_id": 134874,
"author_profile": "https://wordpress.stackexchange.com/users/134874",
"pm_score": -1,
"selected": false,
"text": "<p>In the child-theme, you must duplicate a file class-hestia-footer.php like as parent-theme and edit fi... | 2018/08/31 | [
"https://wordpress.stackexchange.com/questions/312988",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149738/"
] | I am currently using a Hesita Child Theme.
I want to edit the copyright text in the footer.
I have found the text I need to edit in 'hestia/inc/views/main/class-hestia-footer.php'
I think know what code to edit, however, I do not know how to make that change in the child theme. I have changed it before, but it has b... | You Could Also Try This Cheeky Little Trick :)
----------------------------------------------
If you just want a quick and easy, no fuss change, you can do this to the [Hestia](https://themeisle.com/demo/?theme=Hestia) theme copyright area.
Just add the following code to your child theme CSS or to the WordPress Custo... |
313,015 | <p>I'm developing a system where I have a Deck presentation.<br>
I have a field that takes the post by the 'copas' type of card being within the 'meta_value' array specification, and I would like it to be sorted exactly as it is in the array:</p>
<pre><code>array('K','Q','J','10','9','8','7','6','5','4','3','2'),
</... | [
{
"answer_id": 313017,
"author": "Peter HvD",
"author_id": 134918,
"author_profile": "https://wordpress.stackexchange.com/users/134918",
"pm_score": 0,
"selected": false,
"text": "<p>You are misunderstanding the use of<code>'meta_value'</code>. It is used to tell the query what you want ... | 2018/08/31 | [
"https://wordpress.stackexchange.com/questions/313015",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149751/"
] | I'm developing a system where I have a Deck presentation.
I have a field that takes the post by the 'copas' type of card being within the 'meta\_value' array specification, and I would like it to be sorted exactly as it is in the array:
```
array('K','Q','J','10','9','8','7','6','5','4','3','2'),
```
But the ne... | Looking at the [`orderby`](https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters) parameter on `WP_Query`, I don't see any way to do this. You could (as Peter HvD suggests in his answer) convert your face cards to numbers; but if you want to keep the `K|Q|J` values, I'd recommend using a ... |
313,090 | <p>I'm working on a project where we'll be creating two different custom post types: <em>Machines</em> and <em>Enquiries</em>. The Machines posts will be created by admin, and will simply be a list of items that are for sale (although this isn't an e-commerce site). Enquiries, however, will be created by users via a fo... | [
{
"answer_id": 313094,
"author": "jdp",
"author_id": 115910,
"author_profile": "https://wordpress.stackexchange.com/users/115910",
"pm_score": 1,
"selected": false,
"text": "<p>I think your answer lies with adding metadata on the Machine post type that links back to the Enquiry post. You... | 2018/09/01 | [
"https://wordpress.stackexchange.com/questions/313090",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/60225/"
] | I'm working on a project where we'll be creating two different custom post types: *Machines* and *Enquiries*. The Machines posts will be created by admin, and will simply be a list of items that are for sale (although this isn't an e-commerce site). Enquiries, however, will be created by users via a form displayed on t... | Add a field to your form that allows selection of a `machine`. You can use `get_posts` to generate a `select` element:
```
$args = [
'posts_per_page' => -1,
'post_type' => 'machine'
];
$machines = get_posts( $args );
if( ! empty( $machines ) ){
echo '<select name="_machine_id">';
foreach( $machines as ... |
313,118 | <p>I am looking for the function to change position the price for the category. (I attached an image).
Ok, is not a switch is a remove and add.</p>
<p>¿Where i can find a good explanation about the php function and the list of it?,will be awesome if somebody know a good explanation of the structure too.</p>
<p>Becaus... | [
{
"answer_id": 313094,
"author": "jdp",
"author_id": 115910,
"author_profile": "https://wordpress.stackexchange.com/users/115910",
"pm_score": 1,
"selected": false,
"text": "<p>I think your answer lies with adding metadata on the Machine post type that links back to the Enquiry post. You... | 2018/09/02 | [
"https://wordpress.stackexchange.com/questions/313118",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/149189/"
] | I am looking for the function to change position the price for the category. (I attached an image).
Ok, is not a switch is a remove and add.
¿Where i can find a good explanation about the php function and the list of it?,will be awesome if somebody know a good explanation of the structure too.
Because Codex from [Woo... | Add a field to your form that allows selection of a `machine`. You can use `get_posts` to generate a `select` element:
```
$args = [
'posts_per_page' => -1,
'post_type' => 'machine'
];
$machines = get_posts( $args );
if( ! empty( $machines ) ){
echo '<select name="_machine_id">';
foreach( $machines as ... |