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
340,919
<p>I am learning wordpress by my own and this is the code of html template.</p> <pre><code> &lt;div class="collapse navbar-collapse" id="ftco-nav"&gt; &lt;ul class="navbar-nav ml-auto"&gt; &lt;li class="nav-item active"&gt;&lt;a href="index.html" class="nav-link"&gt;Home&lt;/a&gt;&lt;/li&gt; ...
[ { "answer_id": 340920, "author": "MikeNGarrett", "author_id": 1670, "author_profile": "https://wordpress.stackexchange.com/users/1670", "pm_score": 1, "selected": false, "text": "<p>Change your active class name in your css. WordPress adds the following active classes, depending on the c...
2019/06/19
[ "https://wordpress.stackexchange.com/questions/340919", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170301/" ]
I am learning wordpress by my own and this is the code of html template. ``` <div class="collapse navbar-collapse" id="ftco-nav"> <ul class="navbar-nav ml-auto"> <li class="nav-item active"><a href="index.html" class="nav-link">Home</a></li> <li class="nav-item"><a href="about.html"...
Change your active class name in your css. WordPress adds the following active classes, depending on the context of the active state: `current-menu-item`, `current-menu-ancestor`, `current-menu-parent`, and `current-page-ancestor`
340,969
<p>I know that this has been frequently asked here, but none of the solutions I find seem to work for me.</p> <p>The issue is as follows: whenever I post the form, I have a console log with the response which is a full html page rather than a simple message.</p> <p>Backend script:</p> <pre><code> add_action( 'adm...
[ { "answer_id": 340920, "author": "MikeNGarrett", "author_id": 1670, "author_profile": "https://wordpress.stackexchange.com/users/1670", "pm_score": 1, "selected": false, "text": "<p>Change your active class name in your css. WordPress adds the following active classes, depending on the c...
2019/06/19
[ "https://wordpress.stackexchange.com/questions/340969", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153230/" ]
I know that this has been frequently asked here, but none of the solutions I find seem to work for me. The issue is as follows: whenever I post the form, I have a console log with the response which is a full html page rather than a simple message. Backend script: ``` add_action( 'admin_ajax_nopriv_email_verific...
Change your active class name in your css. WordPress adds the following active classes, depending on the context of the active state: `current-menu-item`, `current-menu-ancestor`, `current-menu-parent`, and `current-page-ancestor`
340,976
<p>I'm calling an api with <code>wp_remote_get</code> and I can't seem to parse the results. </p> <p>Here is how I call the api:</p> <pre><code> $url = 'https://blah/api/data/'; $args = array( 'headers' =&gt; array( 'Authorization' =&gt; 'Token ' . $my_token, ), ); $data...
[ { "answer_id": 340920, "author": "MikeNGarrett", "author_id": 1670, "author_profile": "https://wordpress.stackexchange.com/users/1670", "pm_score": 1, "selected": false, "text": "<p>Change your active class name in your css. WordPress adds the following active classes, depending on the c...
2019/06/20
[ "https://wordpress.stackexchange.com/questions/340976", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/147485/" ]
I'm calling an api with `wp_remote_get` and I can't seem to parse the results. Here is how I call the api: ``` $url = 'https://blah/api/data/'; $args = array( 'headers' => array( 'Authorization' => 'Token ' . $my_token, ), ); $data = wp_remote_get($url, $args); $da...
Change your active class name in your css. WordPress adds the following active classes, depending on the context of the active state: `current-menu-item`, `current-menu-ancestor`, `current-menu-parent`, and `current-page-ancestor`
341,002
<p>I have in my code the following variable to call the title of the categories.</p> <pre><code>&lt;?php $categories = get_the_terms($custom_args-&gt;ID, 'veranstaltungen-category'); foreach ($categories as $category) { $cats .= $category-&gt;name . ', '; echo rtrim($cats, ', '); ...
[ { "answer_id": 341005, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 3, "selected": true, "text": "<p>In this line:</p>\n\n<pre><code>$cats .= $category-&gt;name . ', ';\n</code></pre>\n\n<p>You append a ...
2019/06/20
[ "https://wordpress.stackexchange.com/questions/341002", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/149472/" ]
I have in my code the following variable to call the title of the categories. ``` <?php $categories = get_the_terms($custom_args->ID, 'veranstaltungen-category'); foreach ($categories as $category) { $cats .= $category->name . ', '; echo rtrim($cats, ', '); } ?> ``` Th...
In this line: ``` $cats .= $category->name . ', '; ``` You append a name of category to variable called $cats. But you never reset this variable. So every post appends its categories to the same variable. So here’s how to fix this: ``` <?php $categories = get_the_terms($custom_args->ID, 'veranstaltungen-categor...
341,024
<p>everybody,</p> <p>I have created a custom_post_type;</p> <pre><code>function create_post_type_veranstaltungen() { register_post_type('veranstaltungen', array( 'label' =&gt; __('Veranstaltungen'), 'public' =&gt; true, 'show_ui' =&gt; true, 'show_in_menu' =&gt; true, 'menu_ico...
[ { "answer_id": 341027, "author": "Bhupen", "author_id": 128529, "author_profile": "https://wordpress.stackexchange.com/users/128529", "pm_score": -1, "selected": false, "text": "<p>you have missed $wp_query like this $wp_query->have_posts() to add in the loop. \nPlease see the code: </p>...
2019/06/20
[ "https://wordpress.stackexchange.com/questions/341024", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/149472/" ]
everybody, I have created a custom\_post\_type; ``` function create_post_type_veranstaltungen() { register_post_type('veranstaltungen', array( 'label' => __('Veranstaltungen'), 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_icon' => 'dashicons-admin-site-alt...
after days of research, I found that the fault was simply in the pagination. By changing the pagination code, I have made it work. ``` <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $custom_args = array( 'post_type' => 'veranstaltungen', ...
341,060
<p>I'm facing an issue where:</p> <ol> <li>I've created a custom attribute type</li> <li>Created an attribute, called it 'test'</li> <li>Added one term to the attribute, and called this 'Hi'</li> <li>Go to edit the varations in edit product and I cannot seem to add any terms to it. There's just nothing there to select...
[ { "answer_id": 359516, "author": "Kevin Silva", "author_id": 183388, "author_profile": "https://wordpress.stackexchange.com/users/183388", "pm_score": 1, "selected": false, "text": "<p>I just had that problem and resolved it alone since i could not find the answer online.\nYou just need ...
2019/06/20
[ "https://wordpress.stackexchange.com/questions/341060", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169069/" ]
I'm facing an issue where: 1. I've created a custom attribute type 2. Created an attribute, called it 'test' 3. Added one term to the attribute, and called this 'Hi' 4. Go to edit the varations in edit product and I cannot seem to add any terms to it. There's just nothing there to select like normal. [![](https://i.s...
I just had that problem and resolved it alone since i could not find the answer online. You just need to put that code inside an if. Only to run that code on attribute page. ``` if ($_GET['page']=='product_attributes') { add_filter( 'product_attributes_type_selector', function($array){ $array['test'] = __( 'Test...
341,087
<p>My js code:</p> <pre><code>$('div[aria-label="Asukohad"] input[type="checkbox"]').on("change", function() { var element = $(this); if(element.is(":checked")) { //todo } else { uncheckAll(); } }); function uncheckAll() { $('div[aria-label="Asukohad"] input[type="checkbox"]').att...
[ { "answer_id": 341092, "author": "Mr.Lister", "author_id": 118678, "author_profile": "https://wordpress.stackexchange.com/users/118678", "pm_score": 1, "selected": false, "text": "<p>Can you please clarify your question? Are you attempting to make a checkbox that can clear all checkboxes...
2019/06/21
[ "https://wordpress.stackexchange.com/questions/341087", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170408/" ]
My js code: ``` $('div[aria-label="Asukohad"] input[type="checkbox"]').on("change", function() { var element = $(this); if(element.is(":checked")) { //todo } else { uncheckAll(); } }); function uncheckAll() { $('div[aria-label="Asukohad"] input[type="checkbox"]').attr('checked', f...
Can you please clarify your question? Are you attempting to make a checkbox that can clear all checkboxes and also recheck all checkboxes by checking that one checkbox? Also a checked input would be written like this: ``` <input id="editor-post-taxonomies-hierarchical-term-48" class="editor-post-taxonomies__hierarchi...
341,111
<p>I have a website with a lot of </p> <pre><code>[mybutton]click here[/mybutton] </code></pre> <p>or</p> <pre><code>[mybutton]click there[/mybutton] </code></pre> <p>in editor. I need to add a function to create a href from this shortcodes. Closing of shortcode is a problem for me. How can i do it?</p>
[ { "answer_id": 341116, "author": "Maneza F8", "author_id": 170430, "author_profile": "https://wordpress.stackexchange.com/users/170430", "pm_score": 0, "selected": false, "text": "<p>That is a short code not HTML you can put any Attribute there, if you want that function got to your page...
2019/06/21
[ "https://wordpress.stackexchange.com/questions/341111", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101908/" ]
I have a website with a lot of ``` [mybutton]click here[/mybutton] ``` or ``` [mybutton]click there[/mybutton] ``` in editor. I need to add a function to create a href from this shortcodes. Closing of shortcode is a problem for me. How can i do it?
To change the functionality of a shortcode you must first `remove_shortcode( 'shortcode_name' );` where shortcode name is the name of the shortcode. Add the shortcode back with your NEW function. A simple example to follow what you might be needing: ``` remove_shortcode( 'mybutton' ); add_shortcode( 'mybutton...
341,126
<p>I'm trying to download images from external sites via api (newsapi.org) and use those as thumbnails, using <code>wp_download_url</code>. Although it doesn’t work on so-called dynamically generated images, e.g. </p> <p><code>https://res.cloudinary.com/demo/image/upload/w_400,h_400,c_crop,g_face,r_max/w_200/lady.jpg<...
[ { "answer_id": 341116, "author": "Maneza F8", "author_id": 170430, "author_profile": "https://wordpress.stackexchange.com/users/170430", "pm_score": 0, "selected": false, "text": "<p>That is a short code not HTML you can put any Attribute there, if you want that function got to your page...
2019/06/21
[ "https://wordpress.stackexchange.com/questions/341126", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121208/" ]
I'm trying to download images from external sites via api (newsapi.org) and use those as thumbnails, using `wp_download_url`. Although it doesn’t work on so-called dynamically generated images, e.g. `https://res.cloudinary.com/demo/image/upload/w_400,h_400,c_crop,g_face,r_max/w_200/lady.jpg` Is there a way to make i...
To change the functionality of a shortcode you must first `remove_shortcode( 'shortcode_name' );` where shortcode name is the name of the shortcode. Add the shortcode back with your NEW function. A simple example to follow what you might be needing: ``` remove_shortcode( 'mybutton' ); add_shortcode( 'mybutton...
341,129
<p>I am using SMTP to send email through WordPress, however this requires using plain text password. What if this password is stored in <code>wp-config.php</code>? Very <a href="https://wordpress.stackexchange.com/questions/53636/password-in-wp-config-dangerous">similar to this</a>. Why this topic differs from the link...
[ { "answer_id": 341133, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 1, "selected": false, "text": "<p>If you want to make it a bit safer, save the password into the database. Making additional steps ne...
2019/06/21
[ "https://wordpress.stackexchange.com/questions/341129", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1210/" ]
I am using SMTP to send email through WordPress, however this requires using plain text password. What if this password is stored in `wp-config.php`? Very [similar to this](https://wordpress.stackexchange.com/questions/53636/password-in-wp-config-dangerous). Why this topic differs from the linked one: the nature of the...
I am not sure where you else you would store the SMTP credentials? I am not comfortable storing those credentials in the Database because of the trouble you mentioned you could get into if they got out. Or putting them in a theme file. Like they mentioned in the other thread, if Apache gets screwed up and that files ge...
341,144
<p>I created a Wordpress REST API custom endpoint to be used as a Webhook URL in WooCommerce in order to convert the received data and then send it to a third party system, but the endpoint apparently is not receiving any data. I tested the code by sending some JSON data to my custom endpoint using Postman and it work...
[ { "answer_id": 341133, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 1, "selected": false, "text": "<p>If you want to make it a bit safer, save the password into the database. Making additional steps ne...
2019/06/21
[ "https://wordpress.stackexchange.com/questions/341144", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170445/" ]
I created a Wordpress REST API custom endpoint to be used as a Webhook URL in WooCommerce in order to convert the received data and then send it to a third party system, but the endpoint apparently is not receiving any data. I tested the code by sending some JSON data to my custom endpoint using Postman and it works on...
I am not sure where you else you would store the SMTP credentials? I am not comfortable storing those credentials in the Database because of the trouble you mentioned you could get into if they got out. Or putting them in a theme file. Like they mentioned in the other thread, if Apache gets screwed up and that files ge...
341,148
<p>I'm very new to the developing world and have been, with the help of Youtube, been learning to design Wordpress themes with HTML, CSS and PHP. I am using MAMP to locally host my wordpress site. When I make an error, like forgetting to close my PHP tag, and I refresh my site, all I see is "the site is experiencing ...
[ { "answer_id": 341133, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 1, "selected": false, "text": "<p>If you want to make it a bit safer, save the password into the database. Making additional steps ne...
2019/06/21
[ "https://wordpress.stackexchange.com/questions/341148", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170494/" ]
I'm very new to the developing world and have been, with the help of Youtube, been learning to design Wordpress themes with HTML, CSS and PHP. I am using MAMP to locally host my wordpress site. When I make an error, like forgetting to close my PHP tag, and I refresh my site, all I see is "the site is experiencing techn...
I am not sure where you else you would store the SMTP credentials? I am not comfortable storing those credentials in the Database because of the trouble you mentioned you could get into if they got out. Or putting them in a theme file. Like they mentioned in the other thread, if Apache gets screwed up and that files ge...
341,167
<p>I have my wordpress multisite setup in LAN network. I also setup dynamic DNS (eg. www.mysite.com) which is directed to my router's public IP (eg. 10.10.10.10). My router will port forward any request to my server's IP (eg. 192.168.0.100). </p> <p>When I tried to view the wordpress site from another device in my LAN...
[ { "answer_id": 341133, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 1, "selected": false, "text": "<p>If you want to make it a bit safer, save the password into the database. Making additional steps ne...
2019/06/22
[ "https://wordpress.stackexchange.com/questions/341167", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170461/" ]
I have my wordpress multisite setup in LAN network. I also setup dynamic DNS (eg. www.mysite.com) which is directed to my router's public IP (eg. 10.10.10.10). My router will port forward any request to my server's IP (eg. 192.168.0.100). When I tried to view the wordpress site from another device in my LAN network b...
I am not sure where you else you would store the SMTP credentials? I am not comfortable storing those credentials in the Database because of the trouble you mentioned you could get into if they got out. Or putting them in a theme file. Like they mentioned in the other thread, if Apache gets screwed up and that files ge...
341,193
<p>I have created a custom section with a setting with one control allowing users to choose fonts from a dropdown. However, when I use the get_theme_mod() function, and echo the results to a styles tag in the header, I get nothing. </p> <p>The debugger tells me that get_theme_mod() is returning 'false', when I expect ...
[ { "answer_id": 341195, "author": "Aniruddha Gawade", "author_id": 101818, "author_profile": "https://wordpress.stackexchange.com/users/101818", "pm_score": 1, "selected": false, "text": "<p>Problem 1: <code>get_option</code> instead of <code>get_theme_mod</code>.</p>\n\n<p>How you store ...
2019/06/22
[ "https://wordpress.stackexchange.com/questions/341193", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153787/" ]
I have created a custom section with a setting with one control allowing users to choose fonts from a dropdown. However, when I use the get\_theme\_mod() function, and echo the results to a styles tag in the header, I get nothing. The debugger tells me that get\_theme\_mod() is returning 'false', when I expect it to ...
> > The debugger tells me that get\_theme\_mod() is returning 'false', when > I expect it to return the value of the selected item. > > > `get_theme_mod()` isn't working because when you registered the setting, you set the `type` to `option`: ``` $wp_customize->add_setting('title_font', array( 'default' ...
341,200
<p>I've cast a pretty wide net to find an answer but nothing seems to quite hit the mark.</p> <p>Process:: I Login to my site/dashboard and I decide I need to edit a portion of my theme through the customiser, so I do, pretty straight forward...</p> <p>In the mean time, I've built up my child theme and it seems to wo...
[ { "answer_id": 341202, "author": "Mobeen Abdullah", "author_id": 170482, "author_profile": "https://wordpress.stackexchange.com/users/170482", "pm_score": -1, "selected": false, "text": "<p>This should load the file from the child theme.</p>\n\n<pre><code>require get_stylesheet_directory...
2019/06/22
[ "https://wordpress.stackexchange.com/questions/341200", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170479/" ]
I've cast a pretty wide net to find an answer but nothing seems to quite hit the mark. Process:: I Login to my site/dashboard and I decide I need to edit a portion of my theme through the customiser, so I do, pretty straight forward... In the mean time, I've built up my child theme and it seems to work pretty well fo...
First remove action of customizer then add your action with new function name. **in your child-theme functions.php** ``` add_action( 'init', 'remove_my_action'); function remove_my_action() { remove_action('customize_register', 'business_prime_settings_control',10); } require_once dirname( __FILE__ ) . '/inc/bus...
341,220
<p>WordPress generates several thumbnail sizes and adding custom image sizes in a theme is great, but is there a way to view all URLs for a given image in WP, ideally right in the media library popup?</p> <p>Currently if I want the "large" thumbnail URL of an image, I have to edit/add a Page/Post, add the image to the...
[ { "answer_id": 341202, "author": "Mobeen Abdullah", "author_id": 170482, "author_profile": "https://wordpress.stackexchange.com/users/170482", "pm_score": -1, "selected": false, "text": "<p>This should load the file from the child theme.</p>\n\n<pre><code>require get_stylesheet_directory...
2019/06/22
[ "https://wordpress.stackexchange.com/questions/341220", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31367/" ]
WordPress generates several thumbnail sizes and adding custom image sizes in a theme is great, but is there a way to view all URLs for a given image in WP, ideally right in the media library popup? Currently if I want the "large" thumbnail URL of an image, I have to edit/add a Page/Post, add the image to the page, vie...
First remove action of customizer then add your action with new function name. **in your child-theme functions.php** ``` add_action( 'init', 'remove_my_action'); function remove_my_action() { remove_action('customize_register', 'business_prime_settings_control',10); } require_once dirname( __FILE__ ) . '/inc/bus...
341,237
<p>I have created a page for plugin. For that page i have added a checkbox meta field. The field is working fine. By default, the checkbox field is unchecked. I mean at first to active the plugin, the checkbox field is unchecked. But I need to make it check by default. I have tried a condition but not working at all....
[ { "answer_id": 341239, "author": "Camille V.", "author_id": 140435, "author_profile": "https://wordpress.stackexchange.com/users/140435", "pm_score": 2, "selected": false, "text": "<p>Actually, your code is working, as long as <code>$val == 'on'</code>.</p>\n\n<p>Did you try debugging by...
2019/06/23
[ "https://wordpress.stackexchange.com/questions/341237", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170505/" ]
I have created a page for plugin. For that page i have added a checkbox meta field. The field is working fine. By default, the checkbox field is unchecked. I mean at first to active the plugin, the checkbox field is unchecked. But I need to make it check by default. I have tried a condition but not working at all. My...
Actually, your code is working, as long as `$val == 'on'`. Did you try debugging by doing `echo $val` ? If it's still not working, try *hard refreshing* (Ctrl + F5) your webpage, checkboxes tend to keep their state on normal refresh (F5). Also, please put your code directly on this forum, so the code is always acces...
341,299
<p>When I try to upload a theme in my Wordpress website I need to fill in FTP credentials. </p> <p>I've installed vsftpd on my Ubuntu 18.04 server. When I connect with the credentials in my FTP client (ex. Cyberduck on mac) I see the following:</p> <p><a href="https://i.stack.imgur.com/7Ps5B.png" rel="nofollow norefe...
[ { "answer_id": 341305, "author": "Owais Alam", "author_id": 91939, "author_profile": "https://wordpress.stackexchange.com/users/91939", "pm_score": 3, "selected": true, "text": "<ul>\n<li>All files should be owned by the actual user's account, not the user account used for the httpd proc...
2019/06/24
[ "https://wordpress.stackexchange.com/questions/341299", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65180/" ]
When I try to upload a theme in my Wordpress website I need to fill in FTP credentials. I've installed vsftpd on my Ubuntu 18.04 server. When I connect with the credentials in my FTP client (ex. Cyberduck on mac) I see the following: [![enter image description here](https://i.stack.imgur.com/7Ps5B.png)](https://i.st...
* All files should be owned by the actual user's account, not the user account used for the httpd process. * Group ownership is irrelevant unless there are specific group requirements for the web-server process permissions checking. This is not usually the case. * All directories should be 755 or 750. * All files shoul...
341,328
<p>I'm working on a setup where user logins <em>have to</em> follow this format : </p> <blockquote> <p>login : user-john@doe.com</p> </blockquote> <p>Even though Wordpress has no problem creating such accounts, it seems they don't play well with the "Forgotten password" form :</p> <p><a href="https://i.stack.imgu...
[ { "answer_id": 341582, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 0, "selected": false, "text": "<p>Usernames typically should not contain any special characters, only letters, numbers and the underline ( _ ...
2019/06/24
[ "https://wordpress.stackexchange.com/questions/341328", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1381/" ]
I'm working on a setup where user logins *have to* follow this format : > > login : user-john@doe.com > > > Even though Wordpress has no problem creating such accounts, it seems they don't play well with the "Forgotten password" form : [![enter image description here](https://i.stack.imgur.com/mpJ9E.png)](https...
Create a custom template for forgot password and add forgot password page link to WordPress login page using theme functions.php. Please see the code given below and modify conditions as per your need. ``` <?php /* * Template Name: Forgot Password */ global $wpdb; $error = ''; $success = ''; // check if we're ...
341,339
<p>How I can Activate and deactivate plugin automatically? For example, I want the "Yoast Seo" plugin to be active only on Monday, Wednesday, Friday, Saturday and the other days deactivated. How can I do it? Thanks..</p>
[ { "answer_id": 341341, "author": "Liam Stewart", "author_id": 121955, "author_profile": "https://wordpress.stackexchange.com/users/121955", "pm_score": 0, "selected": false, "text": "<p>You can mange this by adding the following to your <code>functions.php</code> file.</p>\n\n<p>Checking...
2019/06/24
[ "https://wordpress.stackexchange.com/questions/341339", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135643/" ]
How I can Activate and deactivate plugin automatically? For example, I want the "Yoast Seo" plugin to be active only on Monday, Wednesday, Friday, Saturday and the other days deactivated. How can I do it? Thanks..
I like the idea of running this through a schedule event in WordPress, <https://codex.wordpress.org/Function_Reference/wp_schedule_event> Here is a snippet that hopefully will get you there: ``` <?php if(!wp_next_scheduled('daily_plugin_check')){ wp_schedule_event( time(), 'daily', 'daily_plugin_check' ); } ...
341,347
<p>I've been working on a project and I just cant pull the data from this API. I'm developing a plugin that's supposed to pull data from an API and then use that data. I developed this project offline and after it was working I started developing inside the WordPress plugin space.</p> <p>but for some reason i'm not ge...
[ { "answer_id": 341341, "author": "Liam Stewart", "author_id": 121955, "author_profile": "https://wordpress.stackexchange.com/users/121955", "pm_score": 0, "selected": false, "text": "<p>You can mange this by adding the following to your <code>functions.php</code> file.</p>\n\n<p>Checking...
2019/06/24
[ "https://wordpress.stackexchange.com/questions/341347", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170591/" ]
I've been working on a project and I just cant pull the data from this API. I'm developing a plugin that's supposed to pull data from an API and then use that data. I developed this project offline and after it was working I started developing inside the WordPress plugin space. but for some reason i'm not getting any ...
I like the idea of running this through a schedule event in WordPress, <https://codex.wordpress.org/Function_Reference/wp_schedule_event> Here is a snippet that hopefully will get you there: ``` <?php if(!wp_next_scheduled('daily_plugin_check')){ wp_schedule_event( time(), 'daily', 'daily_plugin_check' ); } ...
341,407
<p>Since Wordpress 5.2 can not display errors on the site. The constants "<em>WP_DEBUG</em>" et "<em>WP_DEBUG_DISPLAY</em>" doesn't work. The following message is always displayed : "The site is experiencing technical difficulties. Please check your site admin email inbox for instructions."</p> <p>Have you solution?</...
[ { "answer_id": 341414, "author": "ChristopherJones", "author_id": 168744, "author_profile": "https://wordpress.stackexchange.com/users/168744", "pm_score": 1, "selected": false, "text": "<p>Maybe I am wrong here, but <code>define( 'WP_DEBUG', true );</code> is still available and works i...
2019/06/25
[ "https://wordpress.stackexchange.com/questions/341407", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170642/" ]
Since Wordpress 5.2 can not display errors on the site. The constants "*WP\_DEBUG*" et "*WP\_DEBUG\_DISPLAY*" doesn't work. The following message is always displayed : "The site is experiencing technical difficulties. Please check your site admin email inbox for instructions." Have you solution?
You can disable this behaviour by setting `WP_DISABLE_FATAL_ERROR_HANDLER` to `true`: ``` define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); ``` This will stop the "The site is experiencing technical difficulties" message from appearing, so errors will appear as they did prior to this feature being added.
341,408
<p>I am tring to implement custom filter for The Event Calendar. I have used this code</p> <pre><code>$args = array( 'post_type' =&gt; 'tribe_events', 'meta_key' =&gt; '_EventStartDate', 'meta_query' =&gt; array( array( 'key' =&gt; '_EventStartDate', 'value' =&gt; array( $start_date, $en...
[ { "answer_id": 341414, "author": "ChristopherJones", "author_id": 168744, "author_profile": "https://wordpress.stackexchange.com/users/168744", "pm_score": 1, "selected": false, "text": "<p>Maybe I am wrong here, but <code>define( 'WP_DEBUG', true );</code> is still available and works i...
2019/06/25
[ "https://wordpress.stackexchange.com/questions/341408", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115907/" ]
I am tring to implement custom filter for The Event Calendar. I have used this code ``` $args = array( 'post_type' => 'tribe_events', 'meta_key' => '_EventStartDate', 'meta_query' => array( array( 'key' => '_EventStartDate', 'value' => array( $start_date, $end_date ), 'compare' =...
You can disable this behaviour by setting `WP_DISABLE_FATAL_ERROR_HANDLER` to `true`: ``` define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); ``` This will stop the "The site is experiencing technical difficulties" message from appearing, so errors will appear as they did prior to this feature being added.
341,419
<pre><code>&lt;div class="row"&gt; &lt;?php $taxonomyName = "product_tag"; if($taxonomyname = "latest-product"){ //This gets top layer terms only. This is done by setting parent to 0. $parent_terms = get_terms($taxonomyName, array('parent' =&gt; 0, 'orderby' =&gt; 'term_id', 'hide_empty' =&gt; true, 'order' ...
[ { "answer_id": 341414, "author": "ChristopherJones", "author_id": 168744, "author_profile": "https://wordpress.stackexchange.com/users/168744", "pm_score": 1, "selected": false, "text": "<p>Maybe I am wrong here, but <code>define( 'WP_DEBUG', true );</code> is still available and works i...
2019/06/25
[ "https://wordpress.stackexchange.com/questions/341419", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/134743/" ]
``` <div class="row"> <?php $taxonomyName = "product_tag"; if($taxonomyname = "latest-product"){ //This gets top layer terms only. This is done by setting parent to 0. $parent_terms = get_terms($taxonomyName, array('parent' => 0, 'orderby' => 'term_id', 'hide_empty' => true, 'order' => 'ASC')); foreach (...
You can disable this behaviour by setting `WP_DISABLE_FATAL_ERROR_HANDLER` to `true`: ``` define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); ``` This will stop the "The site is experiencing technical difficulties" message from appearing, so errors will appear as they did prior to this feature being added.
341,428
<p>So I'm trying to connect to an external db in order to access/update information located on a different non-wordpress database (oracle).</p> <p>I tried constructing a new wpdb object (as suggested by many other posts on stack exchange) like so:</p> <pre><code>function initialize_rgr_db() { global $rgr_db; $r...
[ { "answer_id": 341433, "author": "ChristopherJones", "author_id": 168744, "author_profile": "https://wordpress.stackexchange.com/users/168744", "pm_score": 1, "selected": false, "text": "<p>Have you tried the PDO Class yet?</p>\n\n<pre><code>$db = new PDO(\"sqlsrv:Server=YouAddress;Datab...
2019/06/25
[ "https://wordpress.stackexchange.com/questions/341428", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153230/" ]
So I'm trying to connect to an external db in order to access/update information located on a different non-wordpress database (oracle). I tried constructing a new wpdb object (as suggested by many other posts on stack exchange) like so: ``` function initialize_rgr_db() { global $rgr_db; $rgr_db = new wpdb('usr...
**You can't use `WPDB` to connect to databases that aren't MySQL/MariaDB based.** There are no WordPress APIs or WP based solutions that will do this. Instead you will need to use a general PHP solution inside your plugin, and should look at general PHP resources and communities, not WP ones. I can also guarantee, th...
341,460
<p>I want to run a script before any Wordpress stuff kicks in.</p> <p>I know it's wrong but currently I have my function in the <code>index.php</code> file before the below code:</p> <pre><code>{{{MY FUNCTION IS HERE}}} require 'vendor/autoload.php'; use GeoIp2\Database\Reader; session_start(); if (!isset($_SESSI...
[ { "answer_id": 341461, "author": "ChristopherJones", "author_id": 168744, "author_profile": "https://wordpress.stackexchange.com/users/168744", "pm_score": 1, "selected": false, "text": "<p><code>init</code> is not the first action to run on a WordPress install. Here is a basic rundown o...
2019/06/25
[ "https://wordpress.stackexchange.com/questions/341460", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/159870/" ]
I want to run a script before any Wordpress stuff kicks in. I know it's wrong but currently I have my function in the `index.php` file before the below code: ``` {{{MY FUNCTION IS HERE}}} require 'vendor/autoload.php'; use GeoIp2\Database\Reader; session_start(); if (!isset($_SESSION['country'])) { $reader = ...
`init` is not the first action to run on a WordPress install. Here is a basic rundown of a typical stack order. <https://codex.wordpress.org/Plugin_API/Action_Reference> Try hooking into `muplugins\_loaded'. I don't believe it is conditional, so it should run every time. <https://codex.wordpress.org/Plugin_API/Actio...
341,471
<p>I'm trying to create a nav menu with a clickable dropdown function but minimize scripting at the same time, so I found out a way to achieve this with an invisible input box and CSS. My only problem is I have no experience with PHP and getting the menu to load the right HTML is very frustrating (it took me forever ju...
[ { "answer_id": 341481, "author": "Joy Reynolds", "author_id": 43242, "author_profile": "https://wordpress.stackexchange.com/users/43242", "pm_score": 1, "selected": false, "text": "<p>I did this in my theme, so you can look at the whole code here: <a href=\"https://wordpress.org/themes/t...
2019/06/25
[ "https://wordpress.stackexchange.com/questions/341471", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170670/" ]
I'm trying to create a nav menu with a clickable dropdown function but minimize scripting at the same time, so I found out a way to achieve this with an invisible input box and CSS. My only problem is I have no experience with PHP and getting the menu to load the right HTML is very frustrating (it took me forever just ...
I did this in my theme, so you can look at the whole code here: <https://wordpress.org/themes/twenty8teen> I used the standard walker and added a filter for 'walker\_nav\_menu\_start\_el'. Of course, I also wanted it to work for the fallback Page menu, so I cloned the standard walker and added the call to `apply_filte...
341,474
<p>I'm not so good at coding but managed to write a little piece of code to have a shortcode to display a co-authors (co-authors plus plugin) bio/description in posts.</p> <p>The code I came up with is</p> <pre><code>&lt;?php function torque_hello_world_shortcode() { ?&gt; &lt;?php if ( function_exists( 'get_coauthor...
[ { "answer_id": 341481, "author": "Joy Reynolds", "author_id": 43242, "author_profile": "https://wordpress.stackexchange.com/users/43242", "pm_score": 1, "selected": false, "text": "<p>I did this in my theme, so you can look at the whole code here: <a href=\"https://wordpress.org/themes/t...
2019/06/26
[ "https://wordpress.stackexchange.com/questions/341474", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170688/" ]
I'm not so good at coding but managed to write a little piece of code to have a shortcode to display a co-authors (co-authors plus plugin) bio/description in posts. The code I came up with is ``` <?php function torque_hello_world_shortcode() { ?> <?php if ( function_exists( 'get_coauthors' ) ) ?> <?php $coauthors = g...
I did this in my theme, so you can look at the whole code here: <https://wordpress.org/themes/twenty8teen> I used the standard walker and added a filter for 'walker\_nav\_menu\_start\_el'. Of course, I also wanted it to work for the fallback Page menu, so I cloned the standard walker and added the call to `apply_filte...
341,482
<p>My plugin is throwing the error "Cannot use object of type WP_Error as array". The line in question is...</p> <pre><code>$http = new WP_Http(); $response = $http-&gt;request( $url, array('timeout' =&gt; 20)); if( $response['response']['code'] != 200 ) { // THIS IS THE LINE return false; } $upload = wp_upload...
[ { "answer_id": 341487, "author": "ngearing", "author_id": 50184, "author_profile": "https://wordpress.stackexchange.com/users/50184", "pm_score": 2, "selected": false, "text": "<p>Your logic for your updated if statement is wrong.</p>\n\n<p><code>if( !is_wp_error($response) &amp;&amp; $r...
2019/06/26
[ "https://wordpress.stackexchange.com/questions/341482", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/110183/" ]
My plugin is throwing the error "Cannot use object of type WP\_Error as array". The line in question is... ``` $http = new WP_Http(); $response = $http->request( $url, array('timeout' => 20)); if( $response['response']['code'] != 200 ) { // THIS IS THE LINE return false; } $upload = wp_upload_bits( basename($url...
Your logic for your updated if statement is wrong. `if( !is_wp_error($response) && $response['response']['code'] != 200 )` Here you are saying; if NOT wp\_error AND response code NOT 200 return false. So your not actually catching the WP\_Error I believe what you are after is something like: `if ( is_wp_error($resp...
341,485
<p>My wordpress page URL is like this </p> <p>https:www.com/thanks-page/?origin_name=Sydney&amp;origin_iata=SYD&amp;destination_name=Ahmedabad&amp;destination_iata=AMD</p> <p>I need to display SYD and AMD in to the page content like this..</p> <p>Flights from SYD to AMD... </p> <p>How can I display those two Param ...
[ { "answer_id": 341486, "author": "Nam Duong", "author_id": 167566, "author_profile": "https://wordpress.stackexchange.com/users/167566", "pm_score": 0, "selected": false, "text": "<p>You just use <code>$_GET[\"origin_iata\"]</code> and <code>$_GET[\"destination_iata\"]</code> to get thos...
2019/06/26
[ "https://wordpress.stackexchange.com/questions/341485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170697/" ]
My wordpress page URL is like this https:www.com/thanks-page/?origin\_name=Sydney&origin\_iata=SYD&destination\_name=Ahmedabad&destination\_iata=AMD I need to display SYD and AMD in to the page content like this.. Flights from SYD to AMD... How can I display those two Param query sting in to the actual wordpress ...
Simple, you can use $\_GET method. ``` if(isset($_GET["origin_iata"]) && !empty($_GET["origin_iata"]) && isset($_GET["destination_iata"]) && !empty($_GET["destination_iata"])) { echo "Flights from ".$_GET["origin_iata"]." to ".$_GET["destination_iata"]."..."; } ```
341,496
<p>My wordpress site sits behind Akamai, which is a cacheing service similar to Cloudflare. </p> <p>I make the following API call: </p> <pre><code>GET /wp-json/mytheme/v1/get-posts?post_type=videos </code></pre> <p>This is done using apiFetch from '@wordpress/api-fetch';</p> <p>And it automatically includes this in...
[ { "answer_id": 341640, "author": "thomas_jones", "author_id": 170751, "author_profile": "https://wordpress.stackexchange.com/users/170751", "pm_score": 3, "selected": true, "text": "<p>Based on the authentication documentation <a href=\"https://developer.wordpress.org/rest-api/using-the-...
2019/06/26
[ "https://wordpress.stackexchange.com/questions/341496", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162117/" ]
My wordpress site sits behind Akamai, which is a cacheing service similar to Cloudflare. I make the following API call: ``` GET /wp-json/mytheme/v1/get-posts?post_type=videos ``` This is done using apiFetch from '@wordpress/api-fetch'; And it automatically includes this in the request header ``` X-WP-Nonce: 123...
Based on the authentication documentation [here](https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/) - a nonce key needs to be passed with each request. So if the nonce key is being cached on the frontend beyond its lifespan, you will need to hook into the API request before the authenticatio...
341,500
<p>I'm working on small, vue based SPA. I'm using axios to get data from api that I'm interested about. The problem is that parameters are not working in any way, the same happens in Postman (I tried Postman because I thought that there is an error in my code, but there is not). Let's say I want to get posts from categ...
[ { "answer_id": 341683, "author": "thomas_jones", "author_id": 170751, "author_profile": "https://wordpress.stackexchange.com/users/170751", "pm_score": 1, "selected": false, "text": "<p>If results should be ordered by a method other than the default <code>asc</code> or <code>desc</code>,...
2019/06/26
[ "https://wordpress.stackexchange.com/questions/341500", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170710/" ]
I'm working on small, vue based SPA. I'm using axios to get data from api that I'm interested about. The problem is that parameters are not working in any way, the same happens in Postman (I tried Postman because I thought that there is an error in my code, but there is not). Let's say I want to get posts from category...
If results should be ordered by a method other than the default `asc` or `desc`, you should also pass the `orderby` parameter. This gives you the ability to order by title, date, parent, type and many more that can be seen [here](https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters). For e...
341,516
<p>I am Creating New Wordpress Plugin and splitting my code into different files for code management. Here is code of my main Plugin file which <code>my-best-plugin.php</code>with following code:</p> <pre><code>&lt;?php if ( ! defined('ABSPATH') ){ die; } if(!defined('MY_PLUGIN_PATH')) { ...
[ { "answer_id": 341683, "author": "thomas_jones", "author_id": 170751, "author_profile": "https://wordpress.stackexchange.com/users/170751", "pm_score": 1, "selected": false, "text": "<p>If results should be ordered by a method other than the default <code>asc</code> or <code>desc</code>,...
2019/06/26
[ "https://wordpress.stackexchange.com/questions/341516", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170724/" ]
I am Creating New Wordpress Plugin and splitting my code into different files for code management. Here is code of my main Plugin file which `my-best-plugin.php`with following code: ``` <?php if ( ! defined('ABSPATH') ){ die; } if(!defined('MY_PLUGIN_PATH')) { define( 'MY_PLUGIN_PATH', p...
If results should be ordered by a method other than the default `asc` or `desc`, you should also pass the `orderby` parameter. This gives you the ability to order by title, date, parent, type and many more that can be seen [here](https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters). For e...
341,532
<p>I am trying to modify a portfolio plugin with filter function. The current code for listing to post items is: </p> <pre><code>&lt;?php class FullwidthPortfolioGallery extends ET_Builder_Module { public $slug = 'fullwidth_portfolio_gallery'; public $vb_support = 'on'; protected $module_credits = ...
[ { "answer_id": 341683, "author": "thomas_jones", "author_id": 170751, "author_profile": "https://wordpress.stackexchange.com/users/170751", "pm_score": 1, "selected": false, "text": "<p>If results should be ordered by a method other than the default <code>asc</code> or <code>desc</code>,...
2019/06/26
[ "https://wordpress.stackexchange.com/questions/341532", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170731/" ]
I am trying to modify a portfolio plugin with filter function. The current code for listing to post items is: ``` <?php class FullwidthPortfolioGallery extends ET_Builder_Module { public $slug = 'fullwidth_portfolio_gallery'; public $vb_support = 'on'; protected $module_credits = array( 'm...
If results should be ordered by a method other than the default `asc` or `desc`, you should also pass the `orderby` parameter. This gives you the ability to order by title, date, parent, type and many more that can be seen [here](https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters). For e...
341,550
<p>I'd like to exclude a path that matches a rule from booting WordPress. The normal way I'd approach this is using the last flag <code>[L]</code> in a rule before all the others.</p> <p>To keep things simple in this example, I'll just pretend I want to match a simple path <code>/foo/</code>.</p> <pre><code>&lt;IfMod...
[ { "answer_id": 342001, "author": "T.Todua", "author_id": 33667, "author_profile": "https://wordpress.stackexchange.com/users/33667", "pm_score": 2, "selected": false, "text": "<p>You should use <code>RewriteCond</code> instead of <code>RewriteRule</code>. Use this:</p>\n\n<pre><code>Rewr...
2019/06/26
[ "https://wordpress.stackexchange.com/questions/341550", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18228/" ]
I'd like to exclude a path that matches a rule from booting WordPress. The normal way I'd approach this is using the last flag `[L]` in a rule before all the others. To keep things simple in this example, I'll just pretend I want to match a simple path `/foo/`. ``` <IfModule mod_rewrite.c> RewriteEngine On ``` ``` ...
One small hiccup is that you'll need to update `RewriteRule ./` in that second to last line. Here is an updated (and tested) snippet for you: ``` # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_URI} !^/foo/.*$ RewriteCond %{REQUEST_FILENAME...
341,557
<p>I'm working on a very simple theme. I have tried adding next and previous links and cannot get them to work.</p> <p>After trying a few different things, I ended up with this <code>index.php</code> (mostly based on answers on SO).</p> <pre><code>&lt;?php get_header(); ?&gt; &lt;!-- html stuff --&gt; &lt;?php ...
[ { "answer_id": 341558, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>Put the code block with all the prev/next links code inside the loop.</p>\n\n<p>The <code>get_previous...
2019/06/27
[ "https://wordpress.stackexchange.com/questions/341557", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/109240/" ]
I'm working on a very simple theme. I have tried adding next and previous links and cannot get them to work. After trying a few different things, I ended up with this `index.php` (mostly based on answers on SO). ``` <?php get_header(); ?> <!-- html stuff --> <?php if ( have_posts() ) { while ( have_...
As suggested by the default link labels, "Older Entries" and "Newer Entries", `get_next_posts_link()` and `get_next_posts_link()` are for outputting links between pages of posts. If you only have 2 posts, and your posts per page setting is set to anything higher than 1, then you're not going to have more than one page ...
341,608
<p>I have created a custom post type and I got it to show in the REST API. I have also registered a custom field using the following code :</p> <pre><code>function slug_get_post_meta_cb( $object, $field_name, $request ) { return get_post_meta( $object[ 'id' ], $field_name ); } function slug_update_post_meta_cb( ...
[ { "answer_id": 341612, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 3, "selected": true, "text": "<p>I haven't tested your code, but here the <code>$object</code> is an object and not array:</p>\n\n<pre class...
2019/06/27
[ "https://wordpress.stackexchange.com/questions/341608", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/130265/" ]
I have created a custom post type and I got it to show in the REST API. I have also registered a custom field using the following code : ``` function slug_get_post_meta_cb( $object, $field_name, $request ) { return get_post_meta( $object[ 'id' ], $field_name ); } function slug_update_post_meta_cb( $value, $objec...
I haven't tested your code, but here the `$object` is an object and not array: ```php // Here, $object is a WP_Post object. function slug_update_post_meta_cb( $value, $object, $field_name ) { return update_post_meta( $object->ID, $field_name, $value ); } ``` And you can actually use [`register_meta()`](https://d...
341,641
<p>Will <code>current_theme_supports()</code> return TRUE with a nonstandard <code>add_theme_support()</code> string?</p> <p>If I do this in my theme:</p> <pre><code>add_theme_support( 'my_funky_new_thing' ); </code></pre> <p>Can someone else writing a plugin do this?</p> <pre><code>if( current_theme_supports( 'my_...
[ { "answer_id": 341644, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 3, "selected": true, "text": "<p>Yes. You can take advantage of this to enable or disable features in your plugin if a theme does or does...
2019/06/27
[ "https://wordpress.stackexchange.com/questions/341641", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/109240/" ]
Will `current_theme_supports()` return TRUE with a nonstandard `add_theme_support()` string? If I do this in my theme: ``` add_theme_support( 'my_funky_new_thing' ); ``` Can someone else writing a plugin do this? ``` if( current_theme_supports( 'my_funky_new_thing' ) ){ // ... } ```
Yes. You can take advantage of this to enable or disable features in your plugin if a theme does or does not declare support for a feature. WooCommmerce is an example of a plugin that does this.
341,675
<p>Hey there WordPress community,</p> <p>Google page speed is moaning about dashicons.min.css being on our site. However, we need it for the Mega menu.</p> <p>I wanted to know if it's possible to move it to the footer.</p> <p>I have tried this code already:</p> <pre><code>add_action( 'wp_print_styles', 'my_deregist...
[ { "answer_id": 341681, "author": "Milan Hirpara", "author_id": 168898, "author_profile": "https://wordpress.stackexchange.com/users/168898", "pm_score": 1, "selected": true, "text": "<p>Please try below code :</p>\n\n<pre><code>add_action( 'wp_print_styles', 'my_deregister_styles' );\nfu...
2019/06/28
[ "https://wordpress.stackexchange.com/questions/341675", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/161219/" ]
Hey there WordPress community, Google page speed is moaning about dashicons.min.css being on our site. However, we need it for the Mega menu. I wanted to know if it's possible to move it to the footer. I have tried this code already: ``` add_action( 'wp_print_styles', 'my_deregister_styles' ); function my_deregiste...
Please try below code : ``` add_action( 'wp_print_styles', 'my_deregister_styles' ); function my_deregister_styles() { wp_deregister_style( 'dashicons' ); } ``` Replace your css path "PATH\_OF\_CSS" : ``` add_action( 'wp_footer', 'register_wp_footer', 11 ); function register_wp_footer() { wp_enqueue_st...
341,685
<p>This code goes into an infinite loop! What am i doing wrong? There is only one post called “hello there”. The only way to stop it is use <code>break;</code> in while.</p> <p>Any help appreciated</p> <pre><code> $gotop="hello there"; $args = array( 's' =&gt; $gotop, 'post_type' =&gt; 'post' ); $wp_query...
[ { "answer_id": 341687, "author": "Chetan Vaghela", "author_id": 169856, "author_profile": "https://wordpress.stackexchange.com/users/169856", "pm_score": 1, "selected": false, "text": "<p>add wp_reset_query(); after while loop. </p>\n\n<pre><code>$gotop=\"hello there\";\n\n$args = array...
2019/06/28
[ "https://wordpress.stackexchange.com/questions/341685", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170446/" ]
This code goes into an infinite loop! What am i doing wrong? There is only one post called “hello there”. The only way to stop it is use `break;` in while. Any help appreciated ``` $gotop="hello there"; $args = array( 's' => $gotop, 'post_type' => 'post' ); $wp_query = new WP_Query($args); if ( $wp_quer...
I'm not certain why it would cause an infinite loop, but make sure not to use `$wp_query` as the variable name for your custom query. It's a [reserved global variable](https://codex.wordpress.org/Global_Variables) for the main query. Use a different name for the variable. I'd also suggest using `wp_reset_postdata()` af...
341,726
<p>I'm rewording this because, as it's correctly been pointed out, the original post was "woefully inadequate." I made a plugin which has tabbed views for the various settings. It's based on this <a href="https://github.com/hlashbrooke/WordPress-Plugin-Template" rel="nofollow noreferrer">Wordpress Plugin Template</a>. ...
[ { "answer_id": 341687, "author": "Chetan Vaghela", "author_id": 169856, "author_profile": "https://wordpress.stackexchange.com/users/169856", "pm_score": 1, "selected": false, "text": "<p>add wp_reset_query(); after while loop. </p>\n\n<pre><code>$gotop=\"hello there\";\n\n$args = array...
2019/06/28
[ "https://wordpress.stackexchange.com/questions/341726", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119814/" ]
I'm rewording this because, as it's correctly been pointed out, the original post was "woefully inadequate." I made a plugin which has tabbed views for the various settings. It's based on this [Wordpress Plugin Template](https://github.com/hlashbrooke/WordPress-Plugin-Template). The template uses the WP Settings API to...
I'm not certain why it would cause an infinite loop, but make sure not to use `$wp_query` as the variable name for your custom query. It's a [reserved global variable](https://codex.wordpress.org/Global_Variables) for the main query. Use a different name for the variable. I'd also suggest using `wp_reset_postdata()` af...
341,742
<p>I have an activation hook to create 2 new database tables that don't exist, only the second table is created from this code:</p> <pre><code> public function add_tables() { // Global $wpdb global $wpdb; $wpdb-&gt;hide_errors(); // Require upgrade require_once( ABSPATH ....
[ { "answer_id": 341755, "author": "Faham Shaikh", "author_id": 147414, "author_profile": "https://wordpress.stackexchange.com/users/147414", "pm_score": 2, "selected": false, "text": "<p>One way to get it to work would be to do it like this:</p>\n\n<pre><code>global $wpdb;\n$wpdb-&gt;hide...
2019/06/29
[ "https://wordpress.stackexchange.com/questions/341742", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75779/" ]
I have an activation hook to create 2 new database tables that don't exist, only the second table is created from this code: ``` public function add_tables() { // Global $wpdb global $wpdb; $wpdb->hide_errors(); // Require upgrade require_once( ABSPATH . 'wp-admin/includ...
> > Why only the second? > > > Because `dbDelta()` supports `CREATE TABLE table_name` format only. I.e. Exactly "CREATE TABLE" followed by (one space and) the table name. More specifically, `dbDelta()` uses this regular expression pattern: `CREATE TABLE ([^ ]*)` when parsing the queries into an array indexed by t...
341,744
<p>Where i must put hooks in overridable functions for better child themes? Inside if statement or outside?</p> <pre><code>if( !function_exists( ovveridable_function() ) { function overridable_function() { echo 'Test'; } add_action( 'init', 'overridable_function' ); } </code></pre> <p><strong>OR</...
[ { "answer_id": 341750, "author": "Deepak Gupta", "author_id": 170346, "author_profile": "https://wordpress.stackexchange.com/users/170346", "pm_score": -1, "selected": false, "text": "<p>Try with outside if </p>\n\n<pre><code>function overridable_function() {\n echo 'Test';\n}\n...
2019/06/29
[ "https://wordpress.stackexchange.com/questions/341744", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/133897/" ]
Where i must put hooks in overridable functions for better child themes? Inside if statement or outside? ``` if( !function_exists( ovveridable_function() ) { function overridable_function() { echo 'Test'; } add_action( 'init', 'overridable_function' ); } ``` **OR** ``` if( !function_exists( ovve...
Neither. Hooked functions don’t need to be pluggable because child themes can already unhook and replace them with `remove_action()`. The main functions that you’d want to make pluggable are functions that are used in templates i.e. template tags, and those functions aren’t usually hooked, so the placement of `add_act...
341,757
<p>I have just started learning WP coding . So , I am trying to delete all custom posts on uninstall of my plugin . I have created uninstall.php in my plugin root and have the following : </p> <pre><code>&lt;?php if(!defined(WP_UNINSTALL_PLUGIN)){ die(); } // Delete Database $books= get_posts(['post_type'=&gt;...
[ { "answer_id": 341750, "author": "Deepak Gupta", "author_id": 170346, "author_profile": "https://wordpress.stackexchange.com/users/170346", "pm_score": -1, "selected": false, "text": "<p>Try with outside if </p>\n\n<pre><code>function overridable_function() {\n echo 'Test';\n}\n...
2019/06/29
[ "https://wordpress.stackexchange.com/questions/341757", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170935/" ]
I have just started learning WP coding . So , I am trying to delete all custom posts on uninstall of my plugin . I have created uninstall.php in my plugin root and have the following : ``` <?php if(!defined(WP_UNINSTALL_PLUGIN)){ die(); } // Delete Database $books= get_posts(['post_type'=>'book','numberposts'...
Neither. Hooked functions don’t need to be pluggable because child themes can already unhook and replace them with `remove_action()`. The main functions that you’d want to make pluggable are functions that are used in templates i.e. template tags, and those functions aren’t usually hooked, so the placement of `add_act...
341,769
<p>Having looked at <a href="https://wordpress.stackexchange.com/questions/36570/show-twentyeleven-header-image-only-on-home-page">Show TwentyEleven header image only on home page</a>, <a href="https://wordpress.stackexchange.com/questions/331138/replace-home-with-image-link-inside-custom-header-menu">Replace Home with...
[ { "answer_id": 341750, "author": "Deepak Gupta", "author_id": 170346, "author_profile": "https://wordpress.stackexchange.com/users/170346", "pm_score": -1, "selected": false, "text": "<p>Try with outside if </p>\n\n<pre><code>function overridable_function() {\n echo 'Test';\n}\n...
2019/06/29
[ "https://wordpress.stackexchange.com/questions/341769", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118869/" ]
Having looked at [Show TwentyEleven header image only on home page](https://wordpress.stackexchange.com/questions/36570/show-twentyeleven-header-image-only-on-home-page), [Replace Home with image link inside custom header menu](https://wordpress.stackexchange.com/questions/331138/replace-home-with-image-link-inside-cus...
Neither. Hooked functions don’t need to be pluggable because child themes can already unhook and replace them with `remove_action()`. The main functions that you’d want to make pluggable are functions that are used in templates i.e. template tags, and those functions aren’t usually hooked, so the placement of `add_act...
341,803
<p>Iam trying get selected variation from order.</p> <pre><code>global $order; $items = $order-&gt;get_items(); foreach( $items as $item ) { $product_id = $item-&gt;get_product_id(); $product = wc_get_product( $product_id ); if( $product-&gt;is_type( 'variable' ) ) { $variationName = $product-&gt...
[ { "answer_id": 341822, "author": "Maciej Rogosz", "author_id": 123145, "author_profile": "https://wordpress.stackexchange.com/users/123145", "pm_score": 0, "selected": false, "text": "<p>Why <strong>get_attribute()</strong>? Maybe you're looking for <strong>get_title()</strong>? This wou...
2019/06/30
[ "https://wordpress.stackexchange.com/questions/341803", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/133897/" ]
Iam trying get selected variation from order. ``` global $order; $items = $order->get_items(); foreach( $items as $item ) { $product_id = $item->get_product_id(); $product = wc_get_product( $product_id ); if( $product->is_type( 'variable' ) ) { $variationName = $product->get_attribute( 'pa_my-cus...
Following below code according your need > > To get the selected variation attributes using > get\_variation\_attributes( ) method. > > > ``` // Get an instance of the WC_Order object from an Order ID $order = wc_get_order( $order_id ); // Loop though order "line items" foreach( $order->get_items() as $item_id...
341,929
<p>in a class I have a function for save_post action. In this function I send an email. All this works except for querying the categories for that post:</p> <pre><code>class _new_notifications { public function __construct() { add_action( 'save_post', array( $this, 'send_new_post_notifications' ) ); ...
[ { "answer_id": 341822, "author": "Maciej Rogosz", "author_id": 123145, "author_profile": "https://wordpress.stackexchange.com/users/123145", "pm_score": 0, "selected": false, "text": "<p>Why <strong>get_attribute()</strong>? Maybe you're looking for <strong>get_title()</strong>? This wou...
2019/07/01
[ "https://wordpress.stackexchange.com/questions/341929", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/130709/" ]
in a class I have a function for save\_post action. In this function I send an email. All this works except for querying the categories for that post: ``` class _new_notifications { public function __construct() { add_action( 'save_post', array( $this, 'send_new_post_notifications' ) ); } pub...
Following below code according your need > > To get the selected variation attributes using > get\_variation\_attributes( ) method. > > > ``` // Get an instance of the WC_Order object from an Order ID $order = wc_get_order( $order_id ); // Loop though order "line items" foreach( $order->get_items() as $item_id...
341,933
<p>I am attempting to submit an Ajax call transfer the source URL of a selected image from a WordPress Media Library to PHP in my plugin settings page. Upon clicking save I'm constantly met with "error, bad request". Status 400 when attempting to call my AJAX URL. </p> <p>My AJAX URL is currently domain/wp-admin/admin...
[ { "answer_id": 341945, "author": "Milan Hirpara", "author_id": 168898, "author_profile": "https://wordpress.stackexchange.com/users/168898", "pm_score": 1, "selected": true, "text": "<p>Hi please try below code </p>\n\n<p>jquery :</p>\n\n<pre><code>$('#saveMediaButton').click(function(e)...
2019/07/02
[ "https://wordpress.stackexchange.com/questions/341933", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/146727/" ]
I am attempting to submit an Ajax call transfer the source URL of a selected image from a WordPress Media Library to PHP in my plugin settings page. Upon clicking save I'm constantly met with "error, bad request". Status 400 when attempting to call my AJAX URL. My AJAX URL is currently domain/wp-admin/admin-ajax.php ...
Hi please try below code jquery : ``` $('#saveMediaButton').click(function(e) { e.preventDefault(); $.ajax({ url : my_ajax_object.ajax_url, type : 'post', data : { action : 'action_upload_img', image_attachment_id : document....
341,957
<p>I have the following code in my <code>functions.php</code>. It works great: when a booking is made, it emails me. Simple. </p> <p><em>However</em>, I'd like it to send me the post ID for that booking rather than just a 'Hello World!' message. Help?</p> <pre><code>function add_to_system() { // get post meta //...
[ { "answer_id": 341959, "author": "Chetan Vaghela", "author_id": 169856, "author_profile": "https://wordpress.stackexchange.com/users/169856", "pm_score": -1, "selected": false, "text": "<p>try with this :</p>\n\n<pre><code>function add_to_system($appointment_id) {\n mail(\"michael.mcgu...
2019/07/02
[ "https://wordpress.stackexchange.com/questions/341957", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/171109/" ]
I have the following code in my `functions.php`. It works great: when a booking is made, it emails me. Simple. *However*, I'd like it to send me the post ID for that booking rather than just a 'Hello World!' message. Help? ``` function add_to_system() { // get post meta // $email = get_post_meta('',$post_id) ...
Only posting an alternative answer despite the question being about a 3rd-party plugin, whose source code isn't even freely available, because I don't believe the accepted answer is likely to be a good solution. It's not documented on their website, but a [comment from the developer](https://codecanyon.net/item/booked...
341,965
<p>Is it possible to call a function from functions.php in custom page or blog post? </p> <p>I put simple function in functions.php:</p> <pre><code>function testTest() { echo "Test"; } </code></pre> <p>And called it from the page:</p> <pre><code>&lt;?php testTest();?&gt; </code></pre> <p>But it doesn't work. Do I ...
[ { "answer_id": 341969, "author": "Michelle ", "author_id": 110232, "author_profile": "https://wordpress.stackexchange.com/users/110232", "pm_score": 3, "selected": true, "text": "<p>You could use <a href=\"https://codex.wordpress.org/Function_Reference/add_shortcode\" rel=\"nofollow nore...
2019/07/02
[ "https://wordpress.stackexchange.com/questions/341965", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/90955/" ]
Is it possible to call a function from functions.php in custom page or blog post? I put simple function in functions.php: ``` function testTest() { echo "Test"; } ``` And called it from the page: ``` <?php testTest();?> ``` But it doesn't work. Do I need to make a plugin to use simple function like that inside ...
You could use [add\_shortcode](https://codex.wordpress.org/Function_Reference/add_shortcode) if you want to use it within the editor. ``` function footag_func() { return "Test"; } add_shortcode( 'footag', 'footag_func' ); ``` And then use [footag] in your editor. Or Use code like this in functions.php and add ...
341,967
<p>For example: </p> <pre><code> $args = array( 'type' =&gt; 'string', 'description' =&gt; '', 'sanitize_callback' =&gt; null, 'show_in_rest' =&gt; true ); //Job Board Settings Info register_setting( 'jobboard-settings', 'company_name', $args ); </code></pre> <p>I have trou...
[ { "answer_id": 341968, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 1, "selected": false, "text": "<p>Settings are accessible through the <a href=\"https://developer.wordpress.org/rest-api/reference/settin...
2019/07/02
[ "https://wordpress.stackexchange.com/questions/341967", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/166650/" ]
For example: ``` $args = array( 'type' => 'string', 'description' => '', 'sanitize_callback' => null, 'show_in_rest' => true ); //Job Board Settings Info register_setting( 'jobboard-settings', 'company_name', $args ); ``` I have trouble figuring out which route these are...
Settings are accessible through the [Settings endpoint](https://developer.wordpress.org/rest-api/reference/settings/): ``` /wp-json/wp/v2/settings ```
342,148
<p>Where could I find an exhaustive list of javascript events defined by WooCommerce. ( Events like "woocommerce_variation_has_changed" )</p>
[ { "answer_id": 352171, "author": "jgangso", "author_id": 104184, "author_profile": "https://wordpress.stackexchange.com/users/104184", "pm_score": 8, "selected": true, "text": "<p>On a hunt for the same I took a little dive into the JS source files.</p>\n<h1>Woocommerce Javascript events...
2019/07/04
[ "https://wordpress.stackexchange.com/questions/342148", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82323/" ]
Where could I find an exhaustive list of javascript events defined by WooCommerce. ( Events like "woocommerce\_variation\_has\_changed" )
On a hunt for the same I took a little dive into the JS source files. Woocommerce Javascript events ============================= Woocommerce Checkout JS events ------------------------------ ``` $( document.body ).trigger( 'init_checkout' ); $( document.body ).trigger( 'payment_method_selected' ); $( document.body ...
342,168
<p>I use the latest version of wordpress under php7, I use a theme that uses itself the plugin WPBakery Page Builder (based on visual composer).</p> <p>I create a post that contains this:</p> <pre><code>[vc_row el_id="bloc-doc-a-telecharger"] [vc_column] [vc_basic_grid post_type="post" max_items="-1" styl...
[ { "answer_id": 342171, "author": "Oscprofessionals", "author_id": 171102, "author_profile": "https://wordpress.stackexchange.com/users/171102", "pm_score": -1, "selected": false, "text": "<p>use shortcode inside single quotes as:</p>\n\n<pre><code> do_shortcode('[my_short_code]');\n</cod...
2019/07/04
[ "https://wordpress.stackexchange.com/questions/342168", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/166674/" ]
I use the latest version of wordpress under php7, I use a theme that uses itself the plugin WPBakery Page Builder (based on visual composer). I create a post that contains this: ``` [vc_row el_id="bloc-doc-a-telecharger"] [vc_column] [vc_basic_grid post_type="post" max_items="-1" style="pagination" items_...
I finally found the problem, in fact when you add pagination to visual composer post-grid shortcode, it will use ajax to load the things. But to communicate to the ajax php script it uses the post id. The problem is that the shortcode will have no post id if you create it live, or another post id if you use an externa...
342,259
<p>I want to have various development (say <code>dev.example.com</code>) and staging environments of a WordPress multisite (<code>example.com</code>). For this it would be great if WordPress wouldn't redirect to what it considers the canonical domain name.</p> <p>I'm running into trouble with this in my <code>wp-confi...
[ { "answer_id": 343504, "author": "Haqa", "author_id": 167099, "author_profile": "https://wordpress.stackexchange.com/users/167099", "pm_score": 0, "selected": false, "text": "<p>From: <a href=\"http://www.velvetblues.com/web-development-blog/turn-off-wordpress-homepage-url-redirection/\"...
2019/07/05
[ "https://wordpress.stackexchange.com/questions/342259", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44793/" ]
I want to have various development (say `dev.example.com`) and staging environments of a WordPress multisite (`example.com`). For this it would be great if WordPress wouldn't redirect to what it considers the canonical domain name. I'm running into trouble with this in my `wp-config.php`: ``` define('DOMAIN_CURRENT_S...
In addition to modification of `wp-config` you might need to check `.htaccess` too, if there are any pointers to subfolder. After that, you might need to replace the values in DB tables `wp_site` and `wp_blogs`.
342,271
<p>I have been working on a project where I will have to call a method(that accepts user id as an input) from a click of a submit button(Accept button).</p> <p>I have been trying all the ways but the real challenge I am facing is how to get the user id in the front end and pass it to the method.</p> <p>My method upda...
[ { "answer_id": 342311, "author": "LebCit", "author_id": 102912, "author_profile": "https://wordpress.stackexchange.com/users/102912", "pm_score": 0, "selected": false, "text": "<p>You will need to use <a href=\"https://codex.wordpress.org/Function_Reference/wp_localize_script\" rel=\"nof...
2019/07/06
[ "https://wordpress.stackexchange.com/questions/342271", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/168253/" ]
I have been working on a project where I will have to call a method(that accepts user id as an input) from a click of a submit button(Accept button). I have been trying all the ways but the real challenge I am facing is how to get the user id in the front end and pass it to the method. My method updates the user meta...
You could use AJAX if you don't want to reload the current page — i.e. upon clicking the "Accept" button, make an AJAX request to update the user metadata, all without leaving the current page. However, the solution I'm proposing is *not* using AJAX; instead, we simply submit the form (set its `action` attribute value...
342,290
<p>I have added some code in header.php but it is not showing in shop page. It is showing all other pages.</p> <pre><code> if( is_home() || ! $ed_section || ! ( is_front_page() || is_page_template( 'template-home.php' ) ) ){ echo '&lt;div class = "container"&gt;&lt;div id="content" class="site-content"&gt; ...
[ { "answer_id": 342311, "author": "LebCit", "author_id": 102912, "author_profile": "https://wordpress.stackexchange.com/users/102912", "pm_score": 0, "selected": false, "text": "<p>You will need to use <a href=\"https://codex.wordpress.org/Function_Reference/wp_localize_script\" rel=\"nof...
2019/07/06
[ "https://wordpress.stackexchange.com/questions/342290", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170624/" ]
I have added some code in header.php but it is not showing in shop page. It is showing all other pages. ``` if( is_home() || ! $ed_section || ! ( is_front_page() || is_page_template( 'template-home.php' ) ) ){ echo '<div class = "container"><div id="content" class="site-content"> <div class="tab1"> <a clas...
You could use AJAX if you don't want to reload the current page — i.e. upon clicking the "Accept" button, make an AJAX request to update the user metadata, all without leaving the current page. However, the solution I'm proposing is *not* using AJAX; instead, we simply submit the form (set its `action` attribute value...
342,309
<p>I have a custom post type of Hotel. Hotels can be can be categorised with the taxonomy Resort. </p> <p>On my search page I need to be able to list hotels <strong>and</strong> taxonomy terms in the results, as separate results. eg:</p> <pre><code>Resort Name Hotel Name Hotel Name Hotel Name </code></pre> <p>Resort...
[ { "answer_id": 343204, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 2, "selected": false, "text": "<p>If you mean to have a display like this:</p>\n\n<pre><code>Hotels: Resort 1 &lt;- \"Resort 1\" is a term i...
2019/07/06
[ "https://wordpress.stackexchange.com/questions/342309", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22448/" ]
I have a custom post type of Hotel. Hotels can be can be categorised with the taxonomy Resort. On my search page I need to be able to list hotels **and** taxonomy terms in the results, as separate results. eg: ``` Resort Name Hotel Name Hotel Name Hotel Name ``` Resorts should come first, followed by hotels and an...
> > I just need to be able to spit out the term as a *result itself*, with > a link to the term (and be counted in the search count query). So if a > search matches a taxonomy term that should come first, followed by the > other results in whatever order. > > > `WP_Query::$posts` are `WP_Post` objects and can't...
342,315
<p>A custom page template which has been in use for 3 or 4 years which rendered a custom sidebar has suddenly stopped rendering it. I can't for the life work out what the problem is.</p> <pre><code>/* functions.php */ /** * Register Areas sidebars and widgetized areas. * */ function my_widgets_init() { regist...
[ { "answer_id": 342333, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 2, "selected": true, "text": "<p>In a case like this, you're probably going to need to check the conditions in <code>dynamic_sidebar</code> to f...
2019/07/06
[ "https://wordpress.stackexchange.com/questions/342315", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19216/" ]
A custom page template which has been in use for 3 or 4 years which rendered a custom sidebar has suddenly stopped rendering it. I can't for the life work out what the problem is. ``` /* functions.php */ /** * Register Areas sidebars and widgetized areas. * */ function my_widgets_init() { register_sidebar( ar...
In a case like this, you're probably going to need to check the conditions in `dynamic_sidebar` to find out what is not happening. ``` if (isset($_GET['debugsidebar'])) {add_action('init', 'debug_sidebar');} function debug_sidebar() { $id = $_GET['debugsidebar']; $sidebarswidgets = get_option('sidebars_widg...
342,344
<p>How do I extract just the post ID of the first item in whatever WP_Query returns? All the examples, answers, and documentation that I have seen dives off into doing things with loops. That's nice, but I just want the first ID. Nothing else. As the plugin will only ever generate a custom post type when there is none,...
[ { "answer_id": 342333, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 2, "selected": true, "text": "<p>In a case like this, you're probably going to need to check the conditions in <code>dynamic_sidebar</code> to f...
2019/07/07
[ "https://wordpress.stackexchange.com/questions/342344", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/109240/" ]
How do I extract just the post ID of the first item in whatever WP\_Query returns? All the examples, answers, and documentation that I have seen dives off into doing things with loops. That's nice, but I just want the first ID. Nothing else. As the plugin will only ever generate a custom post type when there is none, t...
In a case like this, you're probably going to need to check the conditions in `dynamic_sidebar` to find out what is not happening. ``` if (isset($_GET['debugsidebar'])) {add_action('init', 'debug_sidebar');} function debug_sidebar() { $id = $_GET['debugsidebar']; $sidebarswidgets = get_option('sidebars_widg...
342,365
<p>I embedded some code to generate post filters referencing an article at <a href="https://premium.wpmudev.org/blog/add-post-filters/" rel="nofollow noreferrer">https://premium.wpmudev.org/blog/add-post-filters/</a> as displayed below:</p> <pre><code>&lt;form class='post-filters'&gt; &lt;select name="orderby"&gt; &lt...
[ { "answer_id": 342366, "author": "Castiblanco", "author_id": 44370, "author_profile": "https://wordpress.stackexchange.com/users/44370", "pm_score": 0, "selected": false, "text": "<p>You are removing necessary parts of the code, you started opening <code>form</code> and <code>select</cod...
2019/07/08
[ "https://wordpress.stackexchange.com/questions/342365", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141638/" ]
I embedded some code to generate post filters referencing an article at <https://premium.wpmudev.org/blog/add-post-filters/> as displayed below: ``` <form class='post-filters'> <select name="orderby"> <?php $orderby_options = array( 'post_date' => 'Order By Date', 'post_title' => 'Order By Title', 'rand'...
It turns out the cause of this lingering filter problem was to do with the way WordPress was set up as well as the argument of `WP_Query`. Once I changed the *Your Homepage Displays* setting to the latest posts and renamed `front-page.php` to be `index.php`, the filter began working and the blank page no longer showed....
342,376
<p>I am trying to implement pagination for category items listing archive.php page. But this does not work. Below is the code that I am using.</p> <p><strong>Custom Query</strong>:</p> <pre><code>$cat = single_cat_title("", false); $cat_ID = get_cat_ID ($cat); $args = array( 'posts_per_page' =&gt; '2', 'p...
[ { "answer_id": 342366, "author": "Castiblanco", "author_id": 44370, "author_profile": "https://wordpress.stackexchange.com/users/44370", "pm_score": 0, "selected": false, "text": "<p>You are removing necessary parts of the code, you started opening <code>form</code> and <code>select</cod...
2019/07/08
[ "https://wordpress.stackexchange.com/questions/342376", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/171484/" ]
I am trying to implement pagination for category items listing archive.php page. But this does not work. Below is the code that I am using. **Custom Query**: ``` $cat = single_cat_title("", false); $cat_ID = get_cat_ID ($cat); $args = array( 'posts_per_page' => '2', 'post_type' => 'mathematics', 'cat'...
It turns out the cause of this lingering filter problem was to do with the way WordPress was set up as well as the argument of `WP_Query`. Once I changed the *Your Homepage Displays* setting to the latest posts and renamed `front-page.php` to be `index.php`, the filter began working and the blank page no longer showed....
342,393
<p>How to send an invoice with detailes to the customers when they payed via credit card using Stripe. I want when someone buy something, he or she will get an confirmation email with the details. </p> <p>Note: if it's possible can the customers pay via invoice with Credit Card instead of direct with Credit Card using...
[ { "answer_id": 342366, "author": "Castiblanco", "author_id": 44370, "author_profile": "https://wordpress.stackexchange.com/users/44370", "pm_score": 0, "selected": false, "text": "<p>You are removing necessary parts of the code, you started opening <code>form</code> and <code>select</cod...
2019/07/08
[ "https://wordpress.stackexchange.com/questions/342393", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/171497/" ]
How to send an invoice with detailes to the customers when they payed via credit card using Stripe. I want when someone buy something, he or she will get an confirmation email with the details. Note: if it's possible can the customers pay via invoice with Credit Card instead of direct with Credit Card using Stripe, b...
It turns out the cause of this lingering filter problem was to do with the way WordPress was set up as well as the argument of `WP_Query`. Once I changed the *Your Homepage Displays* setting to the latest posts and renamed `front-page.php` to be `index.php`, the filter began working and the blank page no longer showed....
342,399
<p>I'm working on a WP website with many CPTs and Custom Taxonomies, but also using the regular "post" post type for the regular blog section of the site.</p> <p>I want the blog posts and archive and categories to have /blog/ in their permalink, but also want to specify permalink structure for the other CPTs without t...
[ { "answer_id": 342366, "author": "Castiblanco", "author_id": 44370, "author_profile": "https://wordpress.stackexchange.com/users/44370", "pm_score": 0, "selected": false, "text": "<p>You are removing necessary parts of the code, you started opening <code>form</code> and <code>select</cod...
2019/07/08
[ "https://wordpress.stackexchange.com/questions/342399", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/171506/" ]
I'm working on a WP website with many CPTs and Custom Taxonomies, but also using the regular "post" post type for the regular blog section of the site. I want the blog posts and archive and categories to have /blog/ in their permalink, but also want to specify permalink structure for the other CPTs without the /blog/ ...
It turns out the cause of this lingering filter problem was to do with the way WordPress was set up as well as the argument of `WP_Query`. Once I changed the *Your Homepage Displays* setting to the latest posts and renamed `front-page.php` to be `index.php`, the filter began working and the blank page no longer showed....
342,409
<p>I have found a code here that will randomize the date of all posts to a random date. Here is the code that someone has posted:</p> <pre><code>&lt;?php /** * Plugin Name: WPSE 259750 Random Dates * Description: On activation, change the dates of all posts to random dates */ //* We want to do this only once, so a...
[ { "answer_id": 342366, "author": "Castiblanco", "author_id": 44370, "author_profile": "https://wordpress.stackexchange.com/users/44370", "pm_score": 0, "selected": false, "text": "<p>You are removing necessary parts of the code, you started opening <code>form</code> and <code>select</cod...
2019/07/08
[ "https://wordpress.stackexchange.com/questions/342409", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/171508/" ]
I have found a code here that will randomize the date of all posts to a random date. Here is the code that someone has posted: ``` <?php /** * Plugin Name: WPSE 259750 Random Dates * Description: On activation, change the dates of all posts to random dates */ //* We want to do this only once, so add hook to plugin...
It turns out the cause of this lingering filter problem was to do with the way WordPress was set up as well as the argument of `WP_Query`. Once I changed the *Your Homepage Displays* setting to the latest posts and renamed `front-page.php` to be `index.php`, the filter began working and the blank page no longer showed....
342,433
<p>I'm struggling to get tabbed plugin settings, created with WordPress Settings API to work.</p> <p>The first tab saves settings correctly. However, every time when I click on "Save Changes" button for any other tab, a white screen with the following error appears:</p> <blockquote> <p>ERROR: Options page not found...
[ { "answer_id": 342457, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 3, "selected": true, "text": "<h2>First Thing</h2>\n\n<blockquote>\n <p>The fields are registered only when the proper tab is selected to\n...
2019/07/08
[ "https://wordpress.stackexchange.com/questions/342433", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153903/" ]
I'm struggling to get tabbed plugin settings, created with WordPress Settings API to work. The first tab saves settings correctly. However, every time when I click on "Save Changes" button for any other tab, a white screen with the following error appears: > > ERROR: Options page not found > > > Chrome and Apach...
First Thing ----------- > > The fields are registered only when the proper tab is selected to > avoid resetting values in other tabs to defaults on save. > > > And because of that, you should pass the proper tab name/slug to the `wp-admin/options.php` page which is where the form is being submitted to. 1. You c...
342,458
<p>I'm trying to get some Javascript to run on one of my pages. But nothing I do seems to work. I ran the code in a sandbox and it is functional.</p> <p>I tried: - Inserting and HTML builder element and putting the code in tags - uploading the .js file in the theme and linking to it in my html code - Multiple script ...
[ { "answer_id": 342459, "author": "Oscprofessionals", "author_id": 171102, "author_profile": "https://wordpress.stackexchange.com/users/171102", "pm_score": 0, "selected": false, "text": "<p>add js file using function.php</p>\n\n<pre><code>function add_theme_scripts() {\n wp_enqueue_sc...
2019/07/09
[ "https://wordpress.stackexchange.com/questions/342458", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/167714/" ]
I'm trying to get some Javascript to run on one of my pages. But nothing I do seems to work. I ran the code in a sandbox and it is functional. I tried: - Inserting and HTML builder element and putting the code in tags - uploading the .js file in the theme and linking to it in my html code - Multiple script plugins Ho...
``` <?php function enqueue_javascript_for_certain_page() { $page_id = 100; // change this to fit your needs if ( is_page( $page_id ) ) { // check the page you are on wp_enqueue_script( 'my_script_name', // script handle get_template_directory_uri() . '/js/my-js-file.js', // sc...
342,479
<p>So I installed a fresh 5.2 WP and set up the Multisite network working with subdomains, then created 2 new test sites. </p> <p>From the outside all works great, I can browse the main site and the 2 test sites properly.</p> <p>On the admin panel though, I can go and change the main site settings tab under network a...
[ { "answer_id": 342498, "author": "robwatson_dev", "author_id": 137115, "author_profile": "https://wordpress.stackexchange.com/users/137115", "pm_score": 0, "selected": false, "text": "<p>I know this sounds ridiculous what I'm about to suggest but I've had a similar issue a number of time...
2019/07/09
[ "https://wordpress.stackexchange.com/questions/342479", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/171556/" ]
So I installed a fresh 5.2 WP and set up the Multisite network working with subdomains, then created 2 new test sites. From the outside all works great, I can browse the main site and the 2 test sites properly. On the admin panel though, I can go and change the main site settings tab under network admin -> Sites and...
I had the same problem - I found the rules in Apache modsecurity that include a set of exclusions for Wordpress didn't cover `/network/site-settings.php`, so I could do everything except edit sites in my multisite setup. In the file `/usr/share/modsecurity-crs/rules/REQUEST-903.9002-WORDPRESS-EXCLUSION-RULES.conf` I ad...
342,527
<p>I embedded standard code for pagination links and everything is working fine except that clicking the Previous or Page 1 link does not take me back to the first paginated page. This is different from other problems with pagination links reported elsewhere. </p> <p>The code for the pagination links is as follows:</p...
[ { "answer_id": 342530, "author": "Justin Waulters", "author_id": 137235, "author_profile": "https://wordpress.stackexchange.com/users/137235", "pm_score": 0, "selected": false, "text": "<p>It looks like <code>$current_page</code> can be a minimum of <code>1</code>. in the <a href=\"https...
2019/07/10
[ "https://wordpress.stackexchange.com/questions/342527", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141638/" ]
I embedded standard code for pagination links and everything is working fine except that clicking the Previous or Page 1 link does not take me back to the first paginated page. This is different from other problems with pagination links reported elsewhere. The code for the pagination links is as follows: ``` $to...
To get the canonical (not `?page=1`) reference URL to start the pagination from you have to change ``` 'base' => '%_%' ``` to ``` 'base' => get_pagenum_link() . '%_%' // get_pagenum_link() default is '1' ``` which will give you the first page of paginated posts and `%_%` will be replaced by `'format'` parameter o...
342,540
<p>I use a third party plugin and plugin has created a custom post type called "creations".</p> <p>Bu there is no archive page, there is no single page, there is no admin menu page... But data are saving on database correctly.</p> <p>Is there a possible way to the active admin menu, archive page &amp; single page? </...
[ { "answer_id": 342577, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 2, "selected": false, "text": "<p>If the plugin only registers the CPT, remove it and build your own.</p>\n\n<p>If the plugin does other th...
2019/07/10
[ "https://wordpress.stackexchange.com/questions/342540", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/123092/" ]
I use a third party plugin and plugin has created a custom post type called "creations". Bu there is no archive page, there is no single page, there is no admin menu page... But data are saving on database correctly. Is there a possible way to the active admin menu, archive page & single page? Other all behaviours ...
You can change [`register_post_type()`](https://codex.wordpress.org/Function_Reference/register_post_type#Arguments) arguments before the new type is created. To do this, use the [`register_post_type_args`](https://developer.wordpress.org/reference/hooks/register_post_type_args/) filter. ```php add_filter( 'register_p...
342,571
<p>Have a widget that's currently filtering a set of categories, and need to make it support more than one set of categories.</p> <p>Right now the code is something like this:</p> <pre><code>$query_args = array( 'post_type' =&gt; 'product', 'tax_query' =&gt; array( 'relation' =...
[ { "answer_id": 342580, "author": "honk31", "author_id": 10994, "author_profile": "https://wordpress.stackexchange.com/users/10994", "pm_score": 0, "selected": false, "text": "<p>you can nest multiple tax queries like so:</p>\n\n<pre><code>$query_args = array(\n 'post_type' =&gt; '...
2019/07/10
[ "https://wordpress.stackexchange.com/questions/342571", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60311/" ]
Have a widget that's currently filtering a set of categories, and need to make it support more than one set of categories. Right now the code is something like this: ``` $query_args = array( 'post_type' => 'product', 'tax_query' => array( 'relation' => 'AND', ar...
You can nest your tax queries. Just make sure you use `OR` as the first relation and `AND` relation on the nested tax queries. ``` $filter_group_a = array( 'relation' => 'AND', array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $term_a, ), array( 'taxonomy' => 'product_cat'...
342,654
<p>I'm trying to show related videos on my single post template. I've set up a custom taxonomy called 'sub-category' in Posts. I want to get the sub-category of the current post and loop through any posts with the same sub-category, outputting them to the page. Any ideas on the best way of achieving this?</p>
[ { "answer_id": 342656, "author": "Oscprofessionals", "author_id": 171102, "author_profile": "https://wordpress.stackexchange.com/users/171102", "pm_score": -1, "selected": false, "text": "<pre><code>function get_the_terms( $post, $taxonomy ) {\nif ( ! $post = get_post( $post ) ) {\n r...
2019/07/11
[ "https://wordpress.stackexchange.com/questions/342654", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/108167/" ]
I'm trying to show related videos on my single post template. I've set up a custom taxonomy called 'sub-category' in Posts. I want to get the sub-category of the current post and loop through any posts with the same sub-category, outputting them to the page. Any ideas on the best way of achieving this?
try with this function ``` function get_posts_in_taxonomy($post_type, $taxonomy, $term_id, $include_children=false, $limit) { $args = [ 'post_type' => $post_type, 'posts_per_page' => $limit, 'tax_query' => [ [ 'taxonomy' => $taxonomy, 'terms' => $term...
342,655
<p>first off, I am sorry if this question has been asked before, don't seem to get it.</p> <p>I would like to change the markup of link in Wordpress to something like this</p> <pre><code>&lt;a href="#" class="s1 s1--top" data-hint="tooltip here"&gt;Just Words.&lt;/a&gt; </code></pre> <p>Where the href would have tw...
[ { "answer_id": 342656, "author": "Oscprofessionals", "author_id": 171102, "author_profile": "https://wordpress.stackexchange.com/users/171102", "pm_score": -1, "selected": false, "text": "<pre><code>function get_the_terms( $post, $taxonomy ) {\nif ( ! $post = get_post( $post ) ) {\n r...
2019/07/11
[ "https://wordpress.stackexchange.com/questions/342655", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/167786/" ]
first off, I am sorry if this question has been asked before, don't seem to get it. I would like to change the markup of link in Wordpress to something like this ``` <a href="#" class="s1 s1--top" data-hint="tooltip here">Just Words.</a> ``` Where the href would have two extra classes, and I would be able to add w...
try with this function ``` function get_posts_in_taxonomy($post_type, $taxonomy, $term_id, $include_children=false, $limit) { $args = [ 'post_type' => $post_type, 'posts_per_page' => $limit, 'tax_query' => [ [ 'taxonomy' => $taxonomy, 'terms' => $term...
342,678
<p>Any help with this would be greatly appreciated - I've been grappling with it for days :)</p> <p>I have 2 post types - <code>product</code> + <code>offer</code></p> <p>I have an ACF relationship field <code>related_products</code>. </p> <p>This field returns an array of post IDs <code>Array ( [0] =&gt; 395 [1] =&...
[ { "answer_id": 342692, "author": "Faye", "author_id": 76600, "author_profile": "https://wordpress.stackexchange.com/users/76600", "pm_score": 2, "selected": false, "text": "<p>I could be wrong, but it looks like you're trying to do something much simpler than what you've got going there....
2019/07/11
[ "https://wordpress.stackexchange.com/questions/342678", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Any help with this would be greatly appreciated - I've been grappling with it for days :) I have 2 post types - `product` + `offer` I have an ACF relationship field `related_products`. This field returns an array of post IDs `Array ( [0] => 395 [1] => 120 [2] => 388 [3] => 391 )` I am using `related_products` on t...
My OP is about using the ACF relationship field in `WP_QUERY`. The ACF documentation leaves out one helpful bit that @JacobPeattie supplied. My final working code looks like this: ``` // ACF field is set to return IDs. // Array ( [0] => 395 [1] => 120 [2] => 388 [3] => 391 ) $related_product = get_field( 'related_p...
342,704
<p>Using latest WP with Gutenberg. The excerpt metabox is (as you'd expect) over in the right column with the Document settings.</p> <p>Is there any way to get it out of that column and into the main area where the textarea would then be of a <em>useful</em> size?</p>
[ { "answer_id": 342692, "author": "Faye", "author_id": 76600, "author_profile": "https://wordpress.stackexchange.com/users/76600", "pm_score": 2, "selected": false, "text": "<p>I could be wrong, but it looks like you're trying to do something much simpler than what you've got going there....
2019/07/12
[ "https://wordpress.stackexchange.com/questions/342704", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105507/" ]
Using latest WP with Gutenberg. The excerpt metabox is (as you'd expect) over in the right column with the Document settings. Is there any way to get it out of that column and into the main area where the textarea would then be of a *useful* size?
My OP is about using the ACF relationship field in `WP_QUERY`. The ACF documentation leaves out one helpful bit that @JacobPeattie supplied. My final working code looks like this: ``` // ACF field is set to return IDs. // Array ( [0] => 395 [1] => 120 [2] => 388 [3] => 391 ) $related_product = get_field( 'related_p...
342,713
<p>How can I put a loop in my single.php that shows the posts of the current category of the single and following the code structure that I have? The question comes, because I can not find the correct code.</p> <p>I have tried with this code</p> <pre><code>&lt;?php $categories = get_the_category($post-&gt;ID); if (...
[ { "answer_id": 342714, "author": "Bhupen", "author_id": 128529, "author_profile": "https://wordpress.stackexchange.com/users/128529", "pm_score": -1, "selected": false, "text": "<p>If you are trying to get \"Related Posts\" by category for custom taxonomy then see the code given below:</...
2019/07/12
[ "https://wordpress.stackexchange.com/questions/342713", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/149472/" ]
How can I put a loop in my single.php that shows the posts of the current category of the single and following the code structure that I have? The question comes, because I can not find the correct code. I have tried with this code ``` <?php $categories = get_the_category($post->ID); if ( $categories ) { $category...
I suggest the following: ``` $categories = get_the_category(); $category_ids = wp_list_pluck( $categories, 'term_id' ); $args = [ 'numberposts' => 4, 'category__in' => $category_ids, ]; $related_posts = get_posts( $args ); $related_posts = wp_list_filter( $related_posts, [ 'ID' => get_queried_oject_id() ]...
342,743
<p>How can I prevent my custom user role to not be able to add new pages.</p> <p>I have this array of capabilities for my user role:</p> <pre><code> $args = array( 'delete_others_pages' =&gt; false, 'delete_others_posts' =&gt; false, 'delete_pages' =&gt; false, 'delete_posts' =&gt; ...
[ { "answer_id": 342744, "author": "Oscprofessionals", "author_id": 171102, "author_profile": "https://wordpress.stackexchange.com/users/171102", "pm_score": -1, "selected": false, "text": "<blockquote>\n <p>this parameter should work for this</p>\n</blockquote>\n\n<pre><code>'publish_pag...
2019/07/12
[ "https://wordpress.stackexchange.com/questions/342743", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/169647/" ]
How can I prevent my custom user role to not be able to add new pages. I have this array of capabilities for my user role: ``` $args = array( 'delete_others_pages' => false, 'delete_others_posts' => false, 'delete_pages' => false, 'delete_posts' => true, 'delete_private_pag...
Post types in WordPress have a list of capabilities that govern permissions surrounding them. These are: ``` edit_post read_post delete_post edit_posts edit_others_posts publish_posts read_private_posts read delete_posts delete_private_posts delete_published_posts delete_others_posts edit_private_posts edit_published_...
342,791
<p>I have the plugin iThemes Security Pro installed on a couple of my websites. Recently, I've noticed that my Sucuri SiteCheck (both automated and not) scans are failing, but I have no idea why that is the case. The log is also ambiguous, telling me: <code>Unable to properly scan your site. Timeout reached</code>.</p>...
[ { "answer_id": 342744, "author": "Oscprofessionals", "author_id": 171102, "author_profile": "https://wordpress.stackexchange.com/users/171102", "pm_score": -1, "selected": false, "text": "<blockquote>\n <p>this parameter should work for this</p>\n</blockquote>\n\n<pre><code>'publish_pag...
2019/07/13
[ "https://wordpress.stackexchange.com/questions/342791", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/78806/" ]
I have the plugin iThemes Security Pro installed on a couple of my websites. Recently, I've noticed that my Sucuri SiteCheck (both automated and not) scans are failing, but I have no idea why that is the case. The log is also ambiguous, telling me: `Unable to properly scan your site. Timeout reached`. Below is the raw...
Post types in WordPress have a list of capabilities that govern permissions surrounding them. These are: ``` edit_post read_post delete_post edit_posts edit_others_posts publish_posts read_private_posts read delete_posts delete_private_posts delete_published_posts delete_others_posts edit_private_posts edit_published_...
342,804
<p>Im looking to edit a parent theme, and not just the functions and style files. I find that child themes don’t have the flexibility i want. How can i edit the parent theme without all the risk and the possibility of an update overriding all my changes?</p>
[ { "answer_id": 342744, "author": "Oscprofessionals", "author_id": 171102, "author_profile": "https://wordpress.stackexchange.com/users/171102", "pm_score": -1, "selected": false, "text": "<blockquote>\n <p>this parameter should work for this</p>\n</blockquote>\n\n<pre><code>'publish_pag...
2019/07/13
[ "https://wordpress.stackexchange.com/questions/342804", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170494/" ]
Im looking to edit a parent theme, and not just the functions and style files. I find that child themes don’t have the flexibility i want. How can i edit the parent theme without all the risk and the possibility of an update overriding all my changes?
Post types in WordPress have a list of capabilities that govern permissions surrounding them. These are: ``` edit_post read_post delete_post edit_posts edit_others_posts publish_posts read_private_posts read delete_posts delete_private_posts delete_published_posts delete_others_posts edit_private_posts edit_published_...
342,867
<p>My need is to have a <code>.php</code> file that is located in the root folders of all WordPress websites I manage, which can flush all cache of all sites.</p> <p>Therefore, I created a file "flush-cache.php" in the root folder of the first website, and I added the following code: </p> <pre><code>&lt;?php /** * F...
[ { "answer_id": 343472, "author": "codingforworlddomination", "author_id": 171633, "author_profile": "https://wordpress.stackexchange.com/users/171633", "pm_score": 1, "selected": false, "text": "<p>The working solution is:</p>\n\n<pre><code>&lt;?php\n/*\n * Flushing the W3TC Plugin's Cac...
2019/07/15
[ "https://wordpress.stackexchange.com/questions/342867", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/171633/" ]
My need is to have a `.php` file that is located in the root folders of all WordPress websites I manage, which can flush all cache of all sites. Therefore, I created a file "flush-cache.php" in the root folder of the first website, and I added the following code: ``` <?php /** * Flushing the W3TC Plugin's Cache ent...
The working solution is: ``` <?php /* * Flushing the W3TC Plugin's Cache entirely * @package WordPress */ ignore_user_abort( true ); include('/home/clients/<client-directory>/<website-directory>' . '/wp-load.php'); w3tc_flush_all(); ```
342,940
<p>I'm just starting to create new theme and i'm new to code. I'm stuck in customizing the post thumbnail code, i tried add </p> <pre><code>&lt;?php previous_post_link(get_the_post_thumbnail(get_previous_post(), array( 'class' =&gt; 'rounded-lg object-cover' )) . '&lt;h4 class="text...
[ { "answer_id": 342941, "author": "haiz85", "author_id": 171911, "author_profile": "https://wordpress.stackexchange.com/users/171911", "pm_score": -1, "selected": false, "text": "<p>i think i already fix it, and now i have problem with customizing image width and height, here are my lates...
2019/07/16
[ "https://wordpress.stackexchange.com/questions/342940", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/171911/" ]
I'm just starting to create new theme and i'm new to code. I'm stuck in customizing the post thumbnail code, i tried add ``` <?php previous_post_link(get_the_post_thumbnail(get_previous_post(), array( 'class' => 'rounded-lg object-cover' )) . '<h4 class="text-center">%link</h4>', ...
Sorry for late reply, already fixed, i miss understood about array, so here the code that completely run as i want it. ``` <?php $next_post = get_next_post(); next_post_link('%link', get_the_post_thumbnail($next_post->ID, 'prev_next_img', array( 'class' => 'rounded-lg object-fill w-full max-h-f...
342,978
<p>I want to get the Woocommerce variable product variation name. If, for example, I have a product that is available in different sizes: small, medium and large. Then I would like to print for example "large". I have almost got it to work. The problem is, I also get the product name at the same time like: "Product na...
[ { "answer_id": 342983, "author": "Chetan Vaghela", "author_id": 169856, "author_profile": "https://wordpress.stackexchange.com/users/169856", "pm_score": -1, "selected": false, "text": "<p>Please try below code. it will output a variation name of attribute size by variation id.</p>\n\n<p...
2019/07/16
[ "https://wordpress.stackexchange.com/questions/342978", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162231/" ]
I want to get the Woocommerce variable product variation name. If, for example, I have a product that is available in different sizes: small, medium and large. Then I would like to print for example "large". I have almost got it to work. The problem is, I also get the product name at the same time like: "Product name ...
> > i have tested below code it works properly for variation name > > > ``` $variationId = 39; $variation = new WC_Product_Variation($variationId); $variationName = implode(" / ", $variation->get_variation_attributes()); echo $variationName; ```
343,037
<p>I am writing a migration script which has to read the post_content of posts and then dynamically change some attributes of some custom Gutenberg blocks.</p> <p>I was able to read the post_content and then convert them into block objects by using the <code>parse_blocks</code> function. I was also able to dynamically...
[ { "answer_id": 343330, "author": "SkyShab", "author_id": 63263, "author_profile": "https://wordpress.stackexchange.com/users/63263", "pm_score": 4, "selected": true, "text": "<p>This markup is generated on the js side of things and saved in the content of the block editor, which is why t...
2019/07/17
[ "https://wordpress.stackexchange.com/questions/343037", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24579/" ]
I am writing a migration script which has to read the post\_content of posts and then dynamically change some attributes of some custom Gutenberg blocks. I was able to read the post\_content and then convert them into block objects by using the `parse_blocks` function. I was also able to dynamically change the attribu...
This markup is generated on the js side of things and saved in the content of the block editor, which is why there doesn't seem to be a native PHP function for this. However, I found a PHP method that does exactly this in an "experimental" class in the Gutenberg plugin. You can see this here: <https://github.com/Word...
343,055
<p>I have a SQL query that get all events ordering by Startdate, and i define startday as $today.</p> <p>but this query didn't take events that start yestarday and that endday is tomorow.</p> <p>how can i make my query to use BETWEEN ?</p> <p>my query </p> <pre><code>SELECT * FROM wp_posts, `wp_mec_dates` AS mecd, ...
[ { "answer_id": 343059, "author": "user2243593", "author_id": 56443, "author_profile": "https://wordpress.stackexchange.com/users/56443", "pm_score": -1, "selected": false, "text": "<p>Try this </p>\n\n<pre><code>WHERE dstart BETWEEN '$startdate' AND '$enddate'\n</code></pre>\n" }, { ...
2019/07/17
[ "https://wordpress.stackexchange.com/questions/343055", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/139936/" ]
I have a SQL query that get all events ordering by Startdate, and i define startday as $today. but this query didn't take events that start yestarday and that endday is tomorow. how can i make my query to use BETWEEN ? my query ``` SELECT * FROM wp_posts, `wp_mec_dates` AS mecd, wp_icl_translations WHERE wp_posts....
found the solution <3 Used WHERE '$startday' BETWEEN dstart AND dend plus : OR dstart >= '$startday' ``` SELECT * FROM wp_posts, wp_mec_dates AS mecd, wp_icl_translations WHERE wp_posts.ID = mecd.post_id and post_status='publish' AND wp_icl_translations.language_code='$lang' AND ('$startday' BETWEEN dstart AND dend ...
343,123
<p>I want to remove the WordPress tag from the From section in when using the contact 7 plugin on WordPress. How can i do this?</p> <p><a href="https://i.stack.imgur.com/rKHaW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rKHaW.png" alt="wordpress email from tag"></a></p> <p>See below for the set...
[ { "answer_id": 343059, "author": "user2243593", "author_id": 56443, "author_profile": "https://wordpress.stackexchange.com/users/56443", "pm_score": -1, "selected": false, "text": "<p>Try this </p>\n\n<pre><code>WHERE dstart BETWEEN '$startdate' AND '$enddate'\n</code></pre>\n" }, { ...
2019/07/18
[ "https://wordpress.stackexchange.com/questions/343123", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/172055/" ]
I want to remove the WordPress tag from the From section in when using the contact 7 plugin on WordPress. How can i do this? [![wordpress email from tag](https://i.stack.imgur.com/rKHaW.png)](https://i.stack.imgur.com/rKHaW.png) See below for the settings I use for the Contact 7 Plugin. [![enter image description he...
found the solution <3 Used WHERE '$startday' BETWEEN dstart AND dend plus : OR dstart >= '$startday' ``` SELECT * FROM wp_posts, wp_mec_dates AS mecd, wp_icl_translations WHERE wp_posts.ID = mecd.post_id and post_status='publish' AND wp_icl_translations.language_code='$lang' AND ('$startday' BETWEEN dstart AND dend ...
343,182
<p>I have custom fields in the user profile that displays in the team page. It reads "director" "researcher" "graduate" "intern" and some others. When adding a new team member, you pick from a select box with the options.</p> <p>Right now the page displays the users in date of creation order but I need to show them in...
[ { "answer_id": 343197, "author": "Faham Shaikh", "author_id": 147414, "author_profile": "https://wordpress.stackexchange.com/users/147414", "pm_score": 2, "selected": true, "text": "<p>@CynthiaLara</p>\n\n<p>I suppose that you are using a container of <code>WP_USER_QUERY::__construct</co...
2019/07/18
[ "https://wordpress.stackexchange.com/questions/343182", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34034/" ]
I have custom fields in the user profile that displays in the team page. It reads "director" "researcher" "graduate" "intern" and some others. When adding a new team member, you pick from a select box with the options. Right now the page displays the users in date of creation order but I need to show them in hierarchy...
@CynthiaLara I suppose that you are using a container of `WP_USER_QUERY::__construct` in the form or `WP_USER_QUERY` or `get_users` or something to that effect. You can use `'meta_key' => '<YOUR_DESIGNATION_META_KEY>','orderby' => 'meta_value_num,` to get results sorted by your meta key's value. If you have used a t...
343,213
<p>please I would like some help about these 2 options:</p> <p>1) how could I show add to cart button instead of "VEDI PRODOTTO" (view product) button?</p> <p>2) how could I display on the left the units (number with "+" and "-") to add for each product with add to cart button on the right?</p> <p>If you know a plug...
[ { "answer_id": 343232, "author": "Tanmay Patel", "author_id": 62026, "author_profile": "https://wordpress.stackexchange.com/users/62026", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p><strong>Point 1:</strong> To change \"VEDI PRODOTTO\" (view product) button instead of \...
2019/07/19
[ "https://wordpress.stackexchange.com/questions/343213", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/172119/" ]
please I would like some help about these 2 options: 1) how could I show add to cart button instead of "VEDI PRODOTTO" (view product) button? 2) how could I display on the left the units (number with "+" and "-") to add for each product with add to cart button on the right? If you know a plugin or some php code work...
> > **Point 1:** To change "VEDI PRODOTTO" (view product) button instead of "Add to Cart" button on product archives: Put below code in **functions.php** file. > > > ``` remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); add_action('woocommerce_after_shop_loop_item', 'add...
343,231
<p>I can make wordpress website but I have an issue with this. I want to fetch data from another third party website to my own wordpress site with the mysql database. I want to fetch only one table with the dynamic entries form the third party website.</p>
[ { "answer_id": 343234, "author": "Abdul Rafay", "author_id": 172133, "author_profile": "https://wordpress.stackexchange.com/users/172133", "pm_score": 0, "selected": false, "text": "<p>You should have a remote mysql option in your cpanel to allow you to do that if not then you may ask yo...
2019/07/19
[ "https://wordpress.stackexchange.com/questions/343231", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/172130/" ]
I can make wordpress website but I have an issue with this. I want to fetch data from another third party website to my own wordpress site with the mysql database. I want to fetch only one table with the dynamic entries form the third party website.
You can set up a new connection from function: ``` $wpdb_b = new wpdb( "user", "password", "brian_db", "localhost" ); $wpdb_b->get_results( "SELECT * FROM brian_table" ); ``` Happy Coding
343,249
<p>I add this code on my website </p> <pre><code>[display-posts image_size="thumbnail" wrapper="div" wrapper_class="display-posts-listing grid" meta_key="_thumbnail_id" display-post category="&lt;code&gt;αρχείο-εκδηλώσεων&lt;/code&gt;" posts_per_page="20" display-posts include_excerpt="true" excerpt_len...
[ { "answer_id": 343234, "author": "Abdul Rafay", "author_id": 172133, "author_profile": "https://wordpress.stackexchange.com/users/172133", "pm_score": 0, "selected": false, "text": "<p>You should have a remote mysql option in your cpanel to allow you to do that if not then you may ask yo...
2019/07/19
[ "https://wordpress.stackexchange.com/questions/343249", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/172149/" ]
I add this code on my website ``` [display-posts image_size="thumbnail" wrapper="div" wrapper_class="display-posts-listing grid" meta_key="_thumbnail_id" display-post category="<code>αρχείο-εκδηλώσεων</code>" posts_per_page="20" display-posts include_excerpt="true" excerpt_length="15" excerpt_more...
You can set up a new connection from function: ``` $wpdb_b = new wpdb( "user", "password", "brian_db", "localhost" ); $wpdb_b->get_results( "SELECT * FROM brian_table" ); ``` Happy Coding
343,324
<p>How I can update Existing (Back-End) metabox variable from front-End, I tried many times but I don't know why doesn't this work? Showing only old value not update, what i did wrong?</p> <p>This is my Front-End Page, I'm using this code inside normal Page With shortCode and also this code between post loop.</p> <pr...
[ { "answer_id": 343234, "author": "Abdul Rafay", "author_id": 172133, "author_profile": "https://wordpress.stackexchange.com/users/172133", "pm_score": 0, "selected": false, "text": "<p>You should have a remote mysql option in your cpanel to allow you to do that if not then you may ask yo...
2019/07/21
[ "https://wordpress.stackexchange.com/questions/343324", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/149857/" ]
How I can update Existing (Back-End) metabox variable from front-End, I tried many times but I don't know why doesn't this work? Showing only old value not update, what i did wrong? This is my Front-End Page, I'm using this code inside normal Page With shortCode and also this code between post loop. ``` if ( isset( $...
You can set up a new connection from function: ``` $wpdb_b = new wpdb( "user", "password", "brian_db", "localhost" ); $wpdb_b->get_results( "SELECT * FROM brian_table" ); ``` Happy Coding
343,355
<p>So when I am creating a post, I would like to only be able to see images (after clicking ,add media above wp editor) that have been uploaded and attached to posts of the same family of the current post i'm creating.</p> <p>My current code does not seem to work.</p> <pre><code>global $post; $parentID = $post-&gt;p...
[ { "answer_id": 343234, "author": "Abdul Rafay", "author_id": 172133, "author_profile": "https://wordpress.stackexchange.com/users/172133", "pm_score": 0, "selected": false, "text": "<p>You should have a remote mysql option in your cpanel to allow you to do that if not then you may ask yo...
2019/07/22
[ "https://wordpress.stackexchange.com/questions/343355", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29133/" ]
So when I am creating a post, I would like to only be able to see images (after clicking ,add media above wp editor) that have been uploaded and attached to posts of the same family of the current post i'm creating. My current code does not seem to work. ``` global $post; $parentID = $post->post_parent; //Shows 2068...
You can set up a new connection from function: ``` $wpdb_b = new wpdb( "user", "password", "brian_db", "localhost" ); $wpdb_b->get_results( "SELECT * FROM brian_table" ); ``` Happy Coding
343,388
<p>I have the following really simple code:</p> <pre><code>function load_peoplesoft_results() { global $wpdb; echo "&lt;h2&gt;Results&lt;/h2&gt;"; } add_shortcode('load_peoplesoft_result_page', 'load_peoplesoft_results()'); </code></pre> <p>And I put the following on the page I want to display the page:</p> ...
[ { "answer_id": 343392, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 1, "selected": true, "text": "<p>Your shortcode callback function is incorrect:</p>\n\n<pre><code>add_shortcode('load_peoplesoft_result_p...
2019/07/22
[ "https://wordpress.stackexchange.com/questions/343388", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154429/" ]
I have the following really simple code: ``` function load_peoplesoft_results() { global $wpdb; echo "<h2>Results</h2>"; } add_shortcode('load_peoplesoft_result_page', 'load_peoplesoft_results()'); ``` And I put the following on the page I want to display the page: ``` [load_peoplesoft_result_page] ``` B...
Your shortcode callback function is incorrect: ``` add_shortcode('load_peoplesoft_result_page', 'load_peoplesoft_results()'); ``` You've included the `()`, but only the function name should be passed: ``` add_shortcode( 'load_peoplesoft_result_page', 'load_peoplesoft_results' ); ``` Note that the second argument ...
343,389
<p>I am working on a WordPress that someone else started and then disappeared. She created a few custom content types and variables using different plugins and I now want to access the data sets in the functions she created for her template.</p> <pre><code>$args = array( 'suppress_filters' =&gt; 0, ...
[ { "answer_id": 343392, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 1, "selected": true, "text": "<p>Your shortcode callback function is incorrect:</p>\n\n<pre><code>add_shortcode('load_peoplesoft_result_p...
2019/07/22
[ "https://wordpress.stackexchange.com/questions/343389", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/161748/" ]
I am working on a WordPress that someone else started and then disappeared. She created a few custom content types and variables using different plugins and I now want to access the data sets in the functions she created for her template. ``` $args = array( 'suppress_filters' => 0, 'pos...
Your shortcode callback function is incorrect: ``` add_shortcode('load_peoplesoft_result_page', 'load_peoplesoft_results()'); ``` You've included the `()`, but only the function name should be passed: ``` add_shortcode( 'load_peoplesoft_result_page', 'load_peoplesoft_results' ); ``` Note that the second argument ...
343,394
<p>I have a database of <code>50,000 articles</code>, One of my categories contains <code>post of 30k</code>, I mistakenly Deleted a category that contains 30k Post, But all the posts still exist.</p> <p>I have search google for the past 2days now but I still can't find a way to move this 30k to a new category I just ...
[ { "answer_id": 343396, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 1, "selected": false, "text": "<p>Option 1: backup - Many hosts offer backups. Sometimes you have to pay for them, but often even when you ...
2019/07/22
[ "https://wordpress.stackexchange.com/questions/343394", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/159376/" ]
I have a database of `50,000 articles`, One of my categories contains `post of 30k`, I mistakenly Deleted a category that contains 30k Post, But all the posts still exist. I have search google for the past 2days now but I still can't find a way to move this 30k to a new category I just created. Please help me out, I ...
Option 1: backup - Many hosts offer backups. Sometimes you have to pay for them, but often even when you do, they've actually been backing everything up and paying just allows you to access them. Worth checking as this will be fastest. Option 2: post listing screen - If these posts all had only 1 category, the one tha...
343,432
<p>I have a custom post type with a custom taxonomy that has been working fine for years, but recently I've seen that the <strong>custom taxonomy doesn't show up in the individual custom post type anymore</strong>. However, it does show up in the listing and I can quick edit it just fine.</p> <p><a href="https://i.sta...
[ { "answer_id": 343434, "author": "Joel Garcia Nuño", "author_id": 135555, "author_profile": "https://wordpress.stackexchange.com/users/135555", "pm_score": 0, "selected": false, "text": "<p>I think so that will help you.</p>\n\n<p><strong><em>setup at register_taxonomy $args:</em></stron...
2019/07/22
[ "https://wordpress.stackexchange.com/questions/343432", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3577/" ]
I have a custom post type with a custom taxonomy that has been working fine for years, but recently I've seen that the **custom taxonomy doesn't show up in the individual custom post type anymore**. However, it does show up in the listing and I can quick edit it just fine. [![enter image description here](https://i.st...
You missed the `'show_in_rest' => true` in `register_taxonomy()`. The default value is `FALSE`, so if you use Gutenberg editor, your custom taxonomy will not be visible.
343,475
<p>I would like to read from a .css file and inject it as an inline style in wp_head. it's possible?</p> <p>i've tried this "<a href="https://wordpress.stackexchange.com/questions/263656/add-inline-css-to-theme">Add inline css to theme</a>" solution but it doesn't do what I expect because I expect all the style to be ...
[ { "answer_id": 343481, "author": "user3135691", "author_id": 59755, "author_profile": "https://wordpress.stackexchange.com/users/59755", "pm_score": 1, "selected": false, "text": "<p>You need to add your css to wp_head. In order to do so, you need to get your dynamic CSS first, load in i...
2019/07/23
[ "https://wordpress.stackexchange.com/questions/343475", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/127675/" ]
I would like to read from a .css file and inject it as an inline style in wp\_head. it's possible? i've tried this "[Add inline css to theme](https://wordpress.stackexchange.com/questions/263656/add-inline-css-to-theme)" solution but it doesn't do what I expect because I expect all the style to be injected into `<st...
You need to add your css to wp\_head. In order to do so, you need to get your dynamic CSS first, load in into a variable and then add that variable to the head output. Just like so: (This code can go into your functions.php, plugin file or somewhere else in your theme, make sure you include this code in a file where i...
343,485
<p>I'm using "Passwordless Login with OTP / SMS &amp; Email - Facebook Account Kit" for login.</p> <p>I want to redirect user to <code>http://www.domain.com/author/&lt;username&gt;/screen</code> after they log in</p> <p>this is the code I used</p> <pre><code>$current_user = wp_get_current_user(); if ( is_user_logged...
[ { "answer_id": 343481, "author": "user3135691", "author_id": 59755, "author_profile": "https://wordpress.stackexchange.com/users/59755", "pm_score": 1, "selected": false, "text": "<p>You need to add your css to wp_head. In order to do so, you need to get your dynamic CSS first, load in i...
2019/07/23
[ "https://wordpress.stackexchange.com/questions/343485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/172321/" ]
I'm using "Passwordless Login with OTP / SMS & Email - Facebook Account Kit" for login. I want to redirect user to `http://www.domain.com/author/<username>/screen` after they log in this is the code I used ``` $current_user = wp_get_current_user(); if ( is_user_logged_in() ) { $redirect = ('http://www.domain.com...
You need to add your css to wp\_head. In order to do so, you need to get your dynamic CSS first, load in into a variable and then add that variable to the head output. Just like so: (This code can go into your functions.php, plugin file or somewhere else in your theme, make sure you include this code in a file where i...
343,491
<p>I have a simple terms page made up of heading and paragraph blocks. I'd like to filter the_content before output in order to get the content of any heading blocks and create a menu with links to named anchors at the top. Of course, by the time I filter <code>the_content</code> passing <code>$content</code> it's alre...
[ { "answer_id": 343507, "author": "Mattimator", "author_id": 168561, "author_profile": "https://wordpress.stackexchange.com/users/168561", "pm_score": 3, "selected": true, "text": "<p>Have you tried using <code>parse_blocks()</code> (pass in <code>get_the_content()</code>)? That returns a...
2019/07/23
[ "https://wordpress.stackexchange.com/questions/343491", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45504/" ]
I have a simple terms page made up of heading and paragraph blocks. I'd like to filter the\_content before output in order to get the content of any heading blocks and create a menu with links to named anchors at the top. Of course, by the time I filter `the_content` passing `$content` it's already just a string of HTM...
Have you tried using `parse_blocks()` (pass in `get_the_content()`)? That returns an array of all the blocks in your content. From there you can pull out block names and id attributes using an array map or foreach. Assuming you only want to pull anchor tags from the headings, you could do something like: ``` $block...
343,498
<p>I am trying to set up my site so that my WooCommerce product categories only show images on my home page. Currently I have this:</p> <pre><code>&lt;?php function fp_categories() { if( is_front_page() ) { add_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10 ) ; ...
[ { "answer_id": 343507, "author": "Mattimator", "author_id": 168561, "author_profile": "https://wordpress.stackexchange.com/users/168561", "pm_score": 3, "selected": true, "text": "<p>Have you tried using <code>parse_blocks()</code> (pass in <code>get_the_content()</code>)? That returns a...
2019/07/23
[ "https://wordpress.stackexchange.com/questions/343498", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/172327/" ]
I am trying to set up my site so that my WooCommerce product categories only show images on my home page. Currently I have this: ``` <?php function fp_categories() { if( is_front_page() ) { add_action( 'woocommerce_before_subcategory_title', 'woocommerce_subcategory_thumbnail', 10 ) ; } else { ...
Have you tried using `parse_blocks()` (pass in `get_the_content()`)? That returns an array of all the blocks in your content. From there you can pull out block names and id attributes using an array map or foreach. Assuming you only want to pull anchor tags from the headings, you could do something like: ``` $block...
343,526
<p>Im having a loop with count to add a clear after 4 items. It is working pretty well but theres one rebell row that will only take 1 post.</p> <p>Code:</p> <pre><code> &lt;section class="bonds-funding"&gt; &lt;h1&gt;Funders&lt;/h1&gt; &lt;?php the_field( "funding_subtitle" ); ?&gt...
[ { "answer_id": 343527, "author": "user3135691", "author_id": 59755, "author_profile": "https://wordpress.stackexchange.com/users/59755", "pm_score": 0, "selected": false, "text": "<p>Why don't you just:</p>\n\n<pre><code>&lt;style&gt;\n.author-nucleus:nth-of-type(4):after {\n clear:bo...
2019/07/23
[ "https://wordpress.stackexchange.com/questions/343526", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34034/" ]
Im having a loop with count to add a clear after 4 items. It is working pretty well but theres one rebell row that will only take 1 post. Code: ``` <section class="bonds-funding"> <h1>Funders</h1> <?php the_field( "funding_subtitle" ); ?> <?php $loop = new WP_Query( array( 'po...
For your clearfix wrapper you are doing it wrong. You have this: ``` $counter = 0; while ( $loop->have_posts() ) : $loop->the_post(); if ($counter % 4 == 0) : echo $counter > 0 ? "</div>" : ""; // close div if it's not the first echo "<div class='clearfix'>"; endif; // BUILDS INTERNAL DIVS $counter++; endwhile; ```...
343,542
<p>I have an HTML form that is used to send messages to a back end server. When the user clicks the send button, it triggers a javascript that makes an Ajax call to WordPress which in turn, makes an API call to the back end server to send the message. This part works flawlessly. The server then responds with a string w...
[ { "answer_id": 343553, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 3, "selected": true, "text": "<p>Returning the result array will only return to the PHP function calling it, instead you actually need to output...
2019/07/24
[ "https://wordpress.stackexchange.com/questions/343542", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92841/" ]
I have an HTML form that is used to send messages to a back end server. When the user clicks the send button, it triggers a javascript that makes an Ajax call to WordPress which in turn, makes an API call to the back end server to send the message. This part works flawlessly. The server then responds with a string whic...
Returning the result array will only return to the PHP function calling it, instead you actually need to output it by echoing it, and in this case because it is an array, encoding it with JSON before outputting. So `return $result` becomes: ``` echo json_encode($result); exit; ``` and then add dataType to the javasc...