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
292,240
<p>I'm working on tweaking a theme and I need to explode the post content to remove some text. The following code is what I am using: </p> <pre><code>$custom_Get_Post_Title = explode('|',get_post()-&gt;post_content); echo "&lt;h4&gt;" . $custom_Get_Post_Title[0] . "&lt;/h4&gt;"; echo "&lt;p&gt;" . $custo...
[ { "answer_id": 292241, "author": "admcfajn", "author_id": 123674, "author_profile": "https://wordpress.stackexchange.com/users/123674", "pm_score": 2, "selected": false, "text": "<p><code>get_post()</code> is the same as <code>global $post</code></p>\n\n<p>functions such as <code>the_con...
2018/01/25
[ "https://wordpress.stackexchange.com/questions/292240", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135605/" ]
I'm working on tweaking a theme and I need to explode the post content to remove some text. The following code is what I am using: ``` $custom_Get_Post_Title = explode('|',get_post()->post_content); echo "<h4>" . $custom_Get_Post_Title[0] . "</h4>"; echo "<p>" . $custom_Get_Post_Title[1] . "</p>"; ``` ...
`post_content` is a *property* of the [`WP_Post`](https://developer.wordpress.org/reference/classes/wp_post/) object. `WP_Post` is an object representing the post data from the database. So `post_content` contains the raw content as stored in the database. [`the_content()`](https://developer.wordpress.org/reference/fu...
292,245
<p>I'm having trouble finding a solution for this:</p> <p>I have a bunch of posts with restrict content, and to access the content of these pages the user has to submit a gravity form. I imagine the best way to do so is to set a cookie when <code>gform_after_submission</code> takes place. Then a function would check f...
[ { "answer_id": 292247, "author": "David Sword", "author_id": 132362, "author_profile": "https://wordpress.stackexchange.com/users/132362", "pm_score": 3, "selected": true, "text": "<p>You can accomplish what you're after by first creating a hidden field in your form. Set the value to the...
2018/01/25
[ "https://wordpress.stackexchange.com/questions/292245", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/78848/" ]
I'm having trouble finding a solution for this: I have a bunch of posts with restrict content, and to access the content of these pages the user has to submit a gravity form. I imagine the best way to do so is to set a cookie when `gform_after_submission` takes place. Then a function would check for that cookie and di...
You can accomplish what you're after by first creating a hidden field in your form. Set the value to the current embed page: [![enter image description here](https://i.stack.imgur.com/zZUkZ.png)](https://i.stack.imgur.com/zZUkZ.png) Take note of the hidden fields ID, for this demo, it's `3`. --- Then your code for ...
292,285
<p>I've been looking for the solution of this issue for a while but cannot find the correct answer.</p> <p>I'm developing a custom Knowledge Base plugin for my site, as requested by my boss. The around plugins are not working for he want, so I need to create my own.</p> <p>I've a Custom Post Type called <code>wikicon...
[ { "answer_id": 292299, "author": "onebc", "author_id": 121233, "author_profile": "https://wordpress.stackexchange.com/users/121233", "pm_score": 0, "selected": false, "text": "<p>Not a very indepth answer, and I'm not sure if this would work for your specific plugin scenario, but it seem...
2018/01/26
[ "https://wordpress.stackexchange.com/questions/292285", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135628/" ]
I've been looking for the solution of this issue for a while but cannot find the correct answer. I'm developing a custom Knowledge Base plugin for my site, as requested by my boss. The around plugins are not working for he want, so I need to create my own. I've a Custom Post Type called `wikicon_recurso` with it's ow...
The problem is that when there are no posts in the search query, WordPress doesn't set the post type in the global WP\_Query (`get_post_type()` relies on that). So, when there are no search results, `get_post_type()` will return false and all of your custom template logic will be skipped. What you can do is also consi...
292,293
<p>By default, the product quantity is always "1" when viewing a product page. There doesn't seem an out-of-the-box option to set a different quantity value upon visit, and I don't know what hook or function to look for. </p> <p>Your help is appreciated.</p>
[ { "answer_id": 292297, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>You can use the <code>woocommerce_quantity_input_args</code> filter:</p>\n\n<pre><code>function wpse_29...
2018/01/26
[ "https://wordpress.stackexchange.com/questions/292293", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118984/" ]
By default, the product quantity is always "1" when viewing a product page. There doesn't seem an out-of-the-box option to set a different quantity value upon visit, and I don't know what hook or function to look for. Your help is appreciated.
You can use the `woocommerce_quantity_input_args` filter: ``` function wpse_292293_quantity_input_default( $args, $product ) { $args['input_value'] = 2; return $args; } add_filter( 'woocommerce_quantity_input_args', 'wpse_292293_quantity_input_default', 10, 2 ); ``` When the quantity input is output, it's o...
292,308
<p>I have a client that wants to manage the editing process on a CPT called Floor Plan. They want to be able to preview and approve/deny all edits to a Floor Plan. I thought I had a solution by having an Admin account create a Floor Plan and have a Contributor enter the necessary content, finally being approved and pub...
[ { "answer_id": 292297, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>You can use the <code>woocommerce_quantity_input_args</code> filter:</p>\n\n<pre><code>function wpse_29...
2018/01/26
[ "https://wordpress.stackexchange.com/questions/292308", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/111880/" ]
I have a client that wants to manage the editing process on a CPT called Floor Plan. They want to be able to preview and approve/deny all edits to a Floor Plan. I thought I had a solution by having an Admin account create a Floor Plan and have a Contributor enter the necessary content, finally being approved and publis...
You can use the `woocommerce_quantity_input_args` filter: ``` function wpse_292293_quantity_input_default( $args, $product ) { $args['input_value'] = 2; return $args; } add_filter( 'woocommerce_quantity_input_args', 'wpse_292293_quantity_input_default', 10, 2 ); ``` When the quantity input is output, it's o...
292,315
<p>I have a problem! I have my website with wordpress. I only have one category and I want to have 5 categories. The problem is that I have published more than 7000 post. How can I use a word of the content of the post and relationship to one of the new categories.</p> <p>Example cat (word of the Post_content) ----> c...
[ { "answer_id": 292297, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>You can use the <code>woocommerce_quantity_input_args</code> filter:</p>\n\n<pre><code>function wpse_29...
2018/01/26
[ "https://wordpress.stackexchange.com/questions/292315", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135643/" ]
I have a problem! I have my website with wordpress. I only have one category and I want to have 5 categories. The problem is that I have published more than 7000 post. How can I use a word of the content of the post and relationship to one of the new categories. Example cat (word of the Post\_content) ----> cat (new c...
You can use the `woocommerce_quantity_input_args` filter: ``` function wpse_292293_quantity_input_default( $args, $product ) { $args['input_value'] = 2; return $args; } add_filter( 'woocommerce_quantity_input_args', 'wpse_292293_quantity_input_default', 10, 2 ); ``` When the quantity input is output, it's o...
292,341
<p>In the following code I would like to remove the div that wrap all the code and pass its class to article, but I do not know how to pass the variable $termString inside the post_class.</p> <p>Can anybody help me?</p> <pre><code>&lt;div class="&lt;?php echo $termsString;?&gt;"&gt; &lt;article id="post-&lt;?php ...
[ { "answer_id": 292342, "author": "swissspidy", "author_id": 12404, "author_profile": "https://wordpress.stackexchange.com/users/12404", "pm_score": 1, "selected": false, "text": "<p>You should be able to just use <code>post_class( 'card ' . $termString )</code>.</p>\n\n<p>The function ac...
2018/01/26
[ "https://wordpress.stackexchange.com/questions/292341", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70257/" ]
In the following code I would like to remove the div that wrap all the code and pass its class to article, but I do not know how to pass the variable $termString inside the post\_class. Can anybody help me? ``` <div class="<?php echo $termsString;?>"> <article id="post-<?php the_ID(); ?>" <?php post_class('card')...
The `post_class` function does also accept an array of classes. You can pass them to the function as follows: ``` $classes = [ 'card', 'grid-item', 'wow', 'fadeInUp', $termsString ]; <div <?php post_class ( $classes ); ?>> ... </div> ``` You can store the custom field's value inside a variabl...
292,351
<p>I have a problem with ajaxurl, I would like to know how I could fix this error code js "not defined" by designthemes-core-features.</p> <pre><code>jQuery.noConflict(); jQuery(document).ready(function($) { jQuery(document).on( 'click', '.dt-plugin-notice .notice-dismiss', function() { jQuery.ajax({ ...
[ { "answer_id": 292362, "author": "Nitin Sharma", "author_id": 43126, "author_profile": "https://wordpress.stackexchange.com/users/43126", "pm_score": -1, "selected": false, "text": "<p>Please try</p>\n\n<pre><code>dttheme_urls.ajaxurl\n</code></pre>\n" }, { "answer_id": 292513, ...
2018/01/27
[ "https://wordpress.stackexchange.com/questions/292351", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135681/" ]
I have a problem with ajaxurl, I would like to know how I could fix this error code js "not defined" by designthemes-core-features. ``` jQuery.noConflict(); jQuery(document).ready(function($) { jQuery(document).on( 'click', '.dt-plugin-notice .notice-dismiss', function() { jQuery.ajax({ url: ...
is the "designthemes-core-features" plugin of a theme, this code can be found in the admin.js file inside the JS folder. The code "`url: ajaxurl`," (says: "ajaxurl is not defined") Would there be any idea? Would you like some more information? Thank you
292,364
<pre><code>PHP Warning: file_put_contents(http://lendersmatch.ca/wp-content/uploads/deals/deal1.pdf): failed to open stream: HTTP wrapper does not support writeable connections in /home/t21jv08zz60b/public_html/wp-content/plugins/mortgage/fpdf181/fpdf.php on line 1023 [27-Jan-2018 11:24:20 UTC] PHP Fatal error: Unca...
[ { "answer_id": 292365, "author": "janh", "author_id": 129206, "author_profile": "https://wordpress.stackexchange.com/users/129206", "pm_score": 3, "selected": true, "text": "<p><code>$name</code> apparently contains a URL. That won't work. Set it to a local path, as you did with <code>$f...
2018/01/27
[ "https://wordpress.stackexchange.com/questions/292364", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/95126/" ]
``` PHP Warning: file_put_contents(http://lendersmatch.ca/wp-content/uploads/deals/deal1.pdf): failed to open stream: HTTP wrapper does not support writeable connections in /home/t21jv08zz60b/public_html/wp-content/plugins/mortgage/fpdf181/fpdf.php on line 1023 [27-Jan-2018 11:24:20 UTC] PHP Fatal error: Uncaught Ex...
`$name` apparently contains a URL. That won't work. Set it to a local path, as you did with `$filename`: ``` $upload_dir = wp_upload_dir(); $filename = $upload_dir["basedir"] . '/deals/deal' . $page->id . '.pdf'; ```
292,417
<p>I have a section in my website where i want to display just the private posts for logged in users, but the loop returns all posts (private and publish), is it possible to change this? I have the next code in my loop:</p> <pre><code>global $listingsearch, $listing_query, $wp_query; $view = listingpress_get_listing_...
[ { "answer_id": 292428, "author": "Vlad Olaru", "author_id": 52726, "author_profile": "https://wordpress.stackexchange.com/users/52726", "pm_score": 3, "selected": false, "text": "<p>You need to filter the main WordPress query using the <code>pre_get_posts</code> <a href=\"https://codex.w...
2018/01/28
[ "https://wordpress.stackexchange.com/questions/292417", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135728/" ]
I have a section in my website where i want to display just the private posts for logged in users, but the loop returns all posts (private and publish), is it possible to change this? I have the next code in my loop: ``` global $listingsearch, $listing_query, $wp_query; $view = listingpress_get_listing_search_view();...
You need to filter the main WordPress query using the `pre_get_posts` [action](https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts). This code will get you started: ``` function show_only_private_post_for_logged_in_users( $query ) { if ( ! $query->is_main_query() || is_admin() ) { return...
292,418
<p>I need some posts excludes from displaying in wp_query in some conditons. I use below code to do it, and the code works correctly, but I set the <code>posts_per_page</code> to <code>12</code> and by this code the skiped posts are counted , for example instead of <code>12</code> post in each page it has different pos...
[ { "answer_id": 292424, "author": "Vlad Olaru", "author_id": 52726, "author_profile": "https://wordpress.stackexchange.com/users/52726", "pm_score": 2, "selected": false, "text": "<p>To have the pagination work properly you need to filter the posts at the WordPress main query level using ...
2018/01/28
[ "https://wordpress.stackexchange.com/questions/292418", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135706/" ]
I need some posts excludes from displaying in wp\_query in some conditons. I use below code to do it, and the code works correctly, but I set the `posts_per_page` to `12` and by this code the skiped posts are counted , for example instead of `12` post in each page it has different post numbers (10,2,5 , ...) ``` while...
To have the pagination work properly you need to filter the posts at the WordPress main query level using the `pre_get_posts` [action](https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts). By looking at your code, I don't see where the post specific information is involved. Is `$course_options` holdi...
292,421
<p>How can I delete a field in my database under the posts table?</p> <p>For example in my <code>posts</code> table where the ID is 800 I would like to delete the a field under the column <code>product_rank</code>.</p> <p>Any help will be appreciated.</p>
[ { "answer_id": 292423, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 3, "selected": true, "text": "<p>You can't \"delete\" a field in MySQL, this only works for complete rows.</p>\n\n<p>However, you can unset valu...
2018/01/28
[ "https://wordpress.stackexchange.com/questions/292421", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132644/" ]
How can I delete a field in my database under the posts table? For example in my `posts` table where the ID is 800 I would like to delete the a field under the column `product_rank`. Any help will be appreciated.
You can't "delete" a field in MySQL, this only works for complete rows. However, you can unset values, meaning setting them to their original state, usually `NULL` or an empty string. ``` $wpdb->update($wpdb->posts, array( 'product_rank' => NULL ), array( 'ID' => $post_id )); ```
292,487
<p>I need to create masonry grid containing the latest posts. I created a grid based on <a href="https://masonry.desandro.com/" rel="nofollow noreferrer">https://masonry.desandro.com/</a> - the grid displays correctly.</p> <p>I am asking for help in creating a wp loop that will display posts in the grid.</p> <p>This ...
[ { "answer_id": 292423, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 3, "selected": true, "text": "<p>You can't \"delete\" a field in MySQL, this only works for complete rows.</p>\n\n<p>However, you can unset valu...
2018/01/29
[ "https://wordpress.stackexchange.com/questions/292487", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135780/" ]
I need to create masonry grid containing the latest posts. I created a grid based on <https://masonry.desandro.com/> - the grid displays correctly. I am asking for help in creating a wp loop that will display posts in the grid. This is my grid: ``` <!-- grid masonry layout --> <div class="news-wrapper container"> ...
You can't "delete" a field in MySQL, this only works for complete rows. However, you can unset values, meaning setting them to their original state, usually `NULL` or an empty string. ``` $wpdb->update($wpdb->posts, array( 'product_rank' => NULL ), array( 'ID' => $post_id )); ```
292,545
<p>I am asking in the last instance because I am totally confused after not being able to invoke custom javascript functions for 2 days straight. I am new to Wordpress plugin developmnet as my background is Java and NodeJS and I simply can't understand why my code is not working.</p> <p>I want to append a script in th...
[ { "answer_id": 292554, "author": "Stefano Tombolini", "author_id": 96268, "author_profile": "https://wordpress.stackexchange.com/users/96268", "pm_score": 0, "selected": false, "text": "<p>That hook will be deprecated in Ultimate Member 2.0.</p>\n\n<p>Beside that, have you added the actu...
2018/01/30
[ "https://wordpress.stackexchange.com/questions/292545", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135841/" ]
I am asking in the last instance because I am totally confused after not being able to invoke custom javascript functions for 2 days straight. I am new to Wordpress plugin developmnet as my background is Java and NodeJS and I simply can't understand why my code is not working. I want to append a script in the html hea...
As it turned out it was not a matter of my code but of the fact that you cannot echo some custom javascript inside the 'wp\_login' hook. What I did to solve this is to call `set_transient` inside my `wp_login` hook and then checking in the `wp_head` if there is any transient set. In this case I am echoing my javascript...
292,552
<p>using the standard <code>__('some-string', 'myplugin')</code> for translations, strings are being correctly loaded for a Japanese (ja) locale in every function and script other than my AJAX functions.</p> <p><strong>my-plugin.php:</strong></p> <pre><code>*Text Domain: myplugin *Domain Path: /languages/ */ add_acti...
[ { "answer_id": 292553, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 1, "selected": false, "text": "<p>I think you just need to load the translations earlier to make them available for ajax hooks:</p>\n\n<pre><co...
2018/01/30
[ "https://wordpress.stackexchange.com/questions/292552", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135842/" ]
using the standard `__('some-string', 'myplugin')` for translations, strings are being correctly loaded for a Japanese (ja) locale in every function and script other than my AJAX functions. **my-plugin.php:** ``` *Text Domain: myplugin *Domain Path: /languages/ */ add_action( 'init', 'myplugin_load_textdomain' ); fun...
It turns out I had a typo in the text domain for every call in my ajax function. For examples sake I entered the text domain as 'myplugin' in my question, but the real text domain is 'asumil-wishlist'. Instead of a hyphen I accidentally put an underscore, so `__('somestring', 'asumil-wishlist')` was `__('somestring', '...
292,562
<p>I'm a Javascript developer and I am very new to PHP/Wordpress. So just like what I saw from samples around the internet I wrote my <code>functions.php</code> script to add my custom css file like this: </p> <p><strong>functions.php</strong></p> <pre><code>&lt;?php echo '&lt;h1&gt;CASH ME OUTSIDE&lt;/h1&gt;'; ...
[ { "answer_id": 292563, "author": "Zex2911", "author_id": 51804, "author_profile": "https://wordpress.stackexchange.com/users/51804", "pm_score": 2, "selected": false, "text": "<p>View source for your website and CTRL+F for foo.css. wp_enqueue_scripts registers script / style and loads it...
2018/01/30
[ "https://wordpress.stackexchange.com/questions/292562", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135849/" ]
I'm a Javascript developer and I am very new to PHP/Wordpress. So just like what I saw from samples around the internet I wrote my `functions.php` script to add my custom css file like this: **functions.php** ``` <?php echo '<h1>CASH ME OUTSIDE</h1>'; add_action('wp_enqueue_scripts', 'theme_styles'); function...
A `echo` in functions.php, `wp_enqueue_scripts` or any other non-template file probably breaks the output due to a fatal error because of headers already sent. `echo` is not a proper way to debug. Delete the echo statements and check the HTML of the page, your css should be there. To debug, use error logs. Other than ...
292,565
<p>I'm currently facing a few loose ends while dealing with the homepage of a theme I am working on. I got my loop set up to show the most recent posts in a certain style and it works perfectly.</p> <p>Now I am trying to position two sticky posts (or even posts from a certain category) on top of that loop, utilizing d...
[ { "answer_id": 292570, "author": "Quang Hoang", "author_id": 134874, "author_profile": "https://wordpress.stackexchange.com/users/134874", "pm_score": 1, "selected": false, "text": "<p>I think you should add a css class and in your loop, put a <code>$i</code> and let <code>$i</code> run,...
2018/01/30
[ "https://wordpress.stackexchange.com/questions/292565", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76017/" ]
I'm currently facing a few loose ends while dealing with the homepage of a theme I am working on. I got my loop set up to show the most recent posts in a certain style and it works perfectly. Now I am trying to position two sticky posts (or even posts from a certain category) on top of that loop, utilizing different s...
I think you should add a css class and in your loop, put a `$i` and let `$i` run, `if $i == 2` then you add the css class attribute to that sticky post. ``` $i = 0; while( have_posts() ): the_post(); $i++; if($i == 2): $css_class = 'top-sticky'; else: $css_class = ''; endif; endwhile...
292,567
<p>I have this simple piece of code that is not working:</p> <pre><code> if ( 'publish' != $post-&gt;post_status ) { return; } </code></pre> <p>When I use this in my code, it blocks posts that should have a status of 'publish'.</p> <p>If I replace this with:</p> <pre><code> if ( 'publish' != get_post_stat...
[ { "answer_id": 292570, "author": "Quang Hoang", "author_id": 134874, "author_profile": "https://wordpress.stackexchange.com/users/134874", "pm_score": 1, "selected": false, "text": "<p>I think you should add a css class and in your loop, put a <code>$i</code> and let <code>$i</code> run,...
2018/01/30
[ "https://wordpress.stackexchange.com/questions/292567", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/134279/" ]
I have this simple piece of code that is not working: ``` if ( 'publish' != $post->post_status ) { return; } ``` When I use this in my code, it blocks posts that should have a status of 'publish'. If I replace this with: ``` if ( 'publish' != get_post_status( $post_id) ) { return; } ``` It works,...
I think you should add a css class and in your loop, put a `$i` and let `$i` run, `if $i == 2` then you add the css class attribute to that sticky post. ``` $i = 0; while( have_posts() ): the_post(); $i++; if($i == 2): $css_class = 'top-sticky'; else: $css_class = ''; endif; endwhile...
292,585
<p>I need a link to enable downloading of each audio file item within the native wordpress playlist.</p> <p>I've used the script from this thread >> <a href="https://wordpress.stackexchange.com/questions/141767/download-button-for-wp-audio-player">Download button for wp audio player</a></p> <p>but there isn't the abi...
[ { "answer_id": 292736, "author": "Peter HvD", "author_id": 134918, "author_profile": "https://wordpress.stackexchange.com/users/134918", "pm_score": 1, "selected": false, "text": "<p>Actually, for the majority of modern browsers all you need to do is add <code>download</code> to your <co...
2018/01/30
[ "https://wordpress.stackexchange.com/questions/292585", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135855/" ]
I need a link to enable downloading of each audio file item within the native wordpress playlist. I've used the script from this thread >> [Download button for wp audio player](https://wordpress.stackexchange.com/questions/141767/download-button-for-wp-audio-player) but there isn't the ability to ask questions of the...
Thanks to both of you for your help. Just so it might help others, this is what I did: Downloaded a wordpress plugin to allow custom scripts. I used this one >> <https://wordpress.org/plugins/header-and-footer-scripts-inserter/> I then pasted this code within the plugin (thanks to Birgire above & [HERE](https://wordpr...
292,617
<p>I have created several custom post types (for example: FAQs, products and case studies) and registered a global custom taxonomy for use across all CPTs. In my case this taxonomy is called <em>audiences</em>. These are listed as consumers, architects and merchants.</p> <p>In this example I'll use FAQs in the Merchan...
[ { "answer_id": 292736, "author": "Peter HvD", "author_id": 134918, "author_profile": "https://wordpress.stackexchange.com/users/134918", "pm_score": 1, "selected": false, "text": "<p>Actually, for the majority of modern browsers all you need to do is add <code>download</code> to your <co...
2018/01/30
[ "https://wordpress.stackexchange.com/questions/292617", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62753/" ]
I have created several custom post types (for example: FAQs, products and case studies) and registered a global custom taxonomy for use across all CPTs. In my case this taxonomy is called *audiences*. These are listed as consumers, architects and merchants. In this example I'll use FAQs in the Merchants taxonomy. ---...
Thanks to both of you for your help. Just so it might help others, this is what I did: Downloaded a wordpress plugin to allow custom scripts. I used this one >> <https://wordpress.org/plugins/header-and-footer-scripts-inserter/> I then pasted this code within the plugin (thanks to Birgire above & [HERE](https://wordpr...
292,639
<p>I created a plugin that displays staff people using a shortcode with custom category from a post type. eg. [board-members term="team1"] It works fine but only on a page or post. When I paste the shortcode into a tab (using whistles by Justin Tadlock) the profiles display outside the tab, above the tabs in the page b...
[ { "answer_id": 292642, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>If you want content to display in a specific spot, you will need to wrap the content in a <code>&lt;di...
2018/01/31
[ "https://wordpress.stackexchange.com/questions/292639", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67916/" ]
I created a plugin that displays staff people using a shortcode with custom category from a post type. eg. [board-members term="team1"] It works fine but only on a page or post. When I paste the shortcode into a tab (using whistles by Justin Tadlock) the profiles display outside the tab, above the tabs in the page body...
Sounds like you need to wrap your shortcode contents in `ob_start()`and `return ob_get_clean()` ``` require_once(dirname(__FILE__).'/post-type.php'); //file that registers CPT function wporg_shortcodes_init(){ function wporg_shortcode($atts = []) { extract( shortcode_atts( array( 'term' => 'columns' ...
292,651
<p>I have a legacy theme that has a lot of page template files. My site is too big to go through each page one by one to check it's template.</p> <p>Is there any way (either through adding a column to the pages list in the the backend, or in the database directly) to see which templates files are being used and determ...
[ { "answer_id": 292642, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>If you want content to display in a specific spot, you will need to wrap the content in a <code>&lt;di...
2018/01/31
[ "https://wordpress.stackexchange.com/questions/292651", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135910/" ]
I have a legacy theme that has a lot of page template files. My site is too big to go through each page one by one to check it's template. Is there any way (either through adding a column to the pages list in the the backend, or in the database directly) to see which templates files are being used and determine which ...
Sounds like you need to wrap your shortcode contents in `ob_start()`and `return ob_get_clean()` ``` require_once(dirname(__FILE__).'/post-type.php'); //file that registers CPT function wporg_shortcodes_init(){ function wporg_shortcode($atts = []) { extract( shortcode_atts( array( 'term' => 'columns' ...
292,662
<p>If two vendors has the same product then when the second vendor publish the product in to the store, 2 is appended to the permalink since the same product from the first vendor already exist</p> <p>Is there any solution to remove the numeric from the permalink? Ideally, the two permalinks should look like this:</p>...
[ { "answer_id": 292642, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>If you want content to display in a specific spot, you will need to wrap the content in a <code>&lt;di...
2018/01/31
[ "https://wordpress.stackexchange.com/questions/292662", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114977/" ]
If two vendors has the same product then when the second vendor publish the product in to the store, 2 is appended to the permalink since the same product from the first vendor already exist Is there any solution to remove the numeric from the permalink? Ideally, the two permalinks should look like this: <http://exam...
Sounds like you need to wrap your shortcode contents in `ob_start()`and `return ob_get_clean()` ``` require_once(dirname(__FILE__).'/post-type.php'); //file that registers CPT function wporg_shortcodes_init(){ function wporg_shortcode($atts = []) { extract( shortcode_atts( array( 'term' => 'columns' ...
292,673
<p>I have registered taxonomy: </p> <pre><code>$taxonomySetup = [ 'label' =&gt; __('Products catalog'), 'has_archive' =&gt; false, 'hierarchical' =&gt; true, 'rewrite' =&gt; [ 'slug' =&gt; __('catalog'), 'hierarchical' =&gt; true, 'with_front' =&gt; true ], ]; register_taxo...
[ { "answer_id": 292642, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>If you want content to display in a specific spot, you will need to wrap the content in a <code>&lt;di...
2018/01/31
[ "https://wordpress.stackexchange.com/questions/292673", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/134456/" ]
I have registered taxonomy: ``` $taxonomySetup = [ 'label' => __('Products catalog'), 'has_archive' => false, 'hierarchical' => true, 'rewrite' => [ 'slug' => __('catalog'), 'hierarchical' => true, 'with_front' => true ], ]; register_taxonomy('products', ['product'], $taxon...
Sounds like you need to wrap your shortcode contents in `ob_start()`and `return ob_get_clean()` ``` require_once(dirname(__FILE__).'/post-type.php'); //file that registers CPT function wporg_shortcodes_init(){ function wporg_shortcode($atts = []) { extract( shortcode_atts( array( 'term' => 'columns' ...
292,723
<p>When I click on "Edit" for an image I see the editor and I see the thumbnails on the right, WordPress just won't show me the actual image in the main area.</p> <pre><code>/wp-admin/admin-ajax.php?action=imgedit-preview&amp;_ajax_nonce=de68a01318&amp;postid=29499&amp;rand=385 (couldn't not find image) </code></pre> ...
[ { "answer_id": 292929, "author": "steffanjj", "author_id": 88213, "author_profile": "https://wordpress.stackexchange.com/users/88213", "pm_score": 2, "selected": false, "text": "<p>The preview is now displayed again after I removed empty lines and whitespaces after <code>?&gt;</code> in ...
2018/01/31
[ "https://wordpress.stackexchange.com/questions/292723", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88213/" ]
When I click on "Edit" for an image I see the editor and I see the thumbnails on the right, WordPress just won't show me the actual image in the main area. ``` /wp-admin/admin-ajax.php?action=imgedit-preview&_ajax_nonce=de68a01318&postid=29499&rand=385 (couldn't not find image) ``` Here is what I have done to try to...
The preview is now displayed again after I removed empty lines and whitespaces after `?>` in my `wp-config.php` file. That solved the problem.
292,727
<p>I'm trying to display all posts and only certain custom posts on the homepage.</p> <p>Essentially: <code>(post_type = post) OR (post_type = exhibition AND featured = 1)</code></p> <p>I'm stuck with the actual implementation though.</p> <p><code>pre_get_posts</code> and <code>$query-&gt;set(...);</code> don't seem...
[ { "answer_id": 292732, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>You can't specify <code>OR</code> or <code>AND</code> on arbitrary <code>WP_Query</code> arguments. Met...
2018/01/31
[ "https://wordpress.stackexchange.com/questions/292727", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm trying to display all posts and only certain custom posts on the homepage. Essentially: `(post_type = post) OR (post_type = exhibition AND featured = 1)` I'm stuck with the actual implementation though. `pre_get_posts` and `$query->set(...);` don't seem to allow logic on the `post_type`, it seems you can only se...
You can't specify `OR` or `AND` on arbitrary `WP_Query` arguments. Meta and Taxonomy queries let you specify `OR` or `AND` for those queries, but other arguments are all combined (`post_type` is a property of the post, not meta, so a meta query won't help). Refer to [the documentation](https://developer.wordpress.org/r...
292,779
<p>I'm trying to make the following mock up with WordPress: <a href="https://imgur.com/a/Sem7y" rel="nofollow noreferrer">https://imgur.com/a/Sem7y</a></p> <p>I created a custom post type and I created two categories (general and filling instructions). I used ACF plugin to create custom fields for the post type: <a hr...
[ { "answer_id": 292732, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>You can't specify <code>OR</code> or <code>AND</code> on arbitrary <code>WP_Query</code> arguments. Met...
2018/01/31
[ "https://wordpress.stackexchange.com/questions/292779", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135993/" ]
I'm trying to make the following mock up with WordPress: <https://imgur.com/a/Sem7y> I created a custom post type and I created two categories (general and filling instructions). I used ACF plugin to create custom fields for the post type: <https://imgur.com/a/o2QJV> However, when I create the loop I can't get it to ...
You can't specify `OR` or `AND` on arbitrary `WP_Query` arguments. Meta and Taxonomy queries let you specify `OR` or `AND` for those queries, but other arguments are all combined (`post_type` is a property of the post, not meta, so a meta query won't help). Refer to [the documentation](https://developer.wordpress.org/r...
292,789
<p>I have a problem I'm wondering, need someone to help.</p> <p>I am doing a function that sends email to followers weekly and monthly. Currently, I have written a function to use, but one thing is I do not know how to use cron to run WP. Can anybody suggest or guide me to make? Thanks very much :)</p>
[ { "answer_id": 292791, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>Your hosting place should have an option on their control panel for adding CRON jobs. If this is self-...
2018/02/01
[ "https://wordpress.stackexchange.com/questions/292789", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/134874/" ]
I have a problem I'm wondering, need someone to help. I am doing a function that sends email to followers weekly and monthly. Currently, I have written a function to use, but one thing is I do not know how to use cron to run WP. Can anybody suggest or guide me to make? Thanks very much :)
i got this proplem with hight load in my [wppit.com](https://www.wppit.com/) so i checked my cpanel and i found the cronjob casue this hiegh load and because WordPress has to work on all sort of different platforms, OS's and configurations, it can't rely that there will be a cronjob service on the server that can hand...
292,804
<p>I have created dynamic add/remove fields in frontend post submission page. I use <code>wp_json_encode</code> and <code>$wpdb-&gt;insert</code> to insert data into my custom WordPress database table. the system is working perfectly.</p> <p>The data is stored in “reward_details” column of my custom table.. It looks l...
[ { "answer_id": 292791, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>Your hosting place should have an option on their control panel for adding CRON jobs. If this is self-...
2018/02/01
[ "https://wordpress.stackexchange.com/questions/292804", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/124069/" ]
I have created dynamic add/remove fields in frontend post submission page. I use `wp_json_encode` and `$wpdb->insert` to insert data into my custom WordPress database table. the system is working perfectly. The data is stored in “reward\_details” column of my custom table.. It looks like : ``` {"reward_amount":["500"...
i got this proplem with hight load in my [wppit.com](https://www.wppit.com/) so i checked my cpanel and i found the cronjob casue this hiegh load and because WordPress has to work on all sort of different platforms, OS's and configurations, it can't rely that there will be a cronjob service on the server that can hand...
292,809
<p>in the Hungarian language we generally use the Lastname + Firstname format when we communicate with each oter. Therefore I would like to change this method in Woocommerce and special in the client e-mail?</p> <p>Where can I edit this emial template or should I use rather a filter? Thank you for your replies in adva...
[ { "answer_id": 292934, "author": "vishalprajapati13", "author_id": 136086, "author_profile": "https://wordpress.stackexchange.com/users/136086", "pm_score": 0, "selected": false, "text": "<p>Edit your store's email templates, go to WooCommerce > Settings > Emails \nfrom here you can edit...
2018/02/01
[ "https://wordpress.stackexchange.com/questions/292809", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136020/" ]
in the Hungarian language we generally use the Lastname + Firstname format when we communicate with each oter. Therefore I would like to change this method in Woocommerce and special in the client e-mail? Where can I edit this emial template or should I use rather a filter? Thank you for your replies in advance! Josep...
I figured out a workaround solution and it works, but not the most beautiful: ``` // I made the original action passive // do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email ); // ... create a new solution from scratch $text_align = is_rtl() ? 'right' : 'left'; //to escape ...
292,813
<p>I have 6 related posts by tag in every post. But some tags have only 2 or 3 posts. So in these posts, related posts section shows only 2 or 3 post.</p> <p>I want to complete related posts (if not 6) with the new posts. </p> <p>I tried many codes but if tags have 2 posts, than related posts show 2 post only. Can I ...
[ { "answer_id": 292934, "author": "vishalprajapati13", "author_id": 136086, "author_profile": "https://wordpress.stackexchange.com/users/136086", "pm_score": 0, "selected": false, "text": "<p>Edit your store's email templates, go to WooCommerce > Settings > Emails \nfrom here you can edit...
2018/02/01
[ "https://wordpress.stackexchange.com/questions/292813", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136023/" ]
I have 6 related posts by tag in every post. But some tags have only 2 or 3 posts. So in these posts, related posts section shows only 2 or 3 post. I want to complete related posts (if not 6) with the new posts. I tried many codes but if tags have 2 posts, than related posts show 2 post only. Can I add new posts to ...
I figured out a workaround solution and it works, but not the most beautiful: ``` // I made the original action passive // do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email ); // ... create a new solution from scratch $text_align = is_rtl() ? 'right' : 'left'; //to escape ...
292,815
<p><br> the task is actually quite simple I believe. I want to query the status of a checkbox, pass it with $.post and JSON to a function, and then save the value.</p> <p><strong>my-html (relevant part)</strong></p> <pre><code>&lt;input type="checkbox" id="&lt;?php echo $category-&gt;column_handle; ?&gt;" name="&lt;?...
[ { "answer_id": 292816, "author": "Maxim Sarandi", "author_id": 135962, "author_profile": "https://wordpress.stackexchange.com/users/135962", "pm_score": 1, "selected": false, "text": "<pre><code>.prop()\n</code></pre>\n\n<p>method return boolean type. True or false. You should send check...
2018/02/01
[ "https://wordpress.stackexchange.com/questions/292815", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/129895/" ]
the task is actually quite simple I believe. I want to query the status of a checkbox, pass it with $.post and JSON to a function, and then save the value. **my-html (relevant part)** ``` <input type="checkbox" id="<?php echo $category->column_handle; ?>" name="<?php echo $category->column_handle; ?>" class="checkbox...
I solved the problem. I tried so many things that I seemingly skipped a variant that worked. So for anyone coming by this way it works: **my-script** as in the question: ``` 'check': $(this).prop('checked') ``` **my-function** as follows: ``` function my_function(){ global $wpdb; $column = esc_attr($_POST['col...
292,831
<p>Is it poossible to add index to the meta_value column in the wp_postmeta table in order to make faster queries in Wordpress?</p> <p>I have about 5 million rows in the wp_postmeta table and my queries takes about 3 seconds when limited to 500 rows.</p> <p>I am trying to do add an index to meta_value in phpMyAdmin b...
[ { "answer_id": 292832, "author": "janh", "author_id": 129206, "author_profile": "https://wordpress.stackexchange.com/users/129206", "pm_score": 2, "selected": false, "text": "<p>Don't limit the field, instead, limit the index, e.g.</p>\n\n<pre><code>ALTER TABLE wp_postmeta ADD key(meta_v...
2018/02/01
[ "https://wordpress.stackexchange.com/questions/292831", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44178/" ]
Is it poossible to add index to the meta\_value column in the wp\_postmeta table in order to make faster queries in Wordpress? I have about 5 million rows in the wp\_postmeta table and my queries takes about 3 seconds when limited to 500 rows. I am trying to do add an index to meta\_value in phpMyAdmin but i am getti...
Don't limit the field, instead, limit the index, e.g. ``` ALTER TABLE wp_postmeta ADD key(meta_value(100)) ``` This limits the index to the first hundred bytes of meta\_value. You'll probably want an index on post\_id, meta\_key, meta\_value for joins. How much of meta\_key and meta\_value is required depends on yo...
292,834
<p>I have a custom page template, I'm using a standard WPQuery to fetch the posts from the default posts custom post type. I'm looping through all the posts however now I have more posts than I allow in the settings of the admin. Instead of changing the limit I want to use some standard WP pagination. However, none of ...
[ { "answer_id": 292832, "author": "janh", "author_id": 129206, "author_profile": "https://wordpress.stackexchange.com/users/129206", "pm_score": 2, "selected": false, "text": "<p>Don't limit the field, instead, limit the index, e.g.</p>\n\n<pre><code>ALTER TABLE wp_postmeta ADD key(meta_v...
2018/02/01
[ "https://wordpress.stackexchange.com/questions/292834", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115473/" ]
I have a custom page template, I'm using a standard WPQuery to fetch the posts from the default posts custom post type. I'm looping through all the posts however now I have more posts than I allow in the settings of the admin. Instead of changing the limit I want to use some standard WP pagination. However, none of the...
Don't limit the field, instead, limit the index, e.g. ``` ALTER TABLE wp_postmeta ADD key(meta_value(100)) ``` This limits the index to the first hundred bytes of meta\_value. You'll probably want an index on post\_id, meta\_key, meta\_value for joins. How much of meta\_key and meta\_value is required depends on yo...
292,838
<p>I want to show a custom taxonomy in the name of custom_tax in a plugin option page as dropdown that user can select terms of taxonomy. I know that I can use <a href="https://developer.wordpress.org/reference/functions/wp_dropdown_categories/" rel="nofollow noreferrer">wp_dropdown_categories()</a> but I don't want sh...
[ { "answer_id": 292842, "author": "Maxim Sarandi", "author_id": 135962, "author_profile": "https://wordpress.stackexchange.com/users/135962", "pm_score": -1, "selected": false, "text": "<p><a href=\"https://developer.wordpress.org/reference/functions/get_terms/\" rel=\"nofollow noreferrer...
2018/02/01
[ "https://wordpress.stackexchange.com/questions/292838", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/133808/" ]
I want to show a custom taxonomy in the name of custom\_tax in a plugin option page as dropdown that user can select terms of taxonomy. I know that I can use [wp\_dropdown\_categories()](https://developer.wordpress.org/reference/functions/wp_dropdown_categories/) but I don't want show the terms of category taxonomy. I'...
[`wp_dropdown_categories()`](https://developer.wordpress.org/reference/functions/wp_dropdown_categories/) has the `taxonomy` parameter, which defaults to `category`, but can be used to retrieve custom taxonomies. Exemplary usage: ``` wp_dropdown_categories([ 'taxonomy' => 'custom-taxonomy-name' ]); ```
292,861
<p>I'm trying to edit wording in terms &amp; conditions checkbox on checkout page (order review section), but without luck. It was easy to edit other fields like billing and shipping fields. But I'm not sure how to target this specific T&amp;C checkbox.</p> <p>For other input fields the code below works fine:</p> <pr...
[ { "answer_id": 314901, "author": "Bjorn", "author_id": 83707, "author_profile": "https://wordpress.stackexchange.com/users/83707", "pm_score": 1, "selected": false, "text": "<p>Woocommerce has moved some settings to the WP customizer.</p>\n\n<p>Go to:\nWP admin menu -> Appearance -> Cust...
2018/02/01
[ "https://wordpress.stackexchange.com/questions/292861", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/133403/" ]
I'm trying to edit wording in terms & conditions checkbox on checkout page (order review section), but without luck. It was easy to edit other fields like billing and shipping fields. But I'm not sure how to target this specific T&C checkbox. For other input fields the code below works fine: ``` // WooCommerc...
Woocommerce has moved some settings to the WP customizer. Go to: WP admin menu -> Appearance -> Customizer -> Woocommerce -> Checkout. There you can set the Privacy & Terms.
292,870
<p>I have a custom page where I ask users to log in to access the page. Once they log in, I would like to redirect them to the same page but I want to add on their user ID to the URL string in the redirect. This is just for analytics, the actual content is being protected by <code>if (current_user_can('')){}</code> </p...
[ { "answer_id": 292884, "author": "user13286", "author_id": 13286, "author_profile": "https://wordpress.stackexchange.com/users/13286", "pm_score": 0, "selected": false, "text": "<p>I was able to resolve this by separating the login page from the page with the content. So I have one page ...
2018/02/01
[ "https://wordpress.stackexchange.com/questions/292870", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13286/" ]
I have a custom page where I ask users to log in to access the page. Once they log in, I would like to redirect them to the same page but I want to add on their user ID to the URL string in the redirect. This is just for analytics, the actual content is being protected by `if (current_user_can('')){}` Here's the code...
you can add the user identifier à the redirection URL with this filter ``` add_filter("login_redirect", function ($redirect_to, $requested_redirect_to, $user) { $redirect_to = add_query_arg([ "user_id" => $user->ID, ], $redirect_to); return $redirect_to; }, 10, 3); ```
292,875
<p>I have a website (<code>www.example.com</code>) that I'd like to add a WordPress blog to, but I want to keep the website's <code>index.php</code> as the homepage.</p> <p>I also want to add two links to the homepage, <code>example.com/newsletters</code> and <code>example.com/explainers</code>, which link to WordPres...
[ { "answer_id": 292884, "author": "user13286", "author_id": 13286, "author_profile": "https://wordpress.stackexchange.com/users/13286", "pm_score": 0, "selected": false, "text": "<p>I was able to resolve this by separating the login page from the page with the content. So I have one page ...
2018/02/01
[ "https://wordpress.stackexchange.com/questions/292875", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19430/" ]
I have a website (`www.example.com`) that I'd like to add a WordPress blog to, but I want to keep the website's `index.php` as the homepage. I also want to add two links to the homepage, `example.com/newsletters` and `example.com/explainers`, which link to WordPress archive pages with all the posts tagged "newsletters...
you can add the user identifier à the redirection URL with this filter ``` add_filter("login_redirect", function ($redirect_to, $requested_redirect_to, $user) { $redirect_to = add_query_arg([ "user_id" => $user->ID, ], $redirect_to); return $redirect_to; }, 10, 3); ```
292,877
<p>I need to insert a menu in the text of one page. I found these two plugin but none of them work. Both of them haven't been updated for 6 years:</p> <p><a href="https://wordpress.org/plugins/custom-menu/" rel="nofollow noreferrer">https://wordpress.org/plugins/custom-menu/</a></p> <p><a href="https://wordpress.org/...
[ { "answer_id": 293006, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 5, "selected": true, "text": "<p>That code should work. Are you usign \"myclass\" as the class and not \".myclass\"? </p>\n\n<p>Is this for a ...
2018/02/01
[ "https://wordpress.stackexchange.com/questions/292877", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/107273/" ]
I need to insert a menu in the text of one page. I found these two plugin but none of them work. Both of them haven't been updated for 6 years: <https://wordpress.org/plugins/custom-menu/> <https://wordpress.org/plugins/custom-menu-shortcode/> I found this code to create my own shortcode ``` function print_menu...
That code should work. Are you usign "myclass" as the class and not ".myclass"? Is this for a specific use where class will always be the same? If you're only looking to ever use this on one place, you can do this: ``` function print_menu_shortcode($atts, $content = null) { extract(shortcode_atts(array( 'name' =...
292,921
<p>Okay So I'm facing a weird problem as i'm receiving 404 errors on blog category and tag pages. I'm using custom theme which includes: </p> <ul> <li>tag.php</li> <li>category.php</li> <li>archive.php </li> <li>home.php</li> <li>index.php and </li> <li>404.php.</li> </ul> <p>The Blog archive is working fine but when...
[ { "answer_id": 292923, "author": "vishalprajapati13", "author_id": 136086, "author_profile": "https://wordpress.stackexchange.com/users/136086", "pm_score": -1, "selected": false, "text": "<p>Go to your WordPress back-end with this path Settings > Permalinks. Ensure that the base of the ...
2018/02/02
[ "https://wordpress.stackexchange.com/questions/292921", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/129705/" ]
Okay So I'm facing a weird problem as i'm receiving 404 errors on blog category and tag pages. I'm using custom theme which includes: * tag.php * category.php * archive.php * home.php * index.php and * 404.php. The Blog archive is working fine but when i try to load tag pages or category pages i'm being redirected t...
I know this is an old question but I was having the same issue in a theme I inherited and came across this question in my search for answers. In my particular case, I found the following PHP code included in the theme's `function.php` file: ``` if( is_category() || is_date() || is_author() ) { global $wp_query; ...
292,947
<p>I'm working an Ajaxifying form. This form is a custom page template. The saving of the data is working, but when the form is submitting, the page is redirects to <code>websiteurl/wp-admin/admin-ajax.php</code> with a white blank page. What I want is to prevent the reloading of the page. I didn't receive any error me...
[ { "answer_id": 292964, "author": "Anton Flärd", "author_id": 107106, "author_profile": "https://wordpress.stackexchange.com/users/107106", "pm_score": 0, "selected": false, "text": "<p>Try one of these:</p>\n\n<ol>\n<li>Put the submit button outside the form and bind the js-function to t...
2018/02/02
[ "https://wordpress.stackexchange.com/questions/292947", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54602/" ]
I'm working an Ajaxifying form. This form is a custom page template. The saving of the data is working, but when the form is submitting, the page is redirects to `websiteurl/wp-admin/admin-ajax.php` with a white blank page. What I want is to prevent the reloading of the page. I didn't receive any error message from `er...
Just saw it... ...in your HTML, take the action out entirely. We're not using the HTML to tell the form/submit button what to do, we're using JS/AJAX for that. `<form method="POST" action="<?php echo admin_url('admin-ajax.php'); ?>" id="modal-form-ajax" autocomplete="off">` Should become: `<form method="POST" id="mo...
292,971
<p>How can I sort an array of elements being hold on a query done by a template function, just before the output starts on a foreach loop? I wanted to order my elements by the Post Title. Here is my code:</p> <pre><code>&lt;?php $show_subproperties = apushome_get_config('show_property_sub', true); if (!$show_subproper...
[ { "answer_id": 292964, "author": "Anton Flärd", "author_id": 107106, "author_profile": "https://wordpress.stackexchange.com/users/107106", "pm_score": 0, "selected": false, "text": "<p>Try one of these:</p>\n\n<ol>\n<li>Put the submit button outside the form and bind the js-function to t...
2018/02/02
[ "https://wordpress.stackexchange.com/questions/292971", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131677/" ]
How can I sort an array of elements being hold on a query done by a template function, just before the output starts on a foreach loop? I wanted to order my elements by the Post Title. Here is my code: ``` <?php $show_subproperties = apushome_get_config('show_property_sub', true); if (!$show_subproperties) { retur...
Just saw it... ...in your HTML, take the action out entirely. We're not using the HTML to tell the form/submit button what to do, we're using JS/AJAX for that. `<form method="POST" action="<?php echo admin_url('admin-ajax.php'); ?>" id="modal-form-ajax" autocomplete="off">` Should become: `<form method="POST" id="mo...
293,008
<p>I need unregister this enqueue style of wp_footer() hook and add it to the top of site with hook wp_head(), this is possible?</p> <p>I'm optimizing my theme to validate in W3C, and one of the requirements of W3C is that all styles are within the tag <code>&lt;head&gt;&lt;/head&gt;</code>... I am using an specific p...
[ { "answer_id": 293012, "author": "Nathan Johnson", "author_id": 106269, "author_profile": "https://wordpress.stackexchange.com/users/106269", "pm_score": 3, "selected": true, "text": "<p>If you look at the <a href=\"https://plugins.trac.wordpress.org/browser/crayon-syntax-highlighter/tru...
2018/02/02
[ "https://wordpress.stackexchange.com/questions/293008", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/39187/" ]
I need unregister this enqueue style of wp\_footer() hook and add it to the top of site with hook wp\_head(), this is possible? I'm optimizing my theme to validate in W3C, and one of the requirements of W3C is that all styles are within the tag `<head></head>`... I am using an specific plugin called `Crayon Syntax Hig...
If you look at the [source code](https://plugins.trac.wordpress.org/browser/crayon-syntax-highlighter/trunk/crayon_wp.class.php), you can see that `wp_enqueue_style( 'crayon' )` is called in `Crayon::enqueue_resources()` which itself is called either from either `Crayon::the_content()` or `Crayon::wp_head()`. The code ...
293,018
<p>I've got a custom theme I've developed and it's basically a 4 page brochure site for a client and I've managed to do away with a few plugins by building in custom-post-types, gzipping via .htaccess and minifying via gulp etc etc.</p> <p>I'll be keeping the security plugin on the site, but I'd like to remove Yoast, ...
[ { "answer_id": 293019, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 5, "selected": false, "text": "<p>The hook you're looking for is specifically <a href=\"https://developer.wordpress.org/reference/hooks/wp_he...
2018/02/02
[ "https://wordpress.stackexchange.com/questions/293018", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106972/" ]
I've got a custom theme I've developed and it's basically a 4 page brochure site for a client and I've managed to do away with a few plugins by building in custom-post-types, gzipping via .htaccess and minifying via gulp etc etc. I'll be keeping the security plugin on the site, but I'd like to remove Yoast, the only b...
The hook you're looking for is specifically [`wp_head`](https://developer.wordpress.org/reference/hooks/wp_head/) which could look something like this: ``` function theme_xyz_header_metadata() { // Post object if needed // global $post; // Page conditional if needed // if( is_page() ){} ?> <m...
293,025
<p>I created a custom user_meta, but I cant update it via curl.</p> <p>I can do this with user_meta</p> <pre><code>curl --header "Authorization: Basic ACCESS_TOKEN" -X POST -d "description=New description" http://domain.com/wp-json/wp/v2/users/1 </code></pre> <p>But I cant do the same with custom meta</p> <pre><cod...
[ { "answer_id": 293027, "author": "janh", "author_id": 129206, "author_profile": "https://wordpress.stackexchange.com/users/129206", "pm_score": 1, "selected": false, "text": "<p>You'll get the value as the first parameter, or you could get it out of $request, which is a <a href=\"https:/...
2018/02/02
[ "https://wordpress.stackexchange.com/questions/293025", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68492/" ]
I created a custom user\_meta, but I cant update it via curl. I can do this with user\_meta ``` curl --header "Authorization: Basic ACCESS_TOKEN" -X POST -d "description=New description" http://domain.com/wp-json/wp/v2/users/1 ``` But I cant do the same with custom meta ``` curl --header "Authorization: Basic ACCE...
arguments `get_callback` and `update_callback` receive different arguments. try this exemple which works for a field `user_continent` ``` add_action("rest_api_init", function () { register_rest_field( "user" , "user_continent" , [ "get_callback" => function ($user, $...
293,033
<p>I'm a complete noob but trying to learn, and I'm stumped.</p> <p>I have a login page as my static homepage, and want to make an if statement, so that if the user is logged in, and goes to the static home page, they are redirected to another page with content.</p> <p>So far, this is what I have, but it doesn't work...
[ { "answer_id": 293034, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 2, "selected": false, "text": "<p>First of all, <code>home_url</code> doesn't provide anything. You should use the <a href=\"https://codex.wo...
2018/02/03
[ "https://wordpress.stackexchange.com/questions/293033", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136139/" ]
I'm a complete noob but trying to learn, and I'm stumped. I have a login page as my static homepage, and want to make an if statement, so that if the user is logged in, and goes to the static home page, they are redirected to another page with content. So far, this is what I have, but it doesn't work: ``` if ( is_us...
First of all, `home_url` doesn't provide anything. You should use the [`is_home()`](https://codex.wordpress.org/Function_Reference/is_home) function instead. After that, you need to exit the script when you are trying to redirect. So, your full code should be like this: ``` if ( is_user_logged_in() && is_home() ) { ...
293,067
<p>I have a meta_key value 'গল্প' inside wp_post_meta as shown value: <a href="https://i.stack.imgur.com/pFjV3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pFjV3.png" alt="enter image description here"></a> </p> <p>Now I want to show all post having meta_key value 'গল্প'. Is there any template f...
[ { "answer_id": 293069, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>Template files are the 'responsibility' of the theme you are using. If your theme doesn't contain a te...
2018/02/03
[ "https://wordpress.stackexchange.com/questions/293067", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120824/" ]
I have a meta\_key value 'গল্প' inside wp\_post\_meta as shown value: [![enter image description here](https://i.stack.imgur.com/pFjV3.png)](https://i.stack.imgur.com/pFjV3.png) Now I want to show all post having meta\_key value 'গল্প'. Is there any template file to manage this option like tag.php?
You might give it a shot this way: ``` add_filter( 'template_include', 'check_post_meta_template_include' ); function check_post_meta_template_include( $template ) { if ( !is_single() ) { return $template; } global $post; if ( $post->post_type != 'post' ) { // Proceed only if post type = post ...
293,148
<p>We're configuring a new WordPress to use custom post types, and we want our editors to log in and only see only the custominzed post types, not the default 'post' post type. We've been able to remove 'post' from the Admin menu using <a href="https://www.techjunkie.com/remove-default-post-type-from-admin-menu-wordpre...
[ { "answer_id": 293203, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 5, "selected": true, "text": "<p>You need to hook to 3 different action hooks to fully hide the default post type. However, a direct access t...
2018/02/05
[ "https://wordpress.stackexchange.com/questions/293148", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136220/" ]
We're configuring a new WordPress to use custom post types, and we want our editors to log in and only see only the custominzed post types, not the default 'post' post type. We've been able to remove 'post' from the Admin menu using [this trick](https://www.techjunkie.com/remove-default-post-type-from-admin-menu-wordpr...
You need to hook to 3 different action hooks to fully hide the default post type. However, a direct access to the default post by URL is still possible. So, let's get started. The Side Menu ------------- ``` add_action( 'admin_menu', 'remove_default_post_type' ); function remove_default_post_type() { remove_menu...
293,149
<p>I'm still new to WordPress. I have been encountering <code>Failed to load resource: the server responded with a status of 404 (Not Found)</code> error and its pointing it in <code>wp-admin/admin-ajax.php</code>. I have check the folder and <code>admin-ajax.php</code> is there. I also tried calling <code>admin-ajax.p...
[ { "answer_id": 293151, "author": "Dharmishtha Patel", "author_id": 135085, "author_profile": "https://wordpress.stackexchange.com/users/135085", "pm_score": 0, "selected": false, "text": "<p>finally the problem was that the hosting provider had blocked the admin-ajax.php file saying that...
2018/02/05
[ "https://wordpress.stackexchange.com/questions/293149", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136230/" ]
I'm still new to WordPress. I have been encountering `Failed to load resource: the server responded with a status of 404 (Not Found)` error and its pointing it in `wp-admin/admin-ajax.php`. I have check the folder and `admin-ajax.php` is there. I also tried calling `admin-ajax.php` using `network_admin_url()` instead o...
I contact the hosting provider regarding it. They advise me to fix the .htaccess which causing the error.
293,158
<p>Trying to fetch all data from <code>wp_postmeta</code> table. I am trying to fetch first <code>meta_key</code> column value. so I am running this query. When I am using <code>print_r</code> then all data showing but when I am using foreach loop then its not working.</p> <pre><code>&lt;?php global $wpdb; $myrows = $...
[ { "answer_id": 293151, "author": "Dharmishtha Patel", "author_id": 135085, "author_profile": "https://wordpress.stackexchange.com/users/135085", "pm_score": 0, "selected": false, "text": "<p>finally the problem was that the hosting provider had blocked the admin-ajax.php file saying that...
2018/02/05
[ "https://wordpress.stackexchange.com/questions/293158", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103961/" ]
Trying to fetch all data from `wp_postmeta` table. I am trying to fetch first `meta_key` column value. so I am running this query. When I am using `print_r` then all data showing but when I am using foreach loop then its not working. ``` <?php global $wpdb; $myrows = $wpdb->get_results( "SELECT * FROM wp_postmeta" ); ...
I contact the hosting provider regarding it. They advise me to fix the .htaccess which causing the error.
293,189
<p>Is it possible to have different favicon on on different pages?</p> <p><strong>For example:</strong></p> <pre><code>mywebsite.com/blog-1 -&gt; favicon-1 mywebsite.com/blog -&gt; favicon-2 </code></pre> <p>And so on.</p> <p>I have custom domain name for each blog (And I don't want to put the same favicon on the...
[ { "answer_id": 293196, "author": "Maxim Sarandi", "author_id": 135962, "author_profile": "https://wordpress.stackexchange.com/users/135962", "pm_score": 0, "selected": false, "text": "<p>You can use a few solutions;</p>\n\n<ol>\n<li>Create meta-field with favicon in your page/post. And c...
2018/02/05
[ "https://wordpress.stackexchange.com/questions/293189", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136250/" ]
Is it possible to have different favicon on on different pages? **For example:** ``` mywebsite.com/blog-1 -> favicon-1 mywebsite.com/blog -> favicon-2 ``` And so on. I have custom domain name for each blog (And I don't want to put the same favicon on these pages)
As of WordPress version 5.6, any posts or pages has options on the editor to include any custom scripts/styles and meta tags to the header of the page. So if you put your <link rel"icon" href="favicon.png"/> it should work. You upload your favicon into the media and after you uploaded the media. Refer the uploaded fav...
293,215
<p>I hesitated to ask this question, because it may be too fundamental. However, after digging in to the codex and other topics I became convinced that maybe it is not so fundamental because I could not find an answer to my question.</p> <p>My question is what purpose does the handle serve in functions like wp_enqueue...
[ { "answer_id": 293217, "author": "David Sword", "author_id": 132362, "author_profile": "https://wordpress.stackexchange.com/users/132362", "pm_score": 3, "selected": true, "text": "<p>Below is an example of the <code>jquery</code> handle being used in various ways:</p>\n\n<pre><code>// a...
2018/02/05
[ "https://wordpress.stackexchange.com/questions/293215", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/129826/" ]
I hesitated to ask this question, because it may be too fundamental. However, after digging in to the codex and other topics I became convinced that maybe it is not so fundamental because I could not find an answer to my question. My question is what purpose does the handle serve in functions like wp\_enqueue\_script(...
Below is an example of the `jquery` handle being used in various ways: ``` // add my js, written in jQuery // so it requires `jquery.min.js` to be output first // & say I do this in a early hook like `init` wp_enqueue_script( 'my-js', 'js.js', array('jquery')); // later in theme: // remove Wordpress's default jquery...
293,300
<p>Hi my java script code doesn't work in my <code>wordpress</code> theme i enqueue my <code>scripts.js</code> file what is the problem and what is the expected behaviour? </p> <pre><code> function my_scripts() { wp_enqueue_style( 'responsive', get_template_directory_uri() .'/assets/css/responsive.css' , array...
[ { "answer_id": 293217, "author": "David Sword", "author_id": 132362, "author_profile": "https://wordpress.stackexchange.com/users/132362", "pm_score": 3, "selected": true, "text": "<p>Below is an example of the <code>jquery</code> handle being used in various ways:</p>\n\n<pre><code>// a...
2018/02/06
[ "https://wordpress.stackexchange.com/questions/293300", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136327/" ]
Hi my java script code doesn't work in my `wordpress` theme i enqueue my `scripts.js` file what is the problem and what is the expected behaviour? ``` function my_scripts() { wp_enqueue_style( 'responsive', get_template_directory_uri() .'/assets/css/responsive.css' , array() ); wp_enqueue_script( 'scrip...
Below is an example of the `jquery` handle being used in various ways: ``` // add my js, written in jQuery // so it requires `jquery.min.js` to be output first // & say I do this in a early hook like `init` wp_enqueue_script( 'my-js', 'js.js', array('jquery')); // later in theme: // remove Wordpress's default jquery...
293,308
<p>I have a theme with an option for setting the excerpt length for generated excerpts. Is there a way in the Customizer of conditionally changing the transport mechanism, depending on whether the preview page is showing excerpts?</p> <p>For example, I have another option that controls whether full content or excerpts...
[ { "answer_id": 293424, "author": "ghoul", "author_id": 131136, "author_profile": "https://wordpress.stackexchange.com/users/131136", "pm_score": 0, "selected": false, "text": "<p>I didn't find any solution for this. But I would suggest you to use <code>active_callback</code> parameter su...
2018/02/06
[ "https://wordpress.stackexchange.com/questions/293308", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43242/" ]
I have a theme with an option for setting the excerpt length for generated excerpts. Is there a way in the Customizer of conditionally changing the transport mechanism, depending on whether the preview page is showing excerpts? For example, I have another option that controls whether full content or excerpts are shown...
Yes, you can change the `transport` of a registered setting dynamically after the page loads. And actually the `active_callback` can be used in conjunction with JS to change the `transport` *instead of* causing the control to be hidden. Assuming you have registered a control with the ID of `excerpt_length`, and you ha...
293,317
<p>I’ve found others (<a href="https://wordpress.stackexchange.com/questions/99655/advanced-custom-field-gallery-display-one-random-image">source 1</a>, <a href="https://support.advancedcustomfields.com/forums/topic/random-image-from-gallery-field/" rel="nofollow noreferrer">source 2</a>, <a href="https://gist.github.c...
[ { "answer_id": 293321, "author": "Maxim Sarandi", "author_id": 135962, "author_profile": "https://wordpress.stackexchange.com/users/135962", "pm_score": 2, "selected": false, "text": "<pre><code>&lt;?php \n $images = get_field('gallery');\n $size = 'full'; // (thumbnail, medium, la...
2018/02/06
[ "https://wordpress.stackexchange.com/questions/293317", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40679/" ]
I’ve found others ([source 1](https://wordpress.stackexchange.com/questions/99655/advanced-custom-field-gallery-display-one-random-image), [source 2](https://support.advancedcustomfields.com/forums/topic/random-image-from-gallery-field/), [source 3](https://gist.github.com/tjhole/8054985)) using the following code for ...
Answer found via [ACF Forums](https://support.advancedcustomfields.com/forums/topic/random-gallery-image-with-wp_get_attachment_image/). Adding the `false` parameter returns raw/unformatted value. ``` <?php $images = get_field('gallery', 'option', false); // Adding the `false` parameter returns raw/unformatted v...
293,318
<p>I have a added custom column to a custom post type, and it works fine. I just want it to sort the names by title, so I tried this,</p> <pre><code>function sortable_custom_columns( $columns ) { $columns['custom_column'] = 'title'; return $columns; } add_filter( 'manage_edit-custom_sortable_columns', 'sortable...
[ { "answer_id": 293323, "author": "Maxim Sarandi", "author_id": 135962, "author_profile": "https://wordpress.stackexchange.com/users/135962", "pm_score": -1, "selected": false, "text": "<p>you need sort table using pre_get_posts. Nice step-by-step instructions on <a href=\"https://code.tu...
2018/02/06
[ "https://wordpress.stackexchange.com/questions/293318", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20977/" ]
I have a added custom column to a custom post type, and it works fine. I just want it to sort the names by title, so I tried this, ``` function sortable_custom_columns( $columns ) { $columns['custom_column'] = 'title'; return $columns; } add_filter( 'manage_edit-custom_sortable_columns', 'sortable_custom_colum...
Make sure to change `MY_POST_TYPE`, `MY_CUSTOM_COLUMN` and `MY_META_KEY` to the actual values. First, add your custom column. Unset the date and set it again to keep it in the last column. You can skip this step. ``` <?php function my_manage_MY_POST_TYPE_columns( $columns ) { // save date to the variable $dat...
293,365
<p>I have conntected T5_Nav_Menu_Walker to my WP website. <a href="https://gist.github.com/thefuxia/1053467" rel="nofollow noreferrer">https://gist.github.com/thefuxia/1053467</a></p> <p>And I want customize my WP menu to be able to add icons from wp-admin via FontAwesome classes. Screenshot: <a href="https://screensh...
[ { "answer_id": 293323, "author": "Maxim Sarandi", "author_id": 135962, "author_profile": "https://wordpress.stackexchange.com/users/135962", "pm_score": -1, "selected": false, "text": "<p>you need sort table using pre_get_posts. Nice step-by-step instructions on <a href=\"https://code.tu...
2018/02/07
[ "https://wordpress.stackexchange.com/questions/293365", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/123015/" ]
I have conntected T5\_Nav\_Menu\_Walker to my WP website. <https://gist.github.com/thefuxia/1053467> And I want customize my WP menu to be able to add icons from wp-admin via FontAwesome classes. Screenshot: [Show](https://screenshots.firefox.com/lfGD5DWtdP901KuE/test12.md7.info) But when I add CSS class in menu noth...
Make sure to change `MY_POST_TYPE`, `MY_CUSTOM_COLUMN` and `MY_META_KEY` to the actual values. First, add your custom column. Unset the date and set it again to keep it in the last column. You can skip this step. ``` <?php function my_manage_MY_POST_TYPE_columns( $columns ) { // save date to the variable $dat...
293,420
<p>How can I place categories onto a page using short code from the following function.</p> <pre><code>&lt;?php echo get_the_category_list(); ?&gt; </code></pre>
[ { "answer_id": 293425, "author": "Anton Flärd", "author_id": 107106, "author_profile": "https://wordpress.stackexchange.com/users/107106", "pm_score": 0, "selected": false, "text": "<p>To display it on a page using a shortcode you can add this to your <code>functions.php</code>:</p>\n\n<...
2018/02/07
[ "https://wordpress.stackexchange.com/questions/293420", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136408/" ]
How can I place categories onto a page using short code from the following function. ``` <?php echo get_the_category_list(); ?> ```
`get_the_category_list` works on [The Loop](https://codex.wordpress.org/The_Loop) only and needs a `post_id` as a parameter. As a page does not have category, it won't work by default in a page. If you want to retrieve all the categories on a page, you should use one of the following: ``` wp_list_categories get_cat...
293,427
<p><strong>BACKGROUND</strong></p> <p>After the user on <em>domain1</em> clicks a link to <em>domain 2</em>, I need to <strong>send also the user-data (username,email,..) from server1/domain1 to server2/domain2</strong> and to save it temporary in the server2/database.</p> <p>Both are wordpress websites.</p> <p><str...
[ { "answer_id": 293429, "author": "Maxim Sarandi", "author_id": 135962, "author_profile": "https://wordpress.stackexchange.com/users/135962", "pm_score": 4, "selected": true, "text": "<p><a href=\"https://developer.wordpress.org/reference/functions/wp_remote_get/\" rel=\"noreferrer\">wp_r...
2018/02/07
[ "https://wordpress.stackexchange.com/questions/293427", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122620/" ]
**BACKGROUND** After the user on *domain1* clicks a link to *domain 2*, I need to **send also the user-data (username,email,..) from server1/domain1 to server2/domain2** and to save it temporary in the server2/database. Both are wordpress websites. **CURRENT WORK** Lets say, `$url = 'http://my-domain2.com'`; So far...
[wp\_remote\_get()](https://developer.wordpress.org/reference/functions/wp_remote_get/) and [wp\_remote\_post()](https://developer.wordpress.org/reference/functions/wp_remote_post/) and [wp\_remote\_request()](https://developer.wordpress.org/reference/functions/wp_remote_request/) should answer on your questions.This i...
293,431
<p>I want to fire an event for when AFTER a new widget has been added to the previewer, and then AFTER a widget has been removed.</p> <p>Use Case: After the widget has been added to the previewer DOM, I want to change it's class based on how many other widgets are in that same sidebar area. So when </p> <pre><code>wp...
[ { "answer_id": 293429, "author": "Maxim Sarandi", "author_id": 135962, "author_profile": "https://wordpress.stackexchange.com/users/135962", "pm_score": 4, "selected": true, "text": "<p><a href=\"https://developer.wordpress.org/reference/functions/wp_remote_get/\" rel=\"noreferrer\">wp_r...
2018/02/07
[ "https://wordpress.stackexchange.com/questions/293431", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19536/" ]
I want to fire an event for when AFTER a new widget has been added to the previewer, and then AFTER a widget has been removed. Use Case: After the widget has been added to the previewer DOM, I want to change it's class based on how many other widgets are in that same sidebar area. So when ``` wp.customize('sidebars_...
[wp\_remote\_get()](https://developer.wordpress.org/reference/functions/wp_remote_get/) and [wp\_remote\_post()](https://developer.wordpress.org/reference/functions/wp_remote_post/) and [wp\_remote\_request()](https://developer.wordpress.org/reference/functions/wp_remote_request/) should answer on your questions.This i...
293,443
<p>I have a custom field manually coded using CMB2: <a href="https://cmb2.io/" rel="nofollow noreferrer">https://cmb2.io/</a>. Here is the code:</p> <pre><code>$cmb_pages_customtext-&gt;add_field( array( 'name' =&gt; esc_html__( 'Content', 'defaulttheme' ), 'id' =&gt; $prefix . 'customtext_content'...
[ { "answer_id": 299470, "author": "Leonardo", "author_id": 138721, "author_profile": "https://wordpress.stackexchange.com/users/138721", "pm_score": 0, "selected": false, "text": "<p>how do you assign the variable? use something like this?</p>\n\n<pre><code>$variable = esc_html( get_post_...
2018/02/07
[ "https://wordpress.stackexchange.com/questions/293443", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119722/" ]
I have a custom field manually coded using CMB2: <https://cmb2.io/>. Here is the code: ``` $cmb_pages_customtext->add_field( array( 'name' => esc_html__( 'Content', 'defaulttheme' ), 'id' => $prefix . 'customtext_content', 'type' => 'wysiwyg', 'sanitization_cb' => false, )); `...
I actually figured out the problem. It was a wp\_kses\_post function that was the cause. The wp\_kses\_post function was stripping the iframe tag. Obviously I removed the wp\_kses\_post function.
293,445
<p>I'm working on a website that needs to be RTL, after reading some articles online I understood that in order for the website to be RTL I need to change the site language to a RTL language.</p> <p>Through this path: <strong>Settings >> General >> Site Language</strong></p> <p>Did that and it changed the website to ...
[ { "answer_id": 293506, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 1, "selected": false, "text": "<p>Set your WordPress to a RTL language, then use the following code in <code>functions.php</code> or as the p...
2018/02/07
[ "https://wordpress.stackexchange.com/questions/293445", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136416/" ]
I'm working on a website that needs to be RTL, after reading some articles online I understood that in order for the website to be RTL I need to change the site language to a RTL language. Through this path: **Settings >> General >> Site Language** Did that and it changed the website to RTL but it changed all the web...
Set your WordPress to a RTL language, then use the following code in `functions.php` or as the plugin: ``` <?php add_filter( 'locale', 'my_set_admin_locale' ); function my_set_admin_locale( $locale ) { // check if you are in the Admin area if( is_admin() ) { // set LTR locale $locale = 'en_US...
293,454
<p>I have build a function to fetch a post in Wordpress served over ajax.</p> <pre><code>$.ajax({ url: '/wp-admin/admin-ajax.php', type: 'POST', cache: false, data: { action: 'get_post_info', postId: postId, }, success: function(data){ }); </c...
[ { "answer_id": 293456, "author": "user2752173", "author_id": 136422, "author_profile": "https://wordpress.stackexchange.com/users/136422", "pm_score": 2, "selected": false, "text": "<p>As it is said in the <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_nopriv_(...
2018/02/07
[ "https://wordpress.stackexchange.com/questions/293454", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/130759/" ]
I have build a function to fetch a post in Wordpress served over ajax. ``` $.ajax({ url: '/wp-admin/admin-ajax.php', type: 'POST', cache: false, data: { action: 'get_post_info', postId: postId, }, success: function(data){ }); ``` In order to ...
As it is said in the [codex](https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_nopriv_(action)) The `wp_ajax_nopriv` hook will not fire for authenticated users, i.e. when is\_user\_logged\_in() returns true. To handle both unauthenticated and authenticated users, also use [wp\_ajax\_(action)](https://code...
293,465
<p>following code is returning <code>name</code> of all terms associated with my custom Post Type which are under `generetax taxonomy only</p> <pre><code>$terms = get_the_term_list($post-&gt;ID, 'generetax'); echo $terms; </code></pre> <p>Can you please let me know how to get the <code>term_id</code> instead of name...
[ { "answer_id": 293467, "author": "Maxim Sarandi", "author_id": 135962, "author_profile": "https://wordpress.stackexchange.com/users/135962", "pm_score": 2, "selected": true, "text": "<p><a href=\"https://developer.wordpress.org/reference/functions/get_the_terms/\" rel=\"nofollow noreferr...
2018/02/07
[ "https://wordpress.stackexchange.com/questions/293465", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35444/" ]
following code is returning `name` of all terms associated with my custom Post Type which are under `generetax taxonomy only ``` $terms = get_the_term_list($post->ID, 'generetax'); echo $terms; ``` Can you please let me know how to get the `term_id` instead of name? I tried this way ``` echo $terms->term_id; ```...
[get\_the\_terms()](https://developer.wordpress.org/reference/functions/get_the_terms/) will help you. Function return array with terms objects and you can foreach array and retrieve term id for each term attached to post.
293,491
<p>i have the code that can add a post in a custom post type but adding the category is not working.</p> <pre><code>$args = array( 'post_title' =&gt; $title , 'post_status' =&gt; 'publish', 'post_type' =&gt; 'mypost' ); $post_id = wp_insert_post($args); $category_ids = array(38,39); wp_set_post_catego...
[ { "answer_id": 293494, "author": "Parth Patel", "author_id": 136444, "author_profile": "https://wordpress.stackexchange.com/users/136444", "pm_score": 0, "selected": false, "text": "<p>As you are doing this for the custom post type, you need to use taxonomy. I will suggest you <code>&lt;...
2018/02/08
[ "https://wordpress.stackexchange.com/questions/293491", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131529/" ]
i have the code that can add a post in a custom post type but adding the category is not working. ``` $args = array( 'post_title' => $title , 'post_status' => 'publish', 'post_type' => 'mypost' ); $post_id = wp_insert_post($args); $category_ids = array(38,39); wp_set_post_categories( $post_id, $catego...
You need to register the custom post type with support for the `category` taxonomy: ``` add_action('init', 'cyb_register_post_type'); function cyb_register_post_type() { $args = array( // All the other args 'taxonomies' => array( 'category' ), ); register_post_type( 'my_post_type'...
293,543
<p><a href="https://i.stack.imgur.com/wUqky.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wUqky.png" alt="WooCommerce panel in Customizer"></a></p> <p>I have used the below code to remove other items from Customizer. But unable to remove the WooCommerce section. </p> <pre><code>function my_custom...
[ { "answer_id": 293550, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 1, "selected": false, "text": "<p>Open admin page HTML source and find there all <code>&lt;li&gt;</code> elements having <code>id</code> attr...
2018/02/08
[ "https://wordpress.stackexchange.com/questions/293543", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135161/" ]
[![WooCommerce panel in Customizer](https://i.stack.imgur.com/wUqky.png)](https://i.stack.imgur.com/wUqky.png) I have used the below code to remove other items from Customizer. But unable to remove the WooCommerce section. ``` function my_customize_register() { global $wp_customize; $wp_customize->remove_sectio...
WooCommerce adds itself to the customizer as a "panel", not a "section". Add this to your `my_customize_register()` function and it will be gone: ``` $wp_customize->remove_panel( 'woocommerce' ); ``` References: * [`woocommerce/includes/customizer/class-wc-shop-customizer.php` line 31](https://github.com/woocommer...
293,546
<p>I'm installing Multisite for a fair-sized business, who's WordPress website has been running for around 5 years.</p> <p>When trying to install it, I am receiving the following warning message:</p> <p>"Because your installation is not new, the sites in your WordPress network must use sub-domains. The main site in a...
[ { "answer_id": 323441, "author": "keepkalm", "author_id": 26744, "author_profile": "https://wordpress.stackexchange.com/users/26744", "pm_score": 2, "selected": false, "text": "<p>You should just start with a new install and import the existing site into the new install. </p>\n\n<p>Start...
2018/02/08
[ "https://wordpress.stackexchange.com/questions/293546", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/127880/" ]
I'm installing Multisite for a fair-sized business, who's WordPress website has been running for around 5 years. When trying to install it, I am receiving the following warning message: "Because your installation is not new, the sites in your WordPress network must use sub-domains. The main site in a sub-directory in...
You should just start with a new install and import the existing site into the new install. Starting with an existing install triggers that warning but if you start fresh you can setup the subfolder structure. You can add this to functions.php to allow a subfolder install in multisite: ``` add_filter( 'allow_s...
293,557
<p>I'm running a multilingual site, and I want the emails sent to the user to be in their language. The scheme I already have is the following:</p> <ol> <li>The website determines the user's country through their IP.</li> <li>The website redirects the user to the site's version of the language of their country (eg. if...
[ { "answer_id": 323441, "author": "keepkalm", "author_id": 26744, "author_profile": "https://wordpress.stackexchange.com/users/26744", "pm_score": 2, "selected": false, "text": "<p>You should just start with a new install and import the existing site into the new install. </p>\n\n<p>Start...
2018/02/08
[ "https://wordpress.stackexchange.com/questions/293557", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136502/" ]
I'm running a multilingual site, and I want the emails sent to the user to be in their language. The scheme I already have is the following: 1. The website determines the user's country through their IP. 2. The website redirects the user to the site's version of the language of their country (eg. if the IP detected is...
You should just start with a new install and import the existing site into the new install. Starting with an existing install triggers that warning but if you start fresh you can setup the subfolder structure. You can add this to functions.php to allow a subfolder install in multisite: ``` add_filter( 'allow_s...
293,559
<p>I have recently installed WordPress Multisite on my local dev environment.</p> <p>The original website, mysite.co.uk, however no longer displays any pages which were in the /includes folder.</p> <p>Anything in the normal pages directory works fine. It is just pages from the /includes subdirectory which have sudde...
[ { "answer_id": 293560, "author": "rugbert", "author_id": 19536, "author_profile": "https://wordpress.stackexchange.com/users/19536", "pm_score": 0, "selected": false, "text": "<p>I'm guessing that 1 of 2 things is happening</p>\n\n<ol>\n<li>your .htaccess file might be misconfigured</li>...
2018/02/08
[ "https://wordpress.stackexchange.com/questions/293559", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/127880/" ]
I have recently installed WordPress Multisite on my local dev environment. The original website, mysite.co.uk, however no longer displays any pages which were in the /includes folder. Anything in the normal pages directory works fine. It is just pages from the /includes subdirectory which have suddenly stopped workin...
The problem was caused by the change to permalinks. When I changed it to /%category%/%postname%/, it worked.
293,603
<p>I am using a plugin <code>Chargebee WP Membership</code> to connect up to their API to process payments. At the moment they are only using shortcodes to restrict content. </p> <p>What I am trying to do, is output the functions of these shortcodes inside the page template. So far I've attempted the <code>do_shortcod...
[ { "answer_id": 293606, "author": "Maxim Sarandi", "author_id": 135962, "author_profile": "https://wordpress.stackexchange.com/users/135962", "pm_score": 1, "selected": false, "text": "<p>Looks like function <code>render_content_show_hide()</code> is a method of class. If you want access ...
2018/02/09
[ "https://wordpress.stackexchange.com/questions/293603", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87036/" ]
I am using a plugin `Chargebee WP Membership` to connect up to their API to process payments. At the moment they are only using shortcodes to restrict content. What I am trying to do, is output the functions of these shortcodes inside the page template. So far I've attempted the `do_shortcode` method but would rather...
Managed to get it working by accessing the `get_user_meta` values. ``` <?php $user_id = get_current_user_id(); $key = 'chargebee_user_subscriptions'; $all_meta_for_user = get_user_meta( $user_id, $key, true ); print_r($all_meta_for_user); ```
293,610
<p>I have a query based on two parameters on a multilingual website (with WPML). To simplify, let's say that one of my filter is the language of the post to retrieve : English, French or all languages. English and French are working fine but I can't make the "all languages" filter work.</p> <p>Here is my code:</p> <p...
[ { "answer_id": 294054, "author": "Ravinder Kumar", "author_id": 74268, "author_profile": "https://wordpress.stackexchange.com/users/74268", "pm_score": 0, "selected": false, "text": "<p>Please check this article from wpml</p>\n\n<p><a href=\"https://wpml.org/forums/topic/problems-to-show...
2018/02/09
[ "https://wordpress.stackexchange.com/questions/293610", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54879/" ]
I have a query based on two parameters on a multilingual website (with WPML). To simplify, let's say that one of my filter is the language of the post to retrieve : English, French or all languages. English and French are working fine but I can't make the "all languages" filter work. Here is my code: ``` <?php // Fir...
So I've made it work. The problem was not with the filter but with tax query. Here is the solution for those who might be interested. ``` <?php // I check the lang query var if it's empty we'll display all languages $langGet = get_query_var('lang', 'all'); ?> /* Then have my form to filter posts */ <form action="<?p...
293,655
<p>I am using this code to count number of posts for one custom post type. </p> <p>What's the best way to change this to sum up together 3 different custom post types?</p> <pre><code>function get_all_them_ven_posts(){ $post_type = 'restaurants'; $count_posts = wp_count_posts( $post_type ); $published_pos...
[ { "answer_id": 293663, "author": "Nathan Johnson", "author_id": 106269, "author_profile": "https://wordpress.stackexchange.com/users/106269", "pm_score": 3, "selected": true, "text": "<p>Why not just get the count for each post type and sum them?</p>\n\n<pre><code>function get_all_them_v...
2018/02/09
[ "https://wordpress.stackexchange.com/questions/293655", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40727/" ]
I am using this code to count number of posts for one custom post type. What's the best way to change this to sum up together 3 different custom post types? ``` function get_all_them_ven_posts(){ $post_type = 'restaurants'; $count_posts = wp_count_posts( $post_type ); $published_posts = $count_posts->pu...
Why not just get the count for each post type and sum them? ``` function get_all_them_ven_posts(){ $count= 0; $post_types = [ 'postType1', 'postType2', 'postType3' ]; foreach( $post_types as $post_type ) { $count_posts = wp_count_posts( $post_type ); $count = $count + $count_posts->publish; } return...
293,661
<p>I have a site with around 8000 products, with a slightly poor site structure - instead of custom taxonomies the Brand Name and Retailer are Parent Categories with the various individual brands, and retailers as sub categories.</p> <p>Brands (Cat ID 187 - around 300 brands as sub cats)</p> <ul> <li>Brand 1</li> <li...
[ { "answer_id": 293666, "author": "Colin Smillie", "author_id": 136396, "author_profile": "https://wordpress.stackexchange.com/users/136396", "pm_score": 2, "selected": false, "text": "<p>I think I'd setup a loop for all posts and the do something like this inside the loop:</p>\n\n<pre><c...
2018/02/09
[ "https://wordpress.stackexchange.com/questions/293661", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115825/" ]
I have a site with around 8000 products, with a slightly poor site structure - instead of custom taxonomies the Brand Name and Retailer are Parent Categories with the various individual brands, and retailers as sub categories. Brands (Cat ID 187 - around 300 brands as sub cats) * Brand 1 * Brand 2 * Brand 3 etc Reta...
I think I'd setup a loop for all posts and the do something like this inside the loop: ``` $post_cats = get_the_category(); $brand_cats = 0; $retail_cats = 0; foreach ( $post_cats as $post_cat ) { if ($post_cat->category_parent == 187) { $brand_cats++; if ($post_cat->category_parent == 186) { $...
293,667
<p>I'm sorry to be asking a question that's (from what I've gathered) asked with relative frequency, but I think I've complicated the problem by leaving a project and then coming back to it after my skills have gotten rusty. So, in a very basic theme I created a while ago for a friend, I used PHP in the stylesheet to c...
[ { "answer_id": 293673, "author": "C C", "author_id": 83299, "author_profile": "https://wordpress.stackexchange.com/users/83299", "pm_score": 2, "selected": false, "text": "<p>Suggest you move your desired functionality to javascript; you are so badly attempting to overload the purpose of...
2018/02/09
[ "https://wordpress.stackexchange.com/questions/293667", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102900/" ]
I'm sorry to be asking a question that's (from what I've gathered) asked with relative frequency, but I think I've complicated the problem by leaving a project and then coming back to it after my skills have gotten rusty. So, in a very basic theme I created a while ago for a friend, I used PHP in the stylesheet to crea...
Suggest you move your desired functionality to javascript; you are so badly attempting to overload the purpose of these constructs...even if you get it to work you are going to have a very fragile and difficult to maintain system on your hands. Note that the idea of inlining style may work -- but future Content Secur...
293,698
<p>I have this action: </p> <pre><code>add_action( 'wp_enqueue_scripts', 'my_custom_script_load3' ); function my_custom_script_load3(){ wp_enqueue_script( 'my-custom-script3', '/members/user.js' ); } </code></pre> <p>It works great when I have it in functions.php of my root directory WordPress installation. </p> <...
[ { "answer_id": 293673, "author": "C C", "author_id": 83299, "author_profile": "https://wordpress.stackexchange.com/users/83299", "pm_score": 2, "selected": false, "text": "<p>Suggest you move your desired functionality to javascript; you are so badly attempting to overload the purpose of...
2018/02/10
[ "https://wordpress.stackexchange.com/questions/293698", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/134788/" ]
I have this action: ``` add_action( 'wp_enqueue_scripts', 'my_custom_script_load3' ); function my_custom_script_load3(){ wp_enqueue_script( 'my-custom-script3', '/members/user.js' ); } ``` It works great when I have it in functions.php of my root directory WordPress installation. But I also have a second WordPr...
Suggest you move your desired functionality to javascript; you are so badly attempting to overload the purpose of these constructs...even if you get it to work you are going to have a very fragile and difficult to maintain system on your hands. Note that the idea of inlining style may work -- but future Content Secur...
293,714
<p>I have a code in my theme's stylesheet that looks like this. I would like for my code to not use the width property that is set in here. Deleting is not the option as that would be only temporary solution until the next update of my theme. What can i do, so that this with property is not used?</p> <pre><code>@media...
[ { "answer_id": 293716, "author": "C C", "author_id": 83299, "author_profile": "https://wordpress.stackexchange.com/users/83299", "pm_score": 2, "selected": false, "text": "<p>Research the the topic <a href=\"https://codex.wordpress.org/Child_Themes\" rel=\"nofollow noreferrer\">creating ...
2018/02/10
[ "https://wordpress.stackexchange.com/questions/293714", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136588/" ]
I have a code in my theme's stylesheet that looks like this. I would like for my code to not use the width property that is set in here. Deleting is not the option as that would be only temporary solution until the next update of my theme. What can i do, so that this with property is not used? ``` @media (max-width: 9...
I would not suggest creating a child theme to override a single CSS line. You can simply use the theme customizer and add your CSS to the additional CSS box. Most CSS properties accept an `unset` or `inherit` value. So, you can paste the following code into the additional CSS box: ``` @media (max-width: 991px) and (mi...
293,742
<p>I have one custom post type 'team' to create and display team-members and all works fine (screenshot how it needs to look):</p> <p><a href="https://i.stack.imgur.com/XcVCl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XcVCl.png" alt="enter image description here"></a></p> <p>In admin panel use...
[ { "answer_id": 293763, "author": "Joel M", "author_id": 93297, "author_profile": "https://wordpress.stackexchange.com/users/93297", "pm_score": 0, "selected": false, "text": "<p>add a link field to every team member and do an if else statement in your loop. if the link field is there......
2018/02/10
[ "https://wordpress.stackexchange.com/questions/293742", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135678/" ]
I have one custom post type 'team' to create and display team-members and all works fine (screenshot how it needs to look): [![enter image description here](https://i.stack.imgur.com/XcVCl.png)](https://i.stack.imgur.com/XcVCl.png) In admin panel user entries team member position into input field and attach featured ...
Here are some options I think you can try: ### First Option: If you always have that element in your archive page, you can add this element at the end of the list outside the loop. It should look something like this: ``` <?php $query = new WP_Query(array( 'post_type' => array('team'), 'orderb...
293,747
<p>I have this script that cuts down my menu and adds a "+" dropdown if there are too many menu items in an attempt to prettify long menus, as such:</p> <p><a href="https://i.stack.imgur.com/7ZRGm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7ZRGm.png" alt="Menu With the Script"></a></p> <p>With...
[ { "answer_id": 293763, "author": "Joel M", "author_id": 93297, "author_profile": "https://wordpress.stackexchange.com/users/93297", "pm_score": 0, "selected": false, "text": "<p>add a link field to every team member and do an if else statement in your loop. if the link field is there......
2018/02/10
[ "https://wordpress.stackexchange.com/questions/293747", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/133461/" ]
I have this script that cuts down my menu and adds a "+" dropdown if there are too many menu items in an attempt to prettify long menus, as such: [![Menu With the Script](https://i.stack.imgur.com/7ZRGm.png)](https://i.stack.imgur.com/7ZRGm.png) Without the script running: [![Menu Without the Script](https://i.stack...
Here are some options I think you can try: ### First Option: If you always have that element in your archive page, you can add this element at the end of the list outside the loop. It should look something like this: ``` <?php $query = new WP_Query(array( 'post_type' => array('team'), 'orderb...
293,751
<p>I am using the ACF plugin for custom posts types and am fairly new to using it. I have a field called "app_url" that is a url that I need to include as a link in my header.php file so it is on all pages, the custom post type is called "slider". If I just use </p> <pre><code>&lt;a&gt;&lt;?php get_field('app_url'); ?...
[ { "answer_id": 293754, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 2, "selected": true, "text": "<p>I'm observing three problems here.</p>\n\n<h2>1- Your anchors do not have a <code>href</code> attribute.</h2...
2018/02/11
[ "https://wordpress.stackexchange.com/questions/293751", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/127290/" ]
I am using the ACF plugin for custom posts types and am fairly new to using it. I have a field called "app\_url" that is a url that I need to include as a link in my header.php file so it is on all pages, the custom post type is called "slider". If I just use ``` <a><?php get_field('app_url'); ?></> ``` It doesn't ...
I'm observing three problems here. 1- Your anchors do not have a `href` attribute. ----------------------------------------------- As you mentioned, the `app_url` field is a URL, and should be output in the `href` attribute of an anchor. So, this is how your anchor should look like: ``` <a href="<?php echo esc_url( ...
293,764
<p>I have this function that helps me nicely trim post titles:</p> <pre><code>namespace Helpers; .. function _s_trim_post_title ( $length = null, $delimiter = null ) { $title = get_the_title(); $trimmed_title = mb_strimwidth( $title, 0, ...
[ { "answer_id": 293768, "author": "obiPlabon", "author_id": 135737, "author_profile": "https://wordpress.stackexchange.com/users/135737", "pm_score": 2, "selected": false, "text": "<p>First of all, please try to understand how filter hooks work inside WordPress. These two functions will h...
2018/02/11
[ "https://wordpress.stackexchange.com/questions/293764", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/133461/" ]
I have this function that helps me nicely trim post titles: ``` namespace Helpers; .. function _s_trim_post_title ( $length = null, $delimiter = null ) { $title = get_the_title(); $trimmed_title = mb_strimwidth( $title, 0, $l...
Here's the correct code snippet. Hope it'll work for you. **Helper function** ``` namespace Helpers; .. function _s_trim_content( $content = '', $length = null, $delimiter = null ) { $trimmed_content = mb_strimwidth( $content, 0, is_null( $length ) ? BIG_INT : $length, '' // Won't use, ...
293,771
<p>How to insert new element to existing array in usermeta? This code doesn't work because it makes nested array.</p> <pre><code>$data = array( get_user_meta(2, 'fruits', false), 'apple', 'pear', 'peach' ); update_user_meta(2, 'fruits', $data , false); $sud = get_user_meta(2, 'fruits', false); echo print_r($sud...
[ { "answer_id": 293773, "author": "Aqib Ashef", "author_id": 84179, "author_profile": "https://wordpress.stackexchange.com/users/84179", "pm_score": 1, "selected": false, "text": "<p>try this:</p>\n\n<pre><code>$data = get_user_meta(2, 'fruits', false);\narray_push($data, 'apple', 'pear',...
2018/02/11
[ "https://wordpress.stackexchange.com/questions/293771", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136622/" ]
How to insert new element to existing array in usermeta? This code doesn't work because it makes nested array. ``` $data = array( get_user_meta(2, 'fruits', false), 'apple', 'pear', 'peach' ); update_user_meta(2, 'fruits', $data , false); $sud = get_user_meta(2, 'fruits', false); echo print_r($sud); ```
Let's analyze your code and what it does. Assuming that the current fruits stored in the database are 'pineapple' and 'orange', `get_user_meta(2, 'fruits', false)` will return something like this: ``` array( array( 'pineapple', 'orange' ) ) ``` This is because you passed `false` as the third argument, `$single`. Th...
293,772
<p>This is going to be a big explanation as I don't have any shortcut ways to explain the whole scenario.</p> <p>Let's say I have following category structure. (category ids are withing bracket in front of the each category)</p> <pre><code>First Level 1 (100) Second Level 1 (104) Third Level 1 (108) ...
[ { "answer_id": 294060, "author": "Vlad Olaru", "author_id": 52726, "author_profile": "https://wordpress.stackexchange.com/users/52726", "pm_score": 1, "selected": false, "text": "<p>The query you need to use is not so complicated as you basically just what to get posts from only certain ...
2018/02/11
[ "https://wordpress.stackexchange.com/questions/293772", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68403/" ]
This is going to be a big explanation as I don't have any shortcut ways to explain the whole scenario. Let's say I have following category structure. (category ids are withing bracket in front of the each category) ``` First Level 1 (100) Second Level 1 (104) Third Level 1 (108) Third Level 2 (109...
After a long research, the only way I found was, get the results with custom sql query as bellow. ``` SELECT SQL_CALC_FOUND_ROWS blog_posts.* FROM ( SELECT blog_posts.* FROM blog_posts INNER JOIN blog_term_relationships AS tt0 ON (blog_posts.ID = tt0.object_id AND tt0.term_taxonomy_id IN (108,109)) INNER JOIN blog_t...
293,776
<p>I’m looking to convert around 300 categories, each with advanced custom fields, to a custom taxonomy so I have better website structure.</p> <p>However with all of the plugins I’ve used so far, I can move the terms from the Category taxonomy to the custom taxonomy called Brands, and it keeps the standard WordPress ...
[ { "answer_id": 294060, "author": "Vlad Olaru", "author_id": 52726, "author_profile": "https://wordpress.stackexchange.com/users/52726", "pm_score": 1, "selected": false, "text": "<p>The query you need to use is not so complicated as you basically just what to get posts from only certain ...
2018/02/11
[ "https://wordpress.stackexchange.com/questions/293776", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115825/" ]
I’m looking to convert around 300 categories, each with advanced custom fields, to a custom taxonomy so I have better website structure. However with all of the plugins I’ve used so far, I can move the terms from the Category taxonomy to the custom taxonomy called Brands, and it keeps the standard WordPress data (Name...
After a long research, the only way I found was, get the results with custom sql query as bellow. ``` SELECT SQL_CALC_FOUND_ROWS blog_posts.* FROM ( SELECT blog_posts.* FROM blog_posts INNER JOIN blog_term_relationships AS tt0 ON (blog_posts.ID = tt0.object_id AND tt0.term_taxonomy_id IN (108,109)) INNER JOIN blog_t...
293,795
<p>By default, <a href="https://make.wordpress.org/core/2016/07/06/resource-hints-in-4-6/" rel="nofollow noreferrer">wp_resource_hints()</a> prints hints for <code>s.w.org</code>, I am trying to change the default printed value. I am not trying to get rid of the hook, I indeed need it and want to use it, however witout...
[ { "answer_id": 293797, "author": "lowtechsun", "author_id": 77054, "author_profile": "https://wordpress.stackexchange.com/users/77054", "pm_score": 2, "selected": false, "text": "<pre><code>var_export( $hints );\n</code></pre>\n\n<p>gave me </p>\n\n<pre><code>array (\n 0 =&gt; 'https://...
2018/02/11
[ "https://wordpress.stackexchange.com/questions/293795", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77054/" ]
By default, [wp\_resource\_hints()](https://make.wordpress.org/core/2016/07/06/resource-hints-in-4-6/) prints hints for `s.w.org`, I am trying to change the default printed value. I am not trying to get rid of the hook, I indeed need it and want to use it, however witout `s.w.org`. ``` function resource_hints( $hints,...
``` var_export( $hints ); ``` gave me ``` array ( 0 => 'https://s.w.org/images/core/emoji/2.4/svg/', ) ``` so that means the array key is not `s.w.org` but `https://s.w.org/images/core/emoji/2.4/svg/`. Changing the function and using the key of the array with the full url did remove the s.w.org hint while stil...
293,829
<p>how to disable WordPress flash up-loader and force to use browser up-loader instead ? any solution, is there any function code i can use?</p>
[ { "answer_id": 293831, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 1, "selected": false, "text": "<pre><code>function disable_flash_uploader() {\n return false;\n}\n\nadd_filter( 'flash_uploader', 'disable_flash...
2018/02/11
[ "https://wordpress.stackexchange.com/questions/293829", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136651/" ]
how to disable WordPress flash up-loader and force to use browser up-loader instead ? any solution, is there any function code i can use?
``` function disable_flash_uploader() { return false; } add_filter( 'flash_uploader', 'disable_flash_uploader', 1 ); ``` Or disable/uninstall the plug in
293,862
<p>I want to remove/disable the 'Active Theme' section from customizer. What could be the best way to do it? <a href="https://i.stack.imgur.com/j34tO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j34tO.png" alt="enter image description here"></a></p>
[ { "answer_id": 293831, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 1, "selected": false, "text": "<pre><code>function disable_flash_uploader() {\n return false;\n}\n\nadd_filter( 'flash_uploader', 'disable_flash...
2018/02/12
[ "https://wordpress.stackexchange.com/questions/293862", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135161/" ]
I want to remove/disable the 'Active Theme' section from customizer. What could be the best way to do it? [![enter image description here](https://i.stack.imgur.com/j34tO.png)](https://i.stack.imgur.com/j34tO.png)
``` function disable_flash_uploader() { return false; } add_filter( 'flash_uploader', 'disable_flash_uploader', 1 ); ``` Or disable/uninstall the plug in
293,912
<p>I'm trying to help a friend access his website after a different developer created it, but when I visit the site.com/wp-admin, it doesn't take me to the typical dashboard and backend I'm used to seeing. It looks like this.</p> <p><a href="https://i.stack.imgur.com/s8JpA.png" rel="nofollow noreferrer"><img src="http...
[ { "answer_id": 293831, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 1, "selected": false, "text": "<pre><code>function disable_flash_uploader() {\n return false;\n}\n\nadd_filter( 'flash_uploader', 'disable_flash...
2018/02/12
[ "https://wordpress.stackexchange.com/questions/293912", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136710/" ]
I'm trying to help a friend access his website after a different developer created it, but when I visit the site.com/wp-admin, it doesn't take me to the typical dashboard and backend I'm used to seeing. It looks like this. [![enter image description here](https://i.stack.imgur.com/s8JpA.png)](https://i.stack.imgur.com...
``` function disable_flash_uploader() { return false; } add_filter( 'flash_uploader', 'disable_flash_uploader', 1 ); ``` Or disable/uninstall the plug in
293,944
<p>I would like to disable the Uncategorized public URL (i.e. <code>/category/uncategorized</code>), since I'm not using post categories and already have the posts list with pagination on the main Blog posts page. Having the Uncategorized category URLs simply creates duplicate pages.</p> <p>Is there a way to disable p...
[ { "answer_id": 293947, "author": "Harsh Barach", "author_id": 112248, "author_profile": "https://wordpress.stackexchange.com/users/112248", "pm_score": 0, "selected": false, "text": "<p>First you need to go in <code>Setting &gt;&gt; Writing</code>. Then, you need to follow below steps.</...
2018/02/13
[ "https://wordpress.stackexchange.com/questions/293944", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/135743/" ]
I would like to disable the Uncategorized public URL (i.e. `/category/uncategorized`), since I'm not using post categories and already have the posts list with pagination on the main Blog posts page. Having the Uncategorized category URLs simply creates duplicate pages. Is there a way to disable post categories entire...
`Categories` is a core feature for organizing Posts, providing users with a searchable, context-aware, and relational user experience. Rather than trying to modify the taxonomy itself, **modify the view.** Comb through your site's widgets and menus and remove any filters or widgets that display Posts based on `Categor...
293,995
<p>I'm trying to add a checkbox to the "Menus" panel in the customizer, but for some reason, it's not showing up. If I try changing it from "nav_menus" to "title_tagline," or "colors," the checkbox shows up just fine. What could be preventing it from showing up on the "Menus" panel?</p> <pre><code>// add custom option...
[ { "answer_id": 293997, "author": "obiPlabon", "author_id": 135737, "author_profile": "https://wordpress.stackexchange.com/users/135737", "pm_score": 4, "selected": true, "text": "<p>You cannot add any control/setting to <code>nav_menus</code> because that's not a section that's a panel. ...
2018/02/13
[ "https://wordpress.stackexchange.com/questions/293995", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24566/" ]
I'm trying to add a checkbox to the "Menus" panel in the customizer, but for some reason, it's not showing up. If I try changing it from "nav\_menus" to "title\_tagline," or "colors," the checkbox shows up just fine. What could be preventing it from showing up on the "Menus" panel? ``` // add custom options to the Cus...
You cannot add any control/setting to `nav_menus` because that's not a section that's a panel. And control/setting can be added to the section only. So you have to create a section first under `nav_menus` panel then add your control/setting to that section. Check the following code ``` function nssra_customizer_option...
293,999
<p>I have created a Custom Post Type called <code>Products</code>.</p> <p>Now I need a functionality that will allow me to select or check a product as featured. <br>There can be only one featured product. <br>When one product is selected the others are deselected automatically.<br>This featured product will be displa...
[ { "answer_id": 293997, "author": "obiPlabon", "author_id": 135737, "author_profile": "https://wordpress.stackexchange.com/users/135737", "pm_score": 4, "selected": true, "text": "<p>You cannot add any control/setting to <code>nav_menus</code> because that's not a section that's a panel. ...
2018/02/13
[ "https://wordpress.stackexchange.com/questions/293999", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65324/" ]
I have created a Custom Post Type called `Products`. Now I need a functionality that will allow me to select or check a product as featured. There can be only one featured product. When one product is selected the others are deselected automatically. This featured product will be displayed on homepage. **Ques...
You cannot add any control/setting to `nav_menus` because that's not a section that's a panel. And control/setting can be added to the section only. So you have to create a section first under `nav_menus` panel then add your control/setting to that section. Check the following code ``` function nssra_customizer_option...
294,003
<p>I have a custom post type <code>products</code> and a custom taxonomy 'Product Categories' with the slug <code>products</code>.</p> <p><strong>My goal:</strong> I'm trying to create a URL structure like so:</p> <p>Product Post Type Archive: <code>products/</code></p> <p>Product Top-level Category Archives: <code>...
[ { "answer_id": 294542, "author": "J Robz", "author_id": 112485, "author_profile": "https://wordpress.stackexchange.com/users/112485", "pm_score": 4, "selected": true, "text": "<p>After forever, I figured out an answer!</p>\n<p>First: we register the custom post type &amp; custom taxonomy...
2018/02/13
[ "https://wordpress.stackexchange.com/questions/294003", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112485/" ]
I have a custom post type `products` and a custom taxonomy 'Product Categories' with the slug `products`. **My goal:** I'm trying to create a URL structure like so: Product Post Type Archive: `products/` Product Top-level Category Archives: `products/product-category` Product Category Archives: `products/product-ca...
After forever, I figured out an answer! First: we register the custom post type & custom taxonomy: ``` add_action( 'init', 'register_sps_products_post_type' ); function register_sps_products_post_type() { register_post_type( 'sps-product', array( 'labels' => array( 'name' => 'P...
294,004
<p>I am currently using a Plugin, which has created a Stylesheet within the following directory: <code>/wp-content/uploads/plugin-name/css</code>.</p> <p>I would like to remove this Plugin's Stylesheet, since it is being called after my Custom Stylesheet, where the Plugin is performing unwanted overrides of the Custo...
[ { "answer_id": 294005, "author": "Craig", "author_id": 112472, "author_profile": "https://wordpress.stackexchange.com/users/112472", "pm_score": 3, "selected": true, "text": "<p>My error. All I had to do was knock off the <code>-css</code> and it worked.</p>\n\n<p>Working code:</p>\n\n<...
2018/02/13
[ "https://wordpress.stackexchange.com/questions/294004", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112472/" ]
I am currently using a Plugin, which has created a Stylesheet within the following directory: `/wp-content/uploads/plugin-name/css`. I would like to remove this Plugin's Stylesheet, since it is being called after my Custom Stylesheet, where the Plugin is performing unwanted overrides of the Custom Stylesheet. Instead...
My error. All I had to do was knock off the `-css` and it worked. Working code: ``` <?php function dequeue_dequeue_plugin_style(){ wp_dequeue_style( 'plugin' ); //Name of Style ID. } add_action( 'wp_enqueue_scripts', 'dequeue_dequeue_plugin_style', 999 ); ?> ```
294,011
<p>I am running a site where I let users create a profile, which is a custom post type, which is submitted/edited through an ACF front-end form. Everything works as expected, except when users both use the same 'headline' (which is sanitized and used as permalink).</p> <p>I want the permalink to have the following 'st...
[ { "answer_id": 294034, "author": "Slam", "author_id": 82256, "author_profile": "https://wordpress.stackexchange.com/users/82256", "pm_score": -1, "selected": false, "text": "<p>Are <code>/i-am-cool-123</code> and <code>i-am-cool-456</code> actually two different posts?</p>\n\n<p>If so th...
2018/02/13
[ "https://wordpress.stackexchange.com/questions/294011", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103402/" ]
I am running a site where I let users create a profile, which is a custom post type, which is submitted/edited through an ACF front-end form. Everything works as expected, except when users both use the same 'headline' (which is sanitized and used as permalink). I want the permalink to have the following 'structure': ...
I was thinking too 'difficult'. Instead of rebuilding a new permalink structure I could have easily updated the new permalink the way I want to have it. So I deleted the entire rewrite part and changed the query in acf/save\_post to the following: ``` if ( ! empty( $_POST[ 'acf' ][ $ad_title ] ) ) { $entered_tit...
294,039
<p>I have added the full array in end of the post. I have passed 'post_type', 'posts_per_page', 'tax_query' and 'meta_query' for <code>WP_Query</code>.</p> <p>This page take around 10 - 15 seconds to load... It is too much :-(... [Sorry : 10-15 seconds is wrong, when calculating it is about a minute... ]</p> <p>So I ...
[ { "answer_id": 294178, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 5, "selected": true, "text": "<p>This is a stupendously expensive query, you can mitigate but you can't eliminate the performance issues.</p>\...
2018/02/14
[ "https://wordpress.stackexchange.com/questions/294039", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/123092/" ]
I have added the full array in end of the post. I have passed 'post\_type', 'posts\_per\_page', 'tax\_query' and 'meta\_query' for `WP_Query`. This page take around 10 - 15 seconds to load... It is too much :-(... [Sorry : 10-15 seconds is wrong, when calculating it is about a minute... ] So I was looking at why it i...
This is a stupendously expensive query, you can mitigate but you can't eliminate the performance issues. So lets start with the low hanging fruit and work our way up to the big problems posts\_per\_page ---------------- Always set a maximum, even if it's one you never expect to reach. `-1` is asking for trouble: * ...
294,058
<p>I want to host Google fonts locally to hopefully shave some page loading time off.</p> <p>I hope to use <a href="https://google-webfonts-helper.herokuapp.com/fonts" rel="nofollow noreferrer">google-webfonts-helper</a> to do this.</p> <p>I would need to ensure our theme, Divi, does not load the original Google font...
[ { "answer_id": 294061, "author": "Maxim Sarandi", "author_id": 135962, "author_profile": "https://wordpress.stackexchange.com/users/135962", "pm_score": 2, "selected": false, "text": "<p><a href=\"https://developer.wordpress.org/reference/functions/wp_dequeue_style/\" rel=\"nofollow nore...
2018/02/14
[ "https://wordpress.stackexchange.com/questions/294058", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
I want to host Google fonts locally to hopefully shave some page loading time off. I hope to use [google-webfonts-helper](https://google-webfonts-helper.herokuapp.com/fonts) to do this. I would need to ensure our theme, Divi, does not load the original Google fonts. Currently, our site has the following in the head....
Looks like someone has already done what I need to do. From [this post](https://designsbytierney.com/2017/06/optimize-google-font-delivery-wordpress-divi-theme/), I can add the following code to my child theme's `functions.php`: ``` // REMOVE OPEN SANS GOOGLE FONT FROM DIVI function disable_open_sans_divi() { wp_dequ...
294,104
<p>I'm quite new to WordPress and wonder if there is a way to take the content in a normal page created in WP and show this content in a div tag through a page template?</p> <p>The setup is two divs next to each other showing different content based on the two WP pages. When I change a page's content, the output in th...
[ { "answer_id": 294111, "author": "Den Isahac", "author_id": 113233, "author_profile": "https://wordpress.stackexchange.com/users/113233", "pm_score": 1, "selected": false, "text": "<p>Assuming you have the following pages:</p>\n\n<ol>\n<li><strong>Home</strong></li>\n<li><strong>About us...
2018/02/14
[ "https://wordpress.stackexchange.com/questions/294104", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136852/" ]
I'm quite new to WordPress and wonder if there is a way to take the content in a normal page created in WP and show this content in a div tag through a page template? The setup is two divs next to each other showing different content based on the two WP pages. When I change a page's content, the output in the correspo...
Assuming you have the following pages: 1. **Home** 2. **About us** that has a slug of `about-us` And you want to display the content of the **About us** page into the **Home** page. ``` <?php $about_us = get_page_by_path('about-us'); // supply the page slug; i.e. about-us $about_us_content = get_the_conten...
294,105
<p>I am trying to setup a local version of a website that is live, I have downloaded the files and database and believe it is all ready and sorted, but I am having an issue whereby the site is trying to force HTTPS and so all browsers are reporting 'This site can’t provide a secure connection, localhost sent an invalid...
[ { "answer_id": 294107, "author": "sandrodz", "author_id": 115734, "author_profile": "https://wordpress.stackexchange.com/users/115734", "pm_score": 3, "selected": false, "text": "<p>WordPress keeps <code>WP_HOME</code> and <code>WP_SITEURL</code> in DB, this is set during initial install...
2018/02/14
[ "https://wordpress.stackexchange.com/questions/294105", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82748/" ]
I am trying to setup a local version of a website that is live, I have downloaded the files and database and believe it is all ready and sorted, but I am having an issue whereby the site is trying to force HTTPS and so all browsers are reporting 'This site can’t provide a secure connection, localhost sent an invalid re...
WordPress keeps `WP_HOME` and `WP_SITEURL` in DB, this is set during initial installation and usually is the domain of your website, in your case it is a domain with `https`. Your visiting site via local domain, but WordPress redirects to https live domain, causing redirect loop which obviously fails. To fix this, ch...
294,122
<p>Hello I have a menu with parent and children. Here is the code I am using to display it:</p> <pre><code>&lt;?php wp_nav_menu( array('menu' =&gt; 'Main Menu')); ?&gt; </code></pre> <p>This spits out something like this:</p> <pre><code>&lt;div class="main-menu-menu-container"&gt; &lt;ul class="main-menu-menu"&g...
[ { "answer_id": 294124, "author": "cup_of", "author_id": 112836, "author_profile": "https://wordpress.stackexchange.com/users/112836", "pm_score": 0, "selected": false, "text": "<p>I figured it out with jQuery if anyone is interested.</p>\n\n<pre><code>jQuery('.main-menu-menu-container ul...
2018/02/14
[ "https://wordpress.stackexchange.com/questions/294122", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112836/" ]
Hello I have a menu with parent and children. Here is the code I am using to display it: ``` <?php wp_nav_menu( array('menu' => 'Main Menu')); ?> ``` This spits out something like this: ``` <div class="main-menu-menu-container"> <ul class="main-menu-menu"> <li> <a href="">Parent</a> ...
Since WordPress make use of `Walkers` you can extend the class `Walker_Nav_Menu` with your own and pass the instance of it to the function `wp_nav_menu`. So your call will be: ``` <?php wp_nav_menu( array( 'menu' => 'Main Menu' 'walker' => new Custom_Nav_Walker() ) ); ?> ``` Then in a separated file cre...
294,132
<p>I have created a custom post type called 'reports' to provide an easy method for providing monthly reports to specific people. I don't want users to have to login to view the reports and I also don't want any user to find reports intended for another user. </p> <p>So I have created a custom taxonomy so I can create...
[ { "answer_id": 294124, "author": "cup_of", "author_id": 112836, "author_profile": "https://wordpress.stackexchange.com/users/112836", "pm_score": 0, "selected": false, "text": "<p>I figured it out with jQuery if anyone is interested.</p>\n\n<pre><code>jQuery('.main-menu-menu-container ul...
2018/02/15
[ "https://wordpress.stackexchange.com/questions/294132", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119171/" ]
I have created a custom post type called 'reports' to provide an easy method for providing monthly reports to specific people. I don't want users to have to login to view the reports and I also don't want any user to find reports intended for another user. So I have created a custom taxonomy so I can create a term fo...
Since WordPress make use of `Walkers` you can extend the class `Walker_Nav_Menu` with your own and pass the instance of it to the function `wp_nav_menu`. So your call will be: ``` <?php wp_nav_menu( array( 'menu' => 'Main Menu' 'walker' => new Custom_Nav_Walker() ) ); ?> ``` Then in a separated file cre...
294,138
<p>I want to display products that are related either by category or attributes (not tags)</p> <p>I've modified the solution posted here <a href="https://stackoverflow.com/questions/40769017/wordpress-woocommerce-related-products-by-attribute">here</a> to my needs:</p> <pre><code>function custom_related_product_args ...
[ { "answer_id": 294139, "author": "Dharmishtha Patel", "author_id": 135085, "author_profile": "https://wordpress.stackexchange.com/users/135085", "pm_score": 0, "selected": false, "text": "<pre><code>global $product;\n\n$cats = wc_get_product_terms( $product-&gt;id, 'product_cat'...
2018/02/15
[ "https://wordpress.stackexchange.com/questions/294138", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131684/" ]
I want to display products that are related either by category or attributes (not tags) I've modified the solution posted here [here](https://stackoverflow.com/questions/40769017/wordpress-woocommerce-related-products-by-attribute) to my needs: ``` function custom_related_product_args ( $args ){ global $product; ...
Disable default Related Products and try this (Add custom code to the functions.php) ``` add_action( 'woocommerce_after_single_product_summary', 'custom_output_product_collection', 12 ); function custom_output_product_collection(){ ## --- YOUR SETTINGS --- ## $attribute = "attribute_slug"; // <== HERE define...