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
266,502
<p>I'm definitely missing some basics here.</p> <p>I'm using this <a href="https://github.com/kylephillips/favorites" rel="nofollow noreferrer">plugin</a> wich performs ajax actions, and then fires a js function as callback. I would like to use the callback in a custom js script of my theme.</p> <p>Callback function ...
[ { "answer_id": 266504, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": -1, "selected": false, "text": "<p>This is more of JS question than WP, but in general the code you showed sucks. There are all kinds of wa...
2017/05/10
[ "https://wordpress.stackexchange.com/questions/266502", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4155/" ]
I'm definitely missing some basics here. I'm using this [plugin](https://github.com/kylephillips/favorites) wich performs ajax actions, and then fires a js function as callback. I would like to use the callback in a custom js script of my theme. Callback function is already defined (but empty) at the beginning of the...
Ok, I found out [here](https://wordpress.org/support/topic/javascript-callbacks-clarification/) how to procede. It was so simple I could not believe: 1) include in theme a custom script with a dependency on the favorite plugin. example: ``` wp_enqueue_script('script', get_stylesheet_directory_uri() . '/js/myscript.j...
266,542
<p>I used the following code in <code>functions.php</code> to translate some text:</p> <pre><code>add_filter('gettext', 'aad_translate_words_array'); add_filter('ngettext', 'aad_translate_words_array'); function aad_translate_words_array( $translated ) { $words = array( // 'word to translate' = &gt; 'tran...
[ { "answer_id": 271683, "author": "sMyles", "author_id": 51201, "author_profile": "https://wordpress.stackexchange.com/users/51201", "pm_score": 3, "selected": false, "text": "<p>The code you have is correct and will handle the wording even if the case does not match.</p>\n\n<p>Your probl...
2017/05/11
[ "https://wordpress.stackexchange.com/questions/266542", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
I used the following code in `functions.php` to translate some text: ``` add_filter('gettext', 'aad_translate_words_array'); add_filter('ngettext', 'aad_translate_words_array'); function aad_translate_words_array( $translated ) { $words = array( // 'word to translate' = > 'translation' 'Place Name...
The code you have is correct and will handle the wording even if the case does not match. Your problem is probably that wherever `Place Name` is being output, it is not being passed through a WordPress translation function, `__( 'Place Name' )` or `_e( 'Place Name' );` Either that, or what you're trying to translate ...
266,557
<p>I am working on a task where i need to retrive 100s posts under single-page/single-request with their featured images. </p> <p>By using wordpress method of retriving posts and then retrive featured image individually using <code>get_the_post_thumbnail</code> function it takes so much time to load the page. </p> <p...
[ { "answer_id": 266581, "author": "Vinod Dalvi", "author_id": 14347, "author_profile": "https://wordpress.stackexchange.com/users/14347", "pm_score": 2, "selected": false, "text": "<p>The post and featured image URL is saved in wp_posts table and its relation is saved in wp_postmeta table...
2017/05/11
[ "https://wordpress.stackexchange.com/questions/266557", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115973/" ]
I am working on a task where i need to retrive 100s posts under single-page/single-request with their featured images. By using wordpress method of retriving posts and then retrive featured image individually using `get_the_post_thumbnail` function it takes so much time to load the page. Can someone provide a faste...
Worked on similar problem recently. Here is the SQL query to get the post with Featured Image. ``` global $wpdb; $perpage = 10; $page = 1; // Get the current page FROM $wp_query $counter = $perpage * $page; $uploadDir = wp_upload_dir(); $uploadDir = $uploadDir['baseurl']; $sql = " SELECT post.ID, post.p...
266,589
<p>My Woocommerce shopping cart page displays a column for my product thumbnails, but the heading of the column is missing (<a href="https://imgur.com/a/jh1tp" rel="nofollow noreferrer">screenshot</a>). Can I add a heading here by using a filter hook? If so, can anyone suggest the particular hook to use? I've looked...
[ { "answer_id": 266581, "author": "Vinod Dalvi", "author_id": 14347, "author_profile": "https://wordpress.stackexchange.com/users/14347", "pm_score": 2, "selected": false, "text": "<p>The post and featured image URL is saved in wp_posts table and its relation is saved in wp_postmeta table...
2017/05/11
[ "https://wordpress.stackexchange.com/questions/266589", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51204/" ]
My Woocommerce shopping cart page displays a column for my product thumbnails, but the heading of the column is missing ([screenshot](https://imgur.com/a/jh1tp)). Can I add a heading here by using a filter hook? If so, can anyone suggest the particular hook to use? I've looked through the [big book of Woocommerce hooks...
Worked on similar problem recently. Here is the SQL query to get the post with Featured Image. ``` global $wpdb; $perpage = 10; $page = 1; // Get the current page FROM $wp_query $counter = $perpage * $page; $uploadDir = wp_upload_dir(); $uploadDir = $uploadDir['baseurl']; $sql = " SELECT post.ID, post.p...
266,613
<p>A plugin creates a set of pages and a template. There must be some method to assign the template to one of the pages. I've attempted to adapt the method shown at filter reference <a href="https://codex.wordpress.org/Plugin_API/Filter_Reference/template_include" rel="nofollow noreferrer"><code>template_include</code>...
[ { "answer_id": 266581, "author": "Vinod Dalvi", "author_id": 14347, "author_profile": "https://wordpress.stackexchange.com/users/14347", "pm_score": 2, "selected": false, "text": "<p>The post and featured image URL is saved in wp_posts table and its relation is saved in wp_postmeta table...
2017/05/11
[ "https://wordpress.stackexchange.com/questions/266613", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/116818/" ]
A plugin creates a set of pages and a template. There must be some method to assign the template to one of the pages. I've attempted to adapt the method shown at filter reference [`template_include`](https://codex.wordpress.org/Plugin_API/Filter_Reference/template_include) without success. The page slug is `member-reg...
Worked on similar problem recently. Here is the SQL query to get the post with Featured Image. ``` global $wpdb; $perpage = 10; $page = 1; // Get the current page FROM $wp_query $counter = $perpage * $page; $uploadDir = wp_upload_dir(); $uploadDir = $uploadDir['baseurl']; $sql = " SELECT post.ID, post.p...
266,650
<p>I'm new to WordPress, so I'm not really sure how it works, but I've been editing the theme by changing <code>wp-content/themes/&lt;theme_name&gt;/css/style.css</code>, then uploading this to the website via FTP. Here's the issue I'm having:</p> <p><a href="https://i.stack.imgur.com/VhqL9.png" rel="nofollow noreferr...
[ { "answer_id": 266581, "author": "Vinod Dalvi", "author_id": 14347, "author_profile": "https://wordpress.stackexchange.com/users/14347", "pm_score": 2, "selected": false, "text": "<p>The post and featured image URL is saved in wp_posts table and its relation is saved in wp_postmeta table...
2017/05/11
[ "https://wordpress.stackexchange.com/questions/266650", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119504/" ]
I'm new to WordPress, so I'm not really sure how it works, but I've been editing the theme by changing `wp-content/themes/<theme_name>/css/style.css`, then uploading this to the website via FTP. Here's the issue I'm having: [![](https://i.stack.imgur.com/VhqL9.png)](https://i.stack.imgur.com/VhqL9.png) From the Chrom...
Worked on similar problem recently. Here is the SQL query to get the post with Featured Image. ``` global $wpdb; $perpage = 10; $page = 1; // Get the current page FROM $wp_query $counter = $perpage * $page; $uploadDir = wp_upload_dir(); $uploadDir = $uploadDir['baseurl']; $sql = " SELECT post.ID, post.p...
266,661
<p>On my single.php i want to show the current post and underneath it i want to list all the posts in cat-2. In my loop i tried to query post with cat-2 but it still shows the current post.</p> <pre><code>&lt;?php global $query_string; $posts = query_posts($query_string.''); ?&gt; &lt;?php if (have_posts()): while (ha...
[ { "answer_id": 266581, "author": "Vinod Dalvi", "author_id": 14347, "author_profile": "https://wordpress.stackexchange.com/users/14347", "pm_score": 2, "selected": false, "text": "<p>The post and featured image URL is saved in wp_posts table and its relation is saved in wp_postmeta table...
2017/05/12
[ "https://wordpress.stackexchange.com/questions/266661", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/78173/" ]
On my single.php i want to show the current post and underneath it i want to list all the posts in cat-2. In my loop i tried to query post with cat-2 but it still shows the current post. ``` <?php global $query_string; $posts = query_posts($query_string.''); ?> <?php if (have_posts()): while (have_posts()) : the_post(...
Worked on similar problem recently. Here is the SQL query to get the post with Featured Image. ``` global $wpdb; $perpage = 10; $page = 1; // Get the current page FROM $wp_query $counter = $perpage * $page; $uploadDir = wp_upload_dir(); $uploadDir = $uploadDir['baseurl']; $sql = " SELECT post.ID, post.p...
266,684
<p>My post title appears twice on the browser title bar. Please see this as an example: <a href="https://www.notionbug.com/newly-found-planet-just-right-life/" rel="nofollow noreferrer">https://www.notionbug.com/newly-found-planet-just-right-life/</a></p> <p>I've tried deacivating plugins but didn't worked. I've also ...
[ { "answer_id": 266581, "author": "Vinod Dalvi", "author_id": 14347, "author_profile": "https://wordpress.stackexchange.com/users/14347", "pm_score": 2, "selected": false, "text": "<p>The post and featured image URL is saved in wp_posts table and its relation is saved in wp_postmeta table...
2017/05/12
[ "https://wordpress.stackexchange.com/questions/266684", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112647/" ]
My post title appears twice on the browser title bar. Please see this as an example: <https://www.notionbug.com/newly-found-planet-just-right-life/> I've tried deacivating plugins but didn't worked. I've also tried clearing the cache, still no success.
Worked on similar problem recently. Here is the SQL query to get the post with Featured Image. ``` global $wpdb; $perpage = 10; $page = 1; // Get the current page FROM $wp_query $counter = $perpage * $page; $uploadDir = wp_upload_dir(); $uploadDir = $uploadDir['baseurl']; $sql = " SELECT post.ID, post.p...
266,699
<p>It's possible change the destination of the normal author link to a post page or other link inside the website?</p> <p>I have found this answer but needed do buy php code. Is possible found easier way, form the users page in the back-end? </p> <pre><code>function wpd_author_link( $link, $author_id, $author_nicenam...
[ { "answer_id": 266706, "author": "hwl", "author_id": 118366, "author_profile": "https://wordpress.stackexchange.com/users/118366", "pm_score": 2, "selected": false, "text": "<p>To only edit the link associated with authors, in the functions.php of your theme: </p>\n\n<pre><code>add_filte...
2017/05/12
[ "https://wordpress.stackexchange.com/questions/266699", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104744/" ]
It's possible change the destination of the normal author link to a post page or other link inside the website? I have found this answer but needed do buy php code. Is possible found easier way, form the users page in the back-end? ``` function wpd_author_link( $link, $author_id, $author_nicename ){ return 'http...
To only edit the link associated with authors, in the functions.php of your theme: ``` add_filter( 'author_link', 'new_author_link', 10, 1 ); function new_author_link( $link ) { $link = 'http://newlink.com/'; //set this however you wish return $link; //after you've set $link, return it to the filter ...
266,714
<p>in my functions.php file I've added a custom action for the template_redirect hook which must force download a file stored on the server. The code of the download works fine when it is in a simple PHP file outside of Wordpress. But the feature is broken as soon as I add this code inside my template _redirect hook. C...
[ { "answer_id": 266727, "author": "Sam", "author_id": 115586, "author_profile": "https://wordpress.stackexchange.com/users/115586", "pm_score": -1, "selected": false, "text": "<p>Your not adding your redirect page</p>\n\n<pre><code> add_action( 'template_redirect', 'my_template_redirect' ...
2017/05/12
[ "https://wordpress.stackexchange.com/questions/266714", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60921/" ]
in my functions.php file I've added a custom action for the template\_redirect hook which must force download a file stored on the server. The code of the download works fine when it is in a simple PHP file outside of Wordpress. But the feature is broken as soon as I add this code inside my template \_redirect hook. Ch...
The solution is in fact very simple. Just use the action admin\_post\_(action)... ``` add_action( 'admin_post_export_page', 'export_page' ); function export_page() { // any code you want } ``` than you can make custom links admin\_url( 'admin-post.php?action=export\_page&id=' . $post->ID ); Thanks Milo for givi...
266,715
<p>Im sorry, if you show my blog at <a href="https://autodhil.com" rel="nofollow noreferrer">autodhil.com</a> that have a problem cause on the top of my blog have a wrong scrip..so that show this notification :</p> <pre><code>Deprecated mysql_escape_string(): This function is deprecated; use mysql_real_escape_string()...
[ { "answer_id": 266727, "author": "Sam", "author_id": 115586, "author_profile": "https://wordpress.stackexchange.com/users/115586", "pm_score": -1, "selected": false, "text": "<p>Your not adding your redirect page</p>\n\n<pre><code> add_action( 'template_redirect', 'my_template_redirect' ...
2017/05/12
[ "https://wordpress.stackexchange.com/questions/266715", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119558/" ]
Im sorry, if you show my blog at [autodhil.com](https://autodhil.com) that have a problem cause on the top of my blog have a wrong scrip..so that show this notification : ``` Deprecated mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in /home/autodhil/public_html/wp-content/...
The solution is in fact very simple. Just use the action admin\_post\_(action)... ``` add_action( 'admin_post_export_page', 'export_page' ); function export_page() { // any code you want } ``` than you can make custom links admin\_url( 'admin-post.php?action=export\_page&id=' . $post->ID ); Thanks Milo for givi...
266,716
<p>Using a search filter plugin. I am using to get the total number of posts that exist in the database</p> <pre><code> $wp_query-&gt;found_posts </code></pre> <p>However, when a user filters the results on the page, this number changes according to how many posts are shown on the filter. </p> <p>How could I get the...
[ { "answer_id": 266725, "author": "Sam", "author_id": 115586, "author_profile": "https://wordpress.stackexchange.com/users/115586", "pm_score": 0, "selected": false, "text": "<p>The $wp_query->$found_posts will change once you have filtered as the plugin might be changing the query so fou...
2017/05/12
[ "https://wordpress.stackexchange.com/questions/266716", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40727/" ]
Using a search filter plugin. I am using to get the total number of posts that exist in the database ``` $wp_query->found_posts ``` However, when a user filters the results on the page, this number changes according to how many posts are shown on the filter. How could I get the static total number of posts which ...
> > How could I get the static total number of posts which wouldn't change > irrespective of what the user filters? > > > You may be looking for `wp_count_posts()`: [Codex: WP COUNT POSTS](https://codex.wordpress.org/Function_Reference/wp_count_posts) Example getting number of all published posts: ``` function ...
266,741
<p>I uploaded a php file in the root directory of my Wordpress site that I need to be able to access directly through the browser. </p> <p>When I do, it looks like Wordpress takes over, triggers a 404, and shows the error page.</p> <p>It only occurs for php files that are one level down from root. I tried viewing a p...
[ { "answer_id": 266725, "author": "Sam", "author_id": 115586, "author_profile": "https://wordpress.stackexchange.com/users/115586", "pm_score": 0, "selected": false, "text": "<p>The $wp_query->$found_posts will change once you have filtered as the plugin might be changing the query so fou...
2017/05/12
[ "https://wordpress.stackexchange.com/questions/266741", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119576/" ]
I uploaded a php file in the root directory of my Wordpress site that I need to be able to access directly through the browser. When I do, it looks like Wordpress takes over, triggers a 404, and shows the error page. It only occurs for php files that are one level down from root. I tried viewing a php file in root a...
> > How could I get the static total number of posts which wouldn't change > irrespective of what the user filters? > > > You may be looking for `wp_count_posts()`: [Codex: WP COUNT POSTS](https://codex.wordpress.org/Function_Reference/wp_count_posts) Example getting number of all published posts: ``` function ...
266,752
<p>I have a situation where I need to authenticate users with three values (as opposed to a single <code>USERNAME</code> value. Let's call them <code>VALUE1</code>, <code>VALUE2</code>, <code>VALUE3</code>. They will not be asked for a specific <code>PASSWORD</code>.</p> <p>I looked into modifying the login routine suc...
[ { "answer_id": 266826, "author": "hwl", "author_id": 118366, "author_profile": "https://wordpress.stackexchange.com/users/118366", "pm_score": 1, "selected": false, "text": "<p>If you create the user by passing the values entered to a function that combines them, then you can call it fro...
2017/05/13
[ "https://wordpress.stackexchange.com/questions/266752", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11064/" ]
I have a situation where I need to authenticate users with three values (as opposed to a single `USERNAME` value. Let's call them `VALUE1`, `VALUE2`, `VALUE3`. They will not be asked for a specific `PASSWORD`. I looked into modifying the login routine such that it requests three values, and authenticates the user base...
Here is what ended up working. In case this is of use to someone wishing to do something similar. We created a custom template in the child theme. The final concatenated value is used as the USERNAME and the PASSWORD. Assuming all other necessary code for a typical custom page template is utilised, I'll just post th...
266,753
<p>hi i just modify a category link from domain.com/test/ to domain.com/demo/ all my post have now the new url domain.com/demo/post-name and now i want to redirect all 1000 links from which includes subcategoryes and post.. domain.com/test/post-name to domain.com/demo/post-name domain.com/test/post-name to domain.com/...
[ { "answer_id": 266761, "author": "Eclayaz", "author_id": 98878, "author_profile": "https://wordpress.stackexchange.com/users/98878", "pm_score": 0, "selected": false, "text": "<p>Try this plugin : <a href=\"https://urbangiraffe.com/plugins/redirection/\" rel=\"nofollow noreferrer\">redir...
2017/05/13
[ "https://wordpress.stackexchange.com/questions/266753", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92399/" ]
hi i just modify a category link from domain.com/test/ to domain.com/demo/ all my post have now the new url domain.com/demo/post-name and now i want to redirect all 1000 links from which includes subcategoryes and post.. domain.com/test/post-name to domain.com/demo/post-name domain.com/test/post-name to domain.com/dem...
**Using Apache** I'd go with an `.htaccess` rule ``` RewriteRule ^test/(.*) http://www.example.com/demo/$1 [R=301,L] ``` so `http://www.example.com/test/page` would now go to `http://www.example.com/demo/page` and the 301 redirect would make it permanent make sure you put your rewrite rule *after* these rules ```...
266,766
<p>Here I have custom post type called <code>products</code> and it's taxonomy is <code>product_categories</code> . What I need is whenever I add the post in products , I need to call function1, when I update the post then I need to call function2 . How to do this? </p> <p>I have searched on google and found this so...
[ { "answer_id": 266767, "author": "Picard", "author_id": 118566, "author_profile": "https://wordpress.stackexchange.com/users/118566", "pm_score": -1, "selected": true, "text": "<p><strong>This is the original answer but it is little faulty, look below for the updated</strong></p>\n\n<p>Y...
2017/05/13
[ "https://wordpress.stackexchange.com/questions/266766", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/117462/" ]
Here I have custom post type called `products` and it's taxonomy is `product_categories` . What I need is whenever I add the post in products , I need to call function1, when I update the post then I need to call function2 . How to do this? I have searched on google and found this solution: ``` add_action('save_post...
**This is the original answer but it is little faulty, look below for the updated** You can use following approach. The `my_action_updated_post_meta` is executed after the post insert or update is done: ``` // define the updated_post_meta callback function my_action_updated_post_meta( $array, $int, $int ) { glob...
266,783
<p>I'm using the ColorMag theme and I wanted to know how to edit the footer. What I've found is that:</p> <pre><code>&lt;?php do_action( 'colormag_footer_copyright' ); ?&gt; </code></pre> <p>Is showing the footer and I need to edit <code>customizer.php</code> for that purpose but don't know what to edit as I've seen ...
[ { "answer_id": 266784, "author": "s t", "author_id": 90682, "author_profile": "https://wordpress.stackexchange.com/users/90682", "pm_score": 0, "selected": false, "text": "<p>The action <code>colormag_footer_copyright</code> echos a copyright note. if yout want to replace it with your na...
2017/05/13
[ "https://wordpress.stackexchange.com/questions/266783", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/111131/" ]
I'm using the ColorMag theme and I wanted to know how to edit the footer. What I've found is that: ``` <?php do_action( 'colormag_footer_copyright' ); ?> ``` Is showing the footer and I need to edit `customizer.php` for that purpose but don't know what to edit as I've seen deleting a single line is resulting drastic...
At first go to theme directory find inc>functions.php then search for "colormag\_footer\_copyright" edit this code bellow as you need: ``` add_action( 'colormag_footer_copyright', 'colormag_footer_copyright', 10 ); /** * function to show the footer info, copyright information */ if ( ! function_exists( 'colormag_foo...
266,803
<p>i'm developing a theme. I read <a href="https://make.wordpress.org/themes/2015/08/25/title-tag-support-now-required/" rel="nofollow noreferrer">there</a> that themes should have the support to title tags declaring it in <code>functions.php</code>. I did so, together with removing any title in <code>head.php</code>, ...
[ { "answer_id": 266813, "author": "Porosh Ahammed", "author_id": 68186, "author_profile": "https://wordpress.stackexchange.com/users/68186", "pm_score": 0, "selected": false, "text": "<p>Which version of wordpress you are using. If its older version then you need Backwards Compatibility a...
2017/05/13
[ "https://wordpress.stackexchange.com/questions/266803", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119611/" ]
i'm developing a theme. I read [there](https://make.wordpress.org/themes/2015/08/25/title-tag-support-now-required/) that themes should have the support to title tags declaring it in `functions.php`. I did so, together with removing any title in `head.php`, but my index has no title. My functions.php has this: ``` ad...
I did a typo in funcions.php, typing `title_tag` instead of `title-tag`. ``` add_theme_support( 'title-tag' ); ```
266,808
<p>I have overridden woocommerce <em>customer-completed-order.php</em></p> <pre><code>&lt;?php if ( ! defined( 'ABSPATH' ) ) { exit; } do_action( 'woocommerce_email_header', $email_heading, $email ); ?&gt; &lt;p&gt;&lt;?php printf( __( "Your recent order has been completed.&lt;br&gt; ,'woocommerce' ) ); ?&gt;&...
[ { "answer_id": 266815, "author": "hwl", "author_id": 118366, "author_profile": "https://wordpress.stackexchange.com/users/118366", "pm_score": 1, "selected": false, "text": "<p><code>wp_get_attachement_image</code> wants the second argument to be an array of width, height </p>\n\n<p>like...
2017/05/13
[ "https://wordpress.stackexchange.com/questions/266808", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105581/" ]
I have overridden woocommerce *customer-completed-order.php* ``` <?php if ( ! defined( 'ABSPATH' ) ) { exit; } do_action( 'woocommerce_email_header', $email_heading, $email ); ?> <p><?php printf( __( "Your recent order has been completed.<br> ,'woocommerce' ) ); ?></p> ``` How to add image to the end of the ...
This solution works. ``` <?php if ( ! defined( 'ABSPATH' ) ) { exit; } foreach ($order->get_items() as $item_id => $item) { $product_name = $item['name']; // product name } /** * @hooked WC_Emails::email_header() Output the email header * */ do_action( 'woocommerce_email_header', $email_heading, $email )...
266,812
<p>How to disable register and reset the password from WordPress admin panel?</p> <p>Please I want to do this by codes without using plugins.</p>
[ { "answer_id": 266814, "author": "Porosh Ahammed", "author_id": 68186, "author_profile": "https://wordpress.stackexchange.com/users/68186", "pm_score": 0, "selected": false, "text": "<p>put the code bellow into functions.php : </p>\n\n<pre><code>class Password_Reset_Removed\n{\n\n funct...
2017/05/13
[ "https://wordpress.stackexchange.com/questions/266812", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/117356/" ]
How to disable register and reset the password from WordPress admin panel? Please I want to do this by codes without using plugins.
put the code bellow into functions.php : ``` class Password_Reset_Removed { function __construct() { add_filter( 'show_password_fields', array( $this, 'disable' ) ); add_filter( 'allow_password_reset', array( $this, 'disable' ) ); add_filter( 'gettext', array( $this, 'remove' ) ); } ...
266,841
<p>I'm getting many warnings like:</p> <pre><code> Mixed Content: The page at 'https://www.example.in/' was loaded over HTTPS, but requested an insecure image 'http://www.example.in/wp-content/uploads/2014/12/logo_250.png'. This content should also be served over HTTPS. </code></pre> <p>After following <a href="https...
[ { "answer_id": 266842, "author": "Porosh Ahammed", "author_id": 68186, "author_profile": "https://wordpress.stackexchange.com/users/68186", "pm_score": 0, "selected": false, "text": "<p>You can try this: </p>\n\n<pre><code> UPDATE `wp_options` SET `option_value` = \"https://www.yoursite....
2017/05/14
[ "https://wordpress.stackexchange.com/questions/266841", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119632/" ]
I'm getting many warnings like: ``` Mixed Content: The page at 'https://www.example.in/' was loaded over HTTPS, but requested an insecure image 'http://www.example.in/wp-content/uploads/2014/12/logo_250.png'. This content should also be served over HTTPS. ``` After following [SSL breaks customizer: page isn't retur...
Yeah you need to update more than just the `siteurl` values if you wish that every reference (post and attachment included) are updated properly. And you can't update that with simple SQL queries because you are going to break the serialization of arrays. The best thing you can do is use [Search Replace DB](https://g...
266,853
<p>Let's say I have two customizer controls "setting_category" and "setting_font", I'm trying to change the choices of "setting_font" upon changing the value of "setting_category". Here's what I'm doing:</p> <pre><code>( function( $ ) { var api = wp.customize; api( 'setting_category', function( value ) { ...
[ { "answer_id": 266908, "author": "Weston Ruter", "author_id": 8521, "author_profile": "https://wordpress.stackexchange.com/users/8521", "pm_score": 1, "selected": false, "text": "<p>You're close. You just need to replace <code>changeTheChoices()</code> with <code>set()</code> as this is ...
2017/05/14
[ "https://wordpress.stackexchange.com/questions/266853", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73330/" ]
Let's say I have two customizer controls "setting\_category" and "setting\_font", I'm trying to change the choices of "setting\_font" upon changing the value of "setting\_category". Here's what I'm doing: ``` ( function( $ ) { var api = wp.customize; api( 'setting_category', function( value ) { value....
Here's the solution that I found, it may be useful for some instance: ``` parent.wp.customize.control( 'setting_category', function( control ) { control.setting.bind( function( to ) { var selectElem = parent.wp.customize.control( 'setting_font' ).container.find( 'select' ); selectElem.empty(); ...
266,868
<p>So,</p> <p>I have a product post type with custom meta boxes. One of the meta box is for additional details. I show the custom post type inside other posts using a shortcode.</p> <p>I can show the additional details on the frontend. When the details is kind of long I want to add a show more link which will show th...
[ { "answer_id": 266872, "author": "Porosh Ahammed", "author_id": 68186, "author_profile": "https://wordpress.stackexchange.com/users/68186", "pm_score": 0, "selected": false, "text": "<p>you can try this for you meta box data: </p>\n\n<p>Query your meta data with this:</p>\n\n<pre><code>&...
2017/05/14
[ "https://wordpress.stackexchange.com/questions/266868", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/95244/" ]
So, I have a product post type with custom meta boxes. One of the meta box is for additional details. I show the custom post type inside other posts using a shortcode. I can show the additional details on the frontend. When the details is kind of long I want to add a show more link which will show the rest of the det...
What you're describing, and the example you linked, is using javascript to toggle the display style attribute of a container div. The example you linked is only using it when additional details are available, and they have placed them within a separate div to the description text, etc. The functionality works as fol...
266,890
<p>I'm trying to figure out how I should call a REST API custom endpoint from the JS code of a plugin. Here is the PHP code of a sample plugin I've just written to show my issue. The filename is <code>rest-api-sample.php</code>:</p> <pre><code>&lt;?php /** * @link https://www.virtualbit.it * @since ...
[ { "answer_id": 266891, "author": "hwl", "author_id": 118366, "author_profile": "https://wordpress.stackexchange.com/users/118366", "pm_score": 2, "selected": false, "text": "<h2>previous answer:</h2>\n\n<p>It appears your JS isn't loaded. You have registered the script, but haven't enque...
2017/05/14
[ "https://wordpress.stackexchange.com/questions/266890", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84622/" ]
I'm trying to figure out how I should call a REST API custom endpoint from the JS code of a plugin. Here is the PHP code of a sample plugin I've just written to show my issue. The filename is `rest-api-sample.php`: ``` <?php /** * @link https://www.virtualbit.it * @since 1.0.0 * @package ...
It looks like you are trying to send a POST request to the /istermactive endpoint, is that correct? (I think you may want to remove the trailing slash from the endpoint?) I'm not really sure the wp-api client is the right tool for a standard ajax POST, you may want to use jQuery.ajax or use WordPress's helper [wp-ajax...
266,896
<p>I'm trying to get the input value of a shortcode inside a function that is used by a filter, but there seems to be no success. Here is what i did:</p> <pre><code>function my_shortcode_function($atts){ $value = $atts['id']; function filter_value(){ echo $value; } add_filter('posts_where','fil...
[ { "answer_id": 266901, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 2, "selected": false, "text": "<p>You can use the <code>use</code> keyword of <strong>PHP</strong>. So with the help of this <code>use</code...
2017/05/15
[ "https://wordpress.stackexchange.com/questions/266896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94498/" ]
I'm trying to get the input value of a shortcode inside a function that is used by a filter, but there seems to be no success. Here is what i did: ``` function my_shortcode_function($atts){ $value = $atts['id']; function filter_value(){ echo $value; } add_filter('posts_where','filter_value'); }...
Using a global variable will work. Here's a demonstration: ``` function wpse_shortcode_function( $atts ){ // User provided values are stored in $atts. // Default values are passed to shortcode_atts() below. // Merged values are stored in the $a array. $a = shortcode_atts( [ 'id' => fa...
266,929
<p>I would like two sites to have exactly the same posts and pages. The second website would pull all the content from the first (images, posts, pages, etc). I tried to do it with <a href="https://wordpress.org/plugins/threewp-broadcast/" rel="nofollow noreferrer">Broadcast</a> but it requires a multisite installation ...
[ { "answer_id": 266901, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 2, "selected": false, "text": "<p>You can use the <code>use</code> keyword of <strong>PHP</strong>. So with the help of this <code>use</code...
2017/05/15
[ "https://wordpress.stackexchange.com/questions/266929", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/111810/" ]
I would like two sites to have exactly the same posts and pages. The second website would pull all the content from the first (images, posts, pages, etc). I tried to do it with [Broadcast](https://wordpress.org/plugins/threewp-broadcast/) but it requires a multisite installation if I understood correctly. Is there a ...
Using a global variable will work. Here's a demonstration: ``` function wpse_shortcode_function( $atts ){ // User provided values are stored in $atts. // Default values are passed to shortcode_atts() below. // Merged values are stored in the $a array. $a = shortcode_atts( [ 'id' => fa...
267,002
<p>I have an external website that needs to load the header and footer from another site in Wordpress.</p> <p>I've managed to have this done with the following code:</p> <pre><code>&lt;?php require_once("wp-blog-header.php"); /* setup the wordpress environment */ require_once(dirname(__FILE__) . "/includes/head....
[ { "answer_id": 267003, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 0, "selected": false, "text": "<p>There are probably many ways in which this kind of code may fail, as wordpress will most likely assume it...
2017/05/16
[ "https://wordpress.stackexchange.com/questions/267002", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119747/" ]
I have an external website that needs to load the header and footer from another site in Wordpress. I've managed to have this done with the following code: ``` <?php require_once("wp-blog-header.php"); /* setup the wordpress environment */ require_once(dirname(__FILE__) . "/includes/head.php"); ?> ``` This co...
For what it's worth, I found a solution to my problem and posting it here for other lost souls :) ``` <?php require_once("wp-blog-header.php"); /* setup the wordpress environment */ // This is to fool the system // In order for wp_footer() to execute, we need to run wp_head() but since we don't want the output of th...
267,060
<p>I want to get all posts that have a particular term of taxonomy A <em>and</em> a particular term of taxonomy B. </p> <p>Here is the query I'm running: </p> <pre><code> SELECT wp_posts.ID, wp_posts.post_title FROM wp_posts INNER JOIN wp_term_relationships ON wp_posts.ID = wp_term_relationsh...
[ { "answer_id": 267076, "author": "Anthony", "author_id": 27967, "author_profile": "https://wordpress.stackexchange.com/users/27967", "pm_score": 1, "selected": false, "text": "<p>As @Mark Kaplun mentioned, the WP API can reveal the the queries performed </p>\n\n<p>Below is a simple quer...
2017/05/16
[ "https://wordpress.stackexchange.com/questions/267060", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27967/" ]
I want to get all posts that have a particular term of taxonomy A *and* a particular term of taxonomy B. Here is the query I'm running: ``` SELECT wp_posts.ID, wp_posts.post_title FROM wp_posts INNER JOIN wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id INNER...
As @Mark Kaplun mentioned, the WP API can reveal the the queries performed Below is a simple query using the API in a template to see what's going on: ``` <?php /* * Template Name: Troubleshooting */ $args = array( 'post_type' => 'post', 'tax_query' => array( 'relation' => 'AND', array( ...
267,091
<p>According to the documentation (<a href="https://codex.wordpress.org/Child_Themes" rel="noreferrer">https://codex.wordpress.org/Child_Themes</a> and <a href="https://developer.wordpress.org/reference/functions/get_template_directory_uri/" rel="noreferrer">https://developer.wordpress.org/reference/functions/get_templ...
[ { "answer_id": 267093, "author": "Celso Bessa", "author_id": 22694, "author_profile": "https://wordpress.stackexchange.com/users/22694", "pm_score": 3, "selected": false, "text": "<p>What you need is <a href=\"https://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri\" ...
2017/05/16
[ "https://wordpress.stackexchange.com/questions/267091", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119813/" ]
According to the documentation (<https://codex.wordpress.org/Child_Themes> and <https://developer.wordpress.org/reference/functions/get_template_directory_uri/>), it's my understanding that `get_template_directory_uri()` will return the URL of the parent theme's directory if used within a child theme. But that is not h...
**CAUSE** OK, after digging into the WordPress code and the database, the problem was ``` get_option('template') ``` which is called by ``` wp-includes/theme.php : get_template() ``` was returning the child theme, rather than the parent theme, but only for a specific site within my multi-site. And looking in t...
267,095
<p>I'd like to replace the existing search function with an external query (from Solr) but I'm having trouble showing the results in the <code>search.php</code> page. This is the code I have in <code>functions.php</code>:</p> <pre><code>add_action('pre_get_posts', 'my_search_query'); function my_search_query($query) ...
[ { "answer_id": 267100, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p>You can't return a query object from a <code>pre_get_posts</code> action. In fact, it shouldn't return anything, t...
2017/05/16
[ "https://wordpress.stackexchange.com/questions/267095", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/90416/" ]
I'd like to replace the existing search function with an external query (from Solr) but I'm having trouble showing the results in the `search.php` page. This is the code I have in `functions.php`: ``` add_action('pre_get_posts', 'my_search_query'); function my_search_query($query) { if($query->is_search() && $que...
You can't return a query object from a `pre_get_posts` action. In fact, it shouldn't return anything, the query object is passed by reference. Your second attempt is close, you can unset the `s` query var so WordPress doesn't try to search on that term. Of course, now `s` has no value, so any functions that try to out...
267,124
<p>Been stuck on this for a while now -- This function stopped working on a site I maintain recently, and I'm not sure exactly why. It is failing at the first media_handle_upload function and gives me this error:</p> <pre><code>Array([error] =&gt; Specified file failed upload test. </code></pre> <p>Tried using this c...
[ { "answer_id": 267121, "author": "David Klhufek", "author_id": 113922, "author_profile": "https://wordpress.stackexchange.com/users/113922", "pm_score": 0, "selected": false, "text": "<p>There is more ways to do it, like cpanel or ftp access, check out codex page <a href=\"https://codex....
2017/05/17
[ "https://wordpress.stackexchange.com/questions/267124", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/113177/" ]
Been stuck on this for a while now -- This function stopped working on a site I maintain recently, and I'm not sure exactly why. It is failing at the first media\_handle\_upload function and gives me this error: ``` Array([error] => Specified file failed upload test. ``` Tried using this code instead of media\_handl...
You can install the new theme and preview how it would look before changing it. See <https://en.support.wordpress.com/themes/#preview-themes> for more info. Once you have tested that it works, you can then activate the new theme. I would keep the old theme for a few weeks until you're confident that there is nothing e...
267,131
<p>I know how to filter the output of the function <code>the_permalink</code> - it is like this:</p> <pre><code>add_filter('the_permalink', 'my_the_permalink'); function my_the_permalink($url) { return 'http://mysite/my-link/'; } </code></pre> <p>And it works when I use it like: <code>&lt;?PHP the_permalink($id);...
[ { "answer_id": 267132, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 5, "selected": true, "text": "<p>Note that <code>post_link</code> filter is only for the <code>post</code> post type.</p>\n<p>For other <em>pos...
2017/05/17
[ "https://wordpress.stackexchange.com/questions/267131", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118566/" ]
I know how to filter the output of the function `the_permalink` - it is like this: ``` add_filter('the_permalink', 'my_the_permalink'); function my_the_permalink($url) { return 'http://mysite/my-link/'; } ``` And it works when I use it like: `<?PHP the_permalink($id); ?>`, but I wanted to change the link returne...
Note that `post_link` filter is only for the `post` post type. For other *post types* these filters are available: * [`post_type_link`](https://developer.wordpress.org/reference/hooks/post_type_link/) for *custom post types* * [`page_link`](https://developer.wordpress.org/reference/hooks/page_link/) for *page* * [`at...
267,134
<p>I am very new to website building, and I am currently trying to edit a theme (Change colors of objects etc).</p> <p>I have created a child theme based on the Alpha Store and created style.css and functions.php as instructed on the alpha store child theme set up.</p> <p>Style.css as follows</p> <pre><code>/* Them...
[ { "answer_id": 267132, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 5, "selected": true, "text": "<p>Note that <code>post_link</code> filter is only for the <code>post</code> post type.</p>\n<p>For other <em>pos...
2017/05/17
[ "https://wordpress.stackexchange.com/questions/267134", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119846/" ]
I am very new to website building, and I am currently trying to edit a theme (Change colors of objects etc). I have created a child theme based on the Alpha Store and created style.css and functions.php as instructed on the alpha store child theme set up. Style.css as follows ``` /* Theme Name: Alpha Store child T...
Note that `post_link` filter is only for the `post` post type. For other *post types* these filters are available: * [`post_type_link`](https://developer.wordpress.org/reference/hooks/post_type_link/) for *custom post types* * [`page_link`](https://developer.wordpress.org/reference/hooks/page_link/) for *page* * [`at...
267,148
<p>I want to auto fill some details in contact 7 form , when user is logined and how to pass php value to js.</p> <p><strong>in function.php</strong> </p> <pre><code>if ( is_user_logged_in() ) { echo 'Welcome, registered user!'; $current_user = wp_get_current_user(); $custemail = $current_user-&gt;user_ema...
[ { "answer_id": 267132, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 5, "selected": true, "text": "<p>Note that <code>post_link</code> filter is only for the <code>post</code> post type.</p>\n<p>For other <em>pos...
2017/05/17
[ "https://wordpress.stackexchange.com/questions/267148", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/116990/" ]
I want to auto fill some details in contact 7 form , when user is logined and how to pass php value to js. **in function.php** ``` if ( is_user_logged_in() ) { echo 'Welcome, registered user!'; $current_user = wp_get_current_user(); $custemail = $current_user->user_email; function get_user_fild_details()...
Note that `post_link` filter is only for the `post` post type. For other *post types* these filters are available: * [`post_type_link`](https://developer.wordpress.org/reference/hooks/post_type_link/) for *custom post types* * [`page_link`](https://developer.wordpress.org/reference/hooks/page_link/) for *page* * [`at...
267,174
<p>Hello guys I'm new to Wordpress and I'm having some issues. I'm making a custom theme and I need one of my pages to be password protected. I've read Wordpress codex on the subject and all the threads I found here but none of them helped me. I've made custom template that I use for my page.</p> <p>My custom template...
[ { "answer_id": 267178, "author": "Waqas Ali Shah", "author_id": 119704, "author_profile": "https://wordpress.stackexchange.com/users/119704", "pm_score": 0, "selected": false, "text": "<p>Use get_template_part instead of get_testPage();</p>\n\n<pre><code>&lt;?php get_template_part( 'loop...
2017/05/17
[ "https://wordpress.stackexchange.com/questions/267174", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119868/" ]
Hello guys I'm new to Wordpress and I'm having some issues. I'm making a custom theme and I need one of my pages to be password protected. I've read Wordpress codex on the subject and all the threads I found here but none of them helped me. I've made custom template that I use for my page. My custom template is mostly...
Okay so I made it work with include this is my updated code: ``` <?php /* Template Name: pw-protect */ ?> <?php global $post; get_header(); if ( ! post_password_required( $post ) ) { // Your custom code should here include('indiPartnership.php'); }else{ // we will show pass...
267,190
<p>Having read 'don't use query_posts', I've also read that it's ok to use 'for displaying a list of posts or custom-post-type posts on a page (using a page template), and you want to make pagination of those posts work'.</p> <p>So, in wanting to use it for exactly that, my code is:</p> <pre><code>&lt;?php $page = (g...
[ { "answer_id": 267235, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 0, "selected": false, "text": "<p>As you should never use <code>query_posts()</code>, you can try the <code>WP_Query</code>:</p>\n\n<pre><cod...
2017/05/17
[ "https://wordpress.stackexchange.com/questions/267190", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103213/" ]
Having read 'don't use query\_posts', I've also read that it's ok to use 'for displaying a list of posts or custom-post-type posts on a page (using a page template), and you want to make pagination of those posts work'. So, in wanting to use it for exactly that, my code is: ``` <?php $page = (get_query_var('paged')) ...
Thanks to those who've suggested fixes. I couldn't get my normal pagination working with either, but did find an alternate solution which seems to work and which I'll include here as possible help to others (because I've seen various requests for similar). ``` <?php $wp_query = new WP_Query(); $wp_query->query('post_...
267,194
<p><strong>My Situation :</strong></p> <p>I have a custom post type in my theme, called <code>article</code>. </p> <p>My website has a dozen of categories, which i publish my posts in, and 1 <strong>specific</strong> category (named <code>BLOG</code>) just to publish <code>article</code> in it (has no <code>post</cod...
[ { "answer_id": 267358, "author": "Nathan Johnson", "author_id": 106269, "author_profile": "https://wordpress.stackexchange.com/users/106269", "pm_score": 3, "selected": true, "text": "<p>The reason your code isn't working is because by the time archive.php runs, the <code>pre_get_posts</...
2017/05/17
[ "https://wordpress.stackexchange.com/questions/267194", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94498/" ]
**My Situation :** I have a custom post type in my theme, called `article`. My website has a dozen of categories, which i publish my posts in, and 1 **specific** category (named `BLOG`) just to publish `article` in it (has no `post` in it, only `article`). My articles have different structure, so i can't show them ...
The reason your code isn't working is because by the time archive.php runs, the `pre_get_posts` hook has already fired. You can easily accomplish the task in your functions.php file: ``` add_action( 'pre_get_posts', 'wpse_pre_get_posts' ); function wpse_pre_get_posts( $query ) { remove_action( 'pre_get_posts', 'wps...
267,204
<p>Forgive me – my Wordpress/PHP skills are hilariously rudimentary, so I may not use the correct terminology.</p> <p>I have added a custom tab to the WooCommerce single product page and need it to display a number (sometimes single, sometimes multiple) of term meta values related to a custom taxonomy, 'book-author'. ...
[ { "answer_id": 267218, "author": "Five Carrots", "author_id": 119873, "author_profile": "https://wordpress.stackexchange.com/users/119873", "pm_score": 2, "selected": false, "text": "<p>For anyone else with this annoying problem: </p>\n\n<p>deactivated and removed plugin from server, mov...
2017/05/17
[ "https://wordpress.stackexchange.com/questions/267204", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119877/" ]
Forgive me – my Wordpress/PHP skills are hilariously rudimentary, so I may not use the correct terminology. I have added a custom tab to the WooCommerce single product page and need it to display a number (sometimes single, sometimes multiple) of term meta values related to a custom taxonomy, 'book-author'. These valu...
For anyone else with this annoying problem: deactivated and removed plugin from server, moved the plugin file to a new plugin directory folder with a different name, (same plugin name, same shortcode) activated plugin. Now new code being used. No idea why Wordpress was holding onto the old code, but now I don't car...
267,211
<p>OK. This has probably been asked quite a few times, but here it is again. Everything I find on the web is on how to create a custom template for category, which I don't want, and the rest doesn't work. I want to create a custom template for single post, to have plain and simple selection of templates available. One...
[ { "answer_id": 267218, "author": "Five Carrots", "author_id": 119873, "author_profile": "https://wordpress.stackexchange.com/users/119873", "pm_score": 2, "selected": false, "text": "<p>For anyone else with this annoying problem: </p>\n\n<p>deactivated and removed plugin from server, mov...
2017/05/17
[ "https://wordpress.stackexchange.com/questions/267211", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/80929/" ]
OK. This has probably been asked quite a few times, but here it is again. Everything I find on the web is on how to create a custom template for category, which I don't want, and the rest doesn't work. I want to create a custom template for single post, to have plain and simple selection of templates available. One of...
For anyone else with this annoying problem: deactivated and removed plugin from server, moved the plugin file to a new plugin directory folder with a different name, (same plugin name, same shortcode) activated plugin. Now new code being used. No idea why Wordpress was holding onto the old code, but now I don't car...
267,251
<p>After noodling around on the web to figure out how to add additional jquery features to a WP page, a question follows. After 'enqueue-ing' a js/jquery file in the theme's function.php file and then adding some js/jquery (see example below) directly onto a page via the edit text feature in the control panel to call t...
[ { "answer_id": 267513, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>Have you tried Ctrl-V (paste), after clicking in the edit window where you want things to be inserted?...
2017/05/17
[ "https://wordpress.stackexchange.com/questions/267251", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119905/" ]
After noodling around on the web to figure out how to add additional jquery features to a WP page, a question follows. After 'enqueue-ing' a js/jquery file in the theme's function.php file and then adding some js/jquery (see example below) directly onto a page via the edit text feature in the control panel to call the ...
Can you please try clearing out your cache and cookies using the guide below? <http://en.support.wordpress.com/browser-issues/#clear-your-cache-and-cookies> Also, please make sure your browser is updated to the most recent version: <http://browsehappy.com> Then, finally try testing on browsers like Google Chrome an...
267,261
<p>i am new in wordpress and i am sorry for my english. May be my title is wrong. sorry for that. </p> <p>My question is like that.</p> <p>I have too many custom post types. I need some pages for a specific custom post type.</p> <p>For example: I have musics, books and movies. I want to create a template for them l...
[ { "answer_id": 267264, "author": "Edu Membrillas", "author_id": 111714, "author_profile": "https://wordpress.stackexchange.com/users/111714", "pm_score": 0, "selected": false, "text": "<p>Ok, look. When you create the custom post. you must add this lines. If you see, you add .. 'supports...
2017/05/18
[ "https://wordpress.stackexchange.com/questions/267261", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119908/" ]
i am new in wordpress and i am sorry for my english. May be my title is wrong. sorry for that. My question is like that. I have too many custom post types. I need some pages for a specific custom post type. For example: I have musics, books and movies. I want to create a template for them like that; <http://exampl...
You can add a rewrite tag and rules that capture anything after the post name: ``` function wpd_add_rewrites(){ add_rewrite_tag( '%my_page%', '(.+)' ); $post_types = array( 'movie', 'book', 'album' ); foreach( $post_types as $post_type ){ add_rewrite_rule( ...
267,270
<p>I am facing problems with the sidebar widgets.I have registered sidebar and used wp default sidebars but it is neither within its container div not printing <code>before_widget</code> and <code>after_widget</code></p> <pre><code>add_action( 'widgets_init', 'my_sidebar_widget' ); function my_sidebar_widget(){ re...
[ { "answer_id": 267271, "author": "Porosh Ahammed", "author_id": 68186, "author_profile": "https://wordpress.stackexchange.com/users/68186", "pm_score": 0, "selected": false, "text": "<p>You make some mistake. Use this:</p>\n\n<pre><code>add_action( 'widgets_init', 'my_sidebar_widget' );\...
2017/05/18
[ "https://wordpress.stackexchange.com/questions/267270", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/108233/" ]
I am facing problems with the sidebar widgets.I have registered sidebar and used wp default sidebars but it is neither within its container div not printing `before_widget` and `after_widget` ``` add_action( 'widgets_init', 'my_sidebar_widget' ); function my_sidebar_widget(){ register_sidebar( array( 'name'...
first add this code to functions.php ``` register_sidebar(array( 'name' => __('Top Footer', 'educate'), 'id' => 'top-footer', 'description' => __('Top Full width footer.', 'educate'), 'before_widget' => '<div class="footer-widget %2$s" id="%1$s" >', 'after_widget' => '</div>', ...
267,276
<p>I've a custom <code>WP_Query</code> something like this:</p> <pre><code>$query_args = array( 'post_type' =&gt; 'post', 'cat' =&gt; 12, 'posts_per_page' =&gt; 5 ); $custom_query = new WP_Query($query_args); </code></pre> <p>Now, I need to split the results of this query in 3 se...
[ { "answer_id": 267277, "author": "Porosh Ahammed", "author_id": 68186, "author_profile": "https://wordpress.stackexchange.com/users/68186", "pm_score": -1, "selected": false, "text": "<p>I think you can't do this with single query. You have to use multiple query with post number.</p>\n\n...
2017/05/18
[ "https://wordpress.stackexchange.com/questions/267276", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45269/" ]
I've a custom `WP_Query` something like this: ``` $query_args = array( 'post_type' => 'post', 'cat' => 12, 'posts_per_page' => 5 ); $custom_query = new WP_Query($query_args); ``` Now, I need to split the results of this query in 3 sets, first set will have the first post only, t...
I think the best way to approach this might be to run your WP\_Query just one time, but then access the stored query results three times to output each wanted set of data. This will save you from using multiple DB queries, and by using three separate loops, you can still add a parent div to each set of posts as desired...
267,280
<p>I have widgets on my home page, I also have a landing page with subscribe form. when a user does subscribe, he redirects to home page. The home page is also available via the link to view.</p> <p>The homepage has complete setup having different widgets and text.</p> <p>Now I want when user fill subscribes form and...
[ { "answer_id": 267291, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>There is a function called <a href=\"https://codex.wordpress.org/Function_Reference/wp_get_referer\" rel=\"nofol...
2017/05/18
[ "https://wordpress.stackexchange.com/questions/267280", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119915/" ]
I have widgets on my home page, I also have a landing page with subscribe form. when a user does subscribe, he redirects to home page. The home page is also available via the link to view. The homepage has complete setup having different widgets and text. Now I want when user fill subscribes form and he redirected to...
There is a function called [`wp_get_referrer`](https://codex.wordpress.org/Function_Reference/wp_get_referer) that you can use to see from which page a user is reaching the home page. Usage: ``` if (is_home() && (wp_get_referrer() == 'url/subscription/page')) { ... show page without widget } else { ... show page...
267,292
<p>I have an idea. And I hope it is already implemented somehow. </p> <p>Here is an example of CSS files in the head of a page</p> <pre><code>&lt;link rel='stylesheet' id='validate-engine-css-css' href='https://example.net/wp-content/plugins/wysija-newsletters/css/A.validationEngine.jquery.css,qver=2.7.10.pagespeed.c...
[ { "answer_id": 267291, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>There is a function called <a href=\"https://codex.wordpress.org/Function_Reference/wp_get_referer\" rel=\"nofol...
2017/05/18
[ "https://wordpress.stackexchange.com/questions/267292", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93387/" ]
I have an idea. And I hope it is already implemented somehow. Here is an example of CSS files in the head of a page ``` <link rel='stylesheet' id='validate-engine-css-css' href='https://example.net/wp-content/plugins/wysija-newsletters/css/A.validationEngine.jquery.css,qver=2.7.10.pagespeed.cf.jcn-RfgU3K.css' type='...
There is a function called [`wp_get_referrer`](https://codex.wordpress.org/Function_Reference/wp_get_referer) that you can use to see from which page a user is reaching the home page. Usage: ``` if (is_home() && (wp_get_referrer() == 'url/subscription/page')) { ... show page without widget } else { ... show page...
267,305
<p>Though I have logged in, I cannot create a post on frontend. WordPress always return <strong>401 Unauthorized</strong> response. I have dumped <code>$_COOKIE</code> to make sure logged-in cookie was set and got something like this:</p> <pre><code>array(1) { ["wordpress_logged_in_48f880f2beac6f39fb9ea8d9367e86d6"]...
[ { "answer_id": 267437, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<p>It looks like you're missing the <strong>nonce</strong> part, as explained in the <a href=\"https://developer....
2017/05/18
[ "https://wordpress.stackexchange.com/questions/267305", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92212/" ]
Though I have logged in, I cannot create a post on frontend. WordPress always return **401 Unauthorized** response. I have dumped `$_COOKIE` to make sure logged-in cookie was set and got something like this: ``` array(1) { ["wordpress_logged_in_48f880f2beac6f39fb9ea8d9367e86d6"]=> string(125) "admin|1495526369|PwQ...
It looks like you're missing the **nonce** part, as explained in the [Authentication](https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/) chapter, in the *REST API Handbook*: > > Cookie authentication is the basic authentication method included with > WordPress. When you log in to your dashb...
267,319
<p>How create post using <em>WP-CLI</em> at time of network site create. I am creating network sites using <em>WP-CLI</em>.<br> I have tried:</p> <pre><code>wp post create --post_type=page --post_title='ABC' --post_status=publish --network </code></pre> <p>But it creates post on main site. But, I want to create that ...
[ { "answer_id": 267325, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>You can try the <code>--url</code> argument to target a given <strong>site</strong> in your network:</p>\n\n<p...
2017/05/18
[ "https://wordpress.stackexchange.com/questions/267319", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119935/" ]
How create post using *WP-CLI* at time of network site create. I am creating network sites using *WP-CLI*. I have tried: ``` wp post create --post_type=page --post_title='ABC' --post_status=publish --network ``` But it creates post on main site. But, I want to create that post on network site which was created th...
You can try the `--url` argument to target a given **site** in your network: ``` wp post create \ --post_type=page \ --post_title='ABC' \ --post_status=publish \ --url=http://example.tld/somesite/ ``` where you can view available site urls with ``` wp site list ```
267,330
<p>I am trying to add a container div to the WordPress gallery, I have this so far....</p> <pre><code>function gallery_custom( $output ) { $return = '&lt;div class="mydiv"&gt;'; $return = $output; $return = '&lt;/div&gt;'; return $return; } add_filter( 'post_gallery', 'gallery_custom', 10, 3 ); </co...
[ { "answer_id": 267346, "author": "Vinod Dalvi", "author_id": 14347, "author_profile": "https://wordpress.stackexchange.com/users/14347", "pm_score": 1, "selected": false, "text": "<p>To achieve this you have to develop more custom code like following.</p>\n\n<pre><code>function gallery_c...
2017/05/18
[ "https://wordpress.stackexchange.com/questions/267330", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10247/" ]
I am trying to add a container div to the WordPress gallery, I have this so far.... ``` function gallery_custom( $output ) { $return = '<div class="mydiv">'; $return = $output; $return = '</div>'; return $return; } add_filter( 'post_gallery', 'gallery_custom', 10, 3 ); ``` This is not returning an...
Adding an HTML wrapper to the gallery can be done using the `post_gallery` filter. Here's a fully commented example. ``` add_filter( 'post_gallery', 'gallery_custom', 10, 3 ); /** * Filters the default gallery shortcode output. * * If the filtered output isn't empty, it will be used instead of generating * the def...
267,337
<p>I would like to show latest posts with its thumbnails only in slider. But my first figure element has a class. Can I apply a class to first thumbnail as it is in html structure below? And then Can I auto increment other images, when a user publish a new post with thumbnail?</p> <pre><code> &lt;div class="diy-sli...
[ { "answer_id": 267346, "author": "Vinod Dalvi", "author_id": 14347, "author_profile": "https://wordpress.stackexchange.com/users/14347", "pm_score": 1, "selected": false, "text": "<p>To achieve this you have to develop more custom code like following.</p>\n\n<pre><code>function gallery_c...
2017/05/18
[ "https://wordpress.stackexchange.com/questions/267337", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/113723/" ]
I would like to show latest posts with its thumbnails only in slider. But my first figure element has a class. Can I apply a class to first thumbnail as it is in html structure below? And then Can I auto increment other images, when a user publish a new post with thumbnail? ``` <div class="diy-slideshow"> ...
Adding an HTML wrapper to the gallery can be done using the `post_gallery` filter. Here's a fully commented example. ``` add_filter( 'post_gallery', 'gallery_custom', 10, 3 ); /** * Filters the default gallery shortcode output. * * If the filtered output isn't empty, it will be used instead of generating * the def...
267,339
<p>I have a plugin page, which doesn't have <code>header.php</code> or <code>footer.php</code>. How can I include Wordpress jQuery on this page so I can use syntax like below ?</p> <pre><code> jQuery(document).ready(function() { alert('hello'); }); </code></pre> <p>At the moment it says:</p> <pre><code>Un...
[ { "answer_id": 267340, "author": "Aniruddha Gawade", "author_id": 101818, "author_profile": "https://wordpress.stackexchange.com/users/101818", "pm_score": 2, "selected": false, "text": "<p>Use <code>wp_head();</code> and <code>wp_footer();</code> if you're putting all html in just one f...
2017/05/18
[ "https://wordpress.stackexchange.com/questions/267339", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112778/" ]
I have a plugin page, which doesn't have `header.php` or `footer.php`. How can I include Wordpress jQuery on this page so I can use syntax like below ? ``` jQuery(document).ready(function() { alert('hello'); }); ``` At the moment it says: ``` Uncaught ReferenceError: jQuery is not defined ```
Though uncommon, you can use `wp_print_scripts( ['jquery'] )` for explicit output. Note that you might hit issues with hooks firing in unexpected ways and such. *Generally* all WP pages on front end should just implement header/footer properly.
267,357
<p>So this is my first run at a plugin. I built a "Toolbox" plugin for myself that I can add things to as I feel needed. Right now the plugin only has one feature and that is to create a new role named "Client". What it does is makes a hybrid of the Administrator and Editor role. It is so the client cant update somethi...
[ { "answer_id": 267359, "author": "Muhammad Abdullah", "author_id": 117908, "author_profile": "https://wordpress.stackexchange.com/users/117908", "pm_score": 0, "selected": false, "text": "<p>You can use this plugin : </p>\n\n<p><a href=\"https://wordpress.org/plugins/advanced-access-mana...
2017/05/18
[ "https://wordpress.stackexchange.com/questions/267357", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119962/" ]
So this is my first run at a plugin. I built a "Toolbox" plugin for myself that I can add things to as I feel needed. Right now the plugin only has one feature and that is to create a new role named "Client". What it does is makes a hybrid of the Administrator and Editor role. It is so the client cant update something ...
try using ``` current_user_can( $capability , $object_id ); ``` Reference: <https://codex.wordpress.org/Function_Reference/current_user_can#Usage>
267,361
<p>I have read other posts on this forum and none of which I read are solving my problem.</p> <p>Whenever I do: <a href="http://www.example.com/wp-json/wp/v2/posts?filter[posts_per_page]=-1" rel="nofollow noreferrer">http://www.example.com/wp-json/wp/v2/posts?filter[posts_per_page]=-1</a></p> <p>Or even: <a href="htt...
[ { "answer_id": 267359, "author": "Muhammad Abdullah", "author_id": 117908, "author_profile": "https://wordpress.stackexchange.com/users/117908", "pm_score": 0, "selected": false, "text": "<p>You can use this plugin : </p>\n\n<p><a href=\"https://wordpress.org/plugins/advanced-access-mana...
2017/05/18
[ "https://wordpress.stackexchange.com/questions/267361", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83781/" ]
I have read other posts on this forum and none of which I read are solving my problem. Whenever I do: <http://www.example.com/wp-json/wp/v2/posts?filter[posts_per_page]=-1> Or even: <http://www.example.com/wp-json/wp/v2/posts?filter[posts_per_page]=99> It still returns 10 posts. The same is happening when I try to g...
try using ``` current_user_can( $capability , $object_id ); ``` Reference: <https://codex.wordpress.org/Function_Reference/current_user_can#Usage>
267,381
<p>first of all im new to Wordpress and PHP and i apologize if this is a basic question. I have a Wordpress installation and every post is marked with Tags and these Tags contain a link with: </p> <pre><code>href=domain.com/index.php/tag/TAGNAME </code></pre> <p>but i want the Link to be:</p> <pre><code>href=domain....
[ { "answer_id": 267397, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 0, "selected": false, "text": "<p>You can rewrite the URLs in .htaccess:</p>\n\n<pre><code>RewriteEngine On\nRewriteRule ^tag/(.*)$ http://...
2017/05/18
[ "https://wordpress.stackexchange.com/questions/267381", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119972/" ]
first of all im new to Wordpress and PHP and i apologize if this is a basic question. I have a Wordpress installation and every post is marked with Tags and these Tags contain a link with: ``` href=domain.com/index.php/tag/TAGNAME ``` but i want the Link to be: ``` href=domain.com/index.php/search/TAGNAME ``` As...
You just need to change your **Tag base** in permalinks setting on your website. [![enter image description here](https://i.stack.imgur.com/eMCjv.png)](https://i.stack.imgur.com/eMCjv.png) PS : By default /search/ is a slug for a search result page. To avoid conflict with search result page you may also need to rewr...
267,411
<p>I realise Wordpress questions are hard to answer, given the plethora of plugins and complications out there. </p> <p>We've been having some trouble on our Wordpress page where virtual pages will populate their submenu with all the pages that don't have an explicit parent(Parent: (no parent)). </p> <p>I've isolated...
[ { "answer_id": 267417, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 2, "selected": true, "text": "<p>The WordPress, just like any other CMS, relies on generating content based on the user's request and then ou...
2017/05/19
[ "https://wordpress.stackexchange.com/questions/267411", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119833/" ]
I realise Wordpress questions are hard to answer, given the plethora of plugins and complications out there. We've been having some trouble on our Wordpress page where virtual pages will populate their submenu with all the pages that don't have an explicit parent(Parent: (no parent)). I've isolated the offending co...
The WordPress, just like any other CMS, relies on generating content based on the user's request and then outputting it to the browser as an HTML page. What you asked can have a very long answer, but here is a simple explanation to what you asked. We begin with the file named `.htaccess`, which is a server file. This...
267,435
<p>I use a function to modify the 'read more' link for posts.</p> <pre><code>function modify_read_more_link() { return '&lt;p class="read-more"&gt;&lt;a href="' . get_permalink() . '"&gt;CONTINUE READING &amp;raquo&lt;/a&gt;&lt;/p&gt;'; } add_filter( 'the_content_more_link', 'modify_read_more_link' ); </code></pre> <...
[ { "answer_id": 267440, "author": "Ajay Malhotra", "author_id": 118989, "author_profile": "https://wordpress.stackexchange.com/users/118989", "pm_score": 1, "selected": false, "text": "<p>These are some tricks:</p>\n\n<pre><code> /* Modify the read more link on the_excerpt() */\n\n functi...
2017/05/19
[ "https://wordpress.stackexchange.com/questions/267435", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103213/" ]
I use a function to modify the 'read more' link for posts. ``` function modify_read_more_link() { return '<p class="read-more"><a href="' . get_permalink() . '">CONTINUE READING &raquo</a></p>'; } add_filter( 'the_content_more_link', 'modify_read_more_link' ); ``` I want to use different text for the feed, and wonde...
These are some tricks: ``` /* Modify the read more link on the_excerpt() */ function et_excerpt_length($length) { return 220; } add_filter('excerpt_length', 'et_excerpt_length'); /* Add a link to the end of our excerpt contained in a div for styling purposes and to break to a new line on the page.*/ function...
267,448
<p>I use below function (<code>Nothing here</code> is protection message):</p> <pre><code>function show_user_content($atts,$content = null){ global $post; if (current_user_can('subscriber')){ return $content; } return "Nothing here"; } add_shortcode('RESTRICTROLE','show_user_content'); </code></pre> <...
[ { "answer_id": 267440, "author": "Ajay Malhotra", "author_id": 118989, "author_profile": "https://wordpress.stackexchange.com/users/118989", "pm_score": 1, "selected": false, "text": "<p>These are some tricks:</p>\n\n<pre><code> /* Modify the read more link on the_excerpt() */\n\n functi...
2017/05/19
[ "https://wordpress.stackexchange.com/questions/267448", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114357/" ]
I use below function (`Nothing here` is protection message): ``` function show_user_content($atts,$content = null){ global $post; if (current_user_can('subscriber')){ return $content; } return "Nothing here"; } add_shortcode('RESTRICTROLE','show_user_content'); ``` Then in post content: ``` [RESTRIC...
These are some tricks: ``` /* Modify the read more link on the_excerpt() */ function et_excerpt_length($length) { return 220; } add_filter('excerpt_length', 'et_excerpt_length'); /* Add a link to the end of our excerpt contained in a div for styling purposes and to break to a new line on the page.*/ function...
267,479
<p>I define the wp_enqueue_script in the pugin definition file and I can see my script being fired when I log in as admin, but not as a normal user. Why is this happening? And how can I enable scripts for all logged-in users, and not just admin? I did this on plugin file:</p> <pre><code>function enqueue_team_managemen...
[ { "answer_id": 267486, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 1, "selected": false, "text": "<p>To output your scripts for non-logged-in users, use a conditional in conjunction with <code>wp_enqueue_scri...
2017/05/19
[ "https://wordpress.stackexchange.com/questions/267479", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75915/" ]
I define the wp\_enqueue\_script in the pugin definition file and I can see my script being fired when I log in as admin, but not as a normal user. Why is this happening? And how can I enable scripts for all logged-in users, and not just admin? I did this on plugin file: ``` function enqueue_team_management_scripts() ...
Additionally, apart from the "where" of your `wp_enqueue_script()` function (i.e. theme, plugin, etc.), the "when" is also important, in terms of WP's [Action Reference](https://codex.wordpress.org/Plugin_API/Action_Reference/) hooks, and the order in which they're fired. There are 2 distinct script-related hooks, `wp...
267,519
<p>I have the following PHP array which I encode to JSON as seen in the snippet of my code below:</p> <pre><code>$user_info = [ "user_name" =&gt; $current_user-&gt;user_login, "user_email" =&gt; $current_user-&gt;user_email, "user_id" =&gt; $current_user-&gt;ID, "user_comment" =&gt; $mess...
[ { "answer_id": 267500, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 1, "selected": false, "text": "<p>There are plugins available that will convert taxonomies - search for something like \"taxonomy converter...
2017/05/20
[ "https://wordpress.stackexchange.com/questions/267519", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120067/" ]
I have the following PHP array which I encode to JSON as seen in the snippet of my code below: ``` $user_info = [ "user_name" => $current_user->user_login, "user_email" => $current_user->user_email, "user_id" => $current_user->ID, "user_comment" => $message ]; json_encode( $user_info ); ...
You shouldn't and most likely can't achieve what you are looking for. The `tag` taxonomy term is reserved by WordPress itself, as well as a couple of other terms. Take a look into [this](https://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms) page from the codex. If you use the same slug for d...
267,533
<p>In Gravity Forms I'd like to include a small keyword checker that is checking the user's message for "spammy" words and stops sending the entry to the admin. For this a hidden field changes it's value. I have this code included in my functions.php so far</p> <pre><code>function strpos_arr($haystack, $needle) { if(!...
[ { "answer_id": 267571, "author": "Frank P. Walentynowicz", "author_id": 32851, "author_profile": "https://wordpress.stackexchange.com/users/32851", "pm_score": 1, "selected": false, "text": "<p>The problem is in function <code>strpos_arr</code>. If your bad word is in <code>$pos = 0</cod...
2017/05/20
[ "https://wordpress.stackexchange.com/questions/267533", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118725/" ]
In Gravity Forms I'd like to include a small keyword checker that is checking the user's message for "spammy" words and stops sending the entry to the admin. For this a hidden field changes it's value. I have this code included in my functions.php so far ``` function strpos_arr($haystack, $needle) { if(!is_array($need...
The problem is in function `strpos_arr`. If your bad word is in `$pos = 0` than the output will always be `false`. Replace the line: ``` if(($pos = stripos($haystack, $what))!==false) return $pos; ``` with: ``` if(($pos = stripos($haystack, $what))!==false) return true; ``` Your `keywords_check` function can be m...
267,557
<p>After moving website to my local dev machine, relative links stopped working. When i click button with relative link /login, for example, browser redirects to</p> <p><a href="https://localhost/login/" rel="nofollow noreferrer">https://localhost/login/</a></p> <p>and shows</p> <blockquote> <p>Code: Not Found</p...
[ { "answer_id": 267574, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 2, "selected": false, "text": "<p>If you are in <code>https://localhost/cc</code> and use a relative lnk with <code>href=\"/login\"</code> (rel...
2017/05/20
[ "https://wordpress.stackexchange.com/questions/267557", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105581/" ]
After moving website to my local dev machine, relative links stopped working. When i click button with relative link /login, for example, browser redirects to <https://localhost/login/> and shows > > Code: Not Found > > > The requested URL /index.php was not found on this server. > > > While it should have re...
If you are in `https://localhost/cc` and use a relative lnk with `href="/login"` (relative to current domain/site), the browser (not WordPress) will take you to `https://localhost/login`; if the link is `href="login"` (relative to current path) the browser will take you to `https://localhost/cc/login`. Relative links ...
267,592
<p>As a highly concerned hosting company owner I am using WP-CLI to update plugins, themes and wp core of my clients.</p> <p>Updating WP-Core</p> <pre><code>find /home/*/public_html -name "wp-admin" -execdir /home/wp core update --allow-root \; </code></pre> <p>Updating Plugins</p> <pre><code>find /home/*/public_ht...
[ { "answer_id": 267609, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<p>You could try to change it through the <strong>environment variable</strong>:</p>\n\n<pre><code>WP_CLI_CACHE_D...
2017/05/21
[ "https://wordpress.stackexchange.com/questions/267592", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106221/" ]
As a highly concerned hosting company owner I am using WP-CLI to update plugins, themes and wp core of my clients. Updating WP-Core ``` find /home/*/public_html -name "wp-admin" -execdir /home/wp core update --allow-root \; ``` Updating Plugins ``` find /home/*/public_html -name "wp-admin" -execdir /home/wp plugin...
You could try to change it through the **environment variable**: ``` WP_CLI_CACHE_DIR ``` as we have it included in the `WP_CLI::get_cache()` method ([src](https://github.com/wp-cli/wp-cli/blob/dd30e97d61c570c0e4a64cc11eb5a72c19a51879/php/class-wp-cli.php#L80)): ``` $dir = getenv( 'WP_CLI_CACHE_DIR' ) ? : "$home/.w...
267,600
<p>Using this query to retrieve all of my posts with a specific <code>post_type</code></p> <pre><code>SELECT * FROM wp_posts WHERE post_type = 'product'; </code></pre> <p>As described <a href="https://wordpress.stackexchange.com/questions/66080/how-to-find-out-wordpress-category-table-in-mysql">here</a> the category ...
[ { "answer_id": 267602, "author": "Cedon", "author_id": 80069, "author_profile": "https://wordpress.stackexchange.com/users/80069", "pm_score": 1, "selected": false, "text": "<p>This can be done using the <code>WP_Query</code> class. If all you're looking for is to grab all posts based on...
2017/05/21
[ "https://wordpress.stackexchange.com/questions/267600", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102212/" ]
Using this query to retrieve all of my posts with a specific `post_type` ``` SELECT * FROM wp_posts WHERE post_type = 'product'; ``` As described [here](https://wordpress.stackexchange.com/questions/66080/how-to-find-out-wordpress-category-table-in-mysql) the category is not in the `wp_posts` table but in term table...
Figured it out. @belinus is probably the solution for you if you're looking to do this within WordPress. As for just a raw SQL query you can play around with, I found this one, modified it a little bit and it returns all the products for a particular category. There are three tables required to do this `wp_posts` `wp...
267,613
<p>Note: this question also appears on <a href="https://stackoverflow.com/questions/44060613/update-permalinks-when-new-category-added-to-custom-post-type-taxonomy">https://stackoverflow.com/questions/44060613/update-permalinks-when-new-category-added-to-custom-post-type-taxonomy</a> (but is not getting much love).</p>...
[ { "answer_id": 267802, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>That's not how custom taxonomies and post types work</p>\n\n<p>This is what you do:</p>\n\n<ul>\n<li>On the ...
2017/05/22
[ "https://wordpress.stackexchange.com/questions/267613", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105819/" ]
Note: this question also appears on <https://stackoverflow.com/questions/44060613/update-permalinks-when-new-category-added-to-custom-post-type-taxonomy> (but is not getting much love). Have created a collection of Custom Post Types (CPT) for a WordPress theme I am working on (along with their own taxonomies and tags)...
That's not how custom taxonomies and post types work This is what you do: * On the `init` hook, call `register_custom_taxonomy` or `register_post_type` * If you change your calls to `register_custom_taxonomy` or `register_post_type`, or add new ones in your code, regenerate permalinks by visiting the permalinks setti...
267,629
<p>I am trying to add an external Javascript file from my plugin. My code is -</p> <pre><code>&lt;?php /****** * * Plugin Name: Image Zoom * Author: Kallol Das * Description: This plugin will zoom an image of WordPress posts. * version: 1.0 * *******/ function zoom_image_main_js_init(){ wp_enqueue_scr...
[ { "answer_id": 267626, "author": "Mehedi_Sharif", "author_id": 107089, "author_profile": "https://wordpress.stackexchange.com/users/107089", "pm_score": 0, "selected": false, "text": "<p>1- When you are in a page there is a css class called \"current-menu-item\" assigned to that menu. I ...
2017/05/22
[ "https://wordpress.stackexchange.com/questions/267629", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101459/" ]
I am trying to add an external Javascript file from my plugin. My code is - ``` <?php /****** * * Plugin Name: Image Zoom * Author: Kallol Das * Description: This plugin will zoom an image of WordPress posts. * version: 1.0 * *******/ function zoom_image_main_js_init(){ wp_enqueue_script('zoom-script'...
Typical menu structure with 'Home' item being a **Custom Link** and other menu items being pages: > > ![Typical Menu](https://fw2s.com/wp-content/uploads/2017/05/menu.png) > > > The 'Home' menu item **must not** point to a real page and should look like that: > > ![Home](https://fw2s.com/wp-content/uploads/2017...
267,637
<p>So, I tried to strip all the html tags in a string but I can't get it to work.</p> <p>This is my code snippet</p> <pre><code>$content = get_the_content(); $content = preg_replace("/&lt;embed[^&gt;]+\&gt;/...
[ { "answer_id": 267639, "author": "xvilo", "author_id": 104427, "author_profile": "https://wordpress.stackexchange.com/users/104427", "pm_score": 2, "selected": false, "text": "<p>If you want to strip all tags, you can use <a href=\"http://php.net/manual/en/function.strip-tags.php\" rel=\...
2017/05/22
[ "https://wordpress.stackexchange.com/questions/267637", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115305/" ]
So, I tried to strip all the html tags in a string but I can't get it to work. This is my code snippet ``` $content = get_the_content(); $content = preg_replace("/<embed[^>]+\>/i", "(embed) ", $content); ...
``` $content = get_the_content(); // regex (fixed) replacing '<embed>' with '(embed )' $content = preg_replace("/<embed?[^>]+>/i", "(embed) ", $content); // remove all tags $content = wp_strip_all_tags($content); echo $content; ``` **Edited according to the first comment:** What you are trying to remove are not tags...
267,664
<p>I need to be able to sum up all values of a specific custom field and then get the total count. </p> <p>For example, I have created a custom post type for reviews and each one has custom fields for 5 star rating. </p> <p>What I need is to add up all the values of the star rating and divide by total count to give m...
[ { "answer_id": 267665, "author": "TomC", "author_id": 36980, "author_profile": "https://wordpress.stackexchange.com/users/36980", "pm_score": 0, "selected": false, "text": "<p>I did something similar where I added a custom field for the weight of a product.\nHere's my code:</p>\n\n<pre><...
2017/05/22
[ "https://wordpress.stackexchange.com/questions/267664", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120179/" ]
I need to be able to sum up all values of a specific custom field and then get the total count. For example, I have created a custom post type for reviews and each one has custom fields for 5 star rating. What I need is to add up all the values of the star rating and divide by total count to give me the average.
Thanks for your help guys. They didn't quit work exactly, but I managed to get the result I needed by doing the following ``` $reviewsNum = 0; $reviewsCount = 0; $argsSchema = array( 'post_type' => 'reviews', 'posts_per_page' => -1 ); $loopSchema = new WP_Query( $argsSchema ); $count_reviews = wp_count_posts( 'revie...
267,681
<p>Who could help me with the following:</p> <p>I am moving my site to another domain AND I want to change my permalink structure. I wish to edit my .htaccess file of my OLD domain.</p> <p>So:</p> <p><a href="http://www.olddomain.com/%YEAR/%MONTH/%DATE/example-post" rel="nofollow noreferrer">http://www.olddomain.com...
[ { "answer_id": 267683, "author": "eldoleo", "author_id": 113227, "author_profile": "https://wordpress.stackexchange.com/users/113227", "pm_score": 0, "selected": false, "text": "<p>Assuming Mod_Rewrite is active, on .htaccess file you can use:</p>\n\n<p>Redirect 301 <a href=\"http://www....
2017/05/22
[ "https://wordpress.stackexchange.com/questions/267681", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120193/" ]
Who could help me with the following: I am moving my site to another domain AND I want to change my permalink structure. I wish to edit my .htaccess file of my OLD domain. So: <http://www.olddomain.com/%YEAR/%MONTH/%DATE/example-post> SHOULD BE 301 REDIRECTED TO <http://www.newdomain.com/example-post> All my ol...
on your **old domain** add this following rule at the top of .htaccess ``` RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ http://newdomain.com/$3 ``` plase let me know if its work or not.
267,686
<p>I've built and manage two primary/junior school sites in the UK. They've recently come together under a Multi Academy Trust (MAT) and consequently, they now share a fair amount of common policies and documentation.</p> <p>Currently an admin at each school is provided the latest document version (via email) to uploa...
[ { "answer_id": 267683, "author": "eldoleo", "author_id": 113227, "author_profile": "https://wordpress.stackexchange.com/users/113227", "pm_score": 0, "selected": false, "text": "<p>Assuming Mod_Rewrite is active, on .htaccess file you can use:</p>\n\n<p>Redirect 301 <a href=\"http://www....
2017/05/22
[ "https://wordpress.stackexchange.com/questions/267686", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58528/" ]
I've built and manage two primary/junior school sites in the UK. They've recently come together under a Multi Academy Trust (MAT) and consequently, they now share a fair amount of common policies and documentation. Currently an admin at each school is provided the latest document version (via email) to upload and link...
on your **old domain** add this following rule at the top of .htaccess ``` RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ http://newdomain.com/$3 ``` plase let me know if its work or not.
267,732
<p>I want to create a shortcode for one of the content form theme.</p> <p>My template's content:</p> <pre><code>&lt;section id="standing" style="background-image: url('&lt;?php echo (get_option('pixieclash-standings-background') &amp;&amp; get_option('pixieclash-standings-background') != null) ? esc_url(get_option('...
[ { "answer_id": 267736, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 1, "selected": false, "text": "<p>To create a shortcode from your functions, you need to use the following code:</p>\n\n<pre><code>function m...
2017/05/22
[ "https://wordpress.stackexchange.com/questions/267732", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120212/" ]
I want to create a shortcode for one of the content form theme. My template's content: ``` <section id="standing" style="background-image: url('<?php echo (get_option('pixieclash-standings-background') && get_option('pixieclash-standings-background') != null) ? esc_url(get_option('pixieclash-standings-background')) ...
To create a shortcode from your functions, you need to use the following code: ``` function my_shortcode_function(){ if (get_option('pixieclash-standings-background') && get_option('pixieclash-standings-background') != null) { $background = esc_url(get_option('pixieclash-standings-background')) } els...
267,764
<p>Am working in a Tamil blog site.There I want to display date in Tamil language.(ie) செவ்வாய்க்கிழமை, மே 23, 2017 .I need to display like this in wordpress site.But I dont want to change all.Only the date in tamil.</p>
[ { "answer_id": 267736, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 1, "selected": false, "text": "<p>To create a shortcode from your functions, you need to use the following code:</p>\n\n<pre><code>function m...
2017/05/23
[ "https://wordpress.stackexchange.com/questions/267764", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120242/" ]
Am working in a Tamil blog site.There I want to display date in Tamil language.(ie) செவ்வாய்க்கிழமை, மே 23, 2017 .I need to display like this in wordpress site.But I dont want to change all.Only the date in tamil.
To create a shortcode from your functions, you need to use the following code: ``` function my_shortcode_function(){ if (get_option('pixieclash-standings-background') && get_option('pixieclash-standings-background') != null) { $background = esc_url(get_option('pixieclash-standings-background')) } els...
267,781
<p>For a client I want to do the following thing with .htaccess:</p> <p>domainname.com/path must redirect to sub.domainname.com/path, but only if the first page is a deleted page / 404 page.</p> <p>So all the existing pages must stay intact, and the deleted pages must redirect to a subdomain with the same path.</p> ...
[ { "answer_id": 267785, "author": "Farhad Sakhaei", "author_id": 114465, "author_profile": "https://wordpress.stackexchange.com/users/114465", "pm_score": 0, "selected": false, "text": "<p>Use this direction: </p>\n\n<pre><code>ErrorDocument 404 http://example.com/404/\n</code></pre>\n" ...
2017/05/23
[ "https://wordpress.stackexchange.com/questions/267781", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120256/" ]
For a client I want to do the following thing with .htaccess: domainname.com/path must redirect to sub.domainname.com/path, but only if the first page is a deleted page / 404 page. So all the existing pages must stay intact, and the deleted pages must redirect to a subdomain with the same path. I used the following ...
As far I understand, .htaccess rewrite rules are executed before the request is proccesed by WordPress, or even by PHP engine, so you can not know if a URL will trigger a 404 error in .htaccess, you can not check if a given path will trigger a 404 at that level. You need to do it in WordPress itself: ``` // See https:...
267,824
<p>I tried everything and my action hook wp_enqueue_scripts doesn't work! What can stop it from working? This is my code inside the plugin. The plugin is activated:</p> <pre><code>function wpb_adding_scripts() { error_log("try 9"); } add_action ('wp_enqueue_scripts', 'wpb_adding_scripts'); </code></pre>
[ { "answer_id": 267826, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 1, "selected": false, "text": "<p>The proper way to enqueue your scripts is the following:</p>\n\n<pre><code>function my_scripts(){\n wp_e...
2017/05/23
[ "https://wordpress.stackexchange.com/questions/267824", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75915/" ]
I tried everything and my action hook wp\_enqueue\_scripts doesn't work! What can stop it from working? This is my code inside the plugin. The plugin is activated: ``` function wpb_adding_scripts() { error_log("try 9"); } add_action ('wp_enqueue_scripts', 'wpb_adding_scripts'); ```
The `wp_enqueue_scripts` function is hooked to run on the [`wp_head` action](https://developer.wordpress.org/reference/hooks/wp_head/), which is triggered by the [`wp_head()` function](https://developer.wordpress.org/reference/functions/wp_head/). This function should be placed within the `<head>` tag of your theme's ...
267,855
<p>I have hooked an ajax call for a logged-in user, and now I need to catch his data inside the receiving call (the code that receives the action call). How can I get the user's ID reliably? This code is inside my plugin definition file and the code inside the function (error_log("we're in....kind of");) is being calle...
[ { "answer_id": 267856, "author": "totels", "author_id": 23446, "author_profile": "https://wordpress.stackexchange.com/users/23446", "pm_score": 1, "selected": false, "text": "<p>If you want specific data for your ajax hook, you need to send it with your request.</p>\n\n<pre><code>&lt;scr...
2017/05/23
[ "https://wordpress.stackexchange.com/questions/267855", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75915/" ]
I have hooked an ajax call for a logged-in user, and now I need to catch his data inside the receiving call (the code that receives the action call). How can I get the user's ID reliably? This code is inside my plugin definition file and the code inside the function (error\_log("we're in....kind of");) is being called:...
[`wp_get_current_user`](https://codex.wordpress.org/Function_Reference/wp_get_current_user) will get you the [`WP_User`](https://codex.wordpress.org/Class_Reference/WP_User) object for the currently logged-in user: ``` add_action( 'wp_ajax_create_team', 'create_team' ); function create_team() { $current_user = wp_...
267,865
<p>I have entries in wp_postmeta like so (shortened for brevity:</p> <blockquote> <p><strong>post_id | meta_key | meta_value</strong></p> <p>integer | _thumbnail_id | integer</p> <p>integer | rafi | integer</p> </blockquote> <p>Now it's easy to select and delete all rows containing _thumb.</p> <p>S...
[ { "answer_id": 267886, "author": "Mike", "author_id": 60200, "author_profile": "https://wordpress.stackexchange.com/users/60200", "pm_score": 1, "selected": false, "text": "<p>Here's what I came up with. I tested by enabling the \"Random Auto Featured Image\" plugin, which adds the missi...
2017/05/24
[ "https://wordpress.stackexchange.com/questions/267865", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60200/" ]
I have entries in wp\_postmeta like so (shortened for brevity: > > **post\_id | meta\_key | meta\_value** > > > integer | \_thumbnail\_id | integer > > > integer | rafi | integer > > > Now it's easy to select and delete all rows containing \_thumb. Same with rows containing rafi. What I need to do is delete...
After 5 hours of searching finally I wrote the SQL query and that is- ``` DELETE FROM {$wpdb->postmeta} WHERE post_id IN (SELECT post_id FROM (SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key LIKE '_thumbnail_id' ...
267,871
<p>I made my very own WordPress theme from scratch and I don't use a header nor a footer for it (so no header.php or footer.php files present). All of the important content is directly in the index.php file. </p> <p>So I was wondering where I can put my meta tags in. Specifically this meta tag, </p> <pre><code>&lt;me...
[ { "answer_id": 267886, "author": "Mike", "author_id": 60200, "author_profile": "https://wordpress.stackexchange.com/users/60200", "pm_score": 1, "selected": false, "text": "<p>Here's what I came up with. I tested by enabling the \"Random Auto Featured Image\" plugin, which adds the missi...
2017/05/24
[ "https://wordpress.stackexchange.com/questions/267871", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118296/" ]
I made my very own WordPress theme from scratch and I don't use a header nor a footer for it (so no header.php or footer.php files present). All of the important content is directly in the index.php file. So I was wondering where I can put my meta tags in. Specifically this meta tag, ``` <meta name="viewport" conte...
After 5 hours of searching finally I wrote the SQL query and that is- ``` DELETE FROM {$wpdb->postmeta} WHERE post_id IN (SELECT post_id FROM (SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key LIKE '_thumbnail_id' ...
267,907
<p>I am creating a child theme archive template. I don't know how many posts will be displayed, which is fine except that i want to have a dividing line after each post except the last one.</p> <p>I am using the usual loop, have added a <code>$loopcount</code> variable, and then an include to create the formatting/d...
[ { "answer_id": 267908, "author": "Aftab", "author_id": 64614, "author_profile": "https://wordpress.stackexchange.com/users/64614", "pm_score": 1, "selected": false, "text": "<p>By default it is 10.</p>\n\n<p>You can change it from \"Settings -> Reading\" and then \"Blog pages show at mos...
2017/05/24
[ "https://wordpress.stackexchange.com/questions/267907", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81925/" ]
I am creating a child theme archive template. I don't know how many posts will be displayed, which is fine except that i want to have a dividing line after each post except the last one. I am using the usual loop, have added a `$loopcount` variable, and then an include to create the formatting/display and add the `<di...
Try reversing the logic, put the dividing line before the post but only do it after the first post. To answer your question though, you can get the loop count with the following: ``` global $wp_query; $count = count( $wp_query->posts ); // or $count = $wp_query->post_count; ```
267,936
<p>I've searched for this in the Q&amp;A but I was unable to find it. When I read answers throughout the site I see <code>wp_reset_postdata()</code> placed in multiple areas with the <code>have_posts()</code> conditional and outside the conditional all together. When I read the documentation on <a href="https://devel...
[ { "answer_id": 267937, "author": "Hossein", "author_id": 120345, "author_profile": "https://wordpress.stackexchange.com/users/120345", "pm_score": 0, "selected": false, "text": "<p>Normally I use it outside of <code>if($query-&gt;have_posts())</code> statement. This way you can make sure...
2017/05/24
[ "https://wordpress.stackexchange.com/questions/267936", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25271/" ]
I've searched for this in the Q&A but I was unable to find it. When I read answers throughout the site I see `wp_reset_postdata()` placed in multiple areas with the `have_posts()` conditional and outside the conditional all together. When I read the documentation on [`wp_reset_postdata()`](https://developer.wordpress.o...
**Short version:** As Tom J Nowell said, > > You shouldn't cleanup if there's nothing to clean > > > **Long version:** However, if you put `wp_reset_postdata()` after (or outside) the loop, it would still work perfectly fine. I have used the function in various scenarios, including something like this: ``` dyn...
267,965
<p>My company had our WordPress website made through <a href="http://www.propertyware.com/" rel="nofollow noreferrer">Propertyware</a> or <a href="https://www.realpage.com/" rel="nofollow noreferrer">Real Page</a>. The issue is, it's a different type of WordPress than others. (We did not realize there were different ty...
[ { "answer_id": 267937, "author": "Hossein", "author_id": 120345, "author_profile": "https://wordpress.stackexchange.com/users/120345", "pm_score": 0, "selected": false, "text": "<p>Normally I use it outside of <code>if($query-&gt;have_posts())</code> statement. This way you can make sure...
2017/05/24
[ "https://wordpress.stackexchange.com/questions/267965", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120365/" ]
My company had our WordPress website made through [Propertyware](http://www.propertyware.com/) or [Real Page](https://www.realpage.com/). The issue is, it's a different type of WordPress than others. (We did not realize there were different types.) Our installation will not allow plugins to be used. Is there a way to ...
**Short version:** As Tom J Nowell said, > > You shouldn't cleanup if there's nothing to clean > > > **Long version:** However, if you put `wp_reset_postdata()` after (or outside) the loop, it would still work perfectly fine. I have used the function in various scenarios, including something like this: ``` dyn...
267,966
<p>I needed to develop a technique to delete some data from the database.</p> <p>The technique will be part of a plugin at some point.</p> <p>For immediate results, I was editing functions.php on my local dev site, placing the necessary commands at the bottom of the file and reloading the page upon saving.</p> <p>Is...
[ { "answer_id": 267972, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>There is no place in WP that is considered to be purposefully meant for developing and debugging of code.</p>\n\n<p...
2017/05/24
[ "https://wordpress.stackexchange.com/questions/267966", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60200/" ]
I needed to develop a technique to delete some data from the database. The technique will be part of a plugin at some point. For immediate results, I was editing functions.php on my local dev site, placing the necessary commands at the bottom of the file and reloading the page upon saving. Is this considered bad for...
There isn't really a prescribed way to do this, but it's probably safer to hook an action like `init` to be sure everything you need is loaded, and then maybe check for some sort of flag so you can control *which* page loads run your code. ``` function my_test_func(){ if( isset( $_GET['do_my_test_thing'] ) ){ ...
268,010
<p>I need wordpress category as drop down . So far my code </p> <pre><code>function cat_drop_down(){ $categories_array = array(); $categories = get_categories(); foreach( $categories as $category ){ $categories_array[] = $category-&gt;term_id; } return $categories_array; } </code></pre> <p>This re...
[ { "answer_id": 268012, "author": "Mehedi_Sharif", "author_id": 107089, "author_profile": "https://wordpress.stackexchange.com/users/107089", "pm_score": 0, "selected": false, "text": "<p>There is a default wordpress function called . It will return all categoris in a list with category i...
2017/05/25
[ "https://wordpress.stackexchange.com/questions/268010", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48294/" ]
I need wordpress category as drop down . So far my code ``` function cat_drop_down(){ $categories_array = array(); $categories = get_categories(); foreach( $categories as $category ){ $categories_array[] = $category->term_id; } return $categories_array; } ``` This renders drop down perfectly but...
You are partially correct , you are not passing cat id in your parameter. Try ``` $categories_array[ $category->term_id ] = $category->name; ``` Now you will get category id as drop down value.
268,039
<p>My functions.php includes other function files located within a 'functions' directory.</p> <p>Currently they're individually added, in the format of this example:</p> <pre><code>include('functions/login.php'); </code></pre> <p>How can I modify this to include all files within the 'functions' directory, without li...
[ { "answer_id": 268042, "author": "JItendra Rana", "author_id": 87433, "author_profile": "https://wordpress.stackexchange.com/users/87433", "pm_score": 4, "selected": true, "text": "<p>You can include/require all *.php files recursively using following function.</p>\n\n<pre><code>foreach(...
2017/05/25
[ "https://wordpress.stackexchange.com/questions/268039", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103213/" ]
My functions.php includes other function files located within a 'functions' directory. Currently they're individually added, in the format of this example: ``` include('functions/login.php'); ``` How can I modify this to include all files within the 'functions' directory, without listing them individually?
You can include/require all \*.php files recursively using following function. ``` foreach(glob(get_template_directory() . "/*.php") as $file){ require $file; } ``` Alternatively You can use following function as-well. ``` $Directory = new RecursiveDirectoryIterator(get_template_directory().'functions/'); $Iter...
268,074
<p>One of our websites includes an online store, which alongside phone sales is one of two ways customers can purchase our products. All of our customer info is stored in a program called Orderwise, which assigns a unique number code to each customer. Now, we've set up the ability to add an Orderwise number to user inf...
[ { "answer_id": 268042, "author": "JItendra Rana", "author_id": 87433, "author_profile": "https://wordpress.stackexchange.com/users/87433", "pm_score": 4, "selected": true, "text": "<p>You can include/require all *.php files recursively using following function.</p>\n\n<pre><code>foreach(...
2017/05/25
[ "https://wordpress.stackexchange.com/questions/268074", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120427/" ]
One of our websites includes an online store, which alongside phone sales is one of two ways customers can purchase our products. All of our customer info is stored in a program called Orderwise, which assigns a unique number code to each customer. Now, we've set up the ability to add an Orderwise number to user info o...
You can include/require all \*.php files recursively using following function. ``` foreach(glob(get_template_directory() . "/*.php") as $file){ require $file; } ``` Alternatively You can use following function as-well. ``` $Directory = new RecursiveDirectoryIterator(get_template_directory().'functions/'); $Iter...
268,078
<p>I want to know if I can override a function which is present into the parent theme function.</p> <p>If I redeclare the function into the child theme I am getting function already exist error.</p> <p>So Please guide me how can I define the function with same name in my child theme's functions.php</p>
[ { "answer_id": 268082, "author": "Cedon", "author_id": 80069, "author_profile": "https://wordpress.stackexchange.com/users/80069", "pm_score": 1, "selected": true, "text": "<p>Check the parent theme's <code>functions.php</code>. If properly written to support child themes, each of these ...
2017/05/25
[ "https://wordpress.stackexchange.com/questions/268078", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60922/" ]
I want to know if I can override a function which is present into the parent theme function. If I redeclare the function into the child theme I am getting function already exist error. So Please guide me how can I define the function with same name in my child theme's functions.php
Check the parent theme's `functions.php`. If properly written to support child themes, each of these functions should be wrapped in a conditional as follows: ``` if ( ! function_exists( 'theme_setup' ) ) : function theme_setup() { // Parent Theme Setup Function Code } endif; add_action( 'after_theme_setup', 'theme_...
268,100
<p>I've been searching for a couple of days now so I'll keep my question as short as possible to get out of your ways.</p> <p>What I'm trying to do should be very basic with jQuery (append) I guess but for some strange reason I can't get it done while adding .js to the backend. Also this custom hack is just temporary,...
[ { "answer_id": 268145, "author": "Jack Ottermans", "author_id": 59031, "author_profile": "https://wordpress.stackexchange.com/users/59031", "pm_score": 0, "selected": false, "text": "<p>I'm so ashamed for doing this technique but if nobody <em>(online)</em> wants to help in three days as...
2017/05/25
[ "https://wordpress.stackexchange.com/questions/268100", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59031/" ]
I've been searching for a couple of days now so I'll keep my question as short as possible to get out of your ways. What I'm trying to do should be very basic with jQuery (append) I guess but for some strange reason I can't get it done while adding .js to the backend. Also this custom hack is just temporary, until the...
Here's an alternative technique to manipulating the template. I adapted the solution below from [this post](http://unsalkorkmaz.com/wp3-5-media-gallery-edit-modal-change-captions-to-title/). In the approach below, the `print_media_templates` hook, which is triggered at the bottom of `wp-includes/media-template.php`, i...
268,104
<p>I'm struggling with this for a couple of days already, so any help is most welcome. Not my first time setting up Ajax with WP, so I have some idea at the least. It concerns a very standard form validation and inputting info to database. <strong>This all inside of a plugin.</strong> </p> <p>So, what works: form sub...
[ { "answer_id": 268106, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": false, "text": "<p>The above AJAX callback could be rewritten as a REST API endpoint like this:</p>\n\n<pre><code>function bda_...
2017/05/25
[ "https://wordpress.stackexchange.com/questions/268104", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62159/" ]
I'm struggling with this for a couple of days already, so any help is most welcome. Not my first time setting up Ajax with WP, so I have some idea at the least. It concerns a very standard form validation and inputting info to database. **This all inside of a plugin.** So, what works: form submission works, the jquer...
Since you're serializing the form, as ajax data, you could be missing the `action` part from your form: ``` <input type="hidden" name="action" value="bda_alert"> ``` so your ajax request would contain ``` /wp-admin/admin-ajax.php?action=bda_alert&... ``` that should invoke the `wp_ajax_bda_alert` or `wp_ajax_nopr...
268,111
<p>I currently have a custom post type with a sub menu page via <code>add_submenu_page</code>. On this page I have a form with some basic settings such as a text editor and some radio buttons. </p> <pre><code>function programme_enable_pages() { add_submenu_page( 'edit.php?post_type=programmes', 'co...
[ { "answer_id": 269293, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": -1, "selected": false, "text": "<p>To save options the user needs to have the <code>manage_options</code> capability, which editors lack.</...
2017/05/25
[ "https://wordpress.stackexchange.com/questions/268111", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37243/" ]
I currently have a custom post type with a sub menu page via `add_submenu_page`. On this page I have a form with some basic settings such as a text editor and some radio buttons. ``` function programme_enable_pages() { add_submenu_page( 'edit.php?post_type=programmes', 'content', 'Archive ...
In the `wp-admin/options.php` file you find filter with name created from your settings group to control permissions: ``` $capability = apply_filters( "option_page_capability_{$option_page}", $capability ); ``` to fix issue, add filter with your desired permission level like: ``` add_filter( 'option_page_capability...
268,124
<p><a href="https://developer.wordpress.org/themes/basics/template-hierarchy/" rel="nofollow noreferrer">Here</a> i read that if i create a custom post type, Wordpress will look to its specific template first, then it falls back to single.php.</p> <p>I registered a custom post type (i'll show the taxonomy as well), wh...
[ { "answer_id": 268125, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>I am not sure I follow your question entirely (the bit about \"adding\" them to the blog). However from your descri...
2017/05/25
[ "https://wordpress.stackexchange.com/questions/268124", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119611/" ]
[Here](https://developer.wordpress.org/themes/basics/template-hierarchy/) i read that if i create a custom post type, Wordpress will look to its specific template first, then it falls back to single.php. I registered a custom post type (i'll show the taxonomy as well), which is properly shown in admin; i can create th...
`public` is `false` by default, your post type will not be visible on the front end without explicitly setting it to `true`. ``` $post_args = array( 'public' => true, 'label' => _('Blog Post'), 'description' => _('Site\'s blog posts'), 'show_ui' => true, 'show_in_nav_menus' => true, 'taxonomies...
268,173
<p>Is it possible to get a default value that was set in the Customizer setting? Here is an example of the code:</p> <pre><code>// Add setting. $wp_customize-&gt;add_setting( 'slug_awesome_title', array( 'default' =&gt; esc_html__( 'WordPress', 'slug' ), 'sanitize_callback' =&gt; 'sanitize_text_field', ) ); /...
[ { "answer_id": 268125, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>I am not sure I follow your question entirely (the bit about \"adding\" them to the blog). However from your descri...
2017/05/26
[ "https://wordpress.stackexchange.com/questions/268173", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85513/" ]
Is it possible to get a default value that was set in the Customizer setting? Here is an example of the code: ``` // Add setting. $wp_customize->add_setting( 'slug_awesome_title', array( 'default' => esc_html__( 'WordPress', 'slug' ), 'sanitize_callback' => 'sanitize_text_field', ) ); // Add control. $wp_cust...
`public` is `false` by default, your post type will not be visible on the front end without explicitly setting it to `true`. ``` $post_args = array( 'public' => true, 'label' => _('Blog Post'), 'description' => _('Site\'s blog posts'), 'show_ui' => true, 'show_in_nav_menus' => true, 'taxonomies...
268,188
<p>I made a plugin for my webpage. It works as a standalone HTML file fine. But when I use it as wp plugin a jQuery Plugin I need (Bootstrap Slider <a href="https://github.com/seiyria/bootstrap-slider" rel="nofollow noreferrer">https://github.com/seiyria/bootstrap-slider</a>) throws this error above.</p> <p>I included...
[ { "answer_id": 268125, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>I am not sure I follow your question entirely (the bit about \"adding\" them to the blog). However from your descri...
2017/05/26
[ "https://wordpress.stackexchange.com/questions/268188", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120491/" ]
I made a plugin for my webpage. It works as a standalone HTML file fine. But when I use it as wp plugin a jQuery Plugin I need (Bootstrap Slider <https://github.com/seiyria/bootstrap-slider>) throws this error above. I included jquery and this boostrap-slider plugin like that: ``` wp_enqueue_script( 'child_jquery','c...
`public` is `false` by default, your post type will not be visible on the front end without explicitly setting it to `true`. ``` $post_args = array( 'public' => true, 'label' => _('Blog Post'), 'description' => _('Site\'s blog posts'), 'show_ui' => true, 'show_in_nav_menus' => true, 'taxonomies...
268,246
<p>I have an issue with the shipping tax calculation. I add the shipping cost without tax, and everything is calculated OK in the cart/checkout page. Also, in back office, the order is displayed correctly (cost/taxes are calculated OK). </p> <p>The problem happens when you <strong>change the order status to Complete</...
[ { "answer_id": 268125, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>I am not sure I follow your question entirely (the bit about \"adding\" them to the blog). However from your descri...
2017/05/26
[ "https://wordpress.stackexchange.com/questions/268246", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58102/" ]
I have an issue with the shipping tax calculation. I add the shipping cost without tax, and everything is calculated OK in the cart/checkout page. Also, in back office, the order is displayed correctly (cost/taxes are calculated OK). The problem happens when you **change the order status to Complete** and the invoice...
`public` is `false` by default, your post type will not be visible on the front end without explicitly setting it to `true`. ``` $post_args = array( 'public' => true, 'label' => _('Blog Post'), 'description' => _('Site\'s blog posts'), 'show_ui' => true, 'show_in_nav_menus' => true, 'taxonomies...
268,266
<p>I installed the flatsome theme and it created a menu in the admin panel. I wanted to hide it because it is redundant to Appearance menu that is already in the dashboard. How will I possibly hide the menu item on the sidebar and on the top bar?</p> <p><a href="https://i.stack.imgur.com/oUPDk.png" rel="nofollow noref...
[ { "answer_id": 268278, "author": "Mehedi_Sharif", "author_id": 107089, "author_profile": "https://wordpress.stackexchange.com/users/107089", "pm_score": 0, "selected": false, "text": "<p>You should ask support from flatsome .They have a active facebook group <a href=\"https://www.faceboo...
2017/05/26
[ "https://wordpress.stackexchange.com/questions/268266", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120545/" ]
I installed the flatsome theme and it created a menu in the admin panel. I wanted to hide it because it is redundant to Appearance menu that is already in the dashboard. How will I possibly hide the menu item on the sidebar and on the top bar? [Here](https://i.stack.imgur.com/oUPDk.png) is an screenshot.
1. As a temporary solution, add below script to the function.php file ``` wp_enqueue_style( 'flatsome-hide', get_stylesheet_directory_uri() . '/css/flatsome.css', array('flatsome'), '1.0' ); ``` Crete a CSS file called "flatsome" inside your CSS directory, or whatever you prefer, make sure you update the name and t...
268,268
<p>I'm working on a travel site where there are three parameters: destinations, activities and packages.</p> <p>Destinations mean the country to travel like: United States, Singapore, Switzerland etc.</p> <p>Activities are the activities that can be performed inside that country like: hiking, rafting, tour, climbing....
[ { "answer_id": 268275, "author": "Carl Elder", "author_id": 120223, "author_profile": "https://wordpress.stackexchange.com/users/120223", "pm_score": 1, "selected": false, "text": "<p>Personally, I think it would be easier to manage Packages as the parent taxonomy and Destination / Activ...
2017/05/27
[ "https://wordpress.stackexchange.com/questions/268268", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75767/" ]
I'm working on a travel site where there are three parameters: destinations, activities and packages. Destinations mean the country to travel like: United States, Singapore, Switzerland etc. Activities are the activities that can be performed inside that country like: hiking, rafting, tour, climbing. And, package in...
@asis, use below on function.php to add the CPT "travel" and tamx.. under it. ``` function travel() { $labels = array( 'name' => _x('travel', 'post type general name'), 'singular_name' => _x('Project', 'post type singular name'), 'add_new' => _x('Add New ...
268,269
<p>I always see these on my dashboard </p> <blockquote> <p>Notice: Undefined index: full in /home2/guyfancy/public_html/cafe4apps.net/wp-includes/media.php on line 215</p> <p>Notice: Undefined index: full in /home2/guyfancy/public_html/cafe4apps.net/wp-includes/media.php on line 216</p> <p>Notice: ...
[ { "answer_id": 268270, "author": "Eric B.", "author_id": 118176, "author_profile": "https://wordpress.stackexchange.com/users/118176", "pm_score": 0, "selected": false, "text": "<p>There really wasn't a question in there so I'm not sure which route you're trying to go so here's a little ...
2017/05/27
[ "https://wordpress.stackexchange.com/questions/268269", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94354/" ]
I always see these on my dashboard > > Notice: Undefined index: full > in /home2/guyfancy/public\_html/cafe4apps.net/wp-includes/media.php on > line 215 > > > Notice: Undefined index: full > in /home2/guyfancy/public\_html/cafe4apps.net/wp-includes/media.php on > line 216 > > > Notice: Undefined index: full ...
For anyone else who stumbles on this problem I've found a possible cause. When you're running wp\_get\_attachment\_image\_src($imageid,'full') in your code if the $imageid you're checking doesn't have a 'full' size available you will see this error. As suggested above this particular problem could be caused by a plug...
268,305
<p>I would like to display comments on a static <a href="http://disputeit.org" rel="nofollow noreferrer">home page of a site</a> using the twenty seventeen theme. I have configured it on in the settings and on the page but nothing gets displayed.</p> <p>Am I missing something? </p>
[ { "answer_id": 268309, "author": "Vinod Dalvi", "author_id": 14347, "author_profile": "https://wordpress.stackexchange.com/users/14347", "pm_score": 2, "selected": true, "text": "<p>To achieve this you have to create front-page.php file in the child theme of seventeen theme on your site ...
2017/05/27
[ "https://wordpress.stackexchange.com/questions/268305", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120566/" ]
I would like to display comments on a static [home page of a site](http://disputeit.org) using the twenty seventeen theme. I have configured it on in the settings and on the page but nothing gets displayed. Am I missing something?
To achieve this you have to create front-page.php file in the child theme of seventeen theme on your site and add following modified code in it. ``` <?php /** * The front page template file * * If the user has selected a static page for their homepage, this is what will * appear. * Learn more: https://codex.wordp...
268,339
<p>I know there is a body_class function for WordPress. But is there one (or a way) to add a class to the HTML element? </p> <p>My goal is to be able to add a unique class (or ID) to a page's HTML element. Currently my theme is adding the page-id-XXXX class to the body element, but I need a way to have a unique class ...
[ { "answer_id": 268346, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 0, "selected": false, "text": "<p>Since you're outside of the loop the cleanest solution is to simply create your own function like so</p>\n\n...
2017/05/27
[ "https://wordpress.stackexchange.com/questions/268339", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/91826/" ]
I know there is a body\_class function for WordPress. But is there one (or a way) to add a class to the HTML element? My goal is to be able to add a unique class (or ID) to a page's HTML element. Currently my theme is adding the page-id-XXXX class to the body element, but I need a way to have a unique class or ID on ...
Thanks to the help of [this](https://wordpress.stackexchange.com/a/379654/91826) answer, I've found this solution works for adding an `id`. Though I'm not sure about adding to the `class` attribute. ``` function add_id_to_html_element( $output ) { global $post; $output .= ' id="custom-id-' . $post->ID . '"'; ...
268,361
<p>I need help with removing the Content Filter from a Plugin:</p> <pre><code>add_filter( 'the_content', array( &amp;$this, 'addContentAds' ), 8 ); </code></pre> <p>Do someone could help me please?</p> <p>Thank you and best regards</p>
[ { "answer_id": 268346, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 0, "selected": false, "text": "<p>Since you're outside of the loop the cleanest solution is to simply create your own function like so</p>\n\n...
2017/05/28
[ "https://wordpress.stackexchange.com/questions/268361", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75820/" ]
I need help with removing the Content Filter from a Plugin: ``` add_filter( 'the_content', array( &$this, 'addContentAds' ), 8 ); ``` Do someone could help me please? Thank you and best regards
Thanks to the help of [this](https://wordpress.stackexchange.com/a/379654/91826) answer, I've found this solution works for adding an `id`. Though I'm not sure about adding to the `class` attribute. ``` function add_id_to_html_element( $output ) { global $post; $output .= ' id="custom-id-' . $post->ID . '"'; ...
268,379
<p>How to customize the notice message ('Post published' or 'Post updated') displayed when I add or edit a custom post type registered with <code>register_post_type()</code> function?</p>
[ { "answer_id": 268383, "author": "Welcher", "author_id": 27210, "author_profile": "https://wordpress.stackexchange.com/users/27210", "pm_score": 4, "selected": true, "text": "<p>You can used the <code>post_updated_messages</code> filter.</p>\n\n<pre><code>add_filter( 'post_updated_messag...
2017/05/28
[ "https://wordpress.stackexchange.com/questions/268379", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81094/" ]
How to customize the notice message ('Post published' or 'Post updated') displayed when I add or edit a custom post type registered with `register_post_type()` function?
You can used the `post_updated_messages` filter. ``` add_filter( 'post_updated_messages', 'rw_post_updated_messages' ); function rw_post_updated_messages( $messages ) { $post = get_post(); $post_type = get_post_type( $post ); $post_type_object = get_post_type_object( $post_type ); $messages['my-p...
268,423
<p>I am trying to add a read posts function to my Wordpress website. To achieve this, I create a cookie on which I store all the IDs of read posts. Every time a post is loaded, the following function is fired : </p> <pre><code>function readPosts() { if (is_single()){ $postId = get_the_id() . "/"; $...
[ { "answer_id": 268425, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>The core of the problem is that you set cookies when the content is being accessed, not when it is read. ...
2017/05/29
[ "https://wordpress.stackexchange.com/questions/268423", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120658/" ]
I am trying to add a read posts function to my Wordpress website. To achieve this, I create a cookie on which I store all the IDs of read posts. Every time a post is loaded, the following function is fired : ``` function readPosts() { if (is_single()){ $postId = get_the_id() . "/"; $cookie = empty...
I went the JavaScript way as @Mark Kaplun suggested and it works. There is no more duplicate. Here's my JS for those interested: ``` jQuery(document).ready(function($) { var name = "readposts="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for (var i = 0...
268,435
<p>I have the following settings in <code>php.ini</code>:</p> <pre><code>upload_max_filesize = 100M post_max_size = 100M max_execution_time = 300 </code></pre> <p>My <code>.htaccess</code> file is empty and there is no function about uploading file size.</p> <p>But still I can not upload file larger than 1MB. It giv...
[ { "answer_id": 268460, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": -1, "selected": false, "text": "<p>Although you can change the php.ini file, and other settings, I just use the \"Upload Max File Size\"...
2017/05/29
[ "https://wordpress.stackexchange.com/questions/268435", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120666/" ]
I have the following settings in `php.ini`: ``` upload_max_filesize = 100M post_max_size = 100M max_execution_time = 300 ``` My `.htaccess` file is empty and there is no function about uploading file size. But still I can not upload file larger than 1MB. It gives HTTP error. (p.s. Page shows the maximum upload file...
I had the very same problem. None of googled articles suggesting trivial solutions (like "resize image", "wait a bit") helped. **Symptoms**: media uploading works perfectly, but only for some files (larger than 1Mb) the "HTTP error" occurs. But when I tried to check my web server logs, everything became clear in one ...
268,471
<p>This adds the field to the add new tag form</p> <pre><code>function tag_add_form_fields ( $taxonomy ){ ?&gt; &lt;div class="form-field term-colorpicker-wrap"&gt; &lt;label for="term-colorpicker"&gt;Category Color&lt;/label&gt; &lt;input type="color" name="_tag_color" value="#737373" class="c...
[ { "answer_id": 293850, "author": "Ben", "author_id": 118790, "author_profile": "https://wordpress.stackexchange.com/users/118790", "pm_score": 2, "selected": false, "text": "<p>For updating and saving use <code>add_action( 'edit_term', 'save_termmeta_tag' );</code></p>\n" }, { "a...
2017/05/29
[ "https://wordpress.stackexchange.com/questions/268471", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120690/" ]
This adds the field to the add new tag form ``` function tag_add_form_fields ( $taxonomy ){ ?> <div class="form-field term-colorpicker-wrap"> <label for="term-colorpicker">Category Color</label> <input type="color" name="_tag_color" value="#737373" class="colorpicker" id="term-colorpicker" /> ...
For updating and saving use `add_action( 'edit_term', 'save_termmeta_tag' );`