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
212,241
<p>I am using <a href="http://adambalee.com/search-wordpress-by-custom-fields-without-a-plugin/" rel="nofollow noreferrer">this code</a> to search products from a wordpress/woocommerce website.<br> My requirment is URL will be like "<a href="http://localhost/wp/?s=D34&amp;post_type=product" rel="nofollow noreferrer">ht...
[ { "answer_id": 212242, "author": "Reigel Gallarde", "author_id": 974, "author_profile": "https://wordpress.stackexchange.com/users/974", "pm_score": 0, "selected": false, "text": "<p>try this</p>\n\n<pre><code>function cf_search_where( $where ) {\n global $pagenow, $wpdb;\n\n // a ...
2015/12/18
[ "https://wordpress.stackexchange.com/questions/212241", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85511/" ]
I am using [this code](http://adambalee.com/search-wordpress-by-custom-fields-without-a-plugin/) to search products from a wordpress/woocommerce website. My requirment is URL will be like "<http://localhost/wp/?s=D34&post_type=product>" While `s=D34` is search string. When user will search for a string. Data will ...
If I understand you, what you are doing is wildly complicated. All you should need is a simple `pre_get_posts` filter: ``` add_filter( 'pre_get_posts', 'modified_pre_get_posts' ); function modified_pre_get_posts( $query ) { if ( $query->is_search() ) { $query->set( 'post_type', 'product' ); } return $qu...
212,266
<p>i know how i can print a single script with wp_dequeue_script and wp_enqueue_script to the footer:</p> <pre><code>function dequeue_my_scripts() { wp_dequeue_script('dgx_donate_paypalstd_script'); } add_action( 'wp_print_scripts', 'dequeue_my_scripts', 11 ); function enqueue_scripts_to_footer() { wp_enqueue_scr...
[ { "answer_id": 212268, "author": "C C", "author_id": 83299, "author_profile": "https://wordpress.stackexchange.com/users/83299", "pm_score": 0, "selected": false, "text": "<p>Right out of the codex: the fifth argument to the wp_enqueue_script function call is a boolean to tell it whethe...
2015/12/18
[ "https://wordpress.stackexchange.com/questions/212266", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82174/" ]
i know how i can print a single script with wp\_dequeue\_script and wp\_enqueue\_script to the footer: ``` function dequeue_my_scripts() { wp_dequeue_script('dgx_donate_paypalstd_script'); } add_action( 'wp_print_scripts', 'dequeue_my_scripts', 11 ); function enqueue_scripts_to_footer() { wp_enqueue_script('dgx_d...
Like this:- ``` function dequeue_my_scripts() { wp_dequeue_script('dgx_donate_paypalstd_script'); wp_dequeue_script('next-handle-script'); wp_dequeue_script('next-handle-script-2'); /* and so on*/ } add_action( 'wp_print_scripts', 'dequeue_my_scripts', 11 ); function enqueue_scripts_to_footer() { wp_en...
212,309
<p>I have created a small search tool that unless you know the EXACT code, you will not be taken to the post. For example, if I enter "OI812" it will take me to a custom post type that is ../CPT/OI812.</p> <p>The CPT is not part of the regular search and I've removed anything with that slug from a canonical redirect. ...
[ { "answer_id": 212316, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 3, "selected": false, "text": "<p>Use <a href=\"https://codex.wordpress.org/Rewrite_API/add_rewrite_rule\" rel=\"nofollow\">add_rewrite_rule</a>...
2015/12/18
[ "https://wordpress.stackexchange.com/questions/212309", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64488/" ]
I have created a small search tool that unless you know the EXACT code, you will not be taken to the post. For example, if I enter "OI812" it will take me to a custom post type that is ../CPT/OI812. The CPT is not part of the regular search and I've removed anything with that slug from a canonical redirect. Unless the...
Use [add\_rewrite\_rule](https://codex.wordpress.org/Rewrite_API/add_rewrite_rule) or [add\_rewrite\_endpoint](https://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint) to capture the `HASHorSOMETHINGcrazyANDrandom`. [Hashids](http://hashids.org/php/) could also help you generate a hash that you could read back l...
212,325
<p>Assuming you write a plugin and hook into <a href="https://developer.wordpress.org/plugins/the-basics/activation-deactivation-hooks/" rel="nofollow noreferrer">activation / deactivation</a> to <a href="https://codex.wordpress.org/Function_Reference/register_post_type" rel="nofollow noreferrer">register_post_type</a>...
[ { "answer_id": 212316, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 3, "selected": false, "text": "<p>Use <a href=\"https://codex.wordpress.org/Rewrite_API/add_rewrite_rule\" rel=\"nofollow\">add_rewrite_rule</a>...
2015/12/18
[ "https://wordpress.stackexchange.com/questions/212325", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84219/" ]
Assuming you write a plugin and hook into [activation / deactivation](https://developer.wordpress.org/plugins/the-basics/activation-deactivation-hooks/) to [register\_post\_type](https://codex.wordpress.org/Function_Reference/register_post_type) is that good enough? Or do you need to do it every [init](https://codex.wo...
Use [add\_rewrite\_rule](https://codex.wordpress.org/Rewrite_API/add_rewrite_rule) or [add\_rewrite\_endpoint](https://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint) to capture the `HASHorSOMETHINGcrazyANDrandom`. [Hashids](http://hashids.org/php/) could also help you generate a hash that you could read back l...
212,345
<p>I have put the below code in <strong>functions.php</strong>. (It's used to hide some options from client.) But the problem is, after adding these codes, images are not uploading, can't even even uploaded photos from library or while creating a new post. Someone pls help</p> <pre><code>echo '&lt;style&gt; #...
[ { "answer_id": 212353, "author": "Omar Tariq", "author_id": 36718, "author_profile": "https://wordpress.stackexchange.com/users/36718", "pm_score": 1, "selected": false, "text": "<p>Replace your code with this code:-</p>\n\n<pre><code>add_action('wp_footer', 'myCssCode', PHP_INT_MAX);\nf...
2015/12/19
[ "https://wordpress.stackexchange.com/questions/212345", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85428/" ]
I have put the below code in **functions.php**. (It's used to hide some options from client.) But the problem is, after adding these codes, images are not uploading, can't even even uploaded photos from library or while creating a new post. Someone pls help ``` echo '<style> #toplevel_page_wpcf7, #wp-admin-ba...
Replace your code with this code:- ``` add_action('wp_footer', 'myCssCode', PHP_INT_MAX); function myCssCode() { ?> <style> #toplevel_page_wpcf7, #wp-admin-bar-wp-logo, #screen-meta-links, #menu-tools, #wp-admin-bar-wpseo-menu, #footer-upgrade, #topleve...
212,346
<p>My problem is simple, I just don't want user to shop unless and until user is not logged in. I also want to show specific message "Please Log In First" instead of price or add to cart button on the single product page.</p> <p>I can hide price and add to cart functionality by using...</p> <pre><code>if (!is_user_lo...
[ { "answer_id": 212353, "author": "Omar Tariq", "author_id": 36718, "author_profile": "https://wordpress.stackexchange.com/users/36718", "pm_score": 1, "selected": false, "text": "<p>Replace your code with this code:-</p>\n\n<pre><code>add_action('wp_footer', 'myCssCode', PHP_INT_MAX);\nf...
2015/12/19
[ "https://wordpress.stackexchange.com/questions/212346", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85583/" ]
My problem is simple, I just don't want user to shop unless and until user is not logged in. I also want to show specific message "Please Log In First" instead of price or add to cart button on the single product page. I can hide price and add to cart functionality by using... ``` if (!is_user_logged_in()) { ...
Replace your code with this code:- ``` add_action('wp_footer', 'myCssCode', PHP_INT_MAX); function myCssCode() { ?> <style> #toplevel_page_wpcf7, #wp-admin-bar-wp-logo, #screen-meta-links, #menu-tools, #wp-admin-bar-wpseo-menu, #footer-upgrade, #topleve...
212,348
<p>I am looking for an option where a custom meta value will be saved when user uploads an attachment.</p> <p>Lets say I need a meta key _example_meta_key and want to save meta value of this as ex087659bh <em>(It will be a randomly generated number, I can take care of this.)</em></p> <p>The problem is, I can't seem t...
[ { "answer_id": 212351, "author": "Omar Tariq", "author_id": 36718, "author_profile": "https://wordpress.stackexchange.com/users/36718", "pm_score": -1, "selected": false, "text": "<p>As @jgraup pointed out. You can use the filter <code>wp_handle_upload</code>. The final code will look li...
2015/12/19
[ "https://wordpress.stackexchange.com/questions/212348", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85582/" ]
I am looking for an option where a custom meta value will be saved when user uploads an attachment. Lets say I need a meta key \_example\_meta\_key and want to save meta value of this as ex087659bh *(It will be a randomly generated number, I can take care of this.)* The problem is, I can't seem to find any filters to...
Use `added_post_meta` and `update_post_meta` with the `$post_id`. For extended properties see this [post](https://wordpress.stackexchange.com/a/212390/84219) and [this](https://wordpress.stackexchange.com/a/1065/84219) for more image functions. ``` add_action('added_post_meta', 'wpse_20151218_after_post_meta', 10, 4);...
212,375
<p>I need a code snippet to load css (extra style sheet?) when a author is logged in. This is for a custom dashboard and post "page".</p> <p><a href="https://i.stack.imgur.com/pW6fb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pW6fb.jpg" alt="enter image description here"></a></p> <p>The screens...
[ { "answer_id": 212376, "author": "Alexey", "author_id": 7314, "author_profile": "https://wordpress.stackexchange.com/users/7314", "pm_score": 0, "selected": false, "text": "<p>Get current user ID and compare it with post author ID. If they are equal then load extra style sheet.</p>\n\n<p...
2015/12/19
[ "https://wordpress.stackexchange.com/questions/212375", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57885/" ]
I need a code snippet to load css (extra style sheet?) when a author is logged in. This is for a custom dashboard and post "page". [![enter image description here](https://i.stack.imgur.com/pW6fb.jpg)](https://i.stack.imgur.com/pW6fb.jpg) The screenshot is what i mean by post page. I want to hide stuf by css for only...
If a user is not logged in then [admin\_head](https://codex.wordpress.org/Plugin_API/Action_Reference/admin_head) probably won't run. So let's just check their [capabilities](https://codex.wordpress.org/Roles_and_Capabilities). ``` function my_custom_admin_head() { if ( ! current_user_can( 'have-fun' )) : ?><s...
212,417
<pre><code>&lt;?php global $post; $post_slug=$post-&gt;post_name; ?&gt; </code></pre> <p>This code is used after <code>&lt;head&gt;</code> and before <code>&lt;body&gt;</code> and is supposed to get current page's slug. It works great, however it will get the <em>slug of first blog post</em> when on <em>"gene...
[ { "answer_id": 212421, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p><a href=\"https://codex.wordpress.org/Function_Reference/get_queried_object\" rel=\"nofollow\"...
2015/12/20
[ "https://wordpress.stackexchange.com/questions/212417", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/80903/" ]
``` <?php global $post; $post_slug=$post->post_name; ?> ``` This code is used after `<head>` and before `<body>` and is supposed to get current page's slug. It works great, however it will get the *slug of first blog post* when on *"general"* blog page. Example: * Blog url: `www.my-site.com/blog/ ->` slug...
> > This code is used after `<head>` and before `<body>` and is supposed to > get current page's slug. It works great, however it will get the slug > of first blog post when on "general" blog page. > > > `$post` is going to be set to the first post in the Loop when the page loads. On "page" pages with only one p...
212,418
<p>I have <code>index.php</code> with a pagination. The permalink settings is plain permalinks.</p> <p>I have a correct pagination view when I open a page <code>/?paged=2</code> but if I open just <code>index.php</code> I have all posts without pagination. There is my <code>index.php</code>:</p> <pre><code>&lt;?php g...
[ { "answer_id": 214900, "author": "franz", "author_id": 87029, "author_profile": "https://wordpress.stackexchange.com/users/87029", "pm_score": 0, "selected": false, "text": "<p>Add this two lines to your theme's function.php file and everything will get back to work:</p>\n\n<pre><code>ad...
2015/12/20
[ "https://wordpress.stackexchange.com/questions/212418", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81470/" ]
I have `index.php` with a pagination. The permalink settings is plain permalinks. I have a correct pagination view when I open a page `/?paged=2` but if I open just `index.php` I have all posts without pagination. There is my `index.php`: ``` <?php get_header(); ?> <?php $paged = (get_query_var('paged')) ? get_quer...
Adding ignore sticky line inside array should solve the issue :) ``` $args = array( 'post_type' => 'post', 'posts_per_page' => '6', 'ignore_sticky_posts' => 1,//this is the one :) 'paged' => $paged, ); ```
212,423
<p>I need get all comments of a post including of the meta value.. for eg. i need all comments fields + a meta value.</p> <p>i tried the following code to get but.. its not working</p> <pre><code>$args = array( 'status' =&gt; 'approve', 'type' =&gt; 'comment', 'post_id' =&gt; '99', 'post_type' =&gt; 'prod...
[ { "answer_id": 212450, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": true, "text": "<p><a href=\"https://codex.wordpress.org/Class_Reference/WP_Comment_Query\" rel=\"nofollow\"><code>WP_Comment_Qu...
2015/12/20
[ "https://wordpress.stackexchange.com/questions/212423", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18746/" ]
I need get all comments of a post including of the meta value.. for eg. i need all comments fields + a meta value. i tried the following code to get but.. its not working ``` $args = array( 'status' => 'approve', 'type' => 'comment', 'post_id' => '99', 'post_type' => 'product', //'count' => true, 'm...
[`WP_Comment_Query`](https://codex.wordpress.org/Class_Reference/WP_Comment_Query) doesn't pull comment meta. You can search by comment meta but the query doesn't return that data. You could easily check this yourself by looking at the Codex. You need to loop over the results and run [`get_comment_meta()`](https://cod...
212,425
<p>My site is enerating some code for older/newer posts on the category page, but when you click "older" the link does not work. it is generating /blog/page/2 from /blog/</p> <ol> <li><p>Tried a few plugins (WPnavi, Category pagination fix, and a few others that were the first and 2nd rated under "pagination" search) ...
[ { "answer_id": 212428, "author": "Abhik", "author_id": 26991, "author_profile": "https://wordpress.stackexchange.com/users/26991", "pm_score": 2, "selected": false, "text": "<p>Try this code, not much different from your's but with proper nesting. Let me know if that works.</p>\n\n<pre>...
2015/12/20
[ "https://wordpress.stackexchange.com/questions/212425", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85626/" ]
My site is enerating some code for older/newer posts on the category page, but when you click "older" the link does not work. it is generating /blog/page/2 from /blog/ 1. Tried a few plugins (WPnavi, Category pagination fix, and a few others that were the first and 2nd rated under "pagination" search) but it didn't wo...
Try this code, not much different from your's but with proper nesting. Let me know if that works. ``` <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <a href="<?php the_permalink() ?>" class="noborder"><?php if ( has_po...
212,461
<p>I am trying to have 2 php functions automatically inserted in every post for my CPT. The problem I am having is that even though I've found a way to add text, Im not sure how to add the php functions cause with the code I have it adds it as regular text to the post.</p> <p>This is what I have in my functions file -...
[ { "answer_id": 212428, "author": "Abhik", "author_id": 26991, "author_profile": "https://wordpress.stackexchange.com/users/26991", "pm_score": 2, "selected": false, "text": "<p>Try this code, not much different from your's but with proper nesting. Let me know if that works.</p>\n\n<pre>...
2015/12/20
[ "https://wordpress.stackexchange.com/questions/212461", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24067/" ]
I am trying to have 2 php functions automatically inserted in every post for my CPT. The problem I am having is that even though I've found a way to add text, Im not sure how to add the php functions cause with the code I have it adds it as regular text to the post. This is what I have in my functions file --- ``` ...
Try this code, not much different from your's but with proper nesting. Let me know if that works. ``` <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <a href="<?php the_permalink() ?>" class="noborder"><?php if ( has_po...
212,487
<p>I have a taxonomy called <code>portfolio_cat</code> with its categories.So now I need to create a slider with that categories as a title and their post items. How I can do that? What loop do I need to have so that I could put in a slider categories with their posts?</p> <p>I dont know how to customize this loop to ...
[ { "answer_id": 212491, "author": "Peyman Mohamadpour", "author_id": 75020, "author_profile": "https://wordpress.stackexchange.com/users/75020", "pm_score": 2, "selected": false, "text": "<p>You may do this:</p>\n\n<pre><code>$args = array(\n 'posts_per_page' =&gt; '-1',\n 'post_typ...
2015/12/21
[ "https://wordpress.stackexchange.com/questions/212487", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77773/" ]
I have a taxonomy called `portfolio_cat` with its categories.So now I need to create a slider with that categories as a title and their post items. How I can do that? What loop do I need to have so that I could put in a slider categories with their posts? I dont know how to customize this loop to fit in ``` <?php ...
I'm not going to discuss implementation of a slider, that is too broad. There are a couple of tutorials around which you can look at on how to implement simple sliders The real issue here is the query itself. Sorting a query by the terms a post belongs to is quite heavy operations, and if not done correctly (*no offen...
212,490
<p>I recently had a system crash and had to reinstall WordPress with my backup files.</p> <p>In the JavaScript log I began throwing errors pertaining to the domain and realized I was still using the remote servers URL. So, I read the <em>Changing the Site URL</em> article in the WP Codex and added the following two li...
[ { "answer_id": 212494, "author": "Aftab", "author_id": 64614, "author_profile": "https://wordpress.stackexchange.com/users/64614", "pm_score": 0, "selected": false, "text": "<p>You can go to your database and check for wp-option table.\nIn that if you will try changing the siteurl and ho...
2015/12/21
[ "https://wordpress.stackexchange.com/questions/212490", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85662/" ]
I recently had a system crash and had to reinstall WordPress with my backup files. In the JavaScript log I began throwing errors pertaining to the domain and realized I was still using the remote servers URL. So, I read the *Changing the Site URL* article in the WP Codex and added the following two lines to my `config...
Instead of renaming, set up your local web server to handle requests to that domain and modify your local hosts file to associate the domain with ip 127.0.0.1. Especially when debugging hard to find bugs you will want your enviroment to be as similar to the one of the live site. (I can do it in a not very modern vers...
212,515
<p>I've added a custom field in comment by using </p> <pre><code>function comment_label($fields){ unset( $fields['url'] ); $fields['rate'] = '&lt;p class="comment_form_rate" id="rate_recipe"&gt; &lt;span class="star_rating"&gt; &lt;input class="star star-5" id="star-5" type="rad...
[ { "answer_id": 212526, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 1, "selected": false, "text": "<p>I'm not sure I fully understand your question, but to add some HTML (just <em>over</em> or <em>under</em> the...
2015/12/21
[ "https://wordpress.stackexchange.com/questions/212515", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84319/" ]
I've added a custom field in comment by using ``` function comment_label($fields){ unset( $fields['url'] ); $fields['rate'] = '<p class="comment_form_rate" id="rate_recipe"> <span class="star_rating"> <input class="star star-5" id="star-5" type="radio" name="rate" value="5"/> ...
I'm not sure I fully understand your question, but to add some HTML (just *over* or *under* the submit field) that is visible to both *logged-in* and *logged-out* users, you can try the following: ``` add_filter( 'comment_form_submit_field', function( $submit_field ) { //----------------------------------- // ...
212,519
<p>I've used Advanced Custom Fields to create custom fields for Competition name, answers etc. I've made a custom post type for competitions as shown on the image and I used Wordpress functions.php to create the columns from my custom fields values. </p> <p>I'm trying to get a "Filter by"-dropdown box with the competi...
[ { "answer_id": 212527, "author": "David Gard", "author_id": 10097, "author_profile": "https://wordpress.stackexchange.com/users/10097", "pm_score": 4, "selected": false, "text": "<p>The <strong>restrict_manage_posts</strong> action triggers the <code>add_extra_tablenav()</code> function,...
2015/12/21
[ "https://wordpress.stackexchange.com/questions/212519", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85674/" ]
I've used Advanced Custom Fields to create custom fields for Competition name, answers etc. I've made a custom post type for competitions as shown on the image and I used Wordpress functions.php to create the columns from my custom fields values. I'm trying to get a "Filter by"-dropdown box with the competitions diff...
And for displaying result for Filter then try this code ``` add_filter( 'parse_query', 'prefix_parse_filter' ); function prefix_parse_filter($query) { global $pagenow; $current_page = isset( $_GET['post_type'] ) ? $_GET['post_type'] : ''; if ( is_admin() && 'competition' == $current_page && 'edit...
212,553
<p>Hello there for a custom post type "organizations" I have about 5000 posts which have to be shown in a list with link within one page.</p> <p>However WP_Query just crashes (without PHP timeout just after 4 seconds on the server). Is this a WordPress problem? If so, why do they limit it? Or is it definitly a server ...
[ { "answer_id": 212568, "author": "andrewdcato", "author_id": 55012, "author_profile": "https://wordpress.stackexchange.com/users/55012", "pm_score": 1, "selected": false, "text": "<p>You're probably hitting your DB server's memory limits whenever you're running the query. </p>\n\n<p>Why ...
2015/12/21
[ "https://wordpress.stackexchange.com/questions/212553", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12035/" ]
Hello there for a custom post type "organizations" I have about 5000 posts which have to be shown in a list with link within one page. However WP\_Query just crashes (without PHP timeout just after 4 seconds on the server). Is this a WordPress problem? If so, why do they limit it? Or is it definitly a server problem? ...
Querying this many posts is dangerous and you can ( and do ) take the site down. If you absolutely have to do this, you need to adjust your query to be more performant. If you're just needing the link then add `'fields' => 'ids'` to your params - this will only return the post ID and not the whole Post object. You can...
212,561
<p>I have 3 headers (header.php, header2.php, and header3.php). I want to always display header.php at the top. Below header.php, I want a second header to display depending on what category the post is. If the post is Grizzly Bears, I want header2. If the post is Peace Pipes, I want header3.</p> <p>I understand displ...
[ { "answer_id": 212562, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 0, "selected": false, "text": "<p>For all <a href=\"https://codex.wordpress.org/Category_Templates\" rel=\"nofollow\">categories</a> (<a href=\"...
2015/12/21
[ "https://wordpress.stackexchange.com/questions/212561", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73570/" ]
I have 3 headers (header.php, header2.php, and header3.php). I want to always display header.php at the top. Below header.php, I want a second header to display depending on what category the post is. If the post is Grizzly Bears, I want header2. If the post is Peace Pipes, I want header3. I understand displaying 2 he...
You can use the [has\_category()](https://codex.wordpress.org/Function_Reference/has_category) function for this: ``` if ( has_category( 'Grizzly Bears' ) ) { get_header( 'header2' ); } else if ( has_category( 'Peace Pipes' ) ) { get_header( 'header3' ); } ``` You can add the [has\_tag](https://codex.wordpress.o...
212,588
<p>Reading <a href="https://wordpress.stackexchange.com/q/23169/22728">Kaiser's query and Scribu's answer</a> I'm now in an ocean of no shore. I made a custom taxonomy, where I want to show the terms as per their hierarchy, like below:</p> <pre><code>Level 0 -- Level 1 --- Level 2 ---- Level 3 --- Level 2 ---- Level 3...
[ { "answer_id": 212592, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 1, "selected": false, "text": "<p><code>term_group</code> seemed to have never been fully developed together with the <code>alias_of</cod...
2015/12/22
[ "https://wordpress.stackexchange.com/questions/212588", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22728/" ]
Reading [Kaiser's query and Scribu's answer](https://wordpress.stackexchange.com/q/23169/22728) I'm now in an ocean of no shore. I made a custom taxonomy, where I want to show the terms as per their hierarchy, like below: ``` Level 0 -- Level 1 --- Level 2 ---- Level 3 --- Level 2 ---- Level 3 ---- Level 3 -- Level 1 ...
I solved it using simple PHP, and with the help of my colleague Mr. Afzal. My existing query was: ``` $all_terms = get_categories( array( 'taxonomy' => 'my_tax', 'show_count' => true, 'hide_empty' => false, 'orderby'...
212,597
<p>My text editor in Theme Options doesn't have font color option. How can I add that? I've searched around the web, but no luck. On regular pages and posts I can see the font color option.</p> <p>I'm using Options framework. Here's the code snippet:</p> <pre><code>$options[] = array( 'name' =&gt; __('Main te...
[ { "answer_id": 212624, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 2, "selected": false, "text": "<p>I think you mean the font color inside the TinyMCE editor. The <code>wp_editor()</code> function have the setting...
2015/12/22
[ "https://wordpress.stackexchange.com/questions/212597", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85213/" ]
My text editor in Theme Options doesn't have font color option. How can I add that? I've searched around the web, but no luck. On regular pages and posts I can see the font color option. I'm using Options framework. Here's the code snippet: ``` $options[] = array( 'name' => __('Main text block', 'options_chec...
In theme options, I had to define wp\_editor\_settings. So, just in options.php, I used: ``` //WP_editor settigs $wp_editor_settings = array( 'wpautop' => true, // Default 'textarea_rows' => 15, 'tinymce' => array( 'plugins' => 'fullscreen,wordpress,wplink, textcolor' )...
212,616
<p>i search about it on google but didn't find any thing. I want to remove my wordpress wp_posts table's unused columns, to save my database storage... </p> <p>I know if table column is empty it will not effect on my space, but maintained table can be increase my website performance!!!, currently <code>23 columns</cod...
[ { "answer_id": 212620, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>If you change the DB structure than you are effectively not running wordpress any longer, but your fork o...
2015/12/22
[ "https://wordpress.stackexchange.com/questions/212616", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85716/" ]
i search about it on google but didn't find any thing. I want to remove my wordpress wp\_posts table's unused columns, to save my database storage... I know if table column is empty it will not effect on my space, but maintained table can be increase my website performance!!!, currently `23 columns` in my wp\_posts t...
If you change the DB structure than you are effectively not running wordpress any longer, but your fork of it. This is not always a negative thing to do as long as you are aware that once you do it there is no guaranty that any plugin or theme or future wordpress version will work with your DB scheme. **TL;DR** Extre...
212,629
<p>One of the functions I'm using in my plugin is polluting the global scope with a name that could collide with another function (used in another plugin). So, I guess I should deprecate it. But how should I go about that?</p> <pre><code>function foo() { echo 'bar'; } </code></pre> <p>I'm aware of <code>_deprecat...
[ { "answer_id": 212630, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 1, "selected": false, "text": "<p>You create a new plugin and advice your users to migrate to it as the current one is EOL.</p>\n\n<p>There...
2015/12/22
[ "https://wordpress.stackexchange.com/questions/212629", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22599/" ]
One of the functions I'm using in my plugin is polluting the global scope with a name that could collide with another function (used in another plugin). So, I guess I should deprecate it. But how should I go about that? ``` function foo() { echo 'bar'; } ``` I'm aware of `_deprecate_function()` but would be grat...
In addition to the answer by @Welcher: There are some good "*graveyard*" examples in the core, where "*[functions come to die](https://github.com/WordPress/WordPress/blob/c1976fff71ad8f56ffe1e22facb9668ea6b5082b/wp-includes/deprecated.php#L11-L13)*". You could use them as guidelines, e.g. regarding the documentation....
212,645
<p>I've created the following custom post type: </p> <pre><code>/** * Register hire custom post type */ function hire() { $labels = array( 'name' =&gt; _x( 'Hire Products', 'Post Type General Name', 'fire' ), 'singular_name' =&gt; _x( 'Hire Product', 'Post Type Singular ...
[ { "answer_id": 212646, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 2, "selected": true, "text": "<p>In your second code block change </p>\n\n<pre><code>'hierarchical' =&gt; false,\n</code></pre>\...
2015/12/22
[ "https://wordpress.stackexchange.com/questions/212645", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37548/" ]
I've created the following custom post type: ``` /** * Register hire custom post type */ function hire() { $labels = array( 'name' => _x( 'Hire Products', 'Post Type General Name', 'fire' ), 'singular_name' => _x( 'Hire Product', 'Post Type Singular Name', 'fire' ), ...
In your second code block change ``` 'hierarchical' => false, ``` to ``` 'hierarchical' => true, ``` This should solve your problem :)
212,653
<p>I am creating a navigation with bootstrap in a custom WP theme. I have managed to get this result:</p> <pre><code>&lt;li id="menu-item-27" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-27"&gt;...&lt;/li&gt; </code></pre> <p>However I have already styled my navigation before transforming...
[ { "answer_id": 212657, "author": "Henry Lynx", "author_id": 85632, "author_profile": "https://wordpress.stackexchange.com/users/85632", "pm_score": 0, "selected": false, "text": "<p>Thank you @birgire I edited the walker class like this:</p>\n\n<pre><code>From: \n$id = apply_filters( 'na...
2015/12/22
[ "https://wordpress.stackexchange.com/questions/212653", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85632/" ]
I am creating a navigation with bootstrap in a custom WP theme. I have managed to get this result: ``` <li id="menu-item-27" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-27">...</li> ``` However I have already styled my navigation before transforming it to WP navigation like this: ``` <...
You could use the `nav_menu_item_id` filter like this: ``` add_filter( 'nav_menu_item_id', function( $menu_id, $item, $args, $depth ) { if( 'menu-item-27' === $menu_id ) $menu_id = 'nava'; return $menu_id; }, 10, 4 ); ``` but I this is "unstable" regarding the menu ID, if you delete and re-insert me...
212,662
<p>How to add Space between sidebar and footer widget in word press theme.In bottom of our <a href="http://www.urdustatus.com" rel="nofollow">Site</a>, I added footer and how can i increase space between sidebar and footer.Its very close and touching the each other. You can see in bottom of home page.</p>
[ { "answer_id": 212657, "author": "Henry Lynx", "author_id": 85632, "author_profile": "https://wordpress.stackexchange.com/users/85632", "pm_score": 0, "selected": false, "text": "<p>Thank you @birgire I edited the walker class like this:</p>\n\n<pre><code>From: \n$id = apply_filters( 'na...
2015/12/22
[ "https://wordpress.stackexchange.com/questions/212662", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83804/" ]
How to add Space between sidebar and footer widget in word press theme.In bottom of our [Site](http://www.urdustatus.com), I added footer and how can i increase space between sidebar and footer.Its very close and touching the each other. You can see in bottom of home page.
You could use the `nav_menu_item_id` filter like this: ``` add_filter( 'nav_menu_item_id', function( $menu_id, $item, $args, $depth ) { if( 'menu-item-27' === $menu_id ) $menu_id = 'nava'; return $menu_id; }, 10, 4 ); ``` but I this is "unstable" regarding the menu ID, if you delete and re-insert me...
212,671
<p>The following error may occur if a previous registration remains pending with a conflicting email address.</p> <blockquote> <p>That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.</p> </blockquote> <p>The re...
[ { "answer_id": 212672, "author": "here", "author_id": 28978, "author_profile": "https://wordpress.stackexchange.com/users/28978", "pm_score": 2, "selected": false, "text": "<ol>\n<li>Login as WordPress administrator</li>\n<li>Navigate to add a new user</li>\n<li>Check box to bypass email...
2015/12/22
[ "https://wordpress.stackexchange.com/questions/212671", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28978/" ]
The following error may occur if a previous registration remains pending with a conflicting email address. > > That email address has already been used. Please check your inbox for > an activation email. It will become available in a couple of days if > you do nothing. > > > The related username error looks lik...
When I add a new user with a different email address, I get the error message: That username is currently reserved but may be available in a couple of days. For me, I removed the row from the database in the table wp\_signups where user\_login equaled the username. Essentially: ``` delete from wp_signups where user_l...
212,696
<p>I have a website hosted on ASP.NET server and using wordpress to build my site. I've extended its functionalities using PHP code. At which directory do I store secure files such as (passwords and certificate.pem)?</p> <p>My server has the following structure:</p> <pre><code>-/ -/mywebsite.com -/data ...
[ { "answer_id": 212672, "author": "here", "author_id": 28978, "author_profile": "https://wordpress.stackexchange.com/users/28978", "pm_score": 2, "selected": false, "text": "<ol>\n<li>Login as WordPress administrator</li>\n<li>Navigate to add a new user</li>\n<li>Check box to bypass email...
2015/12/23
[ "https://wordpress.stackexchange.com/questions/212696", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76324/" ]
I have a website hosted on ASP.NET server and using wordpress to build my site. I've extended its functionalities using PHP code. At which directory do I store secure files such as (passwords and certificate.pem)? My server has the following structure: ``` -/ -/mywebsite.com -/data -/logs -/ww...
When I add a new user with a different email address, I get the error message: That username is currently reserved but may be available in a couple of days. For me, I removed the row from the database in the table wp\_signups where user\_login equaled the username. Essentially: ``` delete from wp_signups where user_l...
212,721
<p>I'm trying that :</p> <pre><code>&lt;?php $phone = get_user_meta($current_user-&gt;ID,'phone_number',true); echo $phone; ?&gt; </code></pre> <p>But it's not working</p>
[ { "answer_id": 212723, "author": "Mohamed Rihan", "author_id": 85768, "author_profile": "https://wordpress.stackexchange.com/users/85768", "pm_score": 2, "selected": false, "text": "<pre><code>&lt;?php\n // number 9 will be user ID\n $all_meta_for_user = get_user_meta( 9 );\n print_r(...
2015/12/23
[ "https://wordpress.stackexchange.com/questions/212721", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74388/" ]
I'm trying that : ``` <?php $phone = get_user_meta($current_user->ID,'phone_number',true); echo $phone; ?> ``` But it's not working
``` <?php // number 9 will be user ID $all_meta_for_user = get_user_meta( 9 ); print_r( $all_meta_for_user ); // find the key that you want Array ( [first_name] => Array ( [0] => Tom ) [last_name] => Array ( [0] => Auger) [nickname] => Array ( [0] => tomauger ) [description] => etc.... ) //...
212,727
<p>I have a function in functions.php which automatically generates a page. It doesn't check to see if there is already a page with the same title at the moment.</p> <p>The function is started with:</p> <pre><code>add_action( 'after_setup_theme', 'add_pages' ); </code></pre> <p><strong>edit</strong>: I only want thi...
[ { "answer_id": 212729, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p><code>after_setup_theme</code> is not the hook you are looking for - you want <a href=\"https://codex.word...
2015/12/23
[ "https://wordpress.stackexchange.com/questions/212727", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82394/" ]
I have a function in functions.php which automatically generates a page. It doesn't check to see if there is already a page with the same title at the moment. The function is started with: ``` add_action( 'after_setup_theme', 'add_pages' ); ``` **edit**: I only want this to run **once** every page load. I think it...
`after_setup_theme` is not the hook you are looking for - you want [`after_switch_theme`](https://codex.wordpress.org/Plugin_API/Action_Reference/after_switch_theme) - this hook will only run once, when your theme is initally activated.
212,744
<p>I have <code>archive-page.php</code>, where my custom posts are displayed. I want to put a link on my image, <code>&lt;a href="" alt=""&gt;&lt;img src="" alt=""&gt;&lt;/a&gt;</code>, which leads to <code>single-page.php</code> for that particular post or product. How can I do that? </p> <p>I have tried this:</p> <...
[ { "answer_id": 212758, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p><a href=\"https://developer.wordpress.org/reference/functions/get_the_permalink/\" rel=\"nofollow\"><code>ge...
2015/12/23
[ "https://wordpress.stackexchange.com/questions/212744", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85790/" ]
I have `archive-page.php`, where my custom posts are displayed. I want to put a link on my image, `<a href="" alt=""><img src="" alt=""></a>`, which leads to `single-page.php` for that particular post or product. How can I do that? I have tried this: ``` <a href= "<?php get_the_permalink ();?>" alt=""><img src="" al...
[`get_the_permalink()`](https://developer.wordpress.org/reference/functions/get_the_permalink/) doesn't `echo` anything. It just returns a string so that you can further manipulate it. You need [`the_permalink()`](https://developer.wordpress.org/reference/functions/the_permalink/) instead, which will `echo` the link....
212,784
<p>I'm using a security plugin that keep sending me emails:</p> <p>"A lockdown event has occurred due to too many failed login attempts or invalid username: Username: Admin IP Address: 195.154.243.31</p> <p>IP Range: 195.154.243.*</p> <p>Log into your site's WordPress administration panel to see the duration of the ...
[ { "answer_id": 212810, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 3, "selected": false, "text": "<p>Under <strong>Custom Base</strong> where you have used <code>/shop/%product_cat%</code> needs to be rep...
2015/12/23
[ "https://wordpress.stackexchange.com/questions/212784", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41168/" ]
I'm using a security plugin that keep sending me emails: "A lockdown event has occurred due to too many failed login attempts or invalid username: Username: Admin IP Address: 195.154.243.31 IP Range: 195.154.243.\* Log into your site's WordPress administration panel to see the duration of the lockout or to unlock th...
Under **Custom Base** where you have used `/shop/%product_cat%` needs to be replaced with `/shop/%product-category%` Please see screenshot below: [![enter image description here](https://i.stack.imgur.com/6v9bL.png)](https://i.stack.imgur.com/6v9bL.png)
212,808
<p>I need to display on a page the list of emails of the users who already posted once on my site. </p> <p>I have this snippet of code:</p> <pre><code>global $wpdb; $min_posts = 1; $author_ids = $wpdb-&gt;get_col("SELECT `post_author` FROM (SELECT `post_author`, COUNT(*) AS `count` FROM {$wpdb-&gt;posts} ...
[ { "answer_id": 212811, "author": "WPTC-Troop", "author_id": 82793, "author_profile": "https://wordpress.stackexchange.com/users/82793", "pm_score": 2, "selected": false, "text": "<p>If your query is correct and returns list of <code>user_id</code> then you can run the below</p>\n\n<pre><...
2015/12/24
[ "https://wordpress.stackexchange.com/questions/212808", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68671/" ]
I need to display on a page the list of emails of the users who already posted once on my site. I have this snippet of code: ``` global $wpdb; $min_posts = 1; $author_ids = $wpdb->get_col("SELECT `post_author` FROM (SELECT `post_author`, COUNT(*) AS `count` FROM {$wpdb->posts} WHERE `post_status`='publi...
You can place following code in your functions.php file & use the shortcode `[myblogwriters min_posts="1"]` anywhere in the page/post content and can also change the min\_posts value :) ``` function show_min_one_post_writers($atts){ global $wpdb; $attrs = shortcode_atts( array( 'min_posts' => '' ...
212,812
<p>I am currently creating a post programmatically, with the <code>wp_insert_post</code> function but am having some difficulties when adding two variables into the content part of the array. I would like to add <code>$_POST['poll-description']</code> as well as the code I am currently using <code>'[poll id=' . $latest...
[ { "answer_id": 212811, "author": "WPTC-Troop", "author_id": 82793, "author_profile": "https://wordpress.stackexchange.com/users/82793", "pm_score": 2, "selected": false, "text": "<p>If your query is correct and returns list of <code>user_id</code> then you can run the below</p>\n\n<pre><...
2015/12/24
[ "https://wordpress.stackexchange.com/questions/212812", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84655/" ]
I am currently creating a post programmatically, with the `wp_insert_post` function but am having some difficulties when adding two variables into the content part of the array. I would like to add `$_POST['poll-description']` as well as the code I am currently using `'[poll id=' . $latest_pollid . ']'` to be the post ...
You can place following code in your functions.php file & use the shortcode `[myblogwriters min_posts="1"]` anywhere in the page/post content and can also change the min\_posts value :) ``` function show_min_one_post_writers($atts){ global $wpdb; $attrs = shortcode_atts( array( 'min_posts' => '' ...
212,833
<p>I understand that each page is assigned its own class such as .page-id-22 &amp; I can use that to assign a background image to it using the stylesheet but I've seen a theme that adds a control to the admin section of the page itself, which is what I'd like to accomplish. </p> <p>Basically, the user would be able t...
[ { "answer_id": 212834, "author": "Arsalan", "author_id": 85844, "author_profile": "https://wordpress.stackexchange.com/users/85844", "pm_score": 1, "selected": false, "text": "<p>It can be done with a custom field and the CSS should be changed to <code>.php</code> file:</p>\n\n<pre><code...
2015/12/24
[ "https://wordpress.stackexchange.com/questions/212833", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76434/" ]
I understand that each page is assigned its own class such as .page-id-22 & I can use that to assign a background image to it using the stylesheet but I've seen a theme that adds a control to the admin section of the page itself, which is what I'd like to accomplish. Basically, the user would be able to click & uploa...
It can be done with a custom field and the CSS should be changed to `.php` file: ``` $image = get_post_meta( $post->ID, "ImagePathFromCustomField", true ); if ( $image != '' ) { ?> <style type="text/css"> .bg-image { background-image: url(<?php echo $image; ?>); background-re...
212,845
<p>I'm looking to add some client-side (JavaScript) events to the post edit screen of wp-admin (<code>post.php?action=edit</code>). I wish to fire events when the user selects a new featured image and a different event when they remove the featured image.</p> <p>So far I've been able to find <a href="https://wordpress...
[ { "answer_id": 213192, "author": "Jordan Foreman", "author_id": 7222, "author_profile": "https://wordpress.stackexchange.com/users/7222", "pm_score": 3, "selected": true, "text": "<p>So I was able to achieve what I wanted, albeit in a bit of a roundabout way. I'll share my solution here ...
2015/12/24
[ "https://wordpress.stackexchange.com/questions/212845", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7222/" ]
I'm looking to add some client-side (JavaScript) events to the post edit screen of wp-admin (`post.php?action=edit`). I wish to fire events when the user selects a new featured image and a different event when they remove the featured image. So far I've been able to find [this wordpress.se answer](https://wordpress.st...
So I was able to achieve what I wanted, albeit in a bit of a roundabout way. I'll share my solution here in case anyone stumbles across this post looking to do something similar. Rather than adding an event listener to some unset event (that doesn't exist) on the object returned by `wp.media.featuredImage.frame()`, I ...
212,911
<p>Don't ask why. Image below pretty much ask what I'm looking to achieve:</p> <p><img src="https://s19.postimg.org/g73zya4ab/how_to_remove_link_to_existing_content.png" alt="screenshot"></p>
[ { "answer_id": 212919, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 2, "selected": false, "text": "<p>Place this code in your functions.php file</p>\n\n<pre><code>add_action( 'admin_print_scripts-post.php'...
2015/12/26
[ "https://wordpress.stackexchange.com/questions/212911", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81346/" ]
Don't ask why. Image below pretty much ask what I'm looking to achieve: ![screenshot](https://s19.postimg.org/g73zya4ab/how_to_remove_link_to_existing_content.png)
We could hook into the `after_wp_tiny_mce` with some CSS to hide it, if the `wplink` editor plugin is loaded. **Example:** ``` add_action( 'after_wp_tiny_mce', function( $settings ) { // Check for the 'wplink' editor plugin if( isset( $settings['content']['plugins'] ) && false !== strpos( $settin...
212,949
<p>I have an issue I can't solve. When my website loads it seems to be grabbing an old version of our customized CSS and using that to override all our new CSS. But that old version no longer exists. I have no idea where it's coming from.</p> <p>If you look at our page source here: <a href="http://view-source:http://w...
[ { "answer_id": 212919, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 2, "selected": false, "text": "<p>Place this code in your functions.php file</p>\n\n<pre><code>add_action( 'admin_print_scripts-post.php'...
2015/12/26
[ "https://wordpress.stackexchange.com/questions/212949", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73388/" ]
I have an issue I can't solve. When my website loads it seems to be grabbing an old version of our customized CSS and using that to override all our new CSS. But that old version no longer exists. I have no idea where it's coming from. If you look at our page source here: [view-source:http://www.universaltheosophy.com...
We could hook into the `after_wp_tiny_mce` with some CSS to hide it, if the `wplink` editor plugin is loaded. **Example:** ``` add_action( 'after_wp_tiny_mce', function( $settings ) { // Check for the 'wplink' editor plugin if( isset( $settings['content']['plugins'] ) && false !== strpos( $settin...
212,951
<p>I have WordPress site 1 on domain1.com.</p> <p>I copied WordPress site 1 to WordPress site 2 on domain2.com (database and files).</p> <p>Both WordPress sites have their independent database names/usernames/passwords and separate FTP credentials/directories.</p> <p>Both WordPress sites are on the same server (loca...
[ { "answer_id": 212919, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 2, "selected": false, "text": "<p>Place this code in your functions.php file</p>\n\n<pre><code>add_action( 'admin_print_scripts-post.php'...
2015/12/27
[ "https://wordpress.stackexchange.com/questions/212951", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20223/" ]
I have WordPress site 1 on domain1.com. I copied WordPress site 1 to WordPress site 2 on domain2.com (database and files). Both WordPress sites have their independent database names/usernames/passwords and separate FTP credentials/directories. Both WordPress sites are on the same server (localhost). When I delete a...
We could hook into the `after_wp_tiny_mce` with some CSS to hide it, if the `wplink` editor plugin is loaded. **Example:** ``` add_action( 'after_wp_tiny_mce', function( $settings ) { // Check for the 'wplink' editor plugin if( isset( $settings['content']['plugins'] ) && false !== strpos( $settin...
212,953
<p>I have a custom post meta box that I want to put in the right sidebar. When I set the priority to <code>high</code> it appears in the number 1 spot in sidebar above everything. If I set to <code>core</code> it appear at the bottom of right sidebar.</p> <p>My desired position is in the number 2 spot in the right s...
[ { "answer_id": 212969, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 3, "selected": false, "text": "<p>Still if its something like client requirement then below is somewhat <strong>hack</strong> sort of sol...
2015/12/27
[ "https://wordpress.stackexchange.com/questions/212953", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8668/" ]
I have a custom post meta box that I want to put in the right sidebar. When I set the priority to `high` it appears in the number 1 spot in sidebar above everything. If I set to `core` it appear at the bottom of right sidebar. My desired position is in the number 2 spot in the right sidebar. Right below the publish me...
Still if its something like client requirement then below is somewhat **hack** sort of solution. Add this code to your `add_meta_box()` function. For the sake of understanding, below I have provided complete function but you will need to use selective code :-) Do let me know how it goes. ``` function myplugin_add_meta...
212,978
<p>I am following <a href="http://www.wpbeginner.com/wp-tutorials/how-to-install-and-setup-wordpress-multisite-network/" rel="noreferrer">This tutorial</a> to Create a Network of WordPress Sites . After adding</p> <pre><code>/* Multisite */ define( 'WP_ALLOW_MULTISITE', true ); </code></pre> <p>to my <code>wp-config.p...
[ { "answer_id": 212988, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": false, "text": "<p>You can't use port 8080. I have no idea why as that is a fairly common port for a web server. However, <a hr...
2015/12/27
[ "https://wordpress.stackexchange.com/questions/212978", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84928/" ]
I am following [This tutorial](http://www.wpbeginner.com/wp-tutorials/how-to-install-and-setup-wordpress-multisite-network/) to Create a Network of WordPress Sites . After adding ``` /* Multisite */ define( 'WP_ALLOW_MULTISITE', true ); ``` to my `wp-config.php` file and when I start to configure multisite network ...
**Warning: This is just a test for dev installs and not production sites** I was curious to see if there was a workaround, for those who want to develope multisites on their dev installs but on different ports than `:80` and `:443`, e.g. `:8080`. I only found this [blog post](http://benohead.com/wordpress-running-mu...
212,979
<p>I'm developing a plugin, and, each time a user uploads an image in the media library, I'd like to modify metadata of this image. I have tried with the hook "wp_handle_upload_prefilter" but it seems this method doesn't work.</p>
[ { "answer_id": 212988, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": false, "text": "<p>You can't use port 8080. I have no idea why as that is a fairly common port for a web server. However, <a hr...
2015/12/27
[ "https://wordpress.stackexchange.com/questions/212979", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85931/" ]
I'm developing a plugin, and, each time a user uploads an image in the media library, I'd like to modify metadata of this image. I have tried with the hook "wp\_handle\_upload\_prefilter" but it seems this method doesn't work.
**Warning: This is just a test for dev installs and not production sites** I was curious to see if there was a workaround, for those who want to develope multisites on their dev installs but on different ports than `:80` and `:443`, e.g. `:8080`. I only found this [blog post](http://benohead.com/wordpress-running-mu...
212,989
<p>I develop my custom widget with setting where I can set up custom color for the widget. I use this code to initialize <code>wpColorPicker</code> instead of default text input in <code>form()</code> method of Widget class:</p> <pre><code>jQuery(document).ready(function($){ $('#&lt;?php echo $this-&gt;get_field_i...
[ { "answer_id": 212988, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": false, "text": "<p>You can't use port 8080. I have no idea why as that is a fairly common port for a web server. However, <a hr...
2015/12/27
[ "https://wordpress.stackexchange.com/questions/212989", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/46077/" ]
I develop my custom widget with setting where I can set up custom color for the widget. I use this code to initialize `wpColorPicker` instead of default text input in `form()` method of Widget class: ``` jQuery(document).ready(function($){ $('#<?php echo $this->get_field_id( 'bg_color_1' ); ?>').wpColorPicker(); }...
**Warning: This is just a test for dev installs and not production sites** I was curious to see if there was a workaround, for those who want to develope multisites on their dev installs but on different ports than `:80` and `:443`, e.g. `:8080`. I only found this [blog post](http://benohead.com/wordpress-running-mu...
212,996
<p>On attachment page I would like to display all images belonging to the parent post, so there should a thumbnail gallery. Using... </p> <pre><code>$parent = get_post_field( 'post_parent', get_the_ID() ); $gallery = get_post_gallery( $parent, false ); </code></pre> <p>...gives this which is kinda weird to use. Why ...
[ { "answer_id": 212988, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": false, "text": "<p>You can't use port 8080. I have no idea why as that is a fairly common port for a web server. However, <a hr...
2015/12/27
[ "https://wordpress.stackexchange.com/questions/212996", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85935/" ]
On attachment page I would like to display all images belonging to the parent post, so there should a thumbnail gallery. Using... ``` $parent = get_post_field( 'post_parent', get_the_ID() ); $gallery = get_post_gallery( $parent, false ); ``` ...gives this which is kinda weird to use. Why are ids seperatated from s...
**Warning: This is just a test for dev installs and not production sites** I was curious to see if there was a workaround, for those who want to develope multisites on their dev installs but on different ports than `:80` and `:443`, e.g. `:8080`. I only found this [blog post](http://benohead.com/wordpress-running-mu...
213,006
<p>I am trying to use the WordPress Rest Api with authentication to get more data from the API. I have installed the Oauth plugin, rest-api plugin, and gotten API credentials from WP-CLI.</p> <p>I have figured out how to access data without authorization. This works:</p> <pre><code>// set our end point $domain = "h...
[ { "answer_id": 223789, "author": "juz", "author_id": 68207, "author_profile": "https://wordpress.stackexchange.com/users/68207", "pm_score": 0, "selected": false, "text": "<p>Update: From what I've read, you need to do multiple curls to get the access_token, which you then use to do the ...
2015/12/27
[ "https://wordpress.stackexchange.com/questions/213006", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49017/" ]
I am trying to use the WordPress Rest Api with authentication to get more data from the API. I have installed the Oauth plugin, rest-api plugin, and gotten API credentials from WP-CLI. I have figured out how to access data without authorization. This works: ``` // set our end point $domain = "http://localhost/wp-api"...
Let's go step by step here. Looks like you're trying to use OAuth just for authentication, ***but before you can do so you need to get the Access Token*** which will be used to authenticate when you make your API calls. Because this is using OAuth version 1, in order to obtain the **Access Token** you must do the fol...
213,016
<p>I want to serve a specific Wordpress page for multiple urls. Basically I want to point all the urls in a specific format to a known page:</p> <pre><code>/some-prefix-* =&gt; /target-page </code></pre> <p>And accessing <code>/some-prefix-and-here-something</code> it should load <code>/target-page</code>.</p> <p>Ho...
[ { "answer_id": 213017, "author": "luukvhoudt", "author_id": 44637, "author_profile": "https://wordpress.stackexchange.com/users/44637", "pm_score": 0, "selected": false, "text": "<p>Create a hook to init and wp_redirect when the current post's slug starts with your prefix.</p>\n\n<pre><c...
2015/12/28
[ "https://wordpress.stackexchange.com/questions/213016", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44849/" ]
I want to serve a specific Wordpress page for multiple urls. Basically I want to point all the urls in a specific format to a known page: ``` /some-prefix-* => /target-page ``` And accessing `/some-prefix-and-here-something` it should load `/target-page`. How to do this? Note I do *not* want to redirect the user b...
You can use [`template_include`](https://codex.wordpress.org/Plugin_API/Filter_Reference/template_include), but before you hook to this filter you must do the following steps: 1. Create page template. e.g: `page-target.php` ``` <?php /** * Template Name: Page Target */ ... ``` 2. Manually query the contents of `ta...
213,043
<p>How to determine if the current file is loaded in a plugin or in a theme? A boolean PHP function.</p>
[ { "answer_id": 213044, "author": "Andrei Surdu", "author_id": 31111, "author_profile": "https://wordpress.stackexchange.com/users/31111", "pm_score": -1, "selected": true, "text": "<p><strong>1. The function:</strong></p>\n\n<pre><code>function wp543_is_plugin(){\n return strpos( str_...
2015/12/28
[ "https://wordpress.stackexchange.com/questions/213043", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31111/" ]
How to determine if the current file is loaded in a plugin or in a theme? A boolean PHP function.
**1. The function:** ``` function wp543_is_plugin(){ return strpos( str_replace("\\", "/", plugin_dir_path( $file ) ) , str_replace("\\", "/", WP_PLUGIN_DIR) ) !== false; } ``` **2. Call the function:** ``` wp543_is_plugin(); ``` Calling this function will return `true` if the current file is loaded in a plug...
213,186
<p>I just started to work with Wordpress (Theme Development) and due to awesome functions like bloginfo('description') and others my static homepage looks a lot like a regular site, but editable with the Wordpress Dashboard.</p> <p>But now, I want to put more information on my homepage which I can edit through the das...
[ { "answer_id": 213044, "author": "Andrei Surdu", "author_id": 31111, "author_profile": "https://wordpress.stackexchange.com/users/31111", "pm_score": -1, "selected": true, "text": "<p><strong>1. The function:</strong></p>\n\n<pre><code>function wp543_is_plugin(){\n return strpos( str_...
2015/12/29
[ "https://wordpress.stackexchange.com/questions/213186", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86005/" ]
I just started to work with Wordpress (Theme Development) and due to awesome functions like bloginfo('description') and others my static homepage looks a lot like a regular site, but editable with the Wordpress Dashboard. But now, I want to put more information on my homepage which I can edit through the dashboard. I ...
**1. The function:** ``` function wp543_is_plugin(){ return strpos( str_replace("\\", "/", plugin_dir_path( $file ) ) , str_replace("\\", "/", WP_PLUGIN_DIR) ) !== false; } ``` **2. Call the function:** ``` wp543_is_plugin(); ``` Calling this function will return `true` if the current file is loaded in a plug...
213,191
<p>Code in my funcitons.php</p> <pre><code>function custom_thumbs() { add_image_size( 'cover-size', 1600, 450, true ); } add_action( 'after_setup_theme', 'custom_thumbs' ); </code></pre> <p>Usage:</p> <p><code>echo the_post_thumbnail($post-&gt;ID,'cover-size');</code></p> <p>but this is the result:</p> <pre><...
[ { "answer_id": 213194, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 3, "selected": true, "text": "<p>You may need to regenerate your images. There are plugins to accomplish this or re-upload your image and see if...
2015/12/29
[ "https://wordpress.stackexchange.com/questions/213191", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3435/" ]
Code in my funcitons.php ``` function custom_thumbs() { add_image_size( 'cover-size', 1600, 450, true ); } add_action( 'after_setup_theme', 'custom_thumbs' ); ``` Usage: `echo the_post_thumbnail($post->ID,'cover-size');` but this is the result: ``` <img width="3648" height="2736" src="http://localhost/sonru/...
You may need to regenerate your images. There are plugins to accomplish this or re-upload your image and see if the size doesn't take affect. It won't happen automatically to existing files. First, check your uploads directory to see if the files exists that way you know they are being generated. Then try another fun...
213,219
<p>I have a filter for the Gallery Shortcode where I grab IDs for images used in a post and using the IDs I grab their meta data. Now I need a way to use the <code>$copyright</code> variable in a filter for grabbing <code>post_content</code> so I can echo the content of that variable.</p> <p>Is there a way to reuse a ...
[ { "answer_id": 213223, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 4, "selected": true, "text": "<p>This is probably a good case for a global variable. Just make sure it is set to an array before you add to it a...
2015/12/29
[ "https://wordpress.stackexchange.com/questions/213219", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85935/" ]
I have a filter for the Gallery Shortcode where I grab IDs for images used in a post and using the IDs I grab their meta data. Now I need a way to use the `$copyright` variable in a filter for grabbing `post_content` so I can echo the content of that variable. Is there a way to reuse a variable in different filter or ...
This is probably a good case for a global variable. Just make sure it is set to an array before you add to it and also when to attempt to output the content. Convert the array to a string before adding to content. Also, make sure the meta data exists before adding to the array -- that way you're not adding empty copyr...
213,224
<p>Unfortunately, <code>the_posts_navigation()</code> function is not working for me. When I click on 'Older Posts' it's showing '404 page I don't know why my code is not working. </p> <p>Here is the code -</p> <pre><code>&lt;div class="row"&gt; &lt;?php while ( have_posts() ) : the_post(); ?&gt; &lt;div cl...
[ { "answer_id": 213225, "author": "Aniket Bhawkar", "author_id": 85953, "author_profile": "https://wordpress.stackexchange.com/users/85953", "pm_score": 1, "selected": false, "text": "<p>This function uses <code>get_the_posts_pagination()</code> which uses the GLOBAL <code>$wp_query</code...
2015/12/29
[ "https://wordpress.stackexchange.com/questions/213224", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81042/" ]
Unfortunately, `the_posts_navigation()` function is not working for me. When I click on 'Older Posts' it's showing '404 page I don't know why my code is not working. Here is the code - ``` <div class="row"> <?php while ( have_posts() ) : the_post(); ?> <div class="col-md-3 thumbnailu"> <a class="thm...
This function uses `get_the_posts_pagination()` which uses the GLOBAL `$wp_query` to setup the `paginate_links()` function, so I believe that doesn't work for `get_posts`. Try use the function `paginate_links()` by itself or the function `posts_nav_link()`
213,266
<p>I want to be able to login to wordpress through a customized function, no dashboard etc showing. I just want the user being logged in and then I want to handle stuff like customized forms, update stuff into db etc for a specific logged in user.</p> <p>I thought <code>wp_signon</code>() looked like a good alternativ...
[ { "answer_id": 213269, "author": "bestprogrammerintheworld", "author_id": 38848, "author_profile": "https://wordpress.stackexchange.com/users/38848", "pm_score": 0, "selected": false, "text": "<p>I found an answer to this myself... if someone stumbles upon the same issue. I installed a p...
2015/12/30
[ "https://wordpress.stackexchange.com/questions/213266", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38848/" ]
I want to be able to login to wordpress through a customized function, no dashboard etc showing. I just want the user being logged in and then I want to handle stuff like customized forms, update stuff into db etc for a specific logged in user. I thought `wp_signon`() looked like a good alternative, but it opens up th...
I assume you're referring to the black bar that may run across the top of a web page. That's called the 'Toolbar'. However, an earlier version of it was called the 'Admin Bar', and that name is still used in the code. To never display it, add this to `functions.php` ``` function my_function_admin_bar(){ return...
213,272
<p>Basically, I have this line of code:</p> <pre><code>&lt;?php echo do_shortcode('[O_U user_name="operator" blocked_message="This page is restricted for guests."] **Content Goes here** [/O_U]'); ?&gt; </code></pre> <p>Now, inside Content Goes here I use regular HTML to create my content. But, now, I need to add so...
[ { "answer_id": 213269, "author": "bestprogrammerintheworld", "author_id": 38848, "author_profile": "https://wordpress.stackexchange.com/users/38848", "pm_score": 0, "selected": false, "text": "<p>I found an answer to this myself... if someone stumbles upon the same issue. I installed a p...
2015/12/30
[ "https://wordpress.stackexchange.com/questions/213272", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85213/" ]
Basically, I have this line of code: ``` <?php echo do_shortcode('[O_U user_name="operator" blocked_message="This page is restricted for guests."] **Content Goes here** [/O_U]'); ?> ``` Now, inside Content Goes here I use regular HTML to create my content. But, now, I need to add some php inside that HTML. Right...
I assume you're referring to the black bar that may run across the top of a web page. That's called the 'Toolbar'. However, an earlier version of it was called the 'Admin Bar', and that name is still used in the code. To never display it, add this to `functions.php` ``` function my_function_admin_bar(){ return...
213,280
<p>I am trying to create some custom database table on wordpress plugin activation with php OOP concept. But no database is created after plugin activation. Here is my code</p> <pre><code>class wpe_Main { public function __construct() { register_activation_hook( __FILE__, array($this,'create_wpe_enquiry_ta...
[ { "answer_id": 213285, "author": "WPTC-Troop", "author_id": 82793, "author_profile": "https://wordpress.stackexchange.com/users/82793", "pm_score": 2, "selected": true, "text": "<p>Is your class <code>wpe_Main</code> file is the mail file of the plugin?</p>\n\n<p>Because <code>__FILE__</...
2015/12/30
[ "https://wordpress.stackexchange.com/questions/213280", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86047/" ]
I am trying to create some custom database table on wordpress plugin activation with php OOP concept. But no database is created after plugin activation. Here is my code ``` class wpe_Main { public function __construct() { register_activation_hook( __FILE__, array($this,'create_wpe_enquiry_table')); } ...
Is your class `wpe_Main` file is the mail file of the plugin? Because `__FILE__` should return main plugin file path. So if your `wpe_Main` class is in a sub directory then the register activation won't work. If you want you can try like below to avoid `__FILE__` confusion Plugin path: `wp-content/plugin/sampleplugi...
213,300
<p>I'm writing a WP CLI command which creates and updates taxonomies using <code>wp_insert_term</code>. Actions on my custom taxonomies are not accepted since they don't show up as registered.</p> <p>The wp-cli included <a href="https://github.com/wp-cli/wp-cli/blob/2ad47776f13cac8cf14c3ba669036b378f879cf1/php/command...
[ { "answer_id": 213285, "author": "WPTC-Troop", "author_id": 82793, "author_profile": "https://wordpress.stackexchange.com/users/82793", "pm_score": 2, "selected": true, "text": "<p>Is your class <code>wpe_Main</code> file is the mail file of the plugin?</p>\n\n<p>Because <code>__FILE__</...
2015/12/30
[ "https://wordpress.stackexchange.com/questions/213300", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/737/" ]
I'm writing a WP CLI command which creates and updates taxonomies using `wp_insert_term`. Actions on my custom taxonomies are not accepted since they don't show up as registered. The wp-cli included [Term\_Command](https://github.com/wp-cli/wp-cli/blob/2ad47776f13cac8cf14c3ba669036b378f879cf1/php/commands/term.php) it...
Is your class `wpe_Main` file is the mail file of the plugin? Because `__FILE__` should return main plugin file path. So if your `wpe_Main` class is in a sub directory then the register activation won't work. If you want you can try like below to avoid `__FILE__` confusion Plugin path: `wp-content/plugin/sampleplugi...
213,324
<p>I have a Wordpress menu that I am using as a Hamburger menu for smaller mobile devices. Since there really isn't a "hover" event for touch devices, I have changed the main menu items to show their corresponding sub menus on "click" (or "touch"). The problem is that I can't make the main menu items clickable. Al...
[ { "answer_id": 213327, "author": "N00b", "author_id": 80903, "author_profile": "https://wordpress.stackexchange.com/users/80903", "pm_score": 1, "selected": false, "text": "<p>You could solve this with other nasty hacks but here's <em>kind of</em> WordPress way:</p>\n\n<p><strong>In your...
2015/12/30
[ "https://wordpress.stackexchange.com/questions/213324", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85560/" ]
I have a Wordpress menu that I am using as a Hamburger menu for smaller mobile devices. Since there really isn't a "hover" event for touch devices, I have changed the main menu items to show their corresponding sub menus on "click" (or "touch"). The problem is that I can't make the main menu items clickable. Also, I do...
You could solve this with other nasty hacks but here's *kind of* WordPress way: **In your `header.php`** ``` <?php // User is not using mobile if( ! wp_is_mobile() ) { wp_nav_menu(); // Your "original menu" } // User is using mobile else if( wp_is_mobile() ) { wp_nav_menu(); // Your another menu that on...
213,342
<p>I have tried below script to load jQuery UI Autocomplete in theme. But it doesn't load their related scripts. How should I call it to work.</p> <pre><code>wp_enqueue_script('jquery-ui-autocomplete'); </code></pre> <p>I think below scripts are jQuery UI related scripts for autocomplete but it's doesn't load.</p> <...
[ { "answer_id": 213327, "author": "N00b", "author_id": 80903, "author_profile": "https://wordpress.stackexchange.com/users/80903", "pm_score": 1, "selected": false, "text": "<p>You could solve this with other nasty hacks but here's <em>kind of</em> WordPress way:</p>\n\n<p><strong>In your...
2015/12/31
[ "https://wordpress.stackexchange.com/questions/213342", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85145/" ]
I have tried below script to load jQuery UI Autocomplete in theme. But it doesn't load their related scripts. How should I call it to work. ``` wp_enqueue_script('jquery-ui-autocomplete'); ``` I think below scripts are jQuery UI related scripts for autocomplete but it's doesn't load. ``` <script type='text/javascri...
You could solve this with other nasty hacks but here's *kind of* WordPress way: **In your `header.php`** ``` <?php // User is not using mobile if( ! wp_is_mobile() ) { wp_nav_menu(); // Your "original menu" } // User is using mobile else if( wp_is_mobile() ) { wp_nav_menu(); // Your another menu that on...
213,354
<p>I'm trying to update the Advanced Custom Fields meta value associated with a custom taxonomy term</p> <pre><code>$term_status = wp_update_term( $rate_id, 'rate', $term_data ); $term_id = $term_status['term_taxonomy_id']; update_field( 'field_56829855eebc9',$rate_daily,$term_id ); </code></pre> <p>However, I'm no...
[ { "answer_id": 213358, "author": "Seen Dru", "author_id": 85739, "author_profile": "https://wordpress.stackexchange.com/users/85739", "pm_score": 4, "selected": true, "text": "<p>I figured it out somehow.. </p>\n\n<p>Syntax of <code>update_field()</code>:</p>\n\n<p><code>update_field($fi...
2015/12/31
[ "https://wordpress.stackexchange.com/questions/213354", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85739/" ]
I'm trying to update the Advanced Custom Fields meta value associated with a custom taxonomy term ``` $term_status = wp_update_term( $rate_id, 'rate', $term_data ); $term_id = $term_status['term_taxonomy_id']; update_field( 'field_56829855eebc9',$rate_daily,$term_id ); ``` However, I'm not getting the field update...
I figured it out somehow.. Syntax of `update_field()`: `update_field($field_key, $value, $post_id)` MY MISTAKE: I was using the wrong parameter for the `$post_id` which i thought was the Term Id of the custom taxonomy term. CORRECT USAGE: rather than using term id (`$term_id` in my question), one should use a stri...
213,367
<p>I use the conditonal function <strong>is_singular($my_post_type)</strong> inside my plugin and it is very convenient. The problem is that is doesn't work backend.</p> <p>Is there an alternative that works frontend &amp; backend ? Thanks !</p>
[ { "answer_id": 213376, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 0, "selected": false, "text": "<p>No. There is no equivalent to <code>is_singular()</code> for backend pages, possible because there are no eq...
2015/12/31
[ "https://wordpress.stackexchange.com/questions/213367", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70449/" ]
I use the conditonal function **is\_singular($my\_post\_type)** inside my plugin and it is very convenient. The problem is that is doesn't work backend. Is there an alternative that works frontend & backend ? Thanks !
Here's what I use now: ``` function custom_singular_backend(){ $screen = get_current_screen(); if ( ( $screen->base == 'post' ) && ( $screen->post_type == POSTTYPE ) ){ //... } } add_action( 'current_screen','custom_singular_backend'); ```
213,369
<p>I have a post type called 'Writers' and another post type called 'Documents'.</p> <p>I use the Relationship field in Advanced Custom Fields to link a list of Writers (post objects) to a Document. This means that the field is basically an array containing multiple writers (some contain only one).</p> <p>I have a te...
[ { "answer_id": 213375, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 5, "selected": true, "text": "<p>I am updating my complete answer based on your clarification in the comment below. I hope this helps:</p...
2015/12/31
[ "https://wordpress.stackexchange.com/questions/213369", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86102/" ]
I have a post type called 'Writers' and another post type called 'Documents'. I use the Relationship field in Advanced Custom Fields to link a list of Writers (post objects) to a Document. This means that the field is basically an array containing multiple writers (some contain only one). I have a template in my them...
I am updating my complete answer based on your clarification in the comment below. I hope this helps: ``` <div class="entry-content"> <h2>Documents written by this writer</h2> <?php /* * Query posts for a relationship value. * This method uses the meta_query LIKE to match the s...
213,390
<p>I am letting users upload avatars which are stored within the uploads folder inside the avatars subfolder which I created. </p> <p>The problem is that avatars are now listed in the media library among other uploaded images.</p> <p>How can I prevent that? </p> <p>I was looking for a filter to filter out what is be...
[ { "answer_id": 213375, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 5, "selected": true, "text": "<p>I am updating my complete answer based on your clarification in the comment below. I hope this helps:</p...
2015/12/31
[ "https://wordpress.stackexchange.com/questions/213390", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86115/" ]
I am letting users upload avatars which are stored within the uploads folder inside the avatars subfolder which I created. The problem is that avatars are now listed in the media library among other uploaded images. How can I prevent that? I was looking for a filter to filter out what is being displayed but couldn...
I am updating my complete answer based on your clarification in the comment below. I hope this helps: ``` <div class="entry-content"> <h2>Documents written by this writer</h2> <?php /* * Query posts for a relationship value. * This method uses the meta_query LIKE to match the s...
213,408
<p>Today is 2016-01-01 in my console.</p> <pre><code>date Fri Jan 1 14:24:04 CST 2016 </code></pre> <p>Now I write an article attached a photo which is taken today and publish it today. I found that the URL of the photo was displayed as:</p> <pre><code>&lt;a href="http://hwy.local/wp/wp-content/uploads/2015/02/scan...
[ { "answer_id": 214348, "author": "Ray Mitchell", "author_id": 2709, "author_profile": "https://wordpress.stackexchange.com/users/2709", "pm_score": 4, "selected": false, "text": "<p>What date was/is the post published? Media uploads are added to the folder when the post/page was publishe...
2016/01/01
[ "https://wordpress.stackexchange.com/questions/213408", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70405/" ]
Today is 2016-01-01 in my console. ``` date Fri Jan 1 14:24:04 CST 2016 ``` Now I write an article attached a photo which is taken today and publish it today. I found that the URL of the photo was displayed as: ``` <a href="http://hwy.local/wp/wp-content/uploads/2015/02/scan.png"> <img src="http://hwy.local/wp/w...
What date was/is the post published? Media uploads are added to the folder when the post/page was published, not the upload date. Was the post originally published in Feb 2015? <https://core.trac.wordpress.org/ticket/10752>
213,425
<p>For example, this works:</p> <pre><code>'default' =&gt; '#ffffff' </code></pre> <p>But this does not:</p> <pre><code>$white = '#ffffff'; 'default' =&gt; $white </code></pre> <p>How can I pass variables to key/value pairs?</p> <p>Here is a more complete example for some context:</p> <pre><code>$white = '#ffffff...
[ { "answer_id": 214348, "author": "Ray Mitchell", "author_id": 2709, "author_profile": "https://wordpress.stackexchange.com/users/2709", "pm_score": 4, "selected": false, "text": "<p>What date was/is the post published? Media uploads are added to the folder when the post/page was publishe...
2016/01/01
[ "https://wordpress.stackexchange.com/questions/213425", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86088/" ]
For example, this works: ``` 'default' => '#ffffff' ``` But this does not: ``` $white = '#ffffff'; 'default' => $white ``` How can I pass variables to key/value pairs? Here is a more complete example for some context: ``` $white = '#ffffff'; $transport = 'refresh'; $wp_customize->add_setting('mytheme_text_colo...
What date was/is the post published? Media uploads are added to the folder when the post/page was published, not the upload date. Was the post originally published in Feb 2015? <https://core.trac.wordpress.org/ticket/10752>
213,438
<p>I can't figure out why this script wont load on site. Am I missing something?</p> <pre><code>function ajax_follow_enqueue_scripts() { wp_register_script('follow', plugins_url('the-follow.js', __FILE__)); wp_enqueue_script('follow'); wp_localize_script( 'the_follow', 'postfollow', array('ajax_url' =&gt; ...
[ { "answer_id": 214348, "author": "Ray Mitchell", "author_id": 2709, "author_profile": "https://wordpress.stackexchange.com/users/2709", "pm_score": 4, "selected": false, "text": "<p>What date was/is the post published? Media uploads are added to the folder when the post/page was publishe...
2016/01/01
[ "https://wordpress.stackexchange.com/questions/213438", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/78840/" ]
I can't figure out why this script wont load on site. Am I missing something? ``` function ajax_follow_enqueue_scripts() { wp_register_script('follow', plugins_url('the-follow.js', __FILE__)); wp_enqueue_script('follow'); wp_localize_script( 'the_follow', 'postfollow', array('ajax_url' => admin_url( 'admin-...
What date was/is the post published? Media uploads are added to the folder when the post/page was published, not the upload date. Was the post originally published in Feb 2015? <https://core.trac.wordpress.org/ticket/10752>
213,453
<p>There may be several aspects to my question but I feel in essence it's easy: how do you make sure changes to a child theme <code>style.css</code> are properly propagated across caches?</p> <p>I read in a few places that WP should/would be placing the WP version in <code>nnn</code> when the resource is fetched as <c...
[ { "answer_id": 213483, "author": "Marcel Stör", "author_id": 30783, "author_profile": "https://wordpress.stackexchange.com/users/30783", "pm_score": 5, "selected": true, "text": "<p>@dalbaeb's comment eventually lead to insightful discussions and a feasible solution. Thanks a lot!</p>\n\...
2016/01/01
[ "https://wordpress.stackexchange.com/questions/213453", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/30783/" ]
There may be several aspects to my question but I feel in essence it's easy: how do you make sure changes to a child theme `style.css` are properly propagated across caches? I read in a few places that WP should/would be placing the WP version in `nnn` when the resource is fetched as `http://host/wp-content/themes/the...
@dalbaeb's comment eventually lead to insightful discussions and a feasible solution. Thanks a lot! I believe the reason my child theme CSS was loaded using `'ver=<parent-theme-version>` was because I had followed the [WP Codex on child themes](http://codex.wordpress.org/Child_Themes) 1:1. My `functions.php` contained...
213,459
<p>What is the advantage of explicitly including a composer.json file in my plugin if potential users of my plugin can already get it as a package through WPackagist?</p>
[ { "answer_id": 213469, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 1, "selected": false, "text": "<p>The <code>composer.json</code> file usually contains extra information that are not available in the <code>re...
2016/01/02
[ "https://wordpress.stackexchange.com/questions/213459", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22599/" ]
What is the advantage of explicitly including a composer.json file in my plugin if potential users of my plugin can already get it as a package through WPackagist?
TL;DR ===== If you want to support Composer, adding a `composer.json` is better then just let WPackagist create a package for you. There are several reasons, no one is *really* important, but considering that to create a `composer.json` does not require much effort, it probably worth it. `composer.json` Benefits ===...
213,480
<p>I offer downloadable products with woocommerce and each product is allowed to have multiple files.</p> <p>I would like to display the file types/formats on the product page so users know what each product contains. Please see the image below.</p> <p><a href="https://i.stack.imgur.com/PB2aw.png" rel="nofollow noref...
[ { "answer_id": 213486, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 3, "selected": true, "text": "<p>Place the following code in your <code>meta.php</code> template file immediately after the lines where i...
2016/01/02
[ "https://wordpress.stackexchange.com/questions/213480", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86102/" ]
I offer downloadable products with woocommerce and each product is allowed to have multiple files. I would like to display the file types/formats on the product page so users know what each product contains. Please see the image below. [![enter image description here](https://i.stack.imgur.com/PB2aw.png)](https://i.s...
Place the following code in your `meta.php` template file immediately after the lines where it prints the categories and tags. Please note, the standard practice is that you shall copy the `meta.php` template file to your theme folder. So to override `meta.php`, copy: **woocommerce/templates/single-product/meta.php** f...
213,482
<p>I have a <code>&lt;form&gt;</code> with about 20 inputs (mostly <code>select</code> and <code>number</code>) which each is an argument in <code>WP_Query</code> if filled.</p> <p>I learned today that I could use transients to <em>store</em> results which seems like a good opportunity to ease the blow on server, afte...
[ { "answer_id": 213493, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>what are the odds, right?</p>\n</blockquote>\n\n<p>The odds make the project pretty pointles...
2016/01/02
[ "https://wordpress.stackexchange.com/questions/213482", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/80903/" ]
I have a `<form>` with about 20 inputs (mostly `select` and `number`) which each is an argument in `WP_Query` if filled. I learned today that I could use transients to *store* results which seems like a good opportunity to ease the blow on server, after all: this is rather complicated query. My plan is: * User fills...
I have read quite a few of your posts and it seems like your queries are really complex which either slows the page or simply crashes it. Transients are definitely an option to store the results of such labor intensive queries. As @s\_ha\_dum mentioned, you'll need to look into what you will be saving. > > Would the...
213,508
<p>This might be a very silly question but I am losing my hair over this.. So basically, I have the following line of code"</p> <pre><code> 'Default' =&gt; '&lt;img src="' . THEMEROOT . '/admin/images/default.png" width="120" height="80" alt="&lt;?php _e( 'Default', 'my_theme' ); ?&gt;"/&gt;', </code></pre> <...
[ { "answer_id": 233020, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 2, "selected": false, "text": "<p>The <code>edit_others_posts</code> capability should allow users to set the author of a post.</p>...
2016/01/02
[ "https://wordpress.stackexchange.com/questions/213508", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82982/" ]
This might be a very silly question but I am losing my hair over this.. So basically, I have the following line of code" ``` 'Default' => '<img src="' . THEMEROOT . '/admin/images/default.png" width="120" height="80" alt="<?php _e( 'Default', 'my_theme' ); ?>"/>', ``` The problem I am having is the alt text...
The `edit_others_posts` capability should allow users to set the author of a post. At first glance you might reply that you don't want your authors to be able to edit one another's posts. The difference in ability is very subtle though: writing a post and then assigning it to another user isn't much different from bei...
213,535
<p>I have googled for this and, did not find any solution.</p> <p>I am trying to add Birth date (datepicker) field in woocommerce registration page.</p> <p>The registration form has been created as per guidance posted <a href="https://support.woothemes.com/hc/en-us/articles/203182373-How-to-add-custom-fields-in-user-...
[ { "answer_id": 213536, "author": "WPTC-Troop", "author_id": 82793, "author_profile": "https://wordpress.stackexchange.com/users/82793", "pm_score": 1, "selected": false, "text": "<p>Don't include jquery from any other source, it will create conflict. Bcoz jQuery is pre bundled in wordpre...
2016/01/03
[ "https://wordpress.stackexchange.com/questions/213535", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86147/" ]
I have googled for this and, did not find any solution. I am trying to add Birth date (datepicker) field in woocommerce registration page. The registration form has been created as per guidance posted [here](https://support.woothemes.com/hc/en-us/articles/203182373-How-to-add-custom-fields-in-user-registration-on-the...
Don't include jquery from any other source, it will create conflict. Bcoz jQuery is pre bundled in wordpress by default. For your question, add an `id` or `class` to the input element then add the datepicker based on the class. For example ``` <input type="text" class="da_test" value="" > <script type="text/javascri...
213,563
<p>I'm trying to load a message after successful login on the front end.</p> <p>I have the script that works as a function,</p> <pre><code>function myscript() { ?&gt; &lt;script type="text/javascript"&gt; $( document ).ready(function() { $('&lt;div class="item login"&gt;Success! You\'re now signed in.&lt;/div&g...
[ { "answer_id": 213566, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 0, "selected": false, "text": "<p><code>login_redirect</code> is a filter, so technically what you are doing is an abuse of the hook but more ...
2016/01/03
[ "https://wordpress.stackexchange.com/questions/213563", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5302/" ]
I'm trying to load a message after successful login on the front end. I have the script that works as a function, ``` function myscript() { ?> <script type="text/javascript"> $( document ).ready(function() { $('<div class="item login">Success! You\'re now signed in.</div>').appendTo('.pop-notice').delay(6000).q...
There could be many approaches to this. Mine is given below .. 1. First you store the time on which the user was logged in so that you can display the successfull login popup for X number of minutes .. ``` function store_login_time($user_login, $user) { $userID = $user->ID; update_user_meta( $userID, '_login_...
213,572
<p>I'm trying to make a mu-plugin dedicated to make OpenGraph tags for my website, since the current plugin in WP directory arent updated for ages.</p> <p>But i ran with several headaches trying to get post or page data, something i never tried before.</p> <p>Using this piece of code:</p> <pre><code>&lt;?php /* ...
[ { "answer_id": 213573, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>You're using non-existent variables in your function, <code>$post_id</code>, <code>$post</code>, <code>$page</code...
2016/01/03
[ "https://wordpress.stackexchange.com/questions/213572", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71362/" ]
I'm trying to make a mu-plugin dedicated to make OpenGraph tags for my website, since the current plugin in WP directory arent updated for ages. But i ran with several headaches trying to get post or page data, something i never tried before. Using this piece of code: ``` <?php /* Plugin Name: Open Graph! De...
After several headaches i managed to solve the issue based on Milo's answer. But i need to add a check if the excerpt returned empty, and if it return empty i need to trim the entire content string to get the desired data. Final code: ``` function pegarConteudoPost() { if( is_single() || is_page() ) { ...
213,576
<h2>The Problem</h2> <p>WP appears to remove the value of my query variable before it gets used to filter the list of users.</p> <h2>My Code</h2> <p>This function adds a custom column to my Users table on <code>/wp-admin/users.php</code>:</p> <pre><code>function add_course_section_to_user_meta( $columns ) { $co...
[ { "answer_id": 213582, "author": "Linnea Huxford", "author_id": 86210, "author_profile": "https://wordpress.stackexchange.com/users/86210", "pm_score": 2, "selected": false, "text": "<p>I tested your code in both Wordpress 4.4 and in Wordpress 4.3.1. With version 4.4, I encounter exactl...
2016/01/04
[ "https://wordpress.stackexchange.com/questions/213576", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9800/" ]
The Problem ----------- WP appears to remove the value of my query variable before it gets used to filter the list of users. My Code ------- This function adds a custom column to my Users table on `/wp-admin/users.php`: ``` function add_course_section_to_user_meta( $columns ) { $columns['course_section'] = 'Sec...
UPDATE 2018-06-28 ----------------- While the code below mostly works fine, here is a rewrite of the code for WP >=4.6.0 (using PHP 7): ``` function add_course_section_filter( $which ) { // create sprintf templates for <select> and <option>s $st = '<select name="course_section_%s" style="float:none;"><option...
213,584
<p>I am working on a website that uses a previously developed image slider plugin. I had it all working in my local environment but once I took it live it kicked the following error anywhere the image slider is located...</p> <pre><code>Warning: Missing argument 2 for wpdb::prepare(), called in /home/content/r/o/b/rob...
[ { "answer_id": 213582, "author": "Linnea Huxford", "author_id": 86210, "author_profile": "https://wordpress.stackexchange.com/users/86210", "pm_score": 2, "selected": false, "text": "<p>I tested your code in both Wordpress 4.4 and in Wordpress 4.3.1. With version 4.4, I encounter exactl...
2016/01/04
[ "https://wordpress.stackexchange.com/questions/213584", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67018/" ]
I am working on a website that uses a previously developed image slider plugin. I had it all working in my local environment but once I took it live it kicked the following error anywhere the image slider is located... ``` Warning: Missing argument 2 for wpdb::prepare(), called in /home/content/r/o/b/robertrhuspeak/ht...
UPDATE 2018-06-28 ----------------- While the code below mostly works fine, here is a rewrite of the code for WP >=4.6.0 (using PHP 7): ``` function add_course_section_filter( $which ) { // create sprintf templates for <select> and <option>s $st = '<select name="course_section_%s" style="float:none;"><option...
213,612
<p>I am trying to send an email to customer after purchased products and when customer click on the the link provided the email for rating the product it should redirect to customer's account/My account page.<br> I put some code in functions.php to get the WooCommerce My Account URL:</p> <pre><code>$myaccount_page = g...
[ { "answer_id": 213614, "author": "WPTC-Troop", "author_id": 82793, "author_profile": "https://wordpress.stackexchange.com/users/82793", "pm_score": 6, "selected": true, "text": "<p>You can get the WooCommerce my-account URL as below</p>\n\n<pre><code>&lt;a href=\"&lt;?php echo get_permal...
2016/01/04
[ "https://wordpress.stackexchange.com/questions/213612", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86097/" ]
I am trying to send an email to customer after purchased products and when customer click on the the link provided the email for rating the product it should redirect to customer's account/My account page. I put some code in functions.php to get the WooCommerce My Account URL: ``` $myaccount_page = get_option( 'woo...
You can get the WooCommerce my-account URL as below ``` <a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('My Account',''); ?>"><?php _e('My Account',''); ?></a> ``` Now you can insert this in completed order mail template too. ``` <h2> <a href="<?php echo get_per...
213,621
<p>I need your help, am trying to add class <code>dropdown-submenu</code> to a <code>&lt;li&gt;</code> element which has children. Not sure if I was clear enough, so here is an example:</p> <pre><code> |-Home (Parent Item) |-Services (Parent Item) *class='dropdown'* |-Orthodontics (Child Item) *** class="d...
[ { "answer_id": 213614, "author": "WPTC-Troop", "author_id": 82793, "author_profile": "https://wordpress.stackexchange.com/users/82793", "pm_score": 6, "selected": true, "text": "<p>You can get the WooCommerce my-account URL as below</p>\n\n<pre><code>&lt;a href=\"&lt;?php echo get_permal...
2016/01/04
[ "https://wordpress.stackexchange.com/questions/213621", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86230/" ]
I need your help, am trying to add class `dropdown-submenu` to a `<li>` element which has children. Not sure if I was clear enough, so here is an example: ``` |-Home (Parent Item) |-Services (Parent Item) *class='dropdown'* |-Orthodontics (Child Item) *** class="dropdown-submenu" *** |-Invisalig...
You can get the WooCommerce my-account URL as below ``` <a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" title="<?php _e('My Account',''); ?>"><?php _e('My Account',''); ?></a> ``` Now you can insert this in completed order mail template too. ``` <h2> <a href="<?php echo get_per...
213,677
<p>Running my own designed custom theme "mdbootstrap" designed by myself. Integrating WooCommerce 2.4.12. and upon testing there is an issue adding variable products to the cart. Basically the add to cart button is hidden and doesn't appear once a variant is selected .</p> <p>If I switch to the TwentyEleven theme, the...
[ { "answer_id": 213696, "author": "Reigel Gallarde", "author_id": 974, "author_profile": "https://wordpress.stackexchange.com/users/974", "pm_score": 2, "selected": true, "text": "<p>I'm not sure why but you have form tag inside a form tag.. and chrome is making it as one... view source a...
2016/01/05
[ "https://wordpress.stackexchange.com/questions/213677", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77480/" ]
Running my own designed custom theme "mdbootstrap" designed by myself. Integrating WooCommerce 2.4.12. and upon testing there is an issue adding variable products to the cart. Basically the add to cart button is hidden and doesn't appear once a variant is selected . If I switch to the TwentyEleven theme, the issue res...
I'm not sure why but you have form tag inside a form tag.. and chrome is making it as one... view source and look for `<form class="cart" method="post" enctype='multipart/form-data'>` and `<form class="variations_form cart" method="post"` `<form class="variations_form cart" method="post"` was removed by the browser wh...
213,701
<p>I read on the WP docs, <a href="https://gist.github.com/wpscholar/4947518" rel="nofollow">which pointed to this gist</a> that the correct way to enqueue styles for IE is by using the <code>$wp_styles</code>. I'm guessing that this would be true then for scripts as well.</p> <h2>Take these examples for instance...</...
[ { "answer_id": 213703, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>And option 5 is to detect on client side what browser it is, and create a script element for your script ...
2016/01/05
[ "https://wordpress.stackexchange.com/questions/213701", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38123/" ]
I read on the WP docs, [which pointed to this gist](https://gist.github.com/wpscholar/4947518) that the correct way to enqueue styles for IE is by using the `$wp_styles`. I'm guessing that this would be true then for scripts as well. Take these examples for instance... ----------------------------------- **Option One...
To extend on **@gmazzap** suggestion on not using globals when you can use `wp_scripts()`, there is a shortcut for `wp_scripts()` for adding conditional comments called `wp_script_add_data` and likewise `wp_style_add_data` for conditional styles. So the correct way to use conditionals as of Wordpress 4.2 is like this...
213,717
<p>On the checkout page, on the Billing Details section, I added two custom fields: Alpha and Beta. During checkout these fields are edited by the user and then saved together with the rest of his address info.</p> <p>On the dashboard, on the "Edit User" page I also added these two custom fields: Alpha and Beta.</p> ...
[ { "answer_id": 213703, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>And option 5 is to detect on client side what browser it is, and create a script element for your script ...
2016/01/05
[ "https://wordpress.stackexchange.com/questions/213717", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86283/" ]
On the checkout page, on the Billing Details section, I added two custom fields: Alpha and Beta. During checkout these fields are edited by the user and then saved together with the rest of his address info. On the dashboard, on the "Edit User" page I also added these two custom fields: Alpha and Beta. On the dashboa...
To extend on **@gmazzap** suggestion on not using globals when you can use `wp_scripts()`, there is a shortcut for `wp_scripts()` for adding conditional comments called `wp_script_add_data` and likewise `wp_style_add_data` for conditional styles. So the correct way to use conditionals as of Wordpress 4.2 is like this...
213,720
<p>I want to delete all posts of a specific post type (in this case "vfb_entry") that are older than 60 days. The cron job should run once a day.</p> <p>I have the following code but it's not working if I trigger the cron job. However, running only the query in phpMyAdmin returns the correct result. So there must be a...
[ { "answer_id": 213886, "author": "jackennils", "author_id": 86289, "author_profile": "https://wordpress.stackexchange.com/users/86289", "pm_score": 1, "selected": false, "text": "<pre><code>// Cron Job to Delete VFB Entries older than 60 days\nif(!wp_next_scheduled( 'remove_old_vfb_entri...
2016/01/05
[ "https://wordpress.stackexchange.com/questions/213720", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86289/" ]
I want to delete all posts of a specific post type (in this case "vfb\_entry") that are older than 60 days. The cron job should run once a day. I have the following code but it's not working if I trigger the cron job. However, running only the query in phpMyAdmin returns the correct result. So there must be an issue w...
``` // add the schedule event if it has been removed if( ! wp_next_scheduled( 'mg_remove_old_entries' ) ) { wp_schedule_event( time(), 'daily', 'mg_remove_old_entries' ); //run the event daily } // action hooked to fired with wordpress cron job add_action( 'mg_remove_old_entries', 'mg_remove_old_entries' ); functio...
213,739
<p>I am trying to get only <strong>one</strong> post and this needs to be <strong>the latest one</strong> so here is what I am doing:</p> <pre><code>$basic_args = $wp_query-&gt;query_vars; $basic_args['tax_query'] = $wp_query-&gt;tax_query; $aditional_args = array( 'post__in' =&gt; get_option('sticky_posts'), ...
[ { "answer_id": 213844, "author": "ReynierPM", "author_id": 16412, "author_profile": "https://wordpress.stackexchange.com/users/16412", "pm_score": 0, "selected": false, "text": "<p>Ok, after the suggestions from <strong>@pieter-goosen</strong> I have found a solution, just adding this <c...
2016/01/05
[ "https://wordpress.stackexchange.com/questions/213739", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16412/" ]
I am trying to get only **one** post and this needs to be **the latest one** so here is what I am doing: ``` $basic_args = $wp_query->query_vars; $basic_args['tax_query'] = $wp_query->tax_query; $aditional_args = array( 'post__in' => get_option('sticky_posts'), 'ignore_sticky_posts' => 1, 'order' => 'desc...
`pre_get_posts` alters all queries, back end and front end regardless. There are two very important checks that a large amount of people misses, that is the `!is_admin()` check which only targets the front end, and then the most important check, `is_main_query()` which will only alter the main query and not custom qu...
213,742
<p>I am building my first WP plugin, it should load some JS and CSS files only on specific pages selected through a form available in the plugin Admin area. Once selected in the form, Page Title gets stored in the DB wp_options table, then the data is pulled back out in a variable named $page_selected. To load JS and C...
[ { "answer_id": 213743, "author": "Puneet Sahalot", "author_id": 19739, "author_profile": "https://wordpress.stackexchange.com/users/19739", "pm_score": 3, "selected": false, "text": "<p>If <code>$page_selected</code> returns a string containing the page title, it should work fine. I have...
2016/01/05
[ "https://wordpress.stackexchange.com/questions/213742", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86296/" ]
I am building my first WP plugin, it should load some JS and CSS files only on specific pages selected through a form available in the plugin Admin area. Once selected in the form, Page Title gets stored in the DB wp\_options table, then the data is pulled back out in a variable named $page\_selected. To load JS and CS...
If `$page_selected` returns a string containing the page title, it should work fine. I have tested it and `is_page()` accepts page title, page ID and the slug. If you are facing issues, it will be better to store page ID in the database and use it with `is_page()` Please refer to <https://codex.wordpress.org/Functi...
213,805
<p>I tried adding placeholder similar to the given for <strong>ContactNumber</strong> for my drop down <strong>Outlet</strong> but it doesn't appear.</p> <p>Code-</p> <pre><code>&lt;div class="form-group form-icon-group"&gt; &lt;i class="fa fa-phone" &gt; &lt;/i&gt; [tel* ContactNumber /8 class:form-control place...
[ { "answer_id": 213809, "author": "Reigel Gallarde", "author_id": 974, "author_profile": "https://wordpress.stackexchange.com/users/974", "pm_score": -1, "selected": true, "text": "<p>to answer the question: this is not possible. </p>\n\n<p>AFAIK, (HTMLwise) there's no way to add a placeh...
2016/01/06
[ "https://wordpress.stackexchange.com/questions/213805", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86319/" ]
I tried adding placeholder similar to the given for **ContactNumber** for my drop down **Outlet** but it doesn't appear. Code- ``` <div class="form-group form-icon-group"> <i class="fa fa-phone" > </i> [tel* ContactNumber /8 class:form-control placeholder "Contact Number *"] </div> <div class="form-group form-ico...
to answer the question: this is not possible. AFAIK, (HTMLwise) there's no way to add a placeholder to select tags. A lot of devs I know however tend to use `disabled selected` combination for the option... ```html <select> <option value="" disabled selected>Select your option</option> <option value="ydasd...
213,808
<p>I just bought the Visual Composer plugin from wpbakery, my problem is that I'm making ajax calls to get the content of posts that have been edited with Visual Composer when I get the data it only show me the shortcodes of the plugin</p> <p>As I see from the information that I have found on how to fix this problem i...
[ { "answer_id": 213833, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>...ajax calls can't show shortcodes because of the admin ajax url that they dont have full...
2016/01/06
[ "https://wordpress.stackexchange.com/questions/213808", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86321/" ]
I just bought the Visual Composer plugin from wpbakery, my problem is that I'm making ajax calls to get the content of posts that have been edited with Visual Composer when I get the data it only show me the shortcodes of the plugin As I see from the information that I have found on how to fix this problem is that aja...
Since Visual Composer Version 4.9 you have to use WPBMap::addAllMappedShortcodes() before the apply\_filters('the\_content', ...) or do\_shortcode(). You don't need both by the way, because apply\_filters('the\_content', ...) executes do\_shortcode() anyway. Your function would then be: ``` function prefix_load_proye...
213,812
<p>How can I get a post's content by post id? I tried <code>get_page('ID');</code> to show content but it does not work. </p>
[ { "answer_id": 213815, "author": "WPTC-Troop", "author_id": 82793, "author_profile": "https://wordpress.stackexchange.com/users/82793", "pm_score": 4, "selected": false, "text": "<p>You can do it multiple ways. Following are best two ways.</p>\n\n<pre><code>$post_id = 5// example post id...
2016/01/06
[ "https://wordpress.stackexchange.com/questions/213812", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76513/" ]
How can I get a post's content by post id? I tried `get_page('ID');` to show content but it does not work.
You can do it multiple ways. Following are best two ways. ``` $post_id = 5// example post id $post_content = get_post($post_id); $content = $post_content->post_content; echo do_shortcode( $content );//executing shortcodes ``` Another method ``` $content = get_post_field('post_content', $post_id); echo do_shortcode(...
213,817
<p>How can I execute DB queries when theme installs and delete those tables on theme uninstall?</p>
[ { "answer_id": 213819, "author": "WPTC-Troop", "author_id": 82793, "author_profile": "https://wordpress.stackexchange.com/users/82793", "pm_score": 0, "selected": false, "text": "<p>Theme activation use <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/after_switch_theme\...
2016/01/06
[ "https://wordpress.stackexchange.com/questions/213817", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86324/" ]
How can I execute DB queries when theme installs and delete those tables on theme uninstall?
Yes, you can accomplish it by WP default functionality. Let me explain it. **1. While switch theme:** There is a `switch_theme` action that runs right after the theme is switched. switch\_theme is triggered when the blog's theme is changed. Specifically, it fires after the theme has been switched but before the next...
213,825
<p>I want to check if the title of the post has changed and do some stuff if it did.</p> <p>I thought of using the post_updated hook, the codex says "Use this hook whenever you need to compare values <strong>before</strong> and <strong>after</strong> the post update.", but i can't figure out how to use the before and ...
[ { "answer_id": 213827, "author": "JoeMoe1984", "author_id": 32601, "author_profile": "https://wordpress.stackexchange.com/users/32601", "pm_score": 4, "selected": true, "text": "<p>First off you are using the function wrong. The function is tied to an action within wordpress whenever you...
2016/01/06
[ "https://wordpress.stackexchange.com/questions/213825", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47701/" ]
I want to check if the title of the post has changed and do some stuff if it did. I thought of using the post\_updated hook, the codex says "Use this hook whenever you need to compare values **before** and **after** the post update.", but i can't figure out how to use the before and after arguments. ``` function chec...
First off you are using the function wrong. The function is tied to an action within wordpress whenever you use the `add_action` function. In this case you have added it to the `post_updated` action. Basically your check\_values function gets added to a queue which will then get called by the action when its time to d...
213,843
<p>I've a dropdown control that lists all pages of the website.</p> <p>When I select a page in the dropdown I would update the preview iframe to that page. </p> <p>There is the following method to change the customizer <code>previewUrl</code></p> <p><code>wp.customize.previewer.previewUrl( url )</code></p> <p>But I...
[ { "answer_id": 213827, "author": "JoeMoe1984", "author_id": 32601, "author_profile": "https://wordpress.stackexchange.com/users/32601", "pm_score": 4, "selected": true, "text": "<p>First off you are using the function wrong. The function is tied to an action within wordpress whenever you...
2016/01/06
[ "https://wordpress.stackexchange.com/questions/213843", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20032/" ]
I've a dropdown control that lists all pages of the website. When I select a page in the dropdown I would update the preview iframe to that page. There is the following method to change the customizer `previewUrl` `wp.customize.previewer.previewUrl( url )` But I can't realize how and where exactly I should do this...
First off you are using the function wrong. The function is tied to an action within wordpress whenever you use the `add_action` function. In this case you have added it to the `post_updated` action. Basically your check\_values function gets added to a queue which will then get called by the action when its time to d...
213,857
<p>I'd like to wrap my post thumbnail with <code>&lt;figure&gt;</code> tags. </p> <p>I have tried the following and the image appears, but the <code>&lt;figure&gt;</code> tags come up empty.</p> <pre><code>&lt;?php if ( has_post_thumbnail() ) { echo '&lt;figure&gt;'.the_post_thumbnail('gallery').'&lt;/figure&gt;'...
[ { "answer_id": 213858, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 3, "selected": true, "text": "<p>Use <a href=\"https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/\" rel=\"nofollow\">ge...
2016/01/06
[ "https://wordpress.stackexchange.com/questions/213857", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37548/" ]
I'd like to wrap my post thumbnail with `<figure>` tags. I have tried the following and the image appears, but the `<figure>` tags come up empty. ``` <?php if ( has_post_thumbnail() ) { echo '<figure>'.the_post_thumbnail('gallery').'</figure>'; } ?> ``` I've also tried the following, but the image is missing a...
Use [get\_the\_post\_thumbnail( $id, $size )](https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/) if you're going to echo the result. And make sure you have post thumbs enabled. ``` add_theme_support( 'post-thumbnails' ); ```
213,861
<p>I developed the theme. Redux Framework configuration file located in the theme directory. Himself ReduX Framework I installed from the repository Wordpress using the TGM. But when I install a theme, then this message appears</p> <blockquote> <p>Redux Framework has an embedded demo. Click here to activate the sa...
[ { "answer_id": 214019, "author": "EndyVelvet", "author_id": 60574, "author_profile": "https://wordpress.stackexchange.com/users/60574", "pm_score": 2, "selected": true, "text": "<p>Problem solved! Helped official support. It was necessary to add the following code.</p>\n\n<pre><code>add_...
2016/01/06
[ "https://wordpress.stackexchange.com/questions/213861", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60574/" ]
I developed the theme. Redux Framework configuration file located in the theme directory. Himself ReduX Framework I installed from the repository Wordpress using the TGM. But when I install a theme, then this message appears > > Redux Framework has an embedded demo. Click here to activate the > sample config file. >...
Problem solved! Helped official support. It was necessary to add the following code. ``` add_action( 'redux/loaded', 'remove_demo' ); /** * Removes the demo link and the notice of integrated demo from the redux-framework plugin */ if ( ! function_exists( 'remove_demo' ) ) { function remove_demo() { // Us...
213,866
<p>I'm coding a theme where I want to display information in the footer that's only available on a template page. I have been using <code>get_page_by_title()</code> which works well if you know what the page will be called, but in my opinion it's not very dynamic, it's impossible to predict what a user will name a page...
[ { "answer_id": 213867, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 4, "selected": true, "text": "<p>If you don't force a title, and obviously do not know the id, the only way you can do it is by letting the...
2016/01/06
[ "https://wordpress.stackexchange.com/questions/213866", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76066/" ]
I'm coding a theme where I want to display information in the footer that's only available on a template page. I have been using `get_page_by_title()` which works well if you know what the page will be called, but in my opinion it's not very dynamic, it's impossible to predict what a user will name a page in your theme...
If you don't force a title, and obviously do not know the id, the only way you can do it is by letting the user select which page to use, usually done in the theme's options page, but can be done in the costumizer, or even as part of page editing
213,894
<p>I am having some issue removing the width and height from my attachment images when using wp_get_attachment_image. This is what I am using to display the image </p> <pre><code> &lt;?php echo $image = wp_get_attachment_image( $entry['slide_image_id'], true, 'full'); ?&gt; </code></pre> <p>How it looks the the sourc...
[ { "answer_id": 213897, "author": "bosco", "author_id": 25324, "author_profile": "https://wordpress.stackexchange.com/users/25324", "pm_score": 4, "selected": true, "text": "<p>Your arguments for both <a href=\"https://developer.wordpress.org/reference/functions/wp_get_attachment_image_ur...
2016/01/06
[ "https://wordpress.stackexchange.com/questions/213894", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54798/" ]
I am having some issue removing the width and height from my attachment images when using wp\_get\_attachment\_image. This is what I am using to display the image ``` <?php echo $image = wp_get_attachment_image( $entry['slide_image_id'], true, 'full'); ?> ``` How it looks the the source code ``` <img width="150"...
Your arguments for both [`wp_get_attachment_image_url()`](https://developer.wordpress.org/reference/functions/wp_get_attachment_image_url/) and [`wp_get_attachment_image()`](https://codex.wordpress.org/Function_Reference/wp_get_attachment_image) are in the wrong order - check the linked documentation for details. Addit...
213,896
<p>i understand with the wp rest API i will be able to build Wordpress themes with other languages but will i be able to do the same in customizer api or would i need to use php to give customization options to users?</p>
[ { "answer_id": 213897, "author": "bosco", "author_id": 25324, "author_profile": "https://wordpress.stackexchange.com/users/25324", "pm_score": 4, "selected": true, "text": "<p>Your arguments for both <a href=\"https://developer.wordpress.org/reference/functions/wp_get_attachment_image_ur...
2016/01/06
[ "https://wordpress.stackexchange.com/questions/213896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86364/" ]
i understand with the wp rest API i will be able to build Wordpress themes with other languages but will i be able to do the same in customizer api or would i need to use php to give customization options to users?
Your arguments for both [`wp_get_attachment_image_url()`](https://developer.wordpress.org/reference/functions/wp_get_attachment_image_url/) and [`wp_get_attachment_image()`](https://codex.wordpress.org/Function_Reference/wp_get_attachment_image) are in the wrong order - check the linked documentation for details. Addit...
213,910
<p>I have posts in two languages, managed by WPML.</p> <p>In one post, I share multiple links which are updated in a regular basis. Updating the same links for both languages is not an option (for now I only added this post in one language).</p> <p>Which is the best way to define links text and URL only once, and reu...
[ { "answer_id": 213897, "author": "bosco", "author_id": 25324, "author_profile": "https://wordpress.stackexchange.com/users/25324", "pm_score": 4, "selected": true, "text": "<p>Your arguments for both <a href=\"https://developer.wordpress.org/reference/functions/wp_get_attachment_image_ur...
2016/01/07
[ "https://wordpress.stackexchange.com/questions/213910", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59235/" ]
I have posts in two languages, managed by WPML. In one post, I share multiple links which are updated in a regular basis. Updating the same links for both languages is not an option (for now I only added this post in one language). Which is the best way to define links text and URL only once, and reuse them in both l...
Your arguments for both [`wp_get_attachment_image_url()`](https://developer.wordpress.org/reference/functions/wp_get_attachment_image_url/) and [`wp_get_attachment_image()`](https://codex.wordpress.org/Function_Reference/wp_get_attachment_image) are in the wrong order - check the linked documentation for details. Addit...
213,920
<p>I am newbee to web development,since last few days i am struggling to login through php code. My PHP code is as follow</p> <pre><code>//my php code @include_once '../wp-includes/user.php'; $creds = array( 'user_login' =&gt; 'abc', 'user_password' =&gt; 'abc', 'reme...
[ { "answer_id": 213924, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 0, "selected": false, "text": "<p>You probably call <code>wp_signon</code> too early. You first need to let all of the wordpress core to lo...
2016/01/07
[ "https://wordpress.stackexchange.com/questions/213920", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86390/" ]
I am newbee to web development,since last few days i am struggling to login through php code. My PHP code is as follow ``` //my php code @include_once '../wp-includes/user.php'; $creds = array( 'user_login' => 'abc', 'user_password' => 'abc', 'rememember' => false ...
You should BIND the codes into action (you can use `plugins_loaded` for earliest stage): ``` add_action('plugins_loaded', 'my_func'); function my_func(){ // ======== HERE YOUR CODES =========// } ``` p.s. you have to include the file correctly! ``` include_once(ABSPATH.'wp-includes/user.php'); ```
213,932
<p>I have a problem with get_pages. It displays the wrong ID for the blog page. I have tried this code.</p> <pre><code>$pages = get_pages(array("echo" =&gt; 0)); foreach($pages as $page){ echo $page-&gt;ID; } </code></pre> <p>But for the blog page it returns the wrong ID. It should be 1 (the blog page is automati...
[ { "answer_id": 213924, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 0, "selected": false, "text": "<p>You probably call <code>wp_signon</code> too early. You first need to let all of the wordpress core to lo...
2016/01/07
[ "https://wordpress.stackexchange.com/questions/213932", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83390/" ]
I have a problem with get\_pages. It displays the wrong ID for the blog page. I have tried this code. ``` $pages = get_pages(array("echo" => 0)); foreach($pages as $page){ echo $page->ID; } ``` But for the blog page it returns the wrong ID. It should be 1 (the blog page is automatically 1 if I understand it corr...
You should BIND the codes into action (you can use `plugins_loaded` for earliest stage): ``` add_action('plugins_loaded', 'my_func'); function my_func(){ // ======== HERE YOUR CODES =========// } ``` p.s. you have to include the file correctly! ``` include_once(ABSPATH.'wp-includes/user.php'); ```
213,939
<p>When I open the newly created page in WordPress I get <code>page not found</code> but when I reset the permalinks to none <code>http://localhost/?page_id=6</code> opens normally .</p> <p>Even with this permalink it works : <code>/index.php/%postname%/</code> But when I change it to only <code>/%postname%/</code> I ...
[ { "answer_id": 214029, "author": "Bharat", "author_id": 83408, "author_profile": "https://wordpress.stackexchange.com/users/83408", "pm_score": 0, "selected": false, "text": "<p>This problem is .htaccess file's. Before doing anything first take backup your files and database.</p>\n\n<p>T...
2016/01/07
[ "https://wordpress.stackexchange.com/questions/213939", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82746/" ]
When I open the newly created page in WordPress I get `page not found` but when I reset the permalinks to none `http://localhost/?page_id=6` opens normally . Even with this permalink it works : `/index.php/%postname%/` But when I change it to only `/%postname%/` I get `page not found error` . Here is my `htaccess` fi...
Do you have mod\_rewrite enabled? This sort of thing tends to happen when it's not. At which point, you only have access to ugly permalinks (?p=N) or "almost pretty" permalinks (/index.php/slug). The latter uses pathinfo to get you the page you're requesting instead. So I'd suggest double checking whether mod\_rewrit...
213,972
<p>Im currently using a theme that has template pages, and they notified me that I cannot use any page restriction plugins, as for that would only work on the default template page. Id like to restrict a certain page, for non logged in users, and they said I must try and use the "is user logged in" function on that spe...
[ { "answer_id": 213984, "author": "Syed Alam Abbas", "author_id": 86425, "author_profile": "https://wordpress.stackexchange.com/users/86425", "pm_score": -1, "selected": false, "text": "<p>You need a plugin that will conditionally show a menu item. There a few out there. <a href=\"https:/...
2016/01/07
[ "https://wordpress.stackexchange.com/questions/213972", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86412/" ]
Im currently using a theme that has template pages, and they notified me that I cannot use any page restriction plugins, as for that would only work on the default template page. Id like to restrict a certain page, for non logged in users, and they said I must try and use the "is user logged in" function on that specif...
You can check for if a user is logged in or not by `is_user_logged_in()` if logged in then show the page if not then redirect them. Perfect hook to use for this `template_redirect`. Example ``` function check_and_redirect(){ if( is_page( 45 ) && !is_user_logged_in() ) { wp_redirect( wp_login_url() ); exit...
213,977
<p>I'm trying to create a metabox in a custom post type. When I attempt to insert information into the Listing Price box and update the post, the information is not saved and disappears once the page reloads. Please take a look at my code below and let me know if you see anything that could be causing this issue. Thank...
[ { "answer_id": 213984, "author": "Syed Alam Abbas", "author_id": 86425, "author_profile": "https://wordpress.stackexchange.com/users/86425", "pm_score": -1, "selected": false, "text": "<p>You need a plugin that will conditionally show a menu item. There a few out there. <a href=\"https:/...
2016/01/07
[ "https://wordpress.stackexchange.com/questions/213977", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38938/" ]
I'm trying to create a metabox in a custom post type. When I attempt to insert information into the Listing Price box and update the post, the information is not saved and disappears once the page reloads. Please take a look at my code below and let me know if you see anything that could be causing this issue. Thanks! ...
You can check for if a user is logged in or not by `is_user_logged_in()` if logged in then show the page if not then redirect them. Perfect hook to use for this `template_redirect`. Example ``` function check_and_redirect(){ if( is_page( 45 ) && !is_user_logged_in() ) { wp_redirect( wp_login_url() ); exit...
213,981
<pre><code>get_terms($taxonomy, array('parent' =&gt; $parent)); </code></pre> <p>This works for some parents and returns an empty array for others. I checked if a term with the parent ID exists and if the same ID is in the 'parent' field of the child term's taxonomy. Even copy-pasted directly from the database. Is the...
[ { "answer_id": 213993, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 1, "selected": false, "text": "<p>The only variable which can really have an effect on the result as you described, is taxonomy. If you h...
2016/01/07
[ "https://wordpress.stackexchange.com/questions/213981", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71594/" ]
``` get_terms($taxonomy, array('parent' => $parent)); ``` This works for some parents and returns an empty array for others. I checked if a term with the parent ID exists and if the same ID is in the 'parent' field of the child term's taxonomy. Even copy-pasted directly from the database. Is there anything else? I do...
Use [`wp_insert_term()`](https://codex.wordpress.org/Function_Reference/wp_insert_term) instead of `$wpdb->insert` for adding new terms.