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
330,574
<p>Maybe this topic needs updating because i have certainly used this in the past, but today adobe illustrator ai files are not uploading.</p> <p>So I'm using <a href="https://docs.gravityforms.com/security/#file-upload-security" rel="nofollow noreferrer">gravity forms plugin</a> to upload my files.</p> <p>When I tri...
[ { "answer_id": 353721, "author": "Mushrit Shabnam", "author_id": 111284, "author_profile": "https://wordpress.stackexchange.com/users/111284", "pm_score": 3, "selected": true, "text": "<p>Please try this:</p>\n\n<pre><code>$mime_types[ 'eps' ] = 'application/postscript';\n$mime_types[ 'a...
2019/03/04
[ "https://wordpress.stackexchange.com/questions/330574", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/111152/" ]
Maybe this topic needs updating because i have certainly used this in the past, but today adobe illustrator ai files are not uploading. So I'm using [gravity forms plugin](https://docs.gravityforms.com/security/#file-upload-security) to upload my files. When I tried to initially uploading these file formats... 1. PS...
Please try this: ``` $mime_types[ 'eps' ] = 'application/postscript'; $mime_types[ 'ai' ] = 'application/pdf'; $mime_types[ 'svg' ] = 'image/svg+xml';` ``` and then return `$mime_types`
330,748
<p>Is there a way to append the image id class to existing attached images in the post content automagically with a php function? That would be incredibly awesome.</p> <p>Here is what I have so far. It seems like it should work, in theory. What am I doing wrong?</p> <pre><code>function be_attachment_id_on_images( $at...
[ { "answer_id": 331032, "author": "Loren Rosen", "author_id": 158993, "author_profile": "https://wordpress.stackexchange.com/users/158993", "pm_score": 1, "selected": false, "text": "<p>According to <a href=\"https://wordpress.stackexchange.com/questions/266702/wp-get-attachment-image-att...
2019/03/05
[ "https://wordpress.stackexchange.com/questions/330748", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/138460/" ]
Is there a way to append the image id class to existing attached images in the post content automagically with a php function? That would be incredibly awesome. Here is what I have so far. It seems like it should work, in theory. What am I doing wrong? ``` function be_attachment_id_on_images( $attr, $attachment ) { ...
Shamelessly copied from here: <https://letswp.io/add-attachment-id-to-the-class-of-wordpress-images/> ``` add_filter( 'wp_get_attachment_image_attributes', 'add_image_id_class', 10, 2 ); function add_image_id_class( $attr, $attachment ) { $class_attr = isset( $attr['class'] ) ? $attr['class'] : ''; $has_cla...
330,762
<p>I have this underscore template to add and delete row :</p> <pre><code>&lt;# jQuery( document ).ready( function() { jQuery( '.add-ingr' ).click( function() { jQuery( '#re-ingr .ingr' ).append( '&lt;div&gt;&lt;input type="text" name="ingr[]" value=""/&gt;&lt;a href="#" class="remove_field" style...
[ { "answer_id": 330764, "author": "RiddleMeThis", "author_id": 86845, "author_profile": "https://wordpress.stackexchange.com/users/86845", "pm_score": 2, "selected": true, "text": "<p>This isn't WP related but Its not working because you are trying to add an event to a dynamically created...
2019/03/05
[ "https://wordpress.stackexchange.com/questions/330762", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/158913/" ]
I have this underscore template to add and delete row : ``` <# jQuery( document ).ready( function() { jQuery( '.add-ingr' ).click( function() { jQuery( '#re-ingr .ingr' ).append( '<div><input type="text" name="ingr[]" value=""/><a href="#" class="remove_field" style="margin-left:10px;">Remove</a><...
This isn't WP related but Its not working because you are trying to add an event to a dynamically created element. Replace... ``` jQuery( '.remove_field' ).on("click", function(e){ e.preventDefault(); jQuery(this).parent('div').remove(); }); ``` With ``` jQuery( 'body' ).on("click", '.remove_field', function(...
330,832
<p>I would like to insert and execute some WordPress shortcode through <code>main.js</code> file, in a string "", but the problem is that it won't execute!</p> <p>Here is an example of my <code>main.js</code>:</p> <pre><code>.. }, "March 6": { "title": "6 March", "subtitle": "Sample text", "content": "[sc...
[ { "answer_id": 330764, "author": "RiddleMeThis", "author_id": 86845, "author_profile": "https://wordpress.stackexchange.com/users/86845", "pm_score": 2, "selected": true, "text": "<p>This isn't WP related but Its not working because you are trying to add an event to a dynamically created...
2019/03/06
[ "https://wordpress.stackexchange.com/questions/330832", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162605/" ]
I would like to insert and execute some WordPress shortcode through `main.js` file, in a string "", but the problem is that it won't execute! Here is an example of my `main.js`: ``` .. }, "March 6": { "title": "6 March", "subtitle": "Sample text", "content": "[sc name=\"sampleshortcode\"]" }, .. ``` So ...
This isn't WP related but Its not working because you are trying to add an event to a dynamically created element. Replace... ``` jQuery( '.remove_field' ).on("click", function(e){ e.preventDefault(); jQuery(this).parent('div').remove(); }); ``` With ``` jQuery( 'body' ).on("click", '.remove_field', function(...
330,838
<p>I am creating a website that would need to only allow some specific email addresses to signup (for example "emailname@uniname.ac.uk"). Do you guys know of any wordpress email confirmation plugins that would allow me to do that?</p> <p>To clear some confusion: What I am looking for is only allowing some email addres...
[ { "answer_id": 330935, "author": "Tanmay Patel", "author_id": 62026, "author_profile": "https://wordpress.stackexchange.com/users/62026", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>Just <strong>copy the above code and paste it into your theme’s functions.php file</stro...
2019/03/06
[ "https://wordpress.stackexchange.com/questions/330838", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162614/" ]
I am creating a website that would need to only allow some specific email addresses to signup (for example "emailname@uniname.ac.uk"). Do you guys know of any wordpress email confirmation plugins that would allow me to do that? To clear some confusion: What I am looking for is only allowing some email addresses (for e...
> > Just **copy the above code and paste it into your theme’s functions.php file**. > Here I am going to show you the code which **will reject registration from all others email addresses** and **Only allowing some email addresses to create an account**. See the code below > > > ``` function is_valid_emails($logi...
330,852
<p>I have a custom meta box for saving values from two input fields into a single post meta field.</p> <p>The data is saved serialized in the DB:</p> <pre><code>get_post_meta( $post-&gt;ID, '_custom_key', true ) </code></pre> <p>will return:</p> <pre><code>a:2:{s:5:"email";s:10:"hello@me.me";s:6:"number";i:15;} </c...
[ { "answer_id": 341735, "author": "rsborn", "author_id": 170908, "author_profile": "https://wordpress.stackexchange.com/users/170908", "pm_score": 1, "selected": false, "text": "<p>Here's an answer to question 1 that uses <a href=\"https://developer.wordpress.org/reference/functions/regis...
2019/03/06
[ "https://wordpress.stackexchange.com/questions/330852", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162620/" ]
I have a custom meta box for saving values from two input fields into a single post meta field. The data is saved serialized in the DB: ``` get_post_meta( $post->ID, '_custom_key', true ) ``` will return: ``` a:2:{s:5:"email";s:10:"hello@me.me";s:6:"number";i:15;} ``` Now, with Gutenberg, I want to move that who...
Here's an answer to question 1 that uses [`register_post_meta`](https://developer.wordpress.org/reference/functions/register_post_meta/). It's also the start of an answer to question 2 by use of the `prepare_callback` option in `show_in_rest` . ``` add_action( 'init', 'wpse_89033_register_custom_meta' ); function wpse...
330,855
<p>For example, I want to add a custom user metadata field for projects he is assigned to. But this field must have a foreign key constraint to another table to make sure that the project it is referencing, is valid.</p> <p>Is there a way to handle this scenario with pure user metadata instead of creating an extra tab...
[ { "answer_id": 341735, "author": "rsborn", "author_id": 170908, "author_profile": "https://wordpress.stackexchange.com/users/170908", "pm_score": 1, "selected": false, "text": "<p>Here's an answer to question 1 that uses <a href=\"https://developer.wordpress.org/reference/functions/regis...
2019/03/06
[ "https://wordpress.stackexchange.com/questions/330855", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/158512/" ]
For example, I want to add a custom user metadata field for projects he is assigned to. But this field must have a foreign key constraint to another table to make sure that the project it is referencing, is valid. Is there a way to handle this scenario with pure user metadata instead of creating an extra table to link...
Here's an answer to question 1 that uses [`register_post_meta`](https://developer.wordpress.org/reference/functions/register_post_meta/). It's also the start of an answer to question 2 by use of the `prepare_callback` option in `show_in_rest` . ``` add_action( 'init', 'wpse_89033_register_custom_meta' ); function wpse...
330,885
<p>I have created a custom taxonomy that I have associated to my CPT. both appear on my dashboard, the issue is that when I add content and I want to choose a term from the list of the custom taxonomy, there is no value (no list, no checkbox...) . I am using wordpress 5.1. Here is the code added to functions.php : </p>...
[ { "answer_id": 330892, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 0, "selected": false, "text": "<p>My guess would be that it's caused by priorities...</p>\n\n<p>Both of your actions are using the same...
2019/03/06
[ "https://wordpress.stackexchange.com/questions/330885", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162634/" ]
I have created a custom taxonomy that I have associated to my CPT. both appear on my dashboard, the issue is that when I add content and I want to choose a term from the list of the custom taxonomy, there is no value (no list, no checkbox...) . I am using wordpress 5.1. Here is the code added to functions.php : ``` f...
Changing the slug of taxonomy works for me. Don't know the reason behind it but it works.
330,886
<h2>Cant access admin-ajax from https. In my js i wrote</h2> <pre><code>$.ajax({ url: 'https://'+window.location.host+'/admin/admin-ajax.php', type:'post', data:'action=bid_now_live_me&amp;_pid='+ mypid , success: function (data) { </code></pre> <h2>So I changed every url to https but still no luck....
[ { "answer_id": 330889, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 0, "selected": false, "text": "<p>for a default Wordpress installation, </p>\n\n<pre><code>url: 'https://'+window.location.host+'/admin...
2019/03/06
[ "https://wordpress.stackexchange.com/questions/330886", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162636/" ]
Cant access admin-ajax from https. In my js i wrote --------------------------------------------------- ``` $.ajax({ url: 'https://'+window.location.host+'/admin/admin-ajax.php', type:'post', data:'action=bid_now_live_me&_pid='+ mypid , success: function (data) { ``` So I changed every url to https...
You shouldn't do something like this in your JS code: ``` url: 'https://'+window.location.host+'/admin/admin-ajax.php', ``` You should use [`wp_localize_script`](https://codex.wordpress.org/Function_Reference/wp_localize_script) and pass proper URL in there. Let's say your AJAX call is located in file `my-js-file.j...
330,920
<p>Orderby of get_terms() does not accept array type. How do I make this code works?</p> <pre><code>$allcities = get_terms( array( 'taxonomy' =&gt; 'city', 'hide_empty' =&gt; false, 'orderby' =&gt; array( 'meta_value_num' =&gt; 'ASC', 'count' =&gt; 'ASC' ), 'meta_query' =&gt; array( array( ...
[ { "answer_id": 330889, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 0, "selected": false, "text": "<p>for a default Wordpress installation, </p>\n\n<pre><code>url: 'https://'+window.location.host+'/admin...
2019/03/07
[ "https://wordpress.stackexchange.com/questions/330920", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136218/" ]
Orderby of get\_terms() does not accept array type. How do I make this code works? ``` $allcities = get_terms( array( 'taxonomy' => 'city', 'hide_empty' => false, 'orderby' => array( 'meta_value_num' => 'ASC', 'count' => 'ASC' ), 'meta_query' => array( array( 'key' => 'country', ...
You shouldn't do something like this in your JS code: ``` url: 'https://'+window.location.host+'/admin/admin-ajax.php', ``` You should use [`wp_localize_script`](https://codex.wordpress.org/Function_Reference/wp_localize_script) and pass proper URL in there. Let's say your AJAX call is located in file `my-js-file.j...
330,943
<p>In my WP Plugin I have made an error handler. It works so far but I'd like to <strong>not echo in admin_notices</strong>, but have that nice little message box of wordpress if sth is going wrong: </p> <p><a href="https://i.stack.imgur.com/lZcK8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lZc...
[ { "answer_id": 330889, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 0, "selected": false, "text": "<p>for a default Wordpress installation, </p>\n\n<pre><code>url: 'https://'+window.location.host+'/admin...
2019/03/07
[ "https://wordpress.stackexchange.com/questions/330943", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162679/" ]
In my WP Plugin I have made an error handler. It works so far but I'd like to **not echo in admin\_notices**, but have that nice little message box of wordpress if sth is going wrong: [![red box](https://i.stack.imgur.com/lZcK8.png)](https://i.stack.imgur.com/lZcK8.png) How can I do so?
You shouldn't do something like this in your JS code: ``` url: 'https://'+window.location.host+'/admin/admin-ajax.php', ``` You should use [`wp_localize_script`](https://codex.wordpress.org/Function_Reference/wp_localize_script) and pass proper URL in there. Let's say your AJAX call is located in file `my-js-file.j...
330,947
<p><strong>I would like to resize the 100px x 100px store thumbnail images.</strong></p> <p>The sizes are supposed to be set under <strong>Appearance › Customize › WooCommerce › Product Images</strong></p> <p><strong>These size settings are missing.</strong></p> <p>After an exhaustive search, it is obvious that the ...
[ { "answer_id": 330949, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 1, "selected": false, "text": "<p>WooCommerce itself registers support for the default themes. For Twenty Fifteen it registers the follow...
2019/03/07
[ "https://wordpress.stackexchange.com/questions/330947", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162680/" ]
**I would like to resize the 100px x 100px store thumbnail images.** The sizes are supposed to be set under **Appearance › Customize › WooCommerce › Product Images** **These size settings are missing.** After an exhaustive search, it is obvious that the sizes only appear there if they are not set in functions.php in...
WooCommerce itself registers support for the default themes. For Twenty Fifteen it registers the following: ``` add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); add_theme_support( 'woocommerce', array( 'thumbnail_i...
330,962
<p>I'm trying to send an Email before a post "type:pelicula" is submited, but it does not enter to the function <strong>post_published_notification</strong>, here is the code:</p> <pre><code>&lt;?php /** * Plugin Name: VRlife Alertas Publicaciones * Description: Avisa por el correo configurado al publicar un nuevo vi...
[ { "answer_id": 330965, "author": "tmdesigned", "author_id": 28273, "author_profile": "https://wordpress.stackexchange.com/users/28273", "pm_score": 0, "selected": false, "text": "<p>Since you are in a class, you need to specify that the function you want (\"post_published_notification\")...
2019/03/07
[ "https://wordpress.stackexchange.com/questions/330962", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162285/" ]
I'm trying to send an Email before a post "type:pelicula" is submited, but it does not enter to the function **post\_published\_notification**, here is the code: ``` <?php /** * Plugin Name: VRlife Alertas Publicaciones * Description: Avisa por el correo configurado al publicar un nuevo video * Version: 1.0.0 * Autho...
Well let's compare the hook to one that is working: ``` add_action( 'admin_init', array( $this, 'page_init' ) ); add_action( 'publish_pelicula', 'post_published_notification', 10, 2 ); ``` `page_init()` and `post_published_notification()` are both methods of the `MySettingsPage` class, but you've set the action call...
330,974
<p>I migrated my site to a new server. Everything seems to be fine, but the browser is redirected to the frontpage when I save configurations in either the "W3 Total Cache" plugin or in "Duplicate post" plugin. It does save the edits, but it´s annoing with the redirect.</p> <p>For example when I press purge all caches...
[ { "answer_id": 331050, "author": "Debbie Kurth", "author_id": 119560, "author_profile": "https://wordpress.stackexchange.com/users/119560", "pm_score": 0, "selected": false, "text": "<p>It is a bit hard to really know what is going on. But a best \"guess\" is that you have a plugin that...
2019/03/07
[ "https://wordpress.stackexchange.com/questions/330974", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/155327/" ]
I migrated my site to a new server. Everything seems to be fine, but the browser is redirected to the frontpage when I save configurations in either the "W3 Total Cache" plugin or in "Duplicate post" plugin. It does save the edits, but it´s annoing with the redirect. For example when I press purge all caches from W3 C...
Okay, I found a solution. To anyone in the future having this problem here's what i did: * I used the plugin "Duplicator" and made a package of the site. * Then i downloaded the installer and the archive. * I then deleted everything in the database and on the ftp. * Then I transfered the archive and installer file to ...
331,002
<p>I am trying to utilize AJAX on my WordPress site for posts as a user scrolls. I followed <a href="https://rudrastyh.com/wordpress/load-more-posts-ajax.html" rel="nofollow noreferrer">this</a> tutorial but it has no effect on my WordPress website. </p> <p>I have used a plugin that works, but I'd much rather learn ho...
[ { "answer_id": 331006, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 2, "selected": false, "text": "<p>There are several issues with your code, such as:</p>\n\n<ol>\n<li><p>The original <a href=\"https://rudra...
2019/03/07
[ "https://wordpress.stackexchange.com/questions/331002", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114269/" ]
I am trying to utilize AJAX on my WordPress site for posts as a user scrolls. I followed [this](https://rudrastyh.com/wordpress/load-more-posts-ajax.html) tutorial but it has no effect on my WordPress website. I have used a plugin that works, but I'd much rather learn how to do this without a plugin both to learn and...
Working Code Based On My Previous Answer ---------------------------------------- *Without using nonce.. but you can check the previous answer on how you can implement a nonce check.* And the code is based on *your* code. ### `misha_my_load_more_scripts()` in `functions.php` ``` function misha_my_load_more_scripts()...
331,028
<p>I have created a custom portfolio with the following code in the function.php in a custom template.</p> <pre><code>if ( ! function_exists('custom_post_type_portafolio') ) { // Register Custom Post Type function custom_post_type_portafolio() { $labels = array( 'name' =&gt; _x( 'Proyectos', 'Post Type General Nam...
[ { "answer_id": 331030, "author": "chrisbergr", "author_id": 45070, "author_profile": "https://wordpress.stackexchange.com/users/45070", "pm_score": 0, "selected": false, "text": "<p>For today, Gutenberg doesn't provide <code>container blocks</code> by default. Therefore you either need a...
2019/03/07
[ "https://wordpress.stackexchange.com/questions/331028", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162739/" ]
I have created a custom portfolio with the following code in the function.php in a custom template. ``` if ( ! function_exists('custom_post_type_portafolio') ) { // Register Custom Post Type function custom_post_type_portafolio() { $labels = array( 'name' => _x( 'Proyectos', 'Post Type General Name', 'text_domain'...
Nested group and cover blocks are the solution, and since you created your question the block editor has improved enough that your design can be created with group and cover blocks, with spacing rules via global styles. No code is necessary. E.g. I was able to create this using just the editor, and no CSS or code: [!...
331,078
<p>Error log on my index file get logged in the <code>error_log.txt</code> file but the same error log is not working in the <code>functions.php</code> file. I am using the latest WordPress and <code>PHP 7.0.</code> I am not using any plugin as well.</p> <pre><code>error_log("Hello there is an error"); </code></pre>
[ { "answer_id": 331082, "author": "butlerblog", "author_id": 38603, "author_profile": "https://wordpress.stackexchange.com/users/38603", "pm_score": 2, "selected": false, "text": "<p>In order for <code>error_log()</code> to do anything, you do need to have the <code>WP_DEBUG</code> and <c...
2019/03/08
[ "https://wordpress.stackexchange.com/questions/331078", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162761/" ]
Error log on my index file get logged in the `error_log.txt` file but the same error log is not working in the `functions.php` file. I am using the latest WordPress and `PHP 7.0.` I am not using any plugin as well. ``` error_log("Hello there is an error"); ```
In order for `error_log()` to do anything, you do need to have the `WP_DEBUG` and `WP_DEBUG_LOG` constants set to true in your wp-config.php. (See: [Debugging in WordPress](https://codex.wordpress.org/Debugging_in_WordPress) in the Codex for more information.) According to [this answer on Stackoverflow](https://stacko...
331,086
<p>I know that there is this option on <code>admin</code> to hide products from the entire catalog if there is no stock, but how do I hide these products only from home page and not from the entire catalog?</p> <p>I want to be able to search the products and see it even if it has no stock.</p>
[ { "answer_id": 331358, "author": "Shihab", "author_id": 113702, "author_profile": "https://wordpress.stackexchange.com/users/113702", "pm_score": 1, "selected": false, "text": "<p>Assuming you are using storefront default homepage template. You can filter products before displaying on ho...
2019/03/08
[ "https://wordpress.stackexchange.com/questions/331086", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/124888/" ]
I know that there is this option on `admin` to hide products from the entire catalog if there is no stock, but how do I hide these products only from home page and not from the entire catalog? I want to be able to search the products and see it even if it has no stock.
Assuming you are using storefront default homepage template. You can filter products before displaying on hompepage ``` function rfl_show_backorders( $is_visible, $id ) { $product = new wC_Product( $id ); if ( ! $product->is_in_stock() && ! $product->backorders_allowed() && is_front_page() ) { $is_vis...
331,103
<p>The 'wp-admin/admin-header.php' file outputs 'viewport' meta data. It seems the value of the viewport is hard coded into the file. (See: <a href="https://github.com/WordPress/WordPress/blob/master/wp-admin/admin-header.php" rel="nofollow noreferrer">https://github.com/WordPress/WordPress/blob/master/wp-admin/admin-h...
[ { "answer_id": 331114, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 0, "selected": false, "text": "<p>As was said, <code>&lt;meta name=\"viewport\" /&gt;</code> is hardcoded, but fortunately it's done before <...
2019/03/08
[ "https://wordpress.stackexchange.com/questions/331103", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/157032/" ]
The 'wp-admin/admin-header.php' file outputs 'viewport' meta data. It seems the value of the viewport is hard coded into the file. (See: <https://github.com/WordPress/WordPress/blob/master/wp-admin/admin-header.php> line 89). I want to edit the viewport from my custom plugin. Are there any suggestions as to how this c...
There's a new filter `admin_viewport_meta` in WordPress 5.5 - <https://developer.wordpress.org/reference/functions/wp_admin_viewport_meta/> Now you can change viewport: ``` function my_meta_viewport() { return 'width=980,initial-scale=1.0'; // your value } add_action( 'admin_viewport_meta', 'my_meta_viewport' ); ...
331,117
<p>How do we hide the admin toolbar from the back end dashboard?</p> <p>We can hide the toolbar when viewing the website with the below code but we want to also hide it from back end?</p> <pre><code>add_filter('show_admin_bar', '__return_false'); </code></pre> <p>Thank you</p>
[ { "answer_id": 331120, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 2, "selected": true, "text": "<p><a href=\"https://codex.wordpress.org/Function_Reference/show_admin_bar\" rel=\"nofollow noreferrer\">W...
2019/03/08
[ "https://wordpress.stackexchange.com/questions/331117", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162788/" ]
How do we hide the admin toolbar from the back end dashboard? We can hide the toolbar when viewing the website with the below code but we want to also hide it from back end? ``` add_filter('show_admin_bar', '__return_false'); ``` Thank you
[WordPress page for](https://codex.wordpress.org/Function_Reference/show_admin_bar) `show_admin_bar` says: > > You cannot turn off the toolbar on the WordPress dashboard > > > However, this trick works ``` function remove_admin_bar() { ?> <style type="text/css"> body { margin-top: -...
331,121
<p>I am facing an issue while I upload the custom HTML page into my Wordpress site.</p> <p>The page all alone working fine as I put it in separate folder or if I change its name to <code>index.php</code> . But then their arise a conflict between this custom page and the other WP theme pages .If I set this as a <code>i...
[ { "answer_id": 331120, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 2, "selected": true, "text": "<p><a href=\"https://codex.wordpress.org/Function_Reference/show_admin_bar\" rel=\"nofollow noreferrer\">W...
2019/03/08
[ "https://wordpress.stackexchange.com/questions/331121", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/150945/" ]
I am facing an issue while I upload the custom HTML page into my Wordpress site. The page all alone working fine as I put it in separate folder or if I change its name to `index.php` . But then their arise a conflict between this custom page and the other WP theme pages .If I set this as a `index.php` page in theme or...
[WordPress page for](https://codex.wordpress.org/Function_Reference/show_admin_bar) `show_admin_bar` says: > > You cannot turn off the toolbar on the WordPress dashboard > > > However, this trick works ``` function remove_admin_bar() { ?> <style type="text/css"> body { margin-top: -...
331,143
<p>I have a custom plugin, using a custom post type for data entry capabilities in the admin section. I would like to use a textarea form, along with the checkboxes, select and text input fields I am presently using. However when I update the bost, my call back receives all the other input fields, not not the textare...
[ { "answer_id": 331144, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 3, "selected": false, "text": "<p>You forgot to add <code>name =\"bizdesc\"</code> to your <code>textarea</code>, so this</p>\n\n<pre><c...
2019/03/09
[ "https://wordpress.stackexchange.com/questions/331143", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119560/" ]
I have a custom plugin, using a custom post type for data entry capabilities in the admin section. I would like to use a textarea form, along with the checkboxes, select and text input fields I am presently using. However when I update the bost, my call back receives all the other input fields, not not the textarea fie...
You forgot to add `name ="bizdesc"` to your `textarea`, so this ``` function DrawCallBack($post) { $Record = GetDBRecord(); echo '<textarea id="bizdesc" rows="2" cols="50">'; echo $Record['BizDescp']; echo '</textarea>'; echo '<input type=text id="YourName" name="YourName" value="' .$Record['Name'] .'"/>'...
331,201
<p>In the legacy (classic editor) it was possible to add buttons to the editor toolbar via tinymce API, that will add shortcode at cursor.</p> <p>seems like this is not supported anymore from the <a href="https://go.tiny.cloud/blog/gutenberg-tinymce-faq/" rel="nofollow noreferrer">tinymce FQA</a> and this <a href="htt...
[ { "answer_id": 358854, "author": "Didier Haller", "author_id": 182874, "author_profile": "https://wordpress.stackexchange.com/users/182874", "pm_score": 0, "selected": false, "text": "<p>you can do this with this filter :</p>\n\n<pre><code>function do_shortcode_in_gut($block_content, $bl...
2019/03/10
[ "https://wordpress.stackexchange.com/questions/331201", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62909/" ]
In the legacy (classic editor) it was possible to add buttons to the editor toolbar via tinymce API, that will add shortcode at cursor. seems like this is not supported anymore from the [tinymce FQA](https://go.tiny.cloud/blog/gutenberg-tinymce-faq/) and this [Gutenberg migration guide](https://github.com/danielbachhu...
They have actually fixed it so you can just add the shortcode within the paragraph content and it works. As simple as ``` ...However, when [expand tag="span" title="this trigger" targtag="span"]hidden content[/expand] is clicked… ``` That would be the contents of a paragraph block with inline shortcode. See [this](...
331,217
<p>I downloaded a starter theme (Underscores). I want to exclude first 3 post from my loop on index page.</p> <p>Here is the loop;</p> <pre><code>&lt;?php if ( have_posts() ) : if ( is_home() &amp;&amp; ! is_front_page() ) : ?&gt; &lt;header&gt; &lt;h1 class="page-title screen-reader-t...
[ { "answer_id": 358854, "author": "Didier Haller", "author_id": 182874, "author_profile": "https://wordpress.stackexchange.com/users/182874", "pm_score": 0, "selected": false, "text": "<p>you can do this with this filter :</p>\n\n<pre><code>function do_shortcode_in_gut($block_content, $bl...
2019/03/10
[ "https://wordpress.stackexchange.com/questions/331217", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93501/" ]
I downloaded a starter theme (Underscores). I want to exclude first 3 post from my loop on index page. Here is the loop; ``` <?php if ( have_posts() ) : if ( is_home() && ! is_front_page() ) : ?> <header> <h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1> ...
They have actually fixed it so you can just add the shortcode within the paragraph content and it works. As simple as ``` ...However, when [expand tag="span" title="this trigger" targtag="span"]hidden content[/expand] is clicked… ``` That would be the contents of a paragraph block with inline shortcode. See [this](...
331,256
<p>I have a custom plugin that I'm trying to edit. I didn't develop the plugin. I just need to add a textarea to it and save the contents. I have the field added, but I can't get it to save. This simply needs to be on the backend in the admin. This field will not be visible anywhere but this page.</p> <p>Here's my cod...
[ { "answer_id": 331260, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 3, "selected": true, "text": "<p>Your <code>textarea</code> needs to have a proper <code>name</code> in order for the browser to send it to ...
2019/03/10
[ "https://wordpress.stackexchange.com/questions/331256", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/145236/" ]
I have a custom plugin that I'm trying to edit. I didn't develop the plugin. I just need to add a textarea to it and save the contents. I have the field added, but I can't get it to save. This simply needs to be on the backend in the admin. This field will not be visible anywhere but this page. Here's my code: ``` <...
Your `textarea` needs to have a proper `name` in order for the browser to send it to the server for processing such as be saved to a database. Secondly, `textarea` fields do not have a `value` and they also need a closing tag `</textarea>` because `textarea` is a multi-line form field. So the proper format is: ``` <...
331,262
<p>Trying to get this function to work. But keep getting a <strong>jQuery not defined</strong> error.</p> <p>I have tried many variations here to get the jQuery to work: <a href="https://blog.templatetoaster.com/fix-jquery-is-not-defined-error/" rel="nofollow noreferrer">https://blog.templatetoaster.com/fix-jquery-is-...
[ { "answer_id": 331263, "author": "butalin", "author_id": 162878, "author_profile": "https://wordpress.stackexchange.com/users/162878", "pm_score": 2, "selected": false, "text": "<p>You must call jQuery at the end of the file, when your document is ready.</p>\n\n<p>Try to add the action t...
2019/03/10
[ "https://wordpress.stackexchange.com/questions/331262", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29133/" ]
Trying to get this function to work. But keep getting a **jQuery not defined** error. I have tried many variations here to get the jQuery to work: <https://blog.templatetoaster.com/fix-jquery-is-not-defined-error/> ``` add_action( 'load-post.php', function () { $status = "status-started"; if($status == 'status-sta...
You have your jQuery hooked too early. The jQuery library has not yet loaded when the [`load-(page)`](https://codex.wordpress.org/Plugin_API/Action_Reference) action is fired. Use [`admin_print_scripts`](https://developer.wordpress.org/reference/hooks/admin_print_scripts/) to print inline scripts. That action comes af...
331,309
<p>There are <a href="https://wordpress.org/support/topic/cookie-error-site-not-letting-me-log-in/" rel="nofollow noreferrer">many</a> <a href="https://stackoverflow.com/questions/20941328/wordpress-admin-login-cookies-blocked-error-after-moving-servers">many</a> <a href="https://premium.wpmudev.org/forums/topic/error-...
[ { "answer_id": 334134, "author": "MikeNGarrett", "author_id": 1670, "author_profile": "https://wordpress.stackexchange.com/users/1670", "pm_score": 4, "selected": true, "text": "<p>When you log in to the admin WordPress sets <a href=\"https://developer.mozilla.org/en-US/docs/Web/HTTP/Coo...
2019/03/11
[ "https://wordpress.stackexchange.com/questions/331309", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/128304/" ]
There are [many](https://wordpress.org/support/topic/cookie-error-site-not-letting-me-log-in/) [many](https://stackoverflow.com/questions/20941328/wordpress-admin-login-cookies-blocked-error-after-moving-servers) [many](https://premium.wpmudev.org/forums/topic/error-cookies-are-blocked-or-not-supported-by-your-browser-...
When you log in to the admin WordPress sets [cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) (in PHP) to keep you logged in while you navigate around your site. If this fails, you get the error message, "Cookies are blocked or not supported by your browser." This could fail in a couple different w...
331,341
<p>I've created a child theme under <code>wp-content/themes/my-theme</code> with 5 files thus far:</p> <pre><code>|-my-theme |----assets |--------css |------------bootstrap.min.css |--------js |------------bootstrap.min.js |----functions.php |----index.php |----style.css </code></pre> <p>Now the problem is within my ...
[ { "answer_id": 331343, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 1, "selected": false, "text": "<p>Because this is a child theme, you should use </p>\n\n<pre><code> # styles\n wp_enqueue_style('bootstra...
2019/03/11
[ "https://wordpress.stackexchange.com/questions/331341", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/155748/" ]
I've created a child theme under `wp-content/themes/my-theme` with 5 files thus far: ``` |-my-theme |----assets |--------css |------------bootstrap.min.css |--------js |------------bootstrap.min.js |----functions.php |----index.php |----style.css ``` Now the problem is within my `functions.php` file, I've tried addi...
`get_template_directory_uri()` is explicitly for getting the URL to the parent theme, which is why your scripts and styles are being enqueued at that path (in this context the "template" is the parent theme). The equivalent function for getting the child theme path is `get_stylesheet_directory_uri()`. If you don't ha...
331,349
<p>Can anyone tell me how to change my social media links? I've tried everything on google. My wordpress was set up by a third party who is no longer able to help me. I have pretty much covered being able to keep it updated. On my website the links to the social media are at the bottom but not a menus, not a footer, or...
[ { "answer_id": 331343, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 1, "selected": false, "text": "<p>Because this is a child theme, you should use </p>\n\n<pre><code> # styles\n wp_enqueue_style('bootstra...
2019/03/11
[ "https://wordpress.stackexchange.com/questions/331349", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162930/" ]
Can anyone tell me how to change my social media links? I've tried everything on google. My wordpress was set up by a third party who is no longer able to help me. I have pretty much covered being able to keep it updated. On my website the links to the social media are at the bottom but not a menus, not a footer, or in...
`get_template_directory_uri()` is explicitly for getting the URL to the parent theme, which is why your scripts and styles are being enqueued at that path (in this context the "template" is the parent theme). The equivalent function for getting the child theme path is `get_stylesheet_directory_uri()`. If you don't ha...
331,413
<p>We build a media (based on bootstrap 4 media object) shortcode with the following syntax:</p> <pre><code>[media img="https://via.placeholder.com/64x64.png"]&lt;h5&gt;List-based media object&lt;/h5&gt;Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibu...
[ { "answer_id": 334438, "author": "Frank P. Walentynowicz", "author_id": 32851, "author_profile": "https://wordpress.stackexchange.com/users/32851", "pm_score": -1, "selected": false, "text": "<p>CSS <code>:first-of-type</code> selector will help to accomplish that:</p>\n\n<pre><code>.med...
2019/03/12
[ "https://wordpress.stackexchange.com/questions/331413", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/161828/" ]
We build a media (based on bootstrap 4 media object) shortcode with the following syntax: ``` [media img="https://via.placeholder.com/64x64.png"]<h5>List-based media object</h5>Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempu...
The empty p tag in the developer console means that you have other HTML being outputted inside it, which shouldn't be there. i.e the H5 tag for the heading. This is because "do\_shortcode" uses the [wpautop](https://codex.wordpress.org/Function_Reference/wpautop) filter which wraps everything in a p tag Try remove th...
331,416
<p>I wan to add a responsive div to my wordpress page using bootstrap css, just when i enqueued bootstrap style it distroy themes, so i wan to make that div load using ajax call, call that enqueued style after document is ready then i will add css classes using jquery addClass( ). This way themes styles will not be afe...
[ { "answer_id": 331481, "author": "semperlabs", "author_id": 163019, "author_profile": "https://wordpress.stackexchange.com/users/163019", "pm_score": 1, "selected": false, "text": "<p>Styles won't be affected if you use different selectors. Create a custom stylesheet, and enqueue it imme...
2019/03/12
[ "https://wordpress.stackexchange.com/questions/331416", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162878/" ]
I wan to add a responsive div to my wordpress page using bootstrap css, just when i enqueued bootstrap style it distroy themes, so i wan to make that div load using ajax call, call that enqueued style after document is ready then i will add css classes using jquery addClass( ). This way themes styles will not be afecte...
Styles won't be affected if you use different selectors. Create a custom stylesheet, and enqueue it immediatelly. When the page is ready just apply the styles to the mentioned responsive div, or create some logic behind it. So for example if you have `<div class="custom-sidebar">Some content</div>` Enqueue custom st...
331,422
<p>I have been delving into AJAX within WordPress and have followed many tutorials on how to do so, but every single request returns a 400 error.</p> <p>In my <strong>functions.php</strong> I have added the following:</p> <p><strong>Step 1</strong> - Register and add scripts to WordPress</p> <pre><code>/** * Initia...
[ { "answer_id": 331432, "author": "Sally CJ", "author_id": 137402, "author_profile": "https://wordpress.stackexchange.com/users/137402", "pm_score": 4, "selected": true, "text": "<p>I have not tested your code, but one problem I noticed is the <code>contentType</code> property in your <co...
2019/03/12
[ "https://wordpress.stackexchange.com/questions/331422", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/146071/" ]
I have been delving into AJAX within WordPress and have followed many tutorials on how to do so, but every single request returns a 400 error. In my **functions.php** I have added the following: **Step 1** - Register and add scripts to WordPress ``` /** * Initialize the JavaScript we need for loading more * * @re...
I have not tested your code, but one problem I noticed is the `contentType` property in your `$.ajax()` call: ``` contentType: 'application/json; charset=utf-8', ``` because that way, (from the PHP side) the action (i.e. `ajax_load_more`) is not available in `$_REQUEST['action']` which WordPress uses to determine th...
331,425
<p>I'm a newbie to WordPress; I just started learning WordPress. I'm trying to link style.css in functions.php but I am unable to achieve what might be the issue here. Can anyone point me the right direction?</p> <p>index.php</p> <pre><code>&lt;?php get_header(); ?&gt; &lt;?php if ( have_posts() ) { wh...
[ { "answer_id": 331431, "author": "Shihab", "author_id": 113702, "author_profile": "https://wordpress.stackexchange.com/users/113702", "pm_score": 2, "selected": false, "text": "<p>Please check <a href=\"https://developer.wordpress.org/reference/functions/wp_enqueue_style/\" rel=\"nofollo...
2019/03/12
[ "https://wordpress.stackexchange.com/questions/331425", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131806/" ]
I'm a newbie to WordPress; I just started learning WordPress. I'm trying to link style.css in functions.php but I am unable to achieve what might be the issue here. Can anyone point me the right direction? index.php ``` <?php get_header(); ?> <?php if ( have_posts() ) { while ( have_posts() ) { ...
To get this working: **(1) Your `index.php` file should begin with:** ``` <?php get_header(); ?> ``` and end with: ``` <?php get_footer(); ?> ``` **(2) Your `header.php` file should have the following right *before* the closing `</head>` tag:** ``` <?php wp_head(); ?> ``` Note: `header.php` also has other thi...
331,445
<p>probably a long shot, but here goes: for a WordPress portfolio site, I’m trying to build a project overview page with a layout similar to this: <a href="http://www.innauer-matt.com/" rel="nofollow noreferrer">http://www.innauer-matt.com/</a></p> <p>Each row of images is centered, with a margin of 60 px between the ...
[ { "answer_id": 331431, "author": "Shihab", "author_id": 113702, "author_profile": "https://wordpress.stackexchange.com/users/113702", "pm_score": 2, "selected": false, "text": "<p>Please check <a href=\"https://developer.wordpress.org/reference/functions/wp_enqueue_style/\" rel=\"nofollo...
2019/03/12
[ "https://wordpress.stackexchange.com/questions/331445", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163000/" ]
probably a long shot, but here goes: for a WordPress portfolio site, I’m trying to build a project overview page with a layout similar to this: <http://www.innauer-matt.com/> Each row of images is centered, with a margin of 60 px between the images. The container max-width is 1400 px, so that every time the viewport w...
To get this working: **(1) Your `index.php` file should begin with:** ``` <?php get_header(); ?> ``` and end with: ``` <?php get_footer(); ?> ``` **(2) Your `header.php` file should have the following right *before* the closing `</head>` tag:** ``` <?php wp_head(); ?> ``` Note: `header.php` also has other thi...
331,457
<p>I'm using an action from one plugin that needs to call a function from another plugin. That function is name spaced.</p> <p>Typically, I would use something like:</p> <pre><code>add_action( 'hook_name', 'function_name' ); </code></pre> <p>But the plugin's function is Namespaced and/or object-oriented, so I'm not ...
[ { "answer_id": 331458, "author": "Joe Fletcher", "author_id": 7397, "author_profile": "https://wordpress.stackexchange.com/users/7397", "pm_score": 2, "selected": true, "text": "<p>Here is generic code that worked for me. If anyone wants a real-life example, please let me know. </p>\n\n<...
2019/03/12
[ "https://wordpress.stackexchange.com/questions/331457", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7397/" ]
I'm using an action from one plugin that needs to call a function from another plugin. That function is name spaced. Typically, I would use something like: ``` add_action( 'hook_name', 'function_name' ); ``` But the plugin's function is Namespaced and/or object-oriented, so I'm not sure how to reference the functio...
Here is generic code that worked for me. If anyone wants a real-life example, please let me know. This creates a function that calls the plugin's function assuming the namespace is "Custom" ``` add_action( 'hook_name', 'my_custom_function_name' ); function my_custom_function_name() { // Check if "Custom Plugin" ...
331,474
<p>I want to exclude two items (using their IDs) from an array that's retrieving images attached to the post: the post's thumbnail (featured image) and an image attached via Advanced Custom Fields.</p> <p>I'm getting the first one's ID using <code>get_post_thumbnail_id()</code> and this last one's ID using <code>get_f...
[ { "answer_id": 331458, "author": "Joe Fletcher", "author_id": 7397, "author_profile": "https://wordpress.stackexchange.com/users/7397", "pm_score": 2, "selected": true, "text": "<p>Here is generic code that worked for me. If anyone wants a real-life example, please let me know. </p>\n\n<...
2019/03/12
[ "https://wordpress.stackexchange.com/questions/331474", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98727/" ]
I want to exclude two items (using their IDs) from an array that's retrieving images attached to the post: the post's thumbnail (featured image) and an image attached via Advanced Custom Fields. I'm getting the first one's ID using `get_post_thumbnail_id()` and this last one's ID using `get_field_object('icon')`, wher...
Here is generic code that worked for me. If anyone wants a real-life example, please let me know. This creates a function that calls the plugin's function assuming the namespace is "Custom" ``` add_action( 'hook_name', 'my_custom_function_name' ); function my_custom_function_name() { // Check if "Custom Plugin" ...
331,513
<p>How do I customize the translation of the Month name strings in WordPress?</p> <p>example </p> <p>"January" be "Jan11" in all of website </p>
[ { "answer_id": 331610, "author": "jsmod", "author_id": 160457, "author_profile": "https://wordpress.stackexchange.com/users/160457", "pm_score": 3, "selected": true, "text": "<p>Add the following to your existing <code>functions.php</code> file:</p>\n\n<pre><code>function ra_change_trans...
2019/03/13
[ "https://wordpress.stackexchange.com/questions/331513", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163057/" ]
How do I customize the translation of the Month name strings in WordPress? example "January" be "Jan11" in all of website
Add the following to your existing `functions.php` file: ``` function ra_change_translate_text( $translated_text ) { if ( $translated_text == 'January' ) { $translated_text = 'Jan11'; } return $translated_text; } add_filter( 'gettext', 'ra_change_translate_text', 20 ); ``` If you want to change m...
331,563
<p>I want to have a small header at the top of a page showing the featured images with a link to the related custom post type.</p> <p>This is my code:</p> <pre><code>// Creates random image header within tax called(defaults to residential). add_shortcode( 'rt-random-projects', 'rt_random_projects' ); function rt_rand...
[ { "answer_id": 331564, "author": "mrben522", "author_id": 84703, "author_profile": "https://wordpress.stackexchange.com/users/84703", "pm_score": 0, "selected": false, "text": "<p>More than likely this is a problem with your host. A lot of the big name managed WP hosting companies disab...
2019/03/13
[ "https://wordpress.stackexchange.com/questions/331563", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77767/" ]
I want to have a small header at the top of a page showing the featured images with a link to the related custom post type. This is my code: ``` // Creates random image header within tax called(defaults to residential). add_shortcode( 'rt-random-projects', 'rt_random_projects' ); function rt_random_projects($atts) { ...
Starting from WordPress version 4.5, you can use `RAND(*seed*)` with the `orderby` parameter. However, when the value is simply `RAND` (i.e. the uppercase of `rand`), `WP_Query` ignores it and defaults to the default sorting (which is by the post date). I've confirmed that by inspecting the `$query->request`: 1. Wit...
331,628
<p>I have a Wordpress/WooCommerce webshop and I use WooCommerce Subscriptions. I want to disable the "Upgrade or Downgrade" button in My account > My Subsccriptions for users which have a specific user role. I found 2 pieces of php script but I don't know how to combine these two.</p> <p>The first is to check if a use...
[ { "answer_id": 332720, "author": "Frotmans", "author_id": 150887, "author_profile": "https://wordpress.stackexchange.com/users/150887", "pm_score": 1, "selected": false, "text": "<p>I have found/made the code that works. Maybe it helps somebody else.</p>\n\n<pre><code>/**\n* Remove the \...
2019/03/14
[ "https://wordpress.stackexchange.com/questions/331628", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/150887/" ]
I have a Wordpress/WooCommerce webshop and I use WooCommerce Subscriptions. I want to disable the "Upgrade or Downgrade" button in My account > My Subsccriptions for users which have a specific user role. I found 2 pieces of php script but I don't know how to combine these two. The first is to check if a user has a sp...
I have found/made the code that works. Maybe it helps somebody else. ``` /** * Remove the "Upgrade or Downgrade" button from the My Subscription table if user role is "subscriber_plus". */ add_filter('woocommerce_subscriptions_switch_link', 'remove_switch_button', 10, 4); function remove_switch_button($switch_link, $i...
331,647
<p>I have a custom post type called dogs. Within the Add Dog interface, I have a radio-button group that gives choices for color, which are added to the new dog post as meta data. There are about five color choices.</p> <p>I also have the color field set up to be displayed as a sortable column in the admin area, when ...
[ { "answer_id": 331655, "author": "Jurgen Oldenburg", "author_id": 163071, "author_profile": "https://wordpress.stackexchange.com/users/163071", "pm_score": 0, "selected": false, "text": "<p>Take a look at Admin Columns Pro plugin, it gives you complete control over all columns and fields...
2019/03/14
[ "https://wordpress.stackexchange.com/questions/331647", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59862/" ]
I have a custom post type called dogs. Within the Add Dog interface, I have a radio-button group that gives choices for color, which are added to the new dog post as meta data. There are about five color choices. I also have the color field set up to be displayed as a sortable column in the admin area, when I look at ...
For comparison, I made a post type of `dog` with both a custom field `dog_colour` and a taxonomy `dog_colour`. With both added as admin columns, we get: [![enter image description here](https://i.stack.imgur.com/WHgHE.png)](https://i.stack.imgur.com/WHgHE.png) The taxonomy terms are automatically linked with a query...
331,661
<p>I mean:</p> <pre><code>&lt;ul&gt; &lt;li&gt; &lt;ul class="sub-menu"&gt; &lt;li&gt; &lt;ul&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;/ul...
[ { "answer_id": 331664, "author": "Luca Reghellin", "author_id": 10381, "author_profile": "https://wordpress.stackexchange.com/users/10381", "pm_score": -1, "selected": false, "text": "<p>Not a real answer, but a real solution at least to the primary task: style differently.</p>\n\n<p>I s...
2019/03/14
[ "https://wordpress.stackexchange.com/questions/331661", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10381/" ]
I mean: ``` <ul> <li> <ul class="sub-menu"> <li> <ul> <li></li> <li></li> <li></li> </ul> </li> <li></li> <li></li> </ul> </li> <li> <ul class="sub-menu"> <li></li> <li></li> <li></li> </ul> </li> <li></l...
> > I can extend the Walker\_Nav\_Menu class, but after taking a look to it, it seems there's no way to know when an sub-menu will contain other sub-menu, because there's no data available about its children > > > You may want to look again mate. The [Walker::display\_element(...)](https://developer.wordpress.org...
331,695
<p>Not sure if this is the best approach - so happy to change - but I've set up a number of categories with child categories. Then on my landing page I list the parent categories - I'm using ACF to select the taxonomies I want - </p> <pre><code> &lt;ul&gt; &lt;?php foreach( $terms as $term ): ?&gt; ...
[ { "answer_id": 331700, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 0, "selected": false, "text": "<p>It's normal behaviour. <code>ctaegory.php</code> is the template meant to display posts of a category ...
2019/03/15
[ "https://wordpress.stackexchange.com/questions/331695", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132385/" ]
Not sure if this is the best approach - so happy to change - but I've set up a number of categories with child categories. Then on my landing page I list the parent categories - I'm using ACF to select the taxonomies I want - ``` <ul> <?php foreach( $terms as $term ): ?> <h2><?php echo $term...
OK solved! I have a post called "Cardio" with a child category name "Cardio". I created a category-cardio.php (cardio is the child category) but the page doesn't display the post "cardio" same name as the category. ``` <?php /** * Cardio category template * * @package clf */ get_header(member); ?> <div id...
331,708
<p>I wanted to include some CSS rules inside of my gutenberg editor (in a way that it better reflected the frontend of the website). Yet I absolutely didn't want to see the same styles applied inside of any Tinymce instance across the backend. I found a simple CSS solution, and I would like to share!</p>
[ { "answer_id": 331709, "author": "Cerere", "author_id": 16281, "author_profile": "https://wordpress.stackexchange.com/users/16281", "pm_score": 2, "selected": true, "text": "<p><strong>SHORT VERSION</strong> </p>\n\n<p>Using css it's possible to use of the <code>:not()</code> selector t...
2019/03/15
[ "https://wordpress.stackexchange.com/questions/331708", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16281/" ]
I wanted to include some CSS rules inside of my gutenberg editor (in a way that it better reflected the frontend of the website). Yet I absolutely didn't want to see the same styles applied inside of any Tinymce instance across the backend. I found a simple CSS solution, and I would like to share!
**SHORT VERSION** Using css it's possible to use of the `:not()` selector to exclude Tinymce instances, e.g. `body:not(.mce-content-body) {...}` **LONG VERSION** Let's assume we have declared theme support for editor styles and included an editor stylesheet somewhere in our theme (e.g functions.php) like this: ```...
331,727
<p>My goal is to show an error message when i check if the user is locked or not, the problem is that when the function ends, it redirects to the page that must appear after succesfull login. Objectives:</p> <ol> <li>Check if the user is locked "solved"</li> <li>If it is, create the error message</li> <li>Display the...
[ { "answer_id": 331744, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 1, "selected": false, "text": "<p>Main problem with your code is that you use <code>wp_login</code> action. The wp_login action hook is...
2019/03/15
[ "https://wordpress.stackexchange.com/questions/331727", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162285/" ]
My goal is to show an error message when i check if the user is locked or not, the problem is that when the function ends, it redirects to the page that must appear after succesfull login. Objectives: 1. Check if the user is locked "solved" 2. If it is, create the error message 3. Display the error message in the pag...
Solved, the wp\_authenticate\_user filter hook instead is better, because it's used to perform additional validation/authentication any time a user logs in to WordPress. That was just what i needed, because i wanted to deny from login if my condition was false adding extra validation. This is the functional code: ``` ...
331,729
<p>I have this sql statement: </p> <pre><code>SELECT post_id FROM wp_postmeta WHERE meta_key = $param1 AND meta_value = $param2 </code></pre> <p>I am facing one problem:</p> <p>I don't know how to do that <strong>sql</strong> code with wordpress functionalities. I have read the manual to <code>get_posts()</code> etc...
[ { "answer_id": 331732, "author": "Prince", "author_id": 162810, "author_profile": "https://wordpress.stackexchange.com/users/162810", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p>You can get using this using SQL</p>\n</blockquote>\n\n<pre><code>global $wpdb;\n\n// For sin...
2019/03/15
[ "https://wordpress.stackexchange.com/questions/331729", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163204/" ]
I have this sql statement: ``` SELECT post_id FROM wp_postmeta WHERE meta_key = $param1 AND meta_value = $param2 ``` I am facing one problem: I don't know how to do that **sql** code with wordpress functionalities. I have read the manual to `get_posts()` etc. (though I might have missed something), but I haven't f...
> > You can get using this using SQL > > > ``` global $wpdb; // For single record $wpdb->get_row("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = $param1 AND meta_value = $param2"); // For multiple records $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = $param1 AND meta_value = $par...
331,760
<p>If you look at the 'most recent posts' on my sidebar for my posts page, you can see that the 'date' is repeating. The code and page is below. Any help would be appreciated. Thanks!</p> <p><a href="https://cenbrandlab.org/home-blog/" rel="nofollow noreferrer">https://cenbrandlab.org/home-blog/</a></p> <p> </p> ...
[ { "answer_id": 331765, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 0, "selected": false, "text": "<p>Replace</p>\n\n<pre><code> &lt;span&gt; &lt;?php echo get_the_date('F j, Y'); ?&gt; &lt;/span&gt;\n<...
2019/03/15
[ "https://wordpress.stackexchange.com/questions/331760", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163223/" ]
If you look at the 'most recent posts' on my sidebar for my posts page, you can see that the 'date' is repeating. The code and page is below. Any help would be appreciated. Thanks! <https://cenbrandlab.org/home-blog/> ``` <!-- [SINGLEPOST SIDEBAR MOST POPULAR ARTICLES] [START]--> <div class="c-singlepost__sidebar__ar...
The same date is always displayed because of the use of `echo get_the_date('F j, Y')`. As you can read in the [documentation](https://codex.wordpress.org/Function_Reference/get_the_date): > > The **get\_the\_date** template tag retrieves the date the **current** $post was written. > > > Change `get_the_date('F j,...
331,804
<p>I want to run a function after the <code>wp();</code> line in the file <code>wp-blog-header.php</code>, what is the proper <code>hook</code> to use here?</p> <pre class="lang-php prettyprint-override"><code>&lt;?php /** * Loads the WordPress environment and template. * * @package WordPress */ if ( !isset($wp_d...
[ { "answer_id": 331830, "author": "Antti Koskinen", "author_id": 144392, "author_profile": "https://wordpress.stackexchange.com/users/144392", "pm_score": 0, "selected": false, "text": "<p>Perhaps you could put your redirect function into a must-use plugin and hook the function to <code>m...
2019/03/16
[ "https://wordpress.stackexchange.com/questions/331804", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/161580/" ]
I want to run a function after the `wp();` line in the file `wp-blog-header.php`, what is the proper `hook` to use here? ```php <?php /** * Loads the WordPress environment and template. * * @package WordPress */ if ( !isset($wp_did_header) ) { $wp_did_header = true; // Load the WordPress library. re...
The appropriate hook for handling redirects would be `template_redirect`: ``` function wpse_331804_redirects() { /** * 1. Check if the URL has a parameter [redirect] * 2. If NO, proceed to the next step * 3. If YES, then get that parameter value and look into [redirects] table * 4. If you found...
331,850
<p>I am creating a website that would need to <strong><em>only allow some specific email addresses to signup</em></strong> .</p> <p>An example of this would allowing all emails ending in "<code>@uniname.ac.uk</code>" but not allowing any "<code>@gmail.com, @hotmail.com, etc...</code>".</p> <p>Do you guys know of <str...
[ { "answer_id": 331830, "author": "Antti Koskinen", "author_id": 144392, "author_profile": "https://wordpress.stackexchange.com/users/144392", "pm_score": 0, "selected": false, "text": "<p>Perhaps you could put your redirect function into a must-use plugin and hook the function to <code>m...
2019/03/17
[ "https://wordpress.stackexchange.com/questions/331850", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162614/" ]
I am creating a website that would need to ***only allow some specific email addresses to signup*** . An example of this would allowing all emails ending in "`@uniname.ac.uk`" but not allowing any "`@gmail.com, @hotmail.com, etc...`". Do you guys know of **any WordPress email confirmation plugins** or **php code** th...
The appropriate hook for handling redirects would be `template_redirect`: ``` function wpse_331804_redirects() { /** * 1. Check if the URL has a parameter [redirect] * 2. If NO, proceed to the next step * 3. If YES, then get that parameter value and look into [redirects] table * 4. If you found...
331,865
<p>Adding Featured Image after getting inside of the post is not that hard. But some people want it to do that outside the loop. So is there a way to add a button on post columns to add a featured image in the post list without going inside the post and doing it like the old ways?? It's a simple thing but it may be har...
[ { "answer_id": 331871, "author": "Christina", "author_id": 73071, "author_profile": "https://wordpress.stackexchange.com/users/73071", "pm_score": 1, "selected": false, "text": "<p>I've used the plugin <a href=\"https://www.admincolumns.com/\" rel=\"nofollow noreferrer\">Admin Columns Pr...
2019/03/17
[ "https://wordpress.stackexchange.com/questions/331865", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/160243/" ]
Adding Featured Image after getting inside of the post is not that hard. But some people want it to do that outside the loop. So is there a way to add a button on post columns to add a featured image in the post list without going inside the post and doing it like the old ways?? It's a simple thing but it may be hard t...
Yes, it can be done very easily. There is a great tutorial by [Misha Rudrastyh](https://rudrastyh.com) on [how to add Featured Images to Quick Edit](https://rudrastyh.com/wordpress/quick-edit-featured-image.html). I recently applied it and can confirm that it works. You will be able to see the featured images in the ad...
331,879
<p>I use <code>get_the_category_list</code> to create a cat link in the header of my posts in the archive page, like so : </p> <pre><code>$categories_list = get_the_category_list( esc_html__( ', ', 'mytheme' ) ); if ( $categories_list ) { echo '&lt;div class="cat-links"&gt;'; get_template_part('images/inline',...
[ { "answer_id": 331871, "author": "Christina", "author_id": 73071, "author_profile": "https://wordpress.stackexchange.com/users/73071", "pm_score": 1, "selected": false, "text": "<p>I've used the plugin <a href=\"https://www.admincolumns.com/\" rel=\"nofollow noreferrer\">Admin Columns Pr...
2019/03/17
[ "https://wordpress.stackexchange.com/questions/331879", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81047/" ]
I use `get_the_category_list` to create a cat link in the header of my posts in the archive page, like so : ``` $categories_list = get_the_category_list( esc_html__( ', ', 'mytheme' ) ); if ( $categories_list ) { echo '<div class="cat-links">'; get_template_part('images/inline', 'picto-actu.svg'); $catego...
Yes, it can be done very easily. There is a great tutorial by [Misha Rudrastyh](https://rudrastyh.com) on [how to add Featured Images to Quick Edit](https://rudrastyh.com/wordpress/quick-edit-featured-image.html). I recently applied it and can confirm that it works. You will be able to see the featured images in the ad...
331,923
<p>We can add some file in theme folder but it showing in the admin panel. We can't getting the theme folder file from</p> <pre><code>add_menu_page('Test', 'test', 'manage_options', 'test', 'test.php', null, 6); </code></pre>
[ { "answer_id": 331925, "author": "rozklad", "author_id": 47861, "author_profile": "https://wordpress.stackexchange.com/users/47861", "pm_score": 1, "selected": false, "text": "<p>Fifth parameter of add_menu_page is of type <a href=\"http://php.net/manual/en/language.types.callable.php\" ...
2019/03/18
[ "https://wordpress.stackexchange.com/questions/331923", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163341/" ]
We can add some file in theme folder but it showing in the admin panel. We can't getting the theme folder file from ``` add_menu_page('Test', 'test', 'manage_options', 'test', 'test.php', null, 6); ```
This is my code to include the file in the theme folder as a page for the admin menu: ```php // functions.php add_action('admin_menu', function () { add_menu_page( 'Custom Admin Page', 'Custom Admin Page', 'manage_options', 'custom-admin-page', function () { incl...
331,937
<p>Basically, we have alot of traffic coming to our site from different sources looking for slightly different things.</p> <p>But instead of creating new pages for each slight change in heading, we were wondering if there was a way to set a custom parameter within the URL and then pull that parameter into a HTML eleme...
[ { "answer_id": 331942, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 0, "selected": false, "text": "<p>In <code>page.php</code> or the <code>php</code> file of currently used template replace <code>the_tit...
2019/03/18
[ "https://wordpress.stackexchange.com/questions/331937", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162529/" ]
Basically, we have alot of traffic coming to our site from different sources looking for slightly different things. But instead of creating new pages for each slight change in heading, we were wondering if there was a way to set a custom parameter within the URL and then pull that parameter into a HTML element to disp...
Another approach that may be a bit more opaque to your users is to look at the referrer\_url. This is a server-level variable that, while not 100% reliable, is generally a good indicator of where someone was when they clicked your link. It would *not* work if someone copied the link and sent it to someone else. ``` f...
331,950
<p>I am trying to display a different template depending on the post type.</p> <p>I have registered two custom post types called <code>resource</code> and <code>contact</code>. When I try to get the post type in search.php (using <code>get_post_type()</code>), I always get back <code>resource</code> post type, even wh...
[ { "answer_id": 331942, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 0, "selected": false, "text": "<p>In <code>page.php</code> or the <code>php</code> file of currently used template replace <code>the_tit...
2019/03/18
[ "https://wordpress.stackexchange.com/questions/331950", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/161697/" ]
I am trying to display a different template depending on the post type. I have registered two custom post types called `resource` and `contact`. When I try to get the post type in search.php (using `get_post_type()`), I always get back `resource` post type, even when the post is definitely `contact`. Registering `res...
Another approach that may be a bit more opaque to your users is to look at the referrer\_url. This is a server-level variable that, while not 100% reliable, is generally a good indicator of where someone was when they clicked your link. It would *not* work if someone copied the link and sent it to someone else. ``` f...
331,954
<p>I have a custom html form from which I am trying to insert records into a custom table .My problem is getting the current user name and inserting that value into the custom table. When the user clicks the Submit button the code below should fire. This is my php code:</p> <pre><code>&lt;?php&gt; session_start; requi...
[ { "answer_id": 331942, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 0, "selected": false, "text": "<p>In <code>page.php</code> or the <code>php</code> file of currently used template replace <code>the_tit...
2019/03/18
[ "https://wordpress.stackexchange.com/questions/331954", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/145942/" ]
I have a custom html form from which I am trying to insert records into a custom table .My problem is getting the current user name and inserting that value into the custom table. When the user clicks the Submit button the code below should fire. This is my php code: ``` <?php> session_start; require_once "wp-load.php...
Another approach that may be a bit more opaque to your users is to look at the referrer\_url. This is a server-level variable that, while not 100% reliable, is generally a good indicator of where someone was when they clicked your link. It would *not* work if someone copied the link and sent it to someone else. ``` f...
331,968
<p>I'm developing Gutenberg custom block for accodrdions on my website. My code was working with only one content field. When I have added second props it has stop worked and console says:</p> <blockquote> <p>Cannot read property 'content' of undefined</p> </blockquote> <pre><code>wp.blocks.registerBlockType('myblo...
[ { "answer_id": 331942, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 0, "selected": false, "text": "<p>In <code>page.php</code> or the <code>php</code> file of currently used template replace <code>the_tit...
2019/03/18
[ "https://wordpress.stackexchange.com/questions/331968", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136526/" ]
I'm developing Gutenberg custom block for accodrdions on my website. My code was working with only one content field. When I have added second props it has stop worked and console says: > > Cannot read property 'content' of undefined > > > ``` wp.blocks.registerBlockType('myblock/question-block', { title: 'Blok...
Another approach that may be a bit more opaque to your users is to look at the referrer\_url. This is a server-level variable that, while not 100% reliable, is generally a good indicator of where someone was when they clicked your link. It would *not* work if someone copied the link and sent it to someone else. ``` f...
331,981
<p>The contents of the <code>/index.php</code> is as follows:</p> <pre><code>/** * Tells WordPress to load the WordPress theme and output it. * * @var bool */ define('WP_USE_THEMES', true); /** Loads the WordPress Environment and Template */ require( dirname( __FILE__ ) . '/wp-blog-header.php' ); </code></pre> <...
[ { "answer_id": 331984, "author": "tmdesigned", "author_id": 28273, "author_profile": "https://wordpress.stackexchange.com/users/28273", "pm_score": 3, "selected": true, "text": "<p>Yes, index.php is part of core and is liable to be overwritten. </p>\n\n<p>In fact, if you look at the <a h...
2019/03/18
[ "https://wordpress.stackexchange.com/questions/331981", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9124/" ]
The contents of the `/index.php` is as follows: ``` /** * Tells WordPress to load the WordPress theme and output it. * * @var bool */ define('WP_USE_THEMES', true); /** Loads the WordPress Environment and Template */ require( dirname( __FILE__ ) . '/wp-blog-header.php' ); ``` If I make any changes in this file,...
Yes, index.php is part of core and is liable to be overwritten. In fact, if you look at the [process to manually update WordPress](https://codex.wordpress.org/Updating_WordPress#Manual_Update), step 7 is: > > Upload all new loose files from the root directory of the new version to your existing WordPress root direc...
331,982
<p>I am trying to replace a word only on post pages. The issue I am running into is that WordPress page content ends up blank even though this code should only run on post pages. </p> <pre><code>&lt;?php /** * Plugin Name: Wordpress plugin test esmond * Plugin URI: https://esmondmccain.com * Description: test p...
[ { "answer_id": 331987, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 2, "selected": true, "text": "<p>Your code is returning <code>$text</code> only for posts and nothing for other post types like pages. ...
2019/03/18
[ "https://wordpress.stackexchange.com/questions/331982", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/160737/" ]
I am trying to replace a word only on post pages. The issue I am running into is that WordPress page content ends up blank even though this code should only run on post pages. ``` <?php /** * Plugin Name: Wordpress plugin test esmond * Plugin URI: https://esmondmccain.com * Description: test plugin. * Version: 1.0 * ...
Your code is returning `$text` only for posts and nothing for other post types like pages. Your function should be like this ``` add_filter('the_content', 'replace_word'); function replace_word($text) { if (is_singular( 'post' )){ $text = str_replace('dog', 'cat', $text); return $text; ...
331,997
<p>I use Plugin Boilerplate for my project. I searched the internet and read all the questions but I couldn’t find what I need. I also read the WordPress Codex. I think I couldn’t get the idea.</p> <p>I have two columns on my page. Col1 and Col2</p> <pre><code>Inside col1: wp_list_table Inside col2: empty </code></pr...
[ { "answer_id": 331987, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 2, "selected": true, "text": "<p>Your code is returning <code>$text</code> only for posts and nothing for other post types like pages. ...
2019/03/18
[ "https://wordpress.stackexchange.com/questions/331997", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163388/" ]
I use Plugin Boilerplate for my project. I searched the internet and read all the questions but I couldn’t find what I need. I also read the WordPress Codex. I think I couldn’t get the idea. I have two columns on my page. Col1 and Col2 ``` Inside col1: wp_list_table Inside col2: empty ``` Page address: `admin.php?p...
Your code is returning `$text` only for posts and nothing for other post types like pages. Your function should be like this ``` add_filter('the_content', 'replace_word'); function replace_word($text) { if (is_singular( 'post' )){ $text = str_replace('dog', 'cat', $text); return $text; ...
332,008
<p>This is my code, where i keep getting either error: unexpected endforeach; if endforeach is used or unexpected end of file if i don't use endforeach; It's driving me crazy!!</p> <pre><code>&lt;ul id="portfolio-filter"&gt; &lt;?php $k=0; $services = array('all', 'marketing', 'SEO', 'web-design', 'web-dev...
[ { "answer_id": 331987, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 2, "selected": true, "text": "<p>Your code is returning <code>$text</code> only for posts and nothing for other post types like pages. ...
2019/03/18
[ "https://wordpress.stackexchange.com/questions/332008", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163393/" ]
This is my code, where i keep getting either error: unexpected endforeach; if endforeach is used or unexpected end of file if i don't use endforeach; It's driving me crazy!! ``` <ul id="portfolio-filter"> <?php $k=0; $services = array('all', 'marketing', 'SEO', 'web-design', 'web-development', ...
Your code is returning `$text` only for posts and nothing for other post types like pages. Your function should be like this ``` add_filter('the_content', 'replace_word'); function replace_word($text) { if (is_singular( 'post' )){ $text = str_replace('dog', 'cat', $text); return $text; ...
332,076
<p>Heads up, I'm pretty new to Wordpress... But I need to loop through multiple posts and change all 'data-src' attributes to 'src' so my images will display. What's the way/best way to go about doing this? Would appreciate any info on this topic. Thanks. </p>
[ { "answer_id": 331987, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 2, "selected": true, "text": "<p>Your code is returning <code>$text</code> only for posts and nothing for other post types like pages. ...
2019/03/19
[ "https://wordpress.stackexchange.com/questions/332076", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163457/" ]
Heads up, I'm pretty new to Wordpress... But I need to loop through multiple posts and change all 'data-src' attributes to 'src' so my images will display. What's the way/best way to go about doing this? Would appreciate any info on this topic. Thanks.
Your code is returning `$text` only for posts and nothing for other post types like pages. Your function should be like this ``` add_filter('the_content', 'replace_word'); function replace_word($text) { if (is_singular( 'post' )){ $text = str_replace('dog', 'cat', $text); return $text; ...
332,096
<p>Today I want to ask you something which is really important what if my WordPress website <a href="https://thecodezine.com" rel="nofollow noreferrer">https://thecodezine.com</a> gets hacked or my jetpack plugin security is broken?Will I lose everything? Is there no way to get back? How can I get all my files safe and...
[ { "answer_id": 331987, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 2, "selected": true, "text": "<p>Your code is returning <code>$text</code> only for posts and nothing for other post types like pages. ...
2019/03/19
[ "https://wordpress.stackexchange.com/questions/332096", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163277/" ]
Today I want to ask you something which is really important what if my WordPress website <https://thecodezine.com> gets hacked or my jetpack plugin security is broken?Will I lose everything? Is there no way to get back? How can I get all my files safe and secured.
Your code is returning `$text` only for posts and nothing for other post types like pages. Your function should be like this ``` add_filter('the_content', 'replace_word'); function replace_word($text) { if (is_singular( 'post' )){ $text = str_replace('dog', 'cat', $text); return $text; ...
332,259
<p>I am trying add custom taxonomy with post using cron job. The problem is since wordpress 4.7, it verify if current user have capability of assigning taxonomy. Crob job don't have the capability.</p> <p>I am using this for registering custom taxonomoy </p> <pre> add_action( 'init', 'create_locations_hierarchical_ta...
[ { "answer_id": 332167, "author": "mrben522", "author_id": 84703, "author_profile": "https://wordpress.stackexchange.com/users/84703", "pm_score": 3, "selected": true, "text": "<p>Some links (those built in code) will automatically change to your new domain. Others (those in post content...
2019/03/21
[ "https://wordpress.stackexchange.com/questions/332259", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162773/" ]
I am trying add custom taxonomy with post using cron job. The problem is since wordpress 4.7, it verify if current user have capability of assigning taxonomy. Crob job don't have the capability. I am using this for registering custom taxonomoy ``` add_action( 'init', 'create_locations_hierarchical_taxonomy', 0 ); ...
Some links (those built in code) will automatically change to your new domain. Others (those in post content) you will want to swap out using something like [better search replace](https://wordpress.org/plugins/better-search-replace/) to swap out localhost for your new domain.
332,295
<p>I am trying to collect data from a search box. Conditions; if the value exists, update the counter field based on how many times it's been searched. </p> <p>Problem: when a duplicate value searched in the form, the counter value increases by 2 not 1. So, if its current value is 5 and the term has been searched agai...
[ { "answer_id": 332167, "author": "mrben522", "author_id": 84703, "author_profile": "https://wordpress.stackexchange.com/users/84703", "pm_score": 3, "selected": true, "text": "<p>Some links (those built in code) will automatically change to your new domain. Others (those in post content...
2019/03/21
[ "https://wordpress.stackexchange.com/questions/332295", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163609/" ]
I am trying to collect data from a search box. Conditions; if the value exists, update the counter field based on how many times it's been searched. Problem: when a duplicate value searched in the form, the counter value increases by 2 not 1. So, if its current value is 5 and the term has been searched again the valu...
Some links (those built in code) will automatically change to your new domain. Others (those in post content) you will want to swap out using something like [better search replace](https://wordpress.org/plugins/better-search-replace/) to swap out localhost for your new domain.
332,307
<p>Is there a way in mySQL or otherwise to bulk convert all my tags into lowercase? Thanks!</p>
[ { "answer_id": 332311, "author": "Uranbold", "author_id": 140634, "author_profile": "https://wordpress.stackexchange.com/users/140634", "pm_score": 1, "selected": false, "text": "<p>Just use the Css for that. Why do you wanna change it on MySQL? I suggest <strong>text-transform: lowercas...
2019/03/21
[ "https://wordpress.stackexchange.com/questions/332307", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163617/" ]
Is there a way in mySQL or otherwise to bulk convert all my tags into lowercase? Thanks!
I would highly suggest that you use CSS to do this, as mentioned per other answer. Still, if you need to update the database due to some technical business, here's the way to go. First, we will try and fetch all the tags using the [`get_terms()`](https://developer.wordpress.org/reference/functions/get_terms/) function...
332,328
<p>I'm implementing infinite loading using the WP API, so I pull in the new posts via an API request. Because the default API response is fine with me and I only really need to filter the posts returned, I'm not creating a custom route but rather customizing the default query: </p> <pre><code>add_filter( 'rest_post_qu...
[ { "answer_id": 332311, "author": "Uranbold", "author_id": 140634, "author_profile": "https://wordpress.stackexchange.com/users/140634", "pm_score": 1, "selected": false, "text": "<p>Just use the Css for that. Why do you wanna change it on MySQL? I suggest <strong>text-transform: lowercas...
2019/03/22
[ "https://wordpress.stackexchange.com/questions/332328", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/129417/" ]
I'm implementing infinite loading using the WP API, so I pull in the new posts via an API request. Because the default API response is fine with me and I only really need to filter the posts returned, I'm not creating a custom route but rather customizing the default query: ``` add_filter( 'rest_post_query', array( $...
I would highly suggest that you use CSS to do this, as mentioned per other answer. Still, if you need to update the database due to some technical business, here's the way to go. First, we will try and fetch all the tags using the [`get_terms()`](https://developer.wordpress.org/reference/functions/get_terms/) function...
332,340
<p>I need an array that contains all the posts names that match with the post_type"pelicula"</p>
[ { "answer_id": 332311, "author": "Uranbold", "author_id": 140634, "author_profile": "https://wordpress.stackexchange.com/users/140634", "pm_score": 1, "selected": false, "text": "<p>Just use the Css for that. Why do you wanna change it on MySQL? I suggest <strong>text-transform: lowercas...
2019/03/22
[ "https://wordpress.stackexchange.com/questions/332340", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/162285/" ]
I need an array that contains all the posts names that match with the post\_type"pelicula"
I would highly suggest that you use CSS to do this, as mentioned per other answer. Still, if you need to update the database due to some technical business, here's the way to go. First, we will try and fetch all the tags using the [`get_terms()`](https://developer.wordpress.org/reference/functions/get_terms/) function...
332,358
<p>I need to show my client error message on all admin pages.</p> <p>I have the following code, that adds a custom notice only on the admin dashboard page:</p> <pre><code>add_action('admin_bar_menu', 'custom_toolbar_link2', 999); function general_admin_notice(){ global $pagenow; if ( $pagenow == 'index.php' ...
[ { "answer_id": 332361, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 0, "selected": false, "text": "<p>Sure there is a method to do this. You just need to attach your function to a different hook, <a href=\"https://...
2019/03/22
[ "https://wordpress.stackexchange.com/questions/332358", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/157966/" ]
I need to show my client error message on all admin pages. I have the following code, that adds a custom notice only on the admin dashboard page: ``` add_action('admin_bar_menu', 'custom_toolbar_link2', 999); function general_admin_notice(){ global $pagenow; if ( $pagenow == 'index.php' ) { echo '<d...
``` function my_admin_notice() { /* * The class of admin notice should be "notice" plus any one of * -"notice-error", * -"notice-warning", * -"notice-success" * -"notice-info". * Optionally use "is-dismissible" to apply a closing icon. */ echo '<div class="notice notice-info...
332,383
<p>I am using plain simple code to make a search page</p> <pre><code>$argscontactdirectory = array( "s" =&gt; get_search_query(), 'post_type' =&gt; array( 'expertarticle'), 'orderby' =&gt; 'title', 'order' =&gt; 'ASC', ); </code></pre> <p>Above is the code I am us...
[ { "answer_id": 332385, "author": "czerspalace", "author_id": 47406, "author_profile": "https://wordpress.stackexchange.com/users/47406", "pm_score": 2, "selected": true, "text": "<p><code>get_search_query</code> escapes the data for outputting to HTML. Can you try the following instead:<...
2019/03/22
[ "https://wordpress.stackexchange.com/questions/332383", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101405/" ]
I am using plain simple code to make a search page ``` $argscontactdirectory = array( "s" => get_search_query(), 'post_type' => array( 'expertarticle'), 'orderby' => 'title', 'order' => 'ASC', ); ``` Above is the code I am using, however, when the search query co...
`get_search_query` escapes the data for outputting to HTML. Can you try the following instead: ``` $argscontactdirectory = array( 's' => sanitize_text_field( get_search_query( false ) ), 'post_type' => array( 'expertarticle'), 'orderby' => 'title', 'order' => 'ASC', ); ```
332,423
<p>i'm create custom admin page via <code>add_menu_page</code>, let's imagine that my custom page has url </p> <blockquote> <p>wp-admin/admin.php?page=settings_page</p> </blockquote> <p>then i'm checki <code>is_admin()</code> function via <code>var_dump</code> on my <code>settings_page</code> and it returns <code>t...
[ { "answer_id": 349511, "author": "DarkNeuron", "author_id": 86731, "author_profile": "https://wordpress.stackexchange.com/users/86731", "pm_score": 1, "selected": false, "text": "<p>It's due to the way WP initializes the REST endpoints. It works something like this:</p>\n\n<p>Someone <co...
2019/03/23
[ "https://wordpress.stackexchange.com/questions/332423", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68798/" ]
i'm create custom admin page via `add_menu_page`, let's imagine that my custom page has url > > wp-admin/admin.php?page=settings\_page > > > then i'm checki `is_admin()` function via `var_dump` on my `settings_page` and it returns `true` - that's OK, but when i'm wrap `rest_api_init` action in `if is_admin()` st...
Essentially, you shouldn't wrap your REST route declarations inside is\_admin() since Wordpress will not load them (see @DarkNueron comment). What you can do is pass a 'permission\_callback' function to the `register_rest_route` function. If the function returns true, the request is allowed to continue; if false, an e...
332,429
<p>I am coding in WordPress to make a button to toggle body class from <code>light-mode</code> to <code>dark-mode</code>. i was experimenting with trying to add a cookie so that the preference is remembered for the browser. But i receive a error <code>Cannot set property className of null at setThemeFromCookie</code>.<...
[ { "answer_id": 332432, "author": "mrben522", "author_id": 84703, "author_profile": "https://wordpress.stackexchange.com/users/84703", "pm_score": 0, "selected": false, "text": "<p><code>var body = document.getElementById('body')</code> is your problem. The document's body is not an id, ...
2019/03/23
[ "https://wordpress.stackexchange.com/questions/332429", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I am coding in WordPress to make a button to toggle body class from `light-mode` to `dark-mode`. i was experimenting with trying to add a cookie so that the preference is remembered for the browser. But i receive a error `Cannot set property className of null at setThemeFromCookie`. moreover clicking the button gives ...
Using JQuery Simplifies the whole thing, using [JS Cookie](https://github.com/js-cookie/js-cookie) -------------------------------------------------------------------------------------------------- ``` $(document).ready(function(){ // Check cookie and set theme if(Cookies.get('theme')) { $('body').re...
332,455
<p>I'm building a custom theme for a client's website and want to allow them to use embedded content in their posts (Youtube videos, Facebook posts, Twitter feeds, etc.) Typically, I've taken to severely limiting what kinds of blocks are available in the Gutenberg editor so this is the first time I've allowed the embed...
[ { "answer_id": 332487, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 3, "selected": false, "text": "<p>It may be that your theme hasn't declared support for responsive embeds. Try adding this code to your functio...
2019/03/23
[ "https://wordpress.stackexchange.com/questions/332455", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163716/" ]
I'm building a custom theme for a client's website and want to allow them to use embedded content in their posts (Youtube videos, Facebook posts, Twitter feeds, etc.) Typically, I've taken to severely limiting what kinds of blocks are available in the Gutenberg editor so this is the first time I've allowed the embed bl...
It may be that your theme hasn't declared support for responsive embeds. Try adding this code to your functions.php ``` // Add support for responsive embedded content. add_theme_support( 'responsive-embeds' ); ``` or your theme setup file if there is one.
332,457
<p>I have a custom bootstrap 4 theme I am building out in wordpress. The drop down mobile menu does not work when the hamburger menu is pressed at smaller viewports. I am not sure if I need to add a something to the function.php file for mobile menu, or some other php/wp code for the collapsible nav? </p> <p>The mobil...
[ { "answer_id": 332487, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 3, "selected": false, "text": "<p>It may be that your theme hasn't declared support for responsive embeds. Try adding this code to your functio...
2019/03/23
[ "https://wordpress.stackexchange.com/questions/332457", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163720/" ]
I have a custom bootstrap 4 theme I am building out in wordpress. The drop down mobile menu does not work when the hamburger menu is pressed at smaller viewports. I am not sure if I need to add a something to the function.php file for mobile menu, or some other php/wp code for the collapsible nav? The mobile menu wil...
It may be that your theme hasn't declared support for responsive embeds. Try adding this code to your functions.php ``` // Add support for responsive embedded content. add_theme_support( 'responsive-embeds' ); ``` or your theme setup file if there is one.
332,518
<p>Using the call back hook, I can get the subscription information of everything EXCEPT the expiration date. Any thoughts on how to grab this. This is what I have:</p> <pre><code>function mmd_woointerface_ProcessOrder($order_id) { $order = new WC_Order( $order_id ); $OrderNumber = $...
[ { "answer_id": 332525, "author": "Antti Koskinen", "author_id": 144392, "author_profile": "https://wordpress.stackexchange.com/users/144392", "pm_score": 0, "selected": false, "text": "<p>Based on the documentation (<a href=\"https://docs.woocommerce.com/document/subscriptions/develop/fu...
2019/03/25
[ "https://wordpress.stackexchange.com/questions/332518", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119560/" ]
Using the call back hook, I can get the subscription information of everything EXCEPT the expiration date. Any thoughts on how to grab this. This is what I have: ``` function mmd_woointerface_ProcessOrder($order_id) { $order = new WC_Order( $order_id ); $OrderNumber = $order->parent_id...
I had a similar problem to the one you have described. In the end i had to hook into `woocommerce_subscription_status_active` from which you can access the related `$subscription` object as a single argument. If you need any further details from the standard `$order` object also then you can access that via `$subscript...
332,531
<p>I have set some css classes for the boxes in the Gutenberg editor, and I can type it in the additional css input box, it is not a problem for me, but for the client it is not convenient, because he does not know and he forget them. There is a way to have a drop-down with all the custom classes instead of a simple in...
[ { "answer_id": 332547, "author": "Botond Vajna", "author_id": 163786, "author_profile": "https://wordpress.stackexchange.com/users/163786", "pm_score": 0, "selected": false, "text": "<p>Finally, I find an alternative solution here:\n<a href=\"https://www.billerickson.net/block-styles-in-...
2019/03/25
[ "https://wordpress.stackexchange.com/questions/332531", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163786/" ]
I have set some css classes for the boxes in the Gutenberg editor, and I can type it in the additional css input box, it is not a problem for me, but for the client it is not convenient, because he does not know and he forget them. There is a way to have a drop-down with all the custom classes instead of a simple input...
You should add a custom plugin. That needs a PHP main file that includes and registers a JavaScript file. The source below should result in a plugin. You will find a usable solution also in the probs below. PHP part -------- ``` add_action( 'enqueue_block_editor_assets', 'my_gutenberg_scripts' ); function my_gutenber...
332,541
<p>I want to show an <code>iframe</code> at the top of a specific Tag page, so once I have <code>is_tag('my_tag')</code>, I will add the <code>iframe</code> before the <code>title</code> of the page.</p> <p>I've tried this code to show the iframe before the content of the page, but it didn't work:</p> <pre class="lan...
[ { "answer_id": 332547, "author": "Botond Vajna", "author_id": 163786, "author_profile": "https://wordpress.stackexchange.com/users/163786", "pm_score": 0, "selected": false, "text": "<p>Finally, I find an alternative solution here:\n<a href=\"https://www.billerickson.net/block-styles-in-...
2019/03/25
[ "https://wordpress.stackexchange.com/questions/332541", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/161580/" ]
I want to show an `iframe` at the top of a specific Tag page, so once I have `is_tag('my_tag')`, I will add the `iframe` before the `title` of the page. I've tried this code to show the iframe before the content of the page, but it didn't work: ```php // Show the iFrame at the beginning of the page function show_ifra...
You should add a custom plugin. That needs a PHP main file that includes and registers a JavaScript file. The source below should result in a plugin. You will find a usable solution also in the probs below. PHP part -------- ``` add_action( 'enqueue_block_editor_assets', 'my_gutenberg_scripts' ); function my_gutenber...
332,560
<p>I created a function which I use to send an email when a specific button is pressed. This works great, except that it always ends up in spam instead of the inbox.</p> <p>This is the function:</p> <pre><code>function search_notify_email() { // Set variables $email = $_POST['email']; $title = $_POST['title']; ...
[ { "answer_id": 332547, "author": "Botond Vajna", "author_id": 163786, "author_profile": "https://wordpress.stackexchange.com/users/163786", "pm_score": 0, "selected": false, "text": "<p>Finally, I find an alternative solution here:\n<a href=\"https://www.billerickson.net/block-styles-in-...
2019/03/25
[ "https://wordpress.stackexchange.com/questions/332560", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/138051/" ]
I created a function which I use to send an email when a specific button is pressed. This works great, except that it always ends up in spam instead of the inbox. This is the function: ``` function search_notify_email() { // Set variables $email = $_POST['email']; $title = $_POST['title']; $content = $_POST['...
You should add a custom plugin. That needs a PHP main file that includes and registers a JavaScript file. The source below should result in a plugin. You will find a usable solution also in the probs below. PHP part -------- ``` add_action( 'enqueue_block_editor_assets', 'my_gutenberg_scripts' ); function my_gutenber...
332,585
<p>I want to redirect all 404 error pages on my WordPress site to the homepage, or to a specific page.<br> Any advice?</p>
[ { "answer_id": 332595, "author": "SherylHohman", "author_id": 109770, "author_profile": "https://wordpress.stackexchange.com/users/109770", "pm_score": 2, "selected": false, "text": "<p>It's probably a better idea to design your 404 page to include relevant information from your homepage...
2019/03/25
[ "https://wordpress.stackexchange.com/questions/332585", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/146130/" ]
I want to redirect all 404 error pages on my WordPress site to the homepage, or to a specific page. Any advice?
> > ***Note: I have read somewhere that redirecting all 404 to Homepage is*** > ***not a good approach for SEO purposes*** > > > --- Simplest way to redirect all 404 to homepage in wordpress. ``` if( !function_exists('redirect_404_to_homepage') ){ add_action( 'template_redirect', 'redirect_404_to_homepage' ...
332,626
<p>I am trying to get a list of posts if has same zipcode values. Thanks in advance for the help.</p> <pre><code>&lt;?php $query = new WP_Query( array( 'post_type'=&gt; array('service'), 'posts_per_page' =&gt; -1, 'meta_query' =&gt; array( array( 'key'=&gt; 'zipcode', 'value'=&gt; ','.$zip.',', 'compare'=...
[ { "answer_id": 332634, "author": "Praveen", "author_id": 97802, "author_profile": "https://wordpress.stackexchange.com/users/97802", "pm_score": 2, "selected": false, "text": "<p>Following code will be proper for the meta query. </p>\n\n<pre><code> $query_args = array(\n 'post_ty...
2019/03/26
[ "https://wordpress.stackexchange.com/questions/332626", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/97802/" ]
I am trying to get a list of posts if has same zipcode values. Thanks in advance for the help. ``` <?php $query = new WP_Query( array( 'post_type'=> array('service'), 'posts_per_page' => -1, 'meta_query' => array( array( 'key'=> 'zipcode', 'value'=> ','.$zip.',', 'compare'=> 'LIKE' ) ) )); ...
Following code will be proper for the meta query. ``` $query_args = array( 'post_type' => 'service', 'posts_per_page' => -1, 'meta_query' => array( array( 'value' => $zip, 'compare' => 'LIKE', 'key' => 'zipcode', ...
332,646
<p>I am developing a plugin and I want to show my custom post type (<code>projects</code>) next to the standard post type <code>posts</code>. I know I can do this by adding some code to the themes functions.php. But is it possible to achieve this within my plugin? The plugin should be usable from the start without requ...
[ { "answer_id": 332649, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 0, "selected": false, "text": "<p>The only way to do this (show CPTs every time Posts are shown) reliably across themes would be to registe...
2019/03/26
[ "https://wordpress.stackexchange.com/questions/332646", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/158872/" ]
I am developing a plugin and I want to show my custom post type (`projects`) next to the standard post type `posts`. I know I can do this by adding some code to the themes functions.php. But is it possible to achieve this within my plugin? The plugin should be usable from the start without requiring the user to do some...
Something like this should achieve your goal. You may need to remove the `is_main_query()` check depending on where you want this to show up though. ``` add_filter('pre_get_posts', 'projects_are_posts'); function projects_are_posts($query) { if (is_admin() || !is_main_query() ) { return $query; } $...
332,656
<p>I'm making a plugin for a website, which methods I'd like to use in a few different places, such as page templates, shortcodes etc.</p> <p>I don't want to make the plugin class global or create more than one instance (I'm creating one instance of it on plugin activation).</p> <p>What's the best approach to do it? ...
[ { "answer_id": 332649, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 0, "selected": false, "text": "<p>The only way to do this (show CPTs every time Posts are shown) reliably across themes would be to registe...
2019/03/26
[ "https://wordpress.stackexchange.com/questions/332656", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75841/" ]
I'm making a plugin for a website, which methods I'd like to use in a few different places, such as page templates, shortcodes etc. I don't want to make the plugin class global or create more than one instance (I'm creating one instance of it on plugin activation). What's the best approach to do it? Should I make sho...
Something like this should achieve your goal. You may need to remove the `is_main_query()` check depending on where you want this to show up though. ``` add_filter('pre_get_posts', 'projects_are_posts'); function projects_are_posts($query) { if (is_admin() || !is_main_query() ) { return $query; } $...
332,661
<p>I've this DOM here:</p> <pre><code>&lt;ul class="sub-menu"&gt; &lt;li id="menu-item-1424" class="menu-item menu-item-type-taxonomy menu-item-object-product_cat"&gt; &lt;a href="#"&gt;Item&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>What I need to do is, to add a custom class (<code>has-rippl...
[ { "answer_id": 332649, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 0, "selected": false, "text": "<p>The only way to do this (show CPTs every time Posts are shown) reliably across themes would be to registe...
2019/03/26
[ "https://wordpress.stackexchange.com/questions/332661", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/151233/" ]
I've this DOM here: ``` <ul class="sub-menu"> <li id="menu-item-1424" class="menu-item menu-item-type-taxonomy menu-item-object-product_cat"> <a href="#">Item</a> </li> </ul> ``` What I need to do is, to add a custom class (`has-ripple`) to only the `sub-menu > a` items: ``` <ul class="sub-menu"> ...
Something like this should achieve your goal. You may need to remove the `is_main_query()` check depending on where you want this to show up though. ``` add_filter('pre_get_posts', 'projects_are_posts'); function projects_are_posts($query) { if (is_admin() || !is_main_query() ) { return $query; } $...
332,712
<p>we have wordpress main site on domain.com now we did copy of the site and put in the sub-folder domain.com/blog we did all necessary url changes. but it seems we have issues with .htaccess file.. the domain.com/blog is redirected to domain.com</p> <p>this is what .htaccess in root </p> <pre><code># BEGIN WordPre...
[ { "answer_id": 332728, "author": "leymannx", "author_id": 30597, "author_profile": "https://wordpress.stackexchange.com/users/30597", "pm_score": 1, "selected": false, "text": "<p>Your <code>.htaccess</code> looks just fine, but you need to tell WordPress itself that it got moved. Simply...
2019/03/27
[ "https://wordpress.stackexchange.com/questions/332712", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
we have wordpress main site on domain.com now we did copy of the site and put in the sub-folder domain.com/blog we did all necessary url changes. but it seems we have issues with .htaccess file.. the domain.com/blog is redirected to domain.com this is what .htaccess in root ``` # BEGIN WordPress <IfModule mod_rewr...
Your `.htaccess` looks just fine, but you need to tell WordPress itself that it got moved. Simply put the following line into your `wp-config.php`, then access your site's login page under the new URL and login. After that you can remove this line.: ``` define('RELOCATE', TRUE); ``` --- Alternatively add the follow...
332,740
<p>The built in function <code>the_content</code> runs through several filters, but does not escape output. It would be difficult for it to do so, as HTML and even some scripts must be allowed through.</p> <p>When outputting, the_content seems to run through these filters (as of 5.0):</p> <pre><code>add_filter( 'the_...
[ { "answer_id": 332741, "author": "butlerblog", "author_id": 38603, "author_profile": "https://wordpress.stackexchange.com/users/38603", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>If I were a hacker with access to the database, wouldn't I just add my code to a post's co...
2019/03/27
[ "https://wordpress.stackexchange.com/questions/332740", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28273/" ]
The built in function `the_content` runs through several filters, but does not escape output. It would be difficult for it to do so, as HTML and even some scripts must be allowed through. When outputting, the\_content seems to run through these filters (as of 5.0): ``` add_filter( 'the_content', 'do_blocks', 9 ); add...
> > If I were a hacker with access to the database, wouldn't I just add my > code to a post's content? > > > If you've got access to the database, chances are that you've got enough access that escaping isn't going to stop you. Escaping is not going to help you if you've been hacked. It's not supposed to. There's...
332,755
<p>I'm currently trying to build a custom reset password form, which seems to work fine up until it needs to validate the key for the user:</p> <pre><code>//Redirect away from default wordpress to reset password function redirect_to_reset_password() { if ( 'GET' == $_SERVER['REQUEST_METHOD'] ) { // Verify ...
[ { "answer_id": 336305, "author": "MikeNGarrett", "author_id": 1670, "author_profile": "https://wordpress.stackexchange.com/users/1670", "pm_score": 0, "selected": false, "text": "<p>I think the problem here is the fact that you're using <code>$_REQUEST</code> instead of explicitly lookin...
2019/03/27
[ "https://wordpress.stackexchange.com/questions/332755", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/163961/" ]
I'm currently trying to build a custom reset password form, which seems to work fine up until it needs to validate the key for the user: ``` //Redirect away from default wordpress to reset password function redirect_to_reset_password() { if ( 'GET' == $_SERVER['REQUEST_METHOD'] ) { // Verify key / login co...
I had the same issue with this, I assume you're working from this guide - <https://code.tutsplus.com/tutorials/build-a-custom-wordpress-user-flow-part-3-password-reset--cms-23811> Have a look at the actual reset password form where it shows pass1 and pass2. The hidden fields values are automatically set to `$attribute...
332,762
<p>I'm planning to create a wordpress plugin that will offload uploaded images to external website and show them from there.</p> <p>What I did so far:</p> <p>1) Whenever a images gets uploaded, my custom functions will trigger and will upload the image including its thumbnails to the external site and store the urls ...
[ { "answer_id": 336328, "author": "ggedde", "author_id": 166772, "author_profile": "https://wordpress.stackexchange.com/users/166772", "pm_score": 4, "selected": true, "text": "<p>You will most likely want to use filters. The main issue is that developers will need to make sure to use th...
2019/03/27
[ "https://wordpress.stackexchange.com/questions/332762", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/116204/" ]
I'm planning to create a wordpress plugin that will offload uploaded images to external website and show them from there. What I did so far: 1) Whenever a images gets uploaded, my custom functions will trigger and will upload the image including its thumbnails to the external site and store the urls to database. No ...
You will most likely want to use filters. The main issue is that developers will need to make sure to use the correct functions like "the\_post\_thumbnail()" etc. You can use wp\_get\_attachment\_url <https://codex.wordpress.org/Function_Reference/wp_get_attachment_url> I use this when doing local development, but wan...
332,771
<p>I am trying to make a new ACF rule to display fields when parent page has a specific template name. Here's my current attempt:</p> <pre><code>add_filter('acf/location/rule_types', 'acf_location_rules_types'); function acf_location_rules_types( $choices ) { $choices['Parent']['parent_template'] = 'Parent Templa...
[ { "answer_id": 332773, "author": "DimChtz", "author_id": 154572, "author_profile": "https://wordpress.stackexchange.com/users/154572", "pm_score": 1, "selected": false, "text": "<p>For anyone dealing with the same issue, I just needed to change:</p>\n\n<pre><code>$choices[ $template_name...
2019/03/27
[ "https://wordpress.stackexchange.com/questions/332771", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154572/" ]
I am trying to make a new ACF rule to display fields when parent page has a specific template name. Here's my current attempt: ``` add_filter('acf/location/rule_types', 'acf_location_rules_types'); function acf_location_rules_types( $choices ) { $choices['Parent']['parent_template'] = 'Parent Template'; retu...
For anyone dealing with the same issue, I just needed to change: ``` $choices[ $template_name ] = $template_name; ``` with: ``` $choices[ $template_filename ] = $template_name; ``` Consider a page template `Homepage (page-home.php)`. This way the template name `Homepage` will appear on the custom fields page but ...
332,828
<p>I have been asked to do some work on a site where the old developer has written this function (create a variable that stores the users avatar into an img tag) into the functions.php:</p> <pre><code>add_filter('get_avatar', 'lb_acf_profile_avatar', 10, 5); function lb_acf_profile_avatar($avatar, $id_or_email, $size,...
[ { "answer_id": 332773, "author": "DimChtz", "author_id": 154572, "author_profile": "https://wordpress.stackexchange.com/users/154572", "pm_score": 1, "selected": false, "text": "<p>For anyone dealing with the same issue, I just needed to change:</p>\n\n<pre><code>$choices[ $template_name...
2019/03/28
[ "https://wordpress.stackexchange.com/questions/332828", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/159876/" ]
I have been asked to do some work on a site where the old developer has written this function (create a variable that stores the users avatar into an img tag) into the functions.php: ``` add_filter('get_avatar', 'lb_acf_profile_avatar', 10, 5); function lb_acf_profile_avatar($avatar, $id_or_email, $size, $default, $al...
For anyone dealing with the same issue, I just needed to change: ``` $choices[ $template_name ] = $template_name; ``` with: ``` $choices[ $template_filename ] = $template_name; ``` Consider a page template `Homepage (page-home.php)`. This way the template name `Homepage` will appear on the custom fields page but ...
332,856
<p>I have a general question about functions and add_action to it.</p> <p>I have a function and adding an action do it. But how can i define a value for the argument on this action?</p> <pre><code>add_action( 'um_members_just_after_name', 'my_members_after_user_name', 10, 1 ); function my_members_after_user_name( $us...
[ { "answer_id": 332839, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 4, "selected": true, "text": "<p>First of all, it is a very bad idea to modify the original theme without creating a child theme. Disab...
2019/03/28
[ "https://wordpress.stackexchange.com/questions/332856", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154739/" ]
I have a general question about functions and add\_action to it. I have a function and adding an action do it. But how can i define a value for the argument on this action? ``` add_action( 'um_members_just_after_name', 'my_members_after_user_name', 10, 1 ); function my_members_after_user_name( $user_id ) { // ho...
First of all, it is a very bad idea to modify the original theme without creating a child theme. Disabling updates of such theme is even worse idea, because without updates, your site may get infected or attacked. So the long-term solution would be to: 1. Check the version of modified theme. 2. Download that version ...
332,857
<p>I'm trying to run some simple javascript on a button click but I can't seem to find clear instructions on how to set up Javascript to run in wordpress.</p> <p>The steps I've taken so far are to enqueue the script:</p> <pre><code>function tyc_load_styles() { wp_enqueue_style('main_font', 'https://fonts.googleap...
[ { "answer_id": 332914, "author": "JakePowell", "author_id": 158548, "author_profile": "https://wordpress.stackexchange.com/users/158548", "pm_score": 1, "selected": false, "text": "<p>Thanks to WebElaine, you got it. </p>\n\n<p>I think that the type error was because the script loaded be...
2019/03/28
[ "https://wordpress.stackexchange.com/questions/332857", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/158548/" ]
I'm trying to run some simple javascript on a button click but I can't seem to find clear instructions on how to set up Javascript to run in wordpress. The steps I've taken so far are to enqueue the script: ``` function tyc_load_styles() { wp_enqueue_style('main_font', 'https://fonts.googleapis.com/css?family=Rob...
Please read this documentation <https://developer.wordpress.org/reference/functions/wp_enqueue_script/> You need to set 5th parameter to true so the javascript is loaded in the footer. `wp_enqueue_script( 'tyc_scripts', get_theme_file_uri('/js/tyc_scripts.js'), array(), false, true );` if the issue still persists ple...
332,878
<p>So I'm trying to set up an AJAX action for a plugin I'm building. </p> <p>When using <code>/wp-admin/admin-ajax.php?action=beacon_podio-get_apps</code> </p> <p>I was just getting <code>hello world0</code> and I'm not seeing <code>Request is valid</code> or the <code>Invalid request</code> so it seems like the acti...
[ { "answer_id": 332880, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 2, "selected": false, "text": "<p>OK, so you misunderstood it a little bit, I guess...</p>\n\n<p>You do the first part correctly. So ye...
2019/03/28
[ "https://wordpress.stackexchange.com/questions/332878", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/39073/" ]
So I'm trying to set up an AJAX action for a plugin I'm building. When using `/wp-admin/admin-ajax.php?action=beacon_podio-get_apps` I was just getting `hello world0` and I'm not seeing `Request is valid` or the `Invalid request` so it seems like the action is not being called I think I'm missing something but I'm...
This appeared to be a bug in WordPress, coming back to this and upgrading to version 5.2 the problem seems to have been fixed for some reason the has\_action was failing to find the action unsure why but it seems to have been fixed.
332,913
<p>I am not able to get this running. What i commented out is running like it should, but i want to use the switch for specific user roles...</p> <pre><code>add_action( 'um_members_just_after_name', 'my_members_after_user_name', 10, 1 ); function my_members_after_user_name( $user_id ) { $user = new WP_User( $user...
[ { "answer_id": 332915, "author": "Tejas Gajjar", "author_id": 155971, "author_profile": "https://wordpress.stackexchange.com/users/155971", "pm_score": 1, "selected": true, "text": "<p>You do not need to use pass the <code>$value</code> in a switch statement, Just pass there <code>$user-...
2019/03/29
[ "https://wordpress.stackexchange.com/questions/332913", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154739/" ]
I am not able to get this running. What i commented out is running like it should, but i want to use the switch for specific user roles... ``` add_action( 'um_members_just_after_name', 'my_members_after_user_name', 10, 1 ); function my_members_after_user_name( $user_id ) { $user = new WP_User( $user_id ); /* ...
You do not need to use pass the `$value` in a switch statement, Just pass there `$user->roles[0]` instead of `$value` and after that your condition. Add below code and let me know your answer towards it. ``` add_action( 'um_members_just_after_name', 'my_members_after_user_name', 10, 1 ); function my_members_after_use...
332,931
<p>So, I am using heading tags <code>h1</code>-<code>h6</code> on my site in various places, what I'd like to do is put a <code>div</code> around those tags using a WP function. Right now I am using some jQuery to get the job done, but I'm trying to minimize the amount of jQuery on my site, so I figured it'd be better ...
[ { "answer_id": 332937, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 0, "selected": false, "text": "<p>The code you’ve posted is a great starting point. All you have to do is to change the expressions ins...
2019/03/29
[ "https://wordpress.stackexchange.com/questions/332931", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9820/" ]
So, I am using heading tags `h1`-`h6` on my site in various places, what I'd like to do is put a `div` around those tags using a WP function. Right now I am using some jQuery to get the job done, but I'm trying to minimize the amount of jQuery on my site, so I figured it'd be better to use some kind of `preg_replace` t...
Try this code ``` function wrap_heading_with_div( $content ) { $heading = '/<h\d.*?>(.*?)<\/h\d>/ims'; $wrapper = '<div class="title">$0</div>'; $content = preg_replace($heading, $wrapper, $content); return $content; } add_filter( 'the_content', 'wrap_heading_with_div' ); ``` [Live Demo](https://www....
332,952
<p>I'm getting errors, warnings and notices being displayed on a site. Those include things like filesystem paths, SQL queries and wpdb prefixes, which I don't think it's particularly good to have them being displayed to all visitors.</p> <p><strong>I have fixed the cause of the issue,</strong> but I want to prevent t...
[ { "answer_id": 332953, "author": "That Brazilian Guy", "author_id": 22510, "author_profile": "https://wordpress.stackexchange.com/users/22510", "pm_score": -1, "selected": false, "text": "<p>As others have already said, it's very important to fix the underlying issues causing the error m...
2019/03/29
[ "https://wordpress.stackexchange.com/questions/332952", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22510/" ]
I'm getting errors, warnings and notices being displayed on a site. Those include things like filesystem paths, SQL queries and wpdb prefixes, which I don't think it's particularly good to have them being displayed to all visitors. **I have fixed the cause of the issue,** but I want to prevent these error messages fro...
As many have already commented, it is better to fix the source of the issue than to hide the messages. That said, these types of messages should never be displayed on production server but, since you just never know, it is also a good idea to disable them on *all* servers (local development machine, development machine...
333,009
<p>I'm using the <code>do_shortcode</code> function to add a shortcode in a page. But I would like to check if that shortcode exists before displaying it. If the user has no gallery, I would like to display a message like this: "Sorry no gallery here".</p> <p>This is my PHP:</p> <pre><code>&lt;?php /** * galeries con...
[ { "answer_id": 333004, "author": "selidamou.gr", "author_id": 126844, "author_profile": "https://wordpress.stackexchange.com/users/126844", "pm_score": -1, "selected": false, "text": "<p>you can certainly alter the <code>wp-content/uploads</code> and make it to appear as <code>/uploads</...
2019/03/30
[ "https://wordpress.stackexchange.com/questions/333009", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/164119/" ]
I'm using the `do_shortcode` function to add a shortcode in a page. But I would like to check if that shortcode exists before displaying it. If the user has no gallery, I would like to display a message like this: "Sorry no gallery here". This is my PHP: ``` <?php /** * galeries content */ function iconic_galeries_e...
You can try this code `define('UPLOADS','')`and also unclick Organize my uploads into month- and year-based folders from media settings.
333,016
<p>I have a custom Gutenberg block which is attempting to take an array of strings and save them as <code>&lt;li&gt;</code> elements. Everything works as expected and displays correctly to the end user, but I'm getting validation errors after reloading the editor.</p> <p>Here is the validation error:</p> <pre><code>E...
[ { "answer_id": 333047, "author": "tmdesigned", "author_id": 28273, "author_profile": "https://wordpress.stackexchange.com/users/28273", "pm_score": 2, "selected": false, "text": "<p>When you set the attribute's source to children, it gives you DOM elements, i.e. including the wrapping HT...
2019/03/30
[ "https://wordpress.stackexchange.com/questions/333016", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/137195/" ]
I have a custom Gutenberg block which is attempting to take an array of strings and save them as `<li>` elements. Everything works as expected and displays correctly to the end user, but I'm getting validation errors after reloading the editor. Here is the validation error: ``` Expected: <div class="wp-block-ggcn-bl...
When you set the attribute's source to children, it gives you DOM elements, i.e. including the wrapping HTML and not just the inner text. So the behavior you're seeing, which you probably already know, is the HTML elements getting nested inside of themselves. You're wrapping the contents in `<li>`, which gets wrapped...
333,071
<p>I am working on a wordpress shortcodes in which I want to the limit the content coming from a xml.</p> <p>The code which I have used for wordpress shortcodes is:</p> <pre><code>function podcast_func( $content = null ){ ob_start(); ?&gt; &lt;script src="https://content.jwplatform.com/libraries/FZ8yNTef.js"&...
[ { "answer_id": 333521, "author": "Serkan Algur", "author_id": 23042, "author_profile": "https://wordpress.stackexchange.com/users/23042", "pm_score": 2, "selected": false, "text": "<p>You need to parse your XML file for creating a playlist for jwplayer according to this <a href=\"https:/...
2019/03/31
[ "https://wordpress.stackexchange.com/questions/333071", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/143115/" ]
I am working on a wordpress shortcodes in which I want to the limit the content coming from a xml. The code which I have used for wordpress shortcodes is: ``` function podcast_func( $content = null ){ ob_start(); ?> <script src="https://content.jwplatform.com/libraries/FZ8yNTef.js"></script> <center><div id="...
It's better to 1st save the returned XML to a file and then loop back to unset. ``` <?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "http://www.cpac.ca/tip-podcast/jwplayer.xml", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT...
333,090
<p>I have 16 published posts of type "portfolio". With the query below, "found_posts" is 16. Correct so far.</p> <p>I've set "posts_per_page" to -1 to see all of them. But only 8 of them get rendered. The wordpress setting posts per page is 10, so this cant be the issues. There is also no multilingual plugin like WPML...
[ { "answer_id": 333091, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 2, "selected": true, "text": "<p>But all of them get obtained from the database.</p>\n\n<p>The problem is that you’re ignoring half of ...
2019/04/01
[ "https://wordpress.stackexchange.com/questions/333090", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/134335/" ]
I have 16 published posts of type "portfolio". With the query below, "found\_posts" is 16. Correct so far. I've set "posts\_per\_page" to -1 to see all of them. But only 8 of them get rendered. The wordpress setting posts per page is 10, so this cant be the issues. There is also no multilingual plugin like WPML workin...
But all of them get obtained from the database. The problem is that you’re ignoring half of them. Or rather merging two of them and displaying as one. Let’s take a look at your code: ``` while ( $query->have_posts() ) { $query->the_post(); // <- here you call the_post() first time $output.='<div class="en...
333,130
<p>i called wordpress function between the shorcodes as a input. </p> <pre><code>&lt;?php echo do_shortcode('[shortcode]'.$var.'[/shortcode]');?&gt; </code></pre> <p>how to add div class for the $var here?</p> <p>I tried few combination but it works for the full shortcode. i just want to use the div only for $var.</...
[ { "answer_id": 333131, "author": "Qaisar Feroz", "author_id": 161501, "author_profile": "https://wordpress.stackexchange.com/users/161501", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>How to add div class <strong>only for $var</strong> here?</p>\n</blockquote>\n\n<p>Try...
2019/04/01
[ "https://wordpress.stackexchange.com/questions/333130", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5669/" ]
i called wordpress function between the shorcodes as a input. ``` <?php echo do_shortcode('[shortcode]'.$var.'[/shortcode]');?> ``` how to add div class for the $var here? I tried few combination but it works for the full shortcode. i just want to use the div only for $var. I tried like, ``` <?php echo '<div cla...
It's a bit difficult to understand or provide an accurate answer as we don't know what the shortcode is executing. Is it stripping html or any other parsing? If this is your own code, then you could add it in the function the shortcode is calling. If its not you could try a couple options: 1: (adding the div direct...
333,138
<p>I'm trying to remove the infinite-wrap class jetpack adds to posts with infinite scroll turned on because I want to add infinitely loaded posts to a gridded layout.</p> <p>I found the article here that says to add the theme support stuff to the functions.php :<a href="https://trickspanda.com/customize-jetpack-infin...
[ { "answer_id": 333210, "author": "Tiago Hillebrandt", "author_id": 44840, "author_profile": "https://wordpress.stackexchange.com/users/44840", "pm_score": 1, "selected": false, "text": "<p>What if you remove the existing infinite-scroll before re-add it?</p>\n\n<pre class=\"lang-php pret...
2019/04/01
[ "https://wordpress.stackexchange.com/questions/333138", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103174/" ]
I'm trying to remove the infinite-wrap class jetpack adds to posts with infinite scroll turned on because I want to add infinitely loaded posts to a gridded layout. I found the article here that says to add the theme support stuff to the functions.php :<https://trickspanda.com/customize-jetpack-infinite-scroll/> I en...
Since I was using the underscores.me theme, I had to look in the 'inc' folder for the jetpack.php file. There is where I had to change the options to get the desired effect.
333,149
<p>in my <code>functions.php</code> I have</p> <pre><code>require 'autoloader.php'; add_action('init', 'MyClass::make'); </code></pre> <p>and in my <code>MyClass</code> class I have</p> <pre class="lang-php prettyprint-override"><code>class MyClass { public static function make($type) { var_dump($type);d...
[ { "answer_id": 333160, "author": "phatskat", "author_id": 20143, "author_profile": "https://wordpress.stackexchange.com/users/20143", "pm_score": 0, "selected": false, "text": "<p>The <code>init</code> hook doesn't pass any parameters - when you call <code>add_action</code>, <code>init</...
2019/04/01
[ "https://wordpress.stackexchange.com/questions/333149", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/164241/" ]
in my `functions.php` I have ``` require 'autoloader.php'; add_action('init', 'MyClass::make'); ``` and in my `MyClass` class I have ```php class MyClass { public static function make($type) { var_dump($type);die; } } ``` but the output of `var_dump` is `string(0) ""`. What I want is to pass the a...
Here's another example on how you could implement the `add_action`: ```php $type = 'my_sample_type'; add_action( 'init', function() use ( $type ) { MyClass::make( $type ); } ); ```