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
161,230
<p>I have a function for a custom post type that redirects NEW posts to a specific url after they are submitted by users: </p> <pre><code>function tribe_redirect_after_community_submission( $wp ) { if ( isset( $wp-&gt;query_vars[WP_Router::QUERY_VAR] ) &amp;&amp; $wp-&gt;query_vars[WP_Router::QUERY_VAR] == 'ce...
[ { "answer_id": 161226, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 0, "selected": false, "text": "<p>Give <a href=\"http://codex.wordpress.org/Function_Reference/wp_strip_all_tags\" rel=\"nofollow\">wp_strip_a...
2014/09/12
[ "https://wordpress.stackexchange.com/questions/161230", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54133/" ]
I have a function for a custom post type that redirects NEW posts to a specific url after they are submitted by users: ``` function tribe_redirect_after_community_submission( $wp ) { if ( isset( $wp->query_vars[WP_Router::QUERY_VAR] ) && $wp->query_vars[WP_Router::QUERY_VAR] == 'ce-add-route' && !empty( $...
KSES is designed to prevent execution of undesired and potentially dangerous tags, not preventing display of the innerHTML. Blocking the content would require --1 Either a custom function that used some kind of string manipulation or xmlDOM manipulation to remove content; or --2 A function that blocked posts that c...
161,248
<p>I am using the following code for a custom archive of all posts:</p> <pre><code>$taxonomy = 'category'; $param_type = 'category__in'; $term_args = array( 'orderby' =&gt; 'slug', 'order' =&gt; 'ASC' ); $terms = get_terms($taxonomy,$term_args); if ($terms) { foreach( $terms as $term ) { $args = ar...
[ { "answer_id": 161258, "author": "MSTannu", "author_id": 59654, "author_profile": "https://wordpress.stackexchange.com/users/59654", "pm_score": 0, "selected": false, "text": "<p>Add a taxonomy argument to specify the post type in your WP_Query. Here's an example straight from codex:</p>...
2014/09/13
[ "https://wordpress.stackexchange.com/questions/161248", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59645/" ]
I am using the following code for a custom archive of all posts: ``` $taxonomy = 'category'; $param_type = 'category__in'; $term_args = array( 'orderby' => 'slug', 'order' => 'ASC' ); $terms = get_terms($taxonomy,$term_args); if ($terms) { foreach( $terms as $term ) { $args = array( "$p...
[Post formats](http://codex.wordpress.org/Post_Formats) are actually terms of the [taxonomy](http://codex.wordpress.org/Taxonomies) `post_format`. I have done a post about this what taxonomies are and their hierarchies which you can check out [here](https://wordpress.stackexchange.com/a/158223/31545) To get a list of ...
161,266
<p>I have a page set up with six posts per page with two rows of three posts. If I only have one post up, I would like the other five to have "placeholder images" letting the viewers know that more posts are coming. Kind of like this:</p> <p><img src="https://i.stack.imgur.com/UMBZB.jpg" alt="enter image description h...
[ { "answer_id": 161275, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 1, "selected": false, "text": "<p>Here's one idea how one could play with the <code>the_posts</code> filter in a way that you don't have to mod...
2014/09/13
[ "https://wordpress.stackexchange.com/questions/161266", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18320/" ]
I have a page set up with six posts per page with two rows of three posts. If I only have one post up, I would like the other five to have "placeholder images" letting the viewers know that more posts are coming. Kind of like this: ![enter image description here](https://i.stack.imgur.com/UMBZB.jpg) I would create th...
You can add a filter to `'loop_start'`, count how may posts you have and inject the needed number of "fake" posts that are intances of `WP_Post` not having a reference in DB. ``` add_filter( 'loop_start', function( $query ) { $module = $query->post_count % 6; $to_fill = $module === 0 ? 0 : 6 - $module ; if ( ...
161,279
<p>I'm new to Wordpress and PHP and I've been battling with this for a while now. What I have for the moment is 2 loops.</p> <p>I want to first loop to only ever show 1 post: either a sticky post, or the latest post if there are no sticky posts.</p> <p>The second loop should show all other recent posts, like a basic ...
[ { "answer_id": 161275, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 1, "selected": false, "text": "<p>Here's one idea how one could play with the <code>the_posts</code> filter in a way that you don't have to mod...
2014/09/13
[ "https://wordpress.stackexchange.com/questions/161279", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76790/" ]
I'm new to Wordpress and PHP and I've been battling with this for a while now. What I have for the moment is 2 loops. I want to first loop to only ever show 1 post: either a sticky post, or the latest post if there are no sticky posts. The second loop should show all other recent posts, like a basic blog, except any ...
You can add a filter to `'loop_start'`, count how may posts you have and inject the needed number of "fake" posts that are intances of `WP_Post` not having a reference in DB. ``` add_filter( 'loop_start', function( $query ) { $module = $query->post_count % 6; $to_fill = $module === 0 ? 0 : 6 - $module ; if ( ...
161,281
<p>I have stored user favorite posts in the <code>user_meta</code> table of WordPress. The data is stored in a format, for example <code>a:1:{s:8:"post-134";s:3:"134";s:8:"post-136";s:3:"136";}</code>.</p> <p>How can I get this in the form of an array like <code>array( 134, 136 )</code> so that I can use it in the que...
[ { "answer_id": 161283, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 2, "selected": true, "text": "<p>Take a look at PHP's <a href=\"http://php.net/manual/en/function.array-values.php\" rel=\"nofollow\"><cod...
2014/09/13
[ "https://wordpress.stackexchange.com/questions/161281", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4609/" ]
I have stored user favorite posts in the `user_meta` table of WordPress. The data is stored in a format, for example `a:1:{s:8:"post-134";s:3:"134";s:8:"post-136";s:3:"136";}`. How can I get this in the form of an array like `array( 134, 136 )` so that I can use it in the query below. ``` $paged = (get_query_var('pag...
Take a look at PHP's [`array_values`](http://php.net/manual/en/function.array-values.php) function. Alternatively, you could [typecast](http://php.net/manual/en/language.types.type-juggling.php#language.types.typecasting). Note that if the array is in serialized form as you have put it above, you will have to unserial...
161,285
<p>My real problem is a bit complex, so I'll try here to abstract it and keep it simple.</p> <p>I'm working on a custom app based on WordPress. I registered a custom post type, let's call it "people" where I store information about... people.</p> <p>The CPT supports only post title and post content default fields, bu...
[ { "answer_id": 161309, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": false, "text": "<h2>The Main Problem:</h2>\n\n<p>The main problem here is that in the <em>closing-</em>, <em>hiding-</em> and <e...
2014/09/13
[ "https://wordpress.stackexchange.com/questions/161285", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35541/" ]
My real problem is a bit complex, so I'll try here to abstract it and keep it simple. I'm working on a custom app based on WordPress. I registered a custom post type, let's call it "people" where I store information about... people. The CPT supports only post title and post content default fields, but there are some ...
As pointed out by **birgire** in [his answer](https://wordpress.stackexchange.com/a/161309/35541), WordPress uses AJAX to update metaboxes status and data passed in the AJAX request does not include post id, and that makes it hard to update boxes status on a per-post basis. Once I found the AJAX action used by WordPre...
161,289
<p>I'm trying to create some custom shortcode - I want to be able to have names and numbers of people I want to display on my website, but as a shortcode, so it doesn't have to be typed in again and again.</p> <p>So for instance to have [joe] relate to 'Joe Bloggs - 01925 265646'</p> <p>I'm currently using the Ultima...
[ { "answer_id": 161299, "author": "Tomás Cot", "author_id": 57843, "author_profile": "https://wordpress.stackexchange.com/users/57843", "pm_score": 1, "selected": false, "text": "<p>You are passing the parameters wrong, try with something like this:</p>\n\n<pre><code>function get_telephon...
2014/09/13
[ "https://wordpress.stackexchange.com/questions/161289", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58966/" ]
I'm trying to create some custom shortcode - I want to be able to have names and numbers of people I want to display on my website, but as a shortcode, so it doesn't have to be typed in again and again. So for instance to have [joe] relate to 'Joe Bloggs - 01925 265646' I'm currently using the Ultimate Tables plugin ...
You are passing the parameters wrong, try with something like this: ``` function get_telephone($attrs) { $attr = shortcode_atts( array( 'name' => 'John Doe' ), $attrs ); return attr['name']; } add_shortcode( 'telephone', 'get_telephone' ); ``` In the post you call the shortcode like this: `[telephone name="J...
161,290
<p>I am trying to insert data into a table, getting errors, I have tried messaging the data, but cannot seem to get it to work, can you please help me figure out what I did wrong, please...</p> <p>Here is my code I execute after validation is done:</p> <pre><code> $sql = 'INSERT INTO `tablename` (`f...
[ { "answer_id": 161292, "author": "Richard Jones", "author_id": 47842, "author_profile": "https://wordpress.stackexchange.com/users/47842", "pm_score": 1, "selected": false, "text": "<p>I found the answer, in the codex. I just used it's code and adapted it, this code:</p>\n\n<pre><code> ...
2014/09/13
[ "https://wordpress.stackexchange.com/questions/161290", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47842/" ]
I am trying to insert data into a table, getting errors, I have tried messaging the data, but cannot seem to get it to work, can you please help me figure out what I did wrong, please... Here is my code I execute after validation is done: ``` $sql = 'INSERT INTO `tablename` (`file`,`afile`,`type`,`...
I found the answer, in the codex. I just used it's code and adapted it, this code: ``` $wpdb->query( $wpdb->prepare( " INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES ( %d, %s, %s ) ", 10, $metakey, $metavalue ) ); ``` So it works now.
161,323
<p>Firstly, I know this is 'bad' practice for several different reasons, but for reasons that I won't waste your time with it's something I need to do.</p> <p>Using a fairly simple plugin and I've tried copying it into functions.php and updating the file paths and dependences, but I'm having some trouble.</p> <p>Plug...
[ { "answer_id": 161327, "author": "Cayce K", "author_id": 58148, "author_profile": "https://wordpress.stackexchange.com/users/58148", "pm_score": 0, "selected": false, "text": "<p>I'm making some brief assumption based on the way you have typed your question..</p>\n\n<p><code>\"After movi...
2014/09/13
[ "https://wordpress.stackexchange.com/questions/161323", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22450/" ]
Firstly, I know this is 'bad' practice for several different reasons, but for reasons that I won't waste your time with it's something I need to do. Using a fairly simple plugin and I've tried copying it into functions.php and updating the file paths and dependences, but I'm having some trouble. Plugin file looks lik...
Just because you think that you have to do it doesn't remove the fact that it is very not smart to do it. The plugin code is built to be used as a plugin and not as a theme, and while you can copy parts of the code and use them in the theme there can not be any simple way to make sure there is no dependency left somewh...
161,330
<p>Using WP_Query, I need to gather a selection of posts that are <strong>both</strong> Category1 and Category2. I want this selection to include Category1 and all of its subcategories (Category3 and Category4), as long as they are also labeled Category2, <strong>even if</strong> they aren't labeled Category1.</p> <p...
[ { "answer_id": 161338, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 2, "selected": false, "text": "<p>What describe is the way it should work:</p>\n\n<ul>\n<li><code>cat_id</code> it is not a valid argument, so ...
2014/09/14
[ "https://wordpress.stackexchange.com/questions/161330", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54631/" ]
Using WP\_Query, I need to gather a selection of posts that are **both** Category1 and Category2. I want this selection to include Category1 and all of its subcategories (Category3 and Category4), as long as they are also labeled Category2, **even if** they aren't labeled Category1. ``` Categories: Name ID ...
The category parameters of [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query) does not have this type of logic. `category__and` and `category__in` does not return posts in child categories of the set categories. I would suggest that you make use of the [`tax_query`](http://codex.wordpress.org/Class_Ref...
161,332
<p>Hi guys I recently created a custom post type for flexslider on my Wordpress theme. However upon testing it got some issues. The slider is showing up but the images wont show up on it.</p> <p>There are two files I created here. slider.php and slider_post_type.php.</p> <p>here's my code on the slider.php:</p> <pre...
[ { "answer_id": 161338, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 2, "selected": false, "text": "<p>What describe is the way it should work:</p>\n\n<ul>\n<li><code>cat_id</code> it is not a valid argument, so ...
2014/09/14
[ "https://wordpress.stackexchange.com/questions/161332", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59679/" ]
Hi guys I recently created a custom post type for flexslider on my Wordpress theme. However upon testing it got some issues. The slider is showing up but the images wont show up on it. There are two files I created here. slider.php and slider\_post\_type.php. here's my code on the slider.php: ``` <?php // Enqueue F...
The category parameters of [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query) does not have this type of logic. `category__and` and `category__in` does not return posts in child categories of the set categories. I would suggest that you make use of the [`tax_query`](http://codex.wordpress.org/Class_Ref...
161,342
<p>I have a website with the custom post type <em>sammenligne</em>, along with some custom fields made using Advanced Custom Fields (ACF). I have modified an archive site (archive-sammenligne.php) which displays the data the way I want it, however when I try to extract the data using a WP query on a page, I get no outp...
[ { "answer_id": 161347, "author": "Even T", "author_id": 59687, "author_profile": "https://wordpress.stackexchange.com/users/59687", "pm_score": 0, "selected": false, "text": "<p>yes it does work on my other site archive-sammenligne.php, which is the archive file for the slug sammenligne....
2014/09/14
[ "https://wordpress.stackexchange.com/questions/161342", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59687/" ]
I have a website with the custom post type *sammenligne*, along with some custom fields made using Advanced Custom Fields (ACF). I have modified an archive site (archive-sammenligne.php) which displays the data the way I want it, however when I try to extract the data using a WP query on a page, I get no output. If I u...
Edit :// try this: ``` <?php add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); function sk_display_custom_fields() { /*Wordpress loop*/ global $wp_query; query_posts(array( 'post_type' => 'sammenligne' )); while(have_posts()) : the_post(); ?> $navn = get_...
161,345
<p>I'm using the following code to add a featured image to my rss feed in wordpress.</p> <pre><code>add_action( 'rss2_item', 'add_post_featured_image_as_rss_item_enclosure' ); function add_post_featured_image_as_rss_item_enclosure() { if ( ! has_post_thumbnail() ) return; $thumbnail_size = apply_filters( 'rss_en...
[ { "answer_id": 161358, "author": "Tomás Cot", "author_id": 57843, "author_profile": "https://wordpress.stackexchange.com/users/57843", "pm_score": 1, "selected": false, "text": "<p>You can use the <code>get_post_thumbnail_id</code> to get the ID of the thumbnail, then with the function <...
2014/09/14
[ "https://wordpress.stackexchange.com/questions/161345", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59689/" ]
I'm using the following code to add a featured image to my rss feed in wordpress. ``` add_action( 'rss2_item', 'add_post_featured_image_as_rss_item_enclosure' ); function add_post_featured_image_as_rss_item_enclosure() { if ( ! has_post_thumbnail() ) return; $thumbnail_size = apply_filters( 'rss_enclosure_image_...
You can use the `get_post_thumbnail_id` to get the ID of the thumbnail, then with the function [`wp_get_attachment_image_src`](http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src) you can get the image of the size you want, including full size, using the second paramenter. ``` $thumb_id = get_pos...
161,368
<p>Can someone translate this:</p> <p>If posts category is "cars" show image</p> <p><strong>For example:</strong></p> <p>I have an article with category 'car' and another article with category 'banana'. No I'm looking for a way to add an car image to every article with 'car' category. And banana image to every artic...
[ { "answer_id": 161370, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": true, "text": "<p>You can make use of the conditional tag <a href=\"http://codex.wordpress.org/Function_Reference/has_cate...
2014/09/14
[ "https://wordpress.stackexchange.com/questions/161368", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59697/" ]
Can someone translate this: If posts category is "cars" show image **For example:** I have an article with category 'car' and another article with category 'banana'. No I'm looking for a way to add an car image to every article with 'car' category. And banana image to every article with 'banana' category. For defaul...
You can make use of the conditional tag [`has_catgeory`](http://codex.wordpress.org/Function_Reference/has_category). You can do something like this ``` if(has_category( 'cars' ) || has_category( 'uncategorized' )) { //display cars image }elseif(has_category( 'banana' )) { //display banana image } ``` From y...
161,403
<p>I'm using redux frmaework for my theme option panel. &amp; I'm using meta slider for my homepage. I used this shortcode in my frontpage template to show the slider:</p> <pre><code>&lt;?php echo do_shortcode('[metaslider id=21]'); ?&gt; </code></pre> <p>but I want to change the id from my option panel, so I don't h...
[ { "answer_id": 161405, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": true, "text": "<p>I would rather pass the variable to the <code>id</code> attribute inside the shortcode. You can even dec...
2014/09/15
[ "https://wordpress.stackexchange.com/questions/161403", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58375/" ]
I'm using redux frmaework for my theme option panel. & I'm using meta slider for my homepage. I used this shortcode in my frontpage template to show the slider: ``` <?php echo do_shortcode('[metaslider id=21]'); ?> ``` but I want to change the id from my option panel, so I don't have to edit my template each time I ...
I would rather pass the variable to the `id` attribute inside the shortcode. You can even decide to remove the `id` attribute inside the shortcode and make it a static value that you pass to your custom query For examples and more info about how shortcodes operate, check out the [Shortcode API](http://codex.wordpress....
161,435
<p>I have taken the following pagination code from a 'premium' Wordpress theme to try and integrate this in to a custom one, but can't seem to get it to work:</p> <p>In the blog.php page template, I have the loop:</p> <pre><code> $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; ...
[ { "answer_id": 161655, "author": "Caleb", "author_id": 59678, "author_profile": "https://wordpress.stackexchange.com/users/59678", "pm_score": 0, "selected": false, "text": "<p>try changing the <code>paged</code> parameter and query var; I've experienced in the past the variable being di...
2014/09/15
[ "https://wordpress.stackexchange.com/questions/161435", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34820/" ]
I have taken the following pagination code from a 'premium' Wordpress theme to try and integrate this in to a custom one, but can't seem to get it to work: In the blog.php page template, I have the loop: ``` $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args=ar...
For pagination these days I use the following: ``` function wpbeginner_numeric_posts_nav() { if( is_singular() ) return; global $wp_query; /** Stop execution if there's only 1 page */ if( $wp_query->max_num_pages <= 1 ) return; $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1; $ma...
161,442
<p>I want to create a custom 404 page, but I cannot seem to override the 404 which is in Wordpress itself. The reason I want a custom 404 page is that if I get 404 within my subdirectories I get directed to my wordpress-site's 404. I'd rather have a 404 for my whole domain. </p> <p>I've only found solutions to do this...
[ { "answer_id": 180882, "author": "Quinn Comendant", "author_id": 68917, "author_profile": "https://wordpress.stackexchange.com/users/68917", "pm_score": 3, "selected": true, "text": "<p>When a URL is processed by Wordpress, its <code>index.php</code> script is loaded with the path to the...
2014/09/15
[ "https://wordpress.stackexchange.com/questions/161442", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59733/" ]
I want to create a custom 404 page, but I cannot seem to override the 404 which is in Wordpress itself. The reason I want a custom 404 page is that if I get 404 within my subdirectories I get directed to my wordpress-site's 404. I'd rather have a 404 for my whole domain. I've only found solutions to do this within Wo...
When a URL is processed by Wordpress, its `index.php` script is loaded with the path to the requested page. Because in this case the `index.php` script is always found, a normal 404 error will never trigger (via `ErrorDocument 404 …`). If the requested URL does not match a page that WP knows about, WP will display its ...
161,464
<p>I am trying to redirect all post pages, once a post or products are saved. It is redirecting to that page but it is not showing any message. Let me know how to register message for particular pages at admin side.</p> <pre><code>add_filter('wp_insert_post_data', 'ccl', 99); function ccl($data) { if ($data['post_...
[ { "answer_id": 161480, "author": "bestprogrammerintheworld", "author_id": 38848, "author_profile": "https://wordpress.stackexchange.com/users/38848", "pm_score": 1, "selected": false, "text": "<p>You could use filter <code>post_updated_messages</code> :</p>\n\n<pre><code>//Message handli...
2014/09/15
[ "https://wordpress.stackexchange.com/questions/161464", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59741/" ]
I am trying to redirect all post pages, once a post or products are saved. It is redirecting to that page but it is not showing any message. Let me know how to register message for particular pages at admin side. ``` add_filter('wp_insert_post_data', 'ccl', 99); function ccl($data) { if ($data['post_type'] !== 're...
You could use filter `post_updated_messages` : ``` //Message handling when updating posts function set_messages($messages) { global $post, $post_ID; $post_type = get_post_type( $post_ID ); $obj = get_post_type_object($post_type); $singular = $obj->labels->singular_name; $messages[$post_type] ...
161,469
<p>I'm new to Wordpress development and am seeing examples everywhere that have a line to declare the $post variable explicitly via:</p> <pre><code>global $post; </code></pre> <p>But I've tested my uses without that line and it makes no noticeable difference.</p> <p>Why should you declare $post explicitly?</p> <ul>...
[ { "answer_id": 161477, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 5, "selected": true, "text": "<p>In the tutorial (Example 1), he has to declare the global $post so that he can access the post_parent from it. In a...
2014/09/15
[ "https://wordpress.stackexchange.com/questions/161469", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59734/" ]
I'm new to Wordpress development and am seeing examples everywhere that have a line to declare the $post variable explicitly via: ``` global $post; ``` But I've tested my uses without that line and it makes no noticeable difference. Why should you declare $post explicitly? * [Example 1 (in tutorial)](http://www.wp...
In the tutorial (Example 1), he has to declare the global $post so that he can access the post\_parent from it. In a function like that, the $post is not a global variable unless he makes it so. In the codex (Example 2), it is declared global because the sample code is just a sample, explicitly trying to tell you that...
161,475
<p>Alright, this might be a tricky one to explain but I'll do my best.</p> <p>At the front page I want to display all the posts from all the categories. However I want them to be divided. Take this for an example:</p> <p><a href="https://i.stack.imgur.com/nuxbo.jpg" rel="nofollow noreferrer"><img src="https://i.stack...
[ { "answer_id": 162598, "author": "dalveer", "author_id": 60260, "author_profile": "https://wordpress.stackexchange.com/users/60260", "pm_score": -1, "selected": false, "text": "<p>You can also use this code for display category and post (if you are using default category and post of Word...
2014/09/15
[ "https://wordpress.stackexchange.com/questions/161475", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59749/" ]
Alright, this might be a tricky one to explain but I'll do my best. At the front page I want to display all the posts from all the categories. However I want them to be divided. Take this for an example: [![enter image description here](https://i.stack.imgur.com/nuxbo.jpg)](https://i.stack.imgur.com/nuxbo.jpg) The y...
To be able to order by category, you have to intercept the MySQL Query. Start with pre\_get\_posts: ``` add_action('pre_get_posts','setup_my_query_interception'); function setup_my_query_interception($query){ if(!is_admin() && $query->is_home() && $query->is_main_query()){ add_filter( 'posts_clauses', 'orde...
161,476
<p>Is there any way to remove the dashicons.min.css file from the frontend? I know that they are used by the admin panel, but my theme doesn't use them so it's an unnecessary request. </p>
[ { "answer_id": 161482, "author": "Domain", "author_id": 26523, "author_profile": "https://wordpress.stackexchange.com/users/26523", "pm_score": 6, "selected": true, "text": "<p>Try deregistering that stylesheet -</p>\n\n<pre><code>add_action( 'wp_print_styles', 'my_deregister_styles'...
2014/09/15
[ "https://wordpress.stackexchange.com/questions/161476", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27915/" ]
Is there any way to remove the dashicons.min.css file from the frontend? I know that they are used by the admin panel, but my theme doesn't use them so it's an unnecessary request.
Try deregistering that stylesheet - ``` add_action( 'wp_print_styles', 'my_deregister_styles', 100 ); function my_deregister_styles() { //wp_deregister_style( 'amethyst-dashicons-style' ); wp_deregister_style( 'dashicons' ); } ```
161,499
<p>After looking at various suggestions here and on StackOverflow, I still can't figure out why my solution is not working.</p> <p>I'm adding an extra <code>wp_editor</code>to my posts / pages, but the data is not saved / updated. What am I doing wrong?</p> <pre><code>class langauge{ function __construct() { ...
[ { "answer_id": 161501, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 0, "selected": false, "text": "<p>You probably are saving it, but you're not loading it back into the editor afterwards. You're saving it as <...
2014/09/15
[ "https://wordpress.stackexchange.com/questions/161499", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1447/" ]
After looking at various suggestions here and on StackOverflow, I still can't figure out why my solution is not working. I'm adding an extra `wp_editor`to my posts / pages, but the data is not saved / updated. What am I doing wrong? ``` class langauge{ function __construct() { add_action('edit_form_after...
you're using : ``` // only low case [a-z], no hyphens and underscores $editor = 'contenten'; ``` and then trying to get it by different name: ``` if(isset($_POST['content_en']) && $_POST['content_en'] != '') ``` another thing is u using different keys like @vancoder said also remember to sanitize the data : <h...
161,514
<p>I've got a site that I'm trying figure out how to apply different child themes to based on a subdomain. Applying the child themes shouldn't be difficult, it's more the .htaccess magic that I'm a bit iffy on.</p> <p>What I'm after is a site that has say:</p> <pre><code>example.com/red/ example.com/blue/ </code></pr...
[ { "answer_id": 161516, "author": "mrwweb", "author_id": 9844, "author_profile": "https://wordpress.stackexchange.com/users/9844", "pm_score": 1, "selected": false, "text": "<p>I'd encourage you to take one step further back and avoid using URLs to determine theme at all. (And FYI, what y...
2014/09/15
[ "https://wordpress.stackexchange.com/questions/161514", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59766/" ]
I've got a site that I'm trying figure out how to apply different child themes to based on a subdomain. Applying the child themes shouldn't be difficult, it's more the .htaccess magic that I'm a bit iffy on. What I'm after is a site that has say: ``` example.com/red/ example.com/blue/ ``` Where red and blue are dif...
I'd encourage you to take one step further back and avoid using URLs to determine theme at all. (And FYI, what you're describing are subfolders, not subdomains which would be red.example.com.) The reason not to do this is to avoid [duplicate content issues](https://support.google.com/webmasters/answer/66359?hl=en) wit...
161,530
<p>I was wondering what's the best way to create a form which can only be seen by registered users. The main idea I'd like to achieve here is for users to log in and gain access to a page where there's an application form which can be submitted multiple times. Each form will be stored on the database and associated wit...
[ { "answer_id": 161531, "author": "Caleb", "author_id": 59678, "author_profile": "https://wordpress.stackexchange.com/users/59678", "pm_score": 0, "selected": false, "text": "<p>I guess it depends on how much work you're wanting to put in. Gravity Forms plugin will do most of what you wan...
2014/09/16
[ "https://wordpress.stackexchange.com/questions/161530", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59770/" ]
I was wondering what's the best way to create a form which can only be seen by registered users. The main idea I'd like to achieve here is for users to log in and gain access to a page where there's an application form which can be submitted multiple times. Each form will be stored on the database and associated with t...
I think you will require to custom develop some part of it but most of it can be done with [Contact Form 7](http://wordpress.org/plugins/contact-form-7/) plugin. You can create forms with upload fields very easily in **Contact Form 7**. And you can make it visible for loggenin users only like this. ``` <?php if (...
161,533
<p>I am making one custom slider where admin can add slider image from back end. I am doing it with the help of custom post type. </p> <p><code>function.php</code></p> <pre><code>// Custom Post types for Feature project on home page add_action('init', 'create_feature'); function create_feature() { $fe...
[ { "answer_id": 161537, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 0, "selected": false, "text": "<p>Hre is the code for adding ID column in feature post type.</p>\n\n<pre><code>add_filter( 'manage_edit-feat...
2014/09/16
[ "https://wordpress.stackexchange.com/questions/161533", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59321/" ]
I am making one custom slider where admin can add slider image from back end. I am doing it with the help of custom post type. `function.php` ``` // Custom Post types for Feature project on home page add_action('init', 'create_feature'); function create_feature() { $feature_args = array( 'l...
If the purpose of the ID is just to set the order of the slides you are better off using the order attribute. Add `page-attributes` to the array for the `supports` argument in `$feature_args` Then in your loop you can specify `&orderby=menu_order&order=ASC` Then you can show it as a column you can refer to this [answ...
161,542
<p>I'm trying to use font awesome icons for my plugin. I've read this page in the <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_style" rel="nofollow noreferrer">codex</a> and this <a href="https://wordpress.stackexchange.com/questions/128247/programmatically-add-font-awesome-icons-to-category-widge...
[ { "answer_id": 161537, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 0, "selected": false, "text": "<p>Hre is the code for adding ID column in feature post type.</p>\n\n<pre><code>add_filter( 'manage_edit-feat...
2014/09/16
[ "https://wordpress.stackexchange.com/questions/161542", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58322/" ]
I'm trying to use font awesome icons for my plugin. I've read this page in the [codex](http://codex.wordpress.org/Function_Reference/wp_enqueue_style) and this [question](https://wordpress.stackexchange.com/questions/128247/programmatically-add-font-awesome-icons-to-category-widget). Here's what I've tried so far: I'...
If the purpose of the ID is just to set the order of the slides you are better off using the order attribute. Add `page-attributes` to the array for the `supports` argument in `$feature_args` Then in your loop you can specify `&orderby=menu_order&order=ASC` Then you can show it as a column you can refer to this [answ...
161,553
<p><strong>Rephrase question</strong></p> <p>I need to order posts inside the loop for my category <code>car</code>. What I need, if I visit the category page of <code>car</code>, I need all posts tagged <code>BMW</code> to display first, and then the other posts not tagged with the tag <code>BMW</code></p> <p>If my ...
[ { "answer_id": 161588, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": false, "text": "<p>You cannot do this type of sorting inside the loop. You can however be done by writing your own functio...
2014/09/16
[ "https://wordpress.stackexchange.com/questions/161553", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59777/" ]
**Rephrase question** I need to order posts inside the loop for my category `car`. What I need, if I visit the category page of `car`, I need all posts tagged `BMW` to display first, and then the other posts not tagged with the tag `BMW` If my `posts_per_page` is set to display 10 posts, and I'm on page one, and thre...
Here's a simplified combination of both @PieterGoosen and @ialocin fine answers by using the `loop_start` hook: ``` add_action( 'loop_start', function( $q ) { if( $q->is_main_query() && $q->is_category( 'car' ) ) usort( $q->posts, function( $a, $b ){ return -1 * has_tag( 'bmw', $a ) + 1 * has_t...
161,556
<p>Trying to get all posts (with all I mean all pages, posts and posts from custom post types). </p> <p>Is this possible? The documentation says I can only pass a string as <code>post_type</code> so how can I get all pages and custom post types?</p> <p>Example where custom post type is called <code>project</code></p>...
[ { "answer_id": 161557, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 3, "selected": false, "text": "<p>Why not use <code>WP_Query</code> instead. Like this.</p>\n\n<pre><code>$args = array(\n 'post__not_in'...
2014/09/16
[ "https://wordpress.stackexchange.com/questions/161556", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57245/" ]
Trying to get all posts (with all I mean all pages, posts and posts from custom post types). Is this possible? The documentation says I can only pass a string as `post_type` so how can I get all pages and custom post types? Example where custom post type is called `project` ``` $args = array( 'exclude' => ...
[`get_pages`](http://codex.wordpress.org/Function_Reference/get_pages) does not work with posts or post types that is not hierarchical like pages, so if your post type is hierarchical like posts, it would not work > > This function can also retrieve other post types using the 'post\_type' parameter, but the type must...
161,577
<p>I am trying to get a custom field value from all posts listed on current blog paginated page. Not sure if it's clear, let me explain it more.</p> <p>On blog index page (or on second page of pagination) I have 10 posts. And each post have a value for custom field <strong>my-field</strong>. So I want to list posts as...
[ { "answer_id": 161592, "author": "Douglas.Sesar", "author_id": 19945, "author_profile": "https://wordpress.stackexchange.com/users/19945", "pm_score": 3, "selected": true, "text": "<p>You could just rewind the query to loop through again:</p>\n\n<pre><code>&lt;?php rewind_posts(); ?&gt;\...
2014/09/16
[ "https://wordpress.stackexchange.com/questions/161577", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22461/" ]
I am trying to get a custom field value from all posts listed on current blog paginated page. Not sure if it's clear, let me explain it more. On blog index page (or on second page of pagination) I have 10 posts. And each post have a value for custom field **my-field**. So I want to list posts as it is but outside the ...
You could just rewind the query to loop through again: ``` <?php rewind_posts(); ?> <?php while ( have_posts() ) : the_post(); ?> <p>Post Number: <?php the_ID(); ?></p> <?php endwhile; ?> ``` [THE LOOP](http://codex.wordpress.org/The_Loop)
161,625
<p>I have 200 tags i am building movie directory website some tag as example</p> <pre><code>The Wolf of Wall Street (2013) Goodfellas (1990) Catch Me If You Can (2002) Monster (2003) The Bling Ring (2013) Devil's Knot (2013) The Frozen Ground (2013) Public Enemies (2009) American Gangster (2007) The Iceman (2012) </co...
[ { "answer_id": 161630, "author": "Mladen Petrovic", "author_id": 28673, "author_profile": "https://wordpress.stackexchange.com/users/28673", "pm_score": 0, "selected": false, "text": "<p>Because ordering posts by value of tags is not an usual occurrence you can't order loop by tags. You ...
2014/09/16
[ "https://wordpress.stackexchange.com/questions/161625", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59810/" ]
I have 200 tags i am building movie directory website some tag as example ``` The Wolf of Wall Street (2013) Goodfellas (1990) Catch Me If You Can (2002) Monster (2003) The Bling Ring (2013) Devil's Knot (2013) The Frozen Ground (2013) Public Enemies (2009) American Gangster (2007) The Iceman (2012) ``` my requireme...
From what I can read in your comments (and your follow up question), you are trying to intercept the `WHERE` clause of your query. The `name__like` argument you mentioned in your other question won't work for what you are trying to achieve. The clause is built this way by `get_terms()` (the underlying function of `get_...
161,632
<p>Background: Creating a dynamic shortcode based on user inputs. This shortcode should change the output of <code>do_shortcode</code> based on the fields the user selects.</p> <p>Example: On a page, a user selects </p> <blockquote> <p>"Show me: (X) Skateboarding (X) Basketball ( ) Hockey"</p> </blockquote> <p>Wh...
[ { "answer_id": 161637, "author": "Caleb", "author_id": 59678, "author_profile": "https://wordpress.stackexchange.com/users/59678", "pm_score": 0, "selected": false, "text": "<p>on click of your \"Insert Shortcode\" button, you'll want to use JavaScript/jQuery to see which checkboxes are ...
2014/09/16
[ "https://wordpress.stackexchange.com/questions/161632", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59814/" ]
Background: Creating a dynamic shortcode based on user inputs. This shortcode should change the output of `do_shortcode` based on the fields the user selects. Example: On a page, a user selects > > "Show me: (X) Skateboarding (X) Basketball ( ) Hockey" > > > When they click submit, the shortcode to do this shou...
Theory ------ It might have been hard to word for you, but is actually quite clear what you are trying to accomplish. A shortcode is a good way to insert dynamic content into a page (or post), the point at which your idea fails is the notion of a "dynamic shortcode". Use the shortcode to insert the form into your co...
161,685
<p>I've got this script to update a table in my database with the logout time of a user, then when they log in next time, this data is shown in the form of "Last login: date time".</p> <p>However this isnt working, and was hoping for some help.</p> <p>Posted in <code>functions.php</code></p> <pre><code>function user...
[ { "answer_id": 161720, "author": "Philip Downer", "author_id": 947, "author_profile": "https://wordpress.stackexchange.com/users/947", "pm_score": 0, "selected": false, "text": "<p>You second function, last_login references the $userloginfo variable which is not within the function's sco...
2014/09/17
[ "https://wordpress.stackexchange.com/questions/161685", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59835/" ]
I've got this script to update a table in my database with the logout time of a user, then when they log in next time, this data is shown in the form of "Last login: date time". However this isnt working, and was hoping for some help. Posted in `functions.php` ``` function userloginvarset($login){ global $user_I...
I found it. After a lot of research I found the way to hook into logout and get user data, and as i was looking for that i found the exact answer i was looking for. ``` function users_last_login() { $cur_login = current_time('mysql'); $userinfo = wp_get_current_user(); update_user_meta( $userinfo->ID, 'la...
161,711
<p>How to get current page ID outside the loop?</p>
[ { "answer_id": 161714, "author": "caramba", "author_id": 57245, "author_profile": "https://wordpress.stackexchange.com/users/57245", "pm_score": 7, "selected": true, "text": "<p><strong>Try</strong></p>\n\n<pre><code>global $post;\necho $post-&gt;ID;\n</code></pre>\n\n<p><strong>or</stro...
2014/09/17
[ "https://wordpress.stackexchange.com/questions/161711", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58576/" ]
How to get current page ID outside the loop?
**Try** ``` global $post; echo $post->ID; ``` **or** (I don't know the difference) ``` global $wp_query; echo $wp_query->post->ID; ```
161,740
<p>I need to get a total count of characters for post titles and post text characters. Are there any build-in WordPress functions available for that? My posts are paginated so the numbers for post text count it would have to come from DB?</p> <p>Using these numbers I would like to build a function that will feed my Go...
[ { "answer_id": 161744, "author": "Tomás Cot", "author_id": 57843, "author_profile": "https://wordpress.stackexchange.com/users/57843", "pm_score": 4, "selected": true, "text": "<p>You can use this function <a href=\"http://codex.wordpress.org/Function_Reference/wp_strip_all_tags\" rel=\"...
2014/09/17
[ "https://wordpress.stackexchange.com/questions/161740", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59859/" ]
I need to get a total count of characters for post titles and post text characters. Are there any build-in WordPress functions available for that? My posts are paginated so the numbers for post text count it would have to come from DB? Using these numbers I would like to build a function that will feed my Google Tag M...
You can use this function [`wp_strip_all_tags`](http://codex.wordpress.org/Function_Reference/wp_strip_all_tags). ``` strlen( wp_strip_all_tags($post->post_content)); ``` With that you get rid of all the HTML tags. Just a little extra detail, you might want to strip the shortcodes, too. You can use this function [`...
161,751
<p>I've created a custom user role and am attempting to change the users role from CUSTOMER to ADVOCATE on purchase of a particular product (using WooCommerce). I'm really close but struggling to get the correctly serialized data into my table: </p> <pre><code>$order = new WC_Order( $order_id ); $items = $order-&gt;ge...
[ { "answer_id": 161753, "author": "Domain", "author_id": 26523, "author_profile": "https://wordpress.stackexchange.com/users/26523", "pm_score": 3, "selected": true, "text": "<p>I think you are not handling the array part correctly.\nThe right syntax is - </p>\n\n<pre><code>$new_role = ar...
2014/09/17
[ "https://wordpress.stackexchange.com/questions/161751", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45504/" ]
I've created a custom user role and am attempting to change the users role from CUSTOMER to ADVOCATE on purchase of a particular product (using WooCommerce). I'm really close but struggling to get the correctly serialized data into my table: ``` $order = new WC_Order( $order_id ); $items = $order->get_items(); $new_...
I think you are not handling the array part correctly. The right syntax is - ``` $new_role = array("advocate" => 1); ``` The syntax that you have used is shown when you print some array on your screen but it should be written in above format in your PHP code. Currently, you are capturing it as a string and not an a...
161,774
<p>How can I obtain ID of images attached (and not necessarily inserted) to a custom post type ? I want to pass this argument in order to use this images in soliloquy slider</p>
[ { "answer_id": 161753, "author": "Domain", "author_id": 26523, "author_profile": "https://wordpress.stackexchange.com/users/26523", "pm_score": 3, "selected": true, "text": "<p>I think you are not handling the array part correctly.\nThe right syntax is - </p>\n\n<pre><code>$new_role = ar...
2014/09/17
[ "https://wordpress.stackexchange.com/questions/161774", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7521/" ]
How can I obtain ID of images attached (and not necessarily inserted) to a custom post type ? I want to pass this argument in order to use this images in soliloquy slider
I think you are not handling the array part correctly. The right syntax is - ``` $new_role = array("advocate" => 1); ``` The syntax that you have used is shown when you print some array on your screen but it should be written in above format in your PHP code. Currently, you are capturing it as a string and not an a...
161,784
<p>Here is my problem. I'm working on a video website and we have different categories for each video. We have setup a custom post type called "videos" in which we use the different taxonomies to categorize them. We use "category" icons to represent each video category, but I can't figure out how to display them outsid...
[ { "answer_id": 161753, "author": "Domain", "author_id": 26523, "author_profile": "https://wordpress.stackexchange.com/users/26523", "pm_score": 3, "selected": true, "text": "<p>I think you are not handling the array part correctly.\nThe right syntax is - </p>\n\n<pre><code>$new_role = ar...
2014/09/17
[ "https://wordpress.stackexchange.com/questions/161784", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17913/" ]
Here is my problem. I'm working on a video website and we have different categories for each video. We have setup a custom post type called "videos" in which we use the different taxonomies to categorize them. We use "category" icons to represent each video category, but I can't figure out how to display them outside t...
I think you are not handling the array part correctly. The right syntax is - ``` $new_role = array("advocate" => 1); ``` The syntax that you have used is shown when you print some array on your screen but it should be written in above format in your PHP code. Currently, you are capturing it as a string and not an a...
161,788
<p>Today I needed to change the arguments on a custom taxonomy that was already registered by a <a href="https://wordpress.org/plugins/people-profile-cpt/" rel="noreferrer">third party plugin</a>. Specifically I wanted to set the <code>show_admin_column</code> argument to <code>true</code> and change the <code>rewrite<...
[ { "answer_id": 161789, "author": "mrwweb", "author_id": 9844, "author_profile": "https://wordpress.stackexchange.com/users/9844", "pm_score": 6, "selected": true, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/register_taxonomy\" rel=\"noreferrer\"><code>register_tax...
2014/09/17
[ "https://wordpress.stackexchange.com/questions/161788", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9844/" ]
Today I needed to change the arguments on a custom taxonomy that was already registered by a [third party plugin](https://wordpress.org/plugins/people-profile-cpt/). Specifically I wanted to set the `show_admin_column` argument to `true` and change the `rewrite` slug so that it wasn't just the taxonomy slug. In this ca...
[`register_taxonomy()`](http://codex.wordpress.org/Function_Reference/register_taxonomy) is the tool for the job. From the Codex: > > This function adds or overwrites a taxonomy. > > > One option would be to copy the `register_taxonomy()` `$args` and modify them. However, that would mean that any future changes t...
161,832
<p>I'm sitting here trying to figure out how to change the Read More text. I'm currently creating a Child Theme of <a href="http://alienwp.com/themes/oxygen/" rel="nofollow noreferrer">Oxygen</a> and as far as I can tell, they don't have a function to easily change it.</p> <p>I want to change the text without copying ...
[ { "answer_id": 161842, "author": "Kees de Bruin", "author_id": 50088, "author_profile": "https://wordpress.stackexchange.com/users/50088", "pm_score": 0, "selected": false, "text": "<p>From the <a href=\"http://codex.wordpress.org/Customizing_the_Read_More#Modify_The_Read_More_Link_Text\...
2014/09/18
[ "https://wordpress.stackexchange.com/questions/161832", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59902/" ]
I'm sitting here trying to figure out how to change the Read More text. I'm currently creating a Child Theme of [Oxygen](http://alienwp.com/themes/oxygen/) and as far as I can tell, they don't have a function to easily change it. I want to change the text without copying over the entire `index.php` file though this is...
As this line of code is hardcoded in the *index.php* file rather than called via a function you only really have two options: * Write your own function to call this code (with your chosen read more text), then replace the relevant section in the child theme's *index.php* file with a call to this function. The function...
161,841
<p>My client wants to ad line breaks in category description via keyboard enter. In the editor the white space is added, but it is not shown on the website. </p> <p>I can add it with <code>&amp;nbsp;</code> but I have to be able to do it by enter key.</p> <p>I tried commenting out this in <code>default-filters.php</c...
[ { "answer_id": 161842, "author": "Kees de Bruin", "author_id": 50088, "author_profile": "https://wordpress.stackexchange.com/users/50088", "pm_score": 0, "selected": false, "text": "<p>From the <a href=\"http://codex.wordpress.org/Customizing_the_Read_More#Modify_The_Read_More_Link_Text\...
2014/09/18
[ "https://wordpress.stackexchange.com/questions/161841", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58117/" ]
My client wants to ad line breaks in category description via keyboard enter. In the editor the white space is added, but it is not shown on the website. I can add it with `&nbsp;` but I have to be able to do it by enter key. I tried commenting out this in `default-filters.php`: ``` foreach ( array( 'pre_term_descr...
As this line of code is hardcoded in the *index.php* file rather than called via a function you only really have two options: * Write your own function to call this code (with your chosen read more text), then replace the relevant section in the child theme's *index.php* file with a call to this function. The function...
161,856
<p>I use the plugin <a href="https://wordpress.org/plugins/show-post-in-lightbox/" rel="nofollow noreferrer">https://wordpress.org/plugins/show-post-in-lightbox/</a> to display all featured image of every post on a page. whenever one of these images get clicked on a lightbox will appear showing the post content.</p> <...
[ { "answer_id": 251887, "author": "Tunji", "author_id": 54764, "author_profile": "https://wordpress.stackexchange.com/users/54764", "pm_score": 3, "selected": true, "text": "<p>First of all, you should learn how to debug. If you're getting a 500 internal error, then the error should show ...
2014/09/18
[ "https://wordpress.stackexchange.com/questions/161856", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59911/" ]
I use the plugin <https://wordpress.org/plugins/show-post-in-lightbox/> to display all featured image of every post on a page. whenever one of these images get clicked on a lightbox will appear showing the post content. This all works fine but the original code that display the content uses: ``` if($_REQUEST['popup']...
First of all, you should learn how to debug. If you're getting a 500 internal error, then the error should show up in your error logs. I've made the following corrections to your code below: [**NEVER USE extract()**](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#dont-extract) instead g...
161,859
<p>is there a way I can get </p> <pre><code>&lt;?php the_field("do_stuff")?&gt; </code></pre> <p>to go in the middle of a multiple loop like this:</p> <pre><code> &lt;?php query_posts('cat=4&amp;posts_per_page=5'); ?&gt; &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt...
[ { "answer_id": 161864, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": true, "text": "<p>You should not be using <a href=\"http://codex.wordpress.org/Function_Reference/query_posts\" rel=\"nofo...
2014/09/18
[ "https://wordpress.stackexchange.com/questions/161859", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6787/" ]
is there a way I can get ``` <?php the_field("do_stuff")?> ``` to go in the middle of a multiple loop like this: ``` <?php query_posts('cat=4&posts_per_page=5'); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h1><?php the_title() ;?></h1> ...
You should not be using [`query_posts`](http://codex.wordpress.org/Function_Reference/query_posts) at all, it is just problematic and is prone to failure > > **Note:** This function isn't meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. quer...
161,893
<p>I have inherited a WP site where some home page slides are pulled using </p> <pre><code>&lt;?php $po = get_posts( array('post_type' =&gt; 'page', 'meta_key' =&gt; 'Home Slide', 'order' =&gt; 'ASC', 'orderby' =&gt; 'menu_order', 'posts_per_page' =&gt; 5 ) ); ?&gt; </code></pre> <p>The site owners want these slide...
[ { "answer_id": 161896, "author": "jerrygarciuh", "author_id": 12414, "author_profile": "https://wordpress.stackexchange.com/users/12414", "pm_score": 0, "selected": false, "text": "<p>Examining the postmeta table I found that meta_key is not the name of the key. The name is 'Home Slide'....
2014/09/18
[ "https://wordpress.stackexchange.com/questions/161893", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12414/" ]
I have inherited a WP site where some home page slides are pulled using ``` <?php $po = get_posts( array('post_type' => 'page', 'meta_key' => 'Home Slide', 'order' => 'ASC', 'orderby' => 'menu_order', 'posts_per_page' => 5 ) ); ?> ``` The site owners want these slides changed but the Home Slide meta\_key is not e...
Go to the Page editor. Click the "Screen Options" box in the top right corner. In the dropdown, turn on the "Custom Fields" option. Now scroll down below the post editor area. Edit the fields as needed.
161,905
<p>I want to combine little javascript files while keeping other script's dependencies for them. Is there any way?</p> <hr> <p><strong>Details:</strong></p> <p>New version of BuddyPress enqueue 6-7 little javascripts:</p> <pre><code>// Legacy 'bp-confirm', 'bp-widget-members', 'bp-jquery-query', 'bp-jquery-cookie',...
[ { "answer_id": 162214, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 1, "selected": false, "text": "<p>In my honest opinion, I would <strong>not</strong> do that. </p>\n\n<p><strong>PRO'S and CON's</strong>...
2014/09/18
[ "https://wordpress.stackexchange.com/questions/161905", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1372/" ]
I want to combine little javascript files while keeping other script's dependencies for them. Is there any way? --- **Details:** New version of BuddyPress enqueue 6-7 little javascripts: ``` // Legacy 'bp-confirm', 'bp-widget-members', 'bp-jquery-query', 'bp-jquery-cookie', // 2.1 'jquery-caret', 'jquery-atwho' ``...
From your comment above I read > > This is one of the reason why i am looking for a way to say to > wordpress: "hey, i added those js files, dont worry". This is whole > purpose of this question > > > I think is perfectly fair, I +1ed your Q but the problem is that way does not exists, or better does not exist...
161,918
<p>When user is logged in WP add in its footer this CSS:</p> <pre><code>&lt;link rel='stylesheet' id='open-sans-css' href='//fonts.googleapis.com/css?family=Open+Sans....' type='text/css' media='all' /&gt; </code></pre> <p>That style is not registered inside my theme, if I change my theme I still have that file call...
[ { "answer_id": 161986, "author": "Caleb", "author_id": 59678, "author_profile": "https://wordpress.stackexchange.com/users/59678", "pm_score": 3, "selected": true, "text": "<p>WP Core actually uses Open Sans font; it's not a plugin. there is a <a href=\"https://wordpress.org/plugins/remo...
2014/09/19
[ "https://wordpress.stackexchange.com/questions/161918", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25053/" ]
When user is logged in WP add in its footer this CSS: ``` <link rel='stylesheet' id='open-sans-css' href='//fonts.googleapis.com/css?family=Open+Sans....' type='text/css' media='all' /> ``` That style is not registered inside my theme, if I change my theme I still have that file called in any theme, it is somewhere...
WP Core actually uses Open Sans font; it's not a plugin. there is a [plugin](https://wordpress.org/plugins/remove-open-sans-font-from-wp-core/) that removes it, but you can probably simply [dequeue](http://codex.wordpress.org/Function_Reference/wp_dequeue_style) or [deregister](http://codex.wordpress.org/Function_Refer...
161,920
<p>I dont know where i am going wrong.I want to save the values of my radio buttons in custom meta box.Here is my code.</p> <pre><code>&lt;?php if (!function_exists('custom_meta_box')) { function custom_meta_box(){ add_meta_box( 'custom-meta-box', __('Post Optio...
[ { "answer_id": 161986, "author": "Caleb", "author_id": 59678, "author_profile": "https://wordpress.stackexchange.com/users/59678", "pm_score": 3, "selected": true, "text": "<p>WP Core actually uses Open Sans font; it's not a plugin. there is a <a href=\"https://wordpress.org/plugins/remo...
2014/09/19
[ "https://wordpress.stackexchange.com/questions/161920", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54732/" ]
I dont know where i am going wrong.I want to save the values of my radio buttons in custom meta box.Here is my code. ``` <?php if (!function_exists('custom_meta_box')) { function custom_meta_box(){ add_meta_box( 'custom-meta-box', __('Post Options', 'spectacular...
WP Core actually uses Open Sans font; it's not a plugin. there is a [plugin](https://wordpress.org/plugins/remove-open-sans-font-from-wp-core/) that removes it, but you can probably simply [dequeue](http://codex.wordpress.org/Function_Reference/wp_dequeue_style) or [deregister](http://codex.wordpress.org/Function_Refer...
161,926
<p>I've paid to someone to create a theme for me. Everything works fine, except the excerpt on category posts.</p> <p>It only shows an excerpt of the post ( not image ) and when I add a shortcode in the excerpt, it show this as text and doesn't compile it </p> <p>When I go to full post, the image and shortcodes works...
[ { "answer_id": 161931, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Please use </p>\n\n<pre><code>&lt;?php echo do_shortcode( $content ) ?&gt;\n</code></pre>\n\n<p>instead of \"plai...
2014/09/19
[ "https://wordpress.stackexchange.com/questions/161926", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59942/" ]
I've paid to someone to create a theme for me. Everything works fine, except the excerpt on category posts. It only shows an excerpt of the post ( not image ) and when I add a shortcode in the excerpt, it show this as text and doesn't compile it When I go to full post, the image and shortcodes works well. I can add...
To get shortcodes to work in the excerpt you'll have to add a filter to your **functions.php** file (found inside your theme folder). ``` add_filter('the_excerpt', 'do_shortcode'); ``` Your other question about the images not showing is hard to answer without knowing how your theme code is like. It has to do with ho...
161,963
<p>I'm looking for a pragmatic way to delete about 100+ individual pages worth of inline styles. I had entered in content for a client by copying and pasting from Word, which took all that data with it and wrapped it in inline styles. It doesn't make sense to go through each post individually. Has anyone done this befo...
[ { "answer_id": 161965, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 3, "selected": true, "text": "<p>I would use the <a href=\"https://wordpress.org/plugins/search-regex/\" rel=\"nofollow\">Search Regex plugin<...
2014/09/19
[ "https://wordpress.stackexchange.com/questions/161963", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54174/" ]
I'm looking for a pragmatic way to delete about 100+ individual pages worth of inline styles. I had entered in content for a client by copying and pasting from Word, which took all that data with it and wrapped it in inline styles. It doesn't make sense to go through each post individually. Has anyone done this before?...
I would use the [Search Regex plugin](https://wordpress.org/plugins/search-regex/). It will allow you to use a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) to find and replace (in your case *delete*) inline styles. Make sure you backup your database before you ...
161,977
<p>I want to call some web service when i publish a post. I want to add a checkbox so as to decide whether to call or not call after publishing.</p> <p>I have found the code to call both REST and SOAP web services but i dont know:</p> <ol> <li>How to add a checkbox in the "new post" admin page.</li> <li>How to invoke...
[ { "answer_id": 161978, "author": "Steve Claridge", "author_id": 1941, "author_profile": "https://wordpress.stackexchange.com/users/1941", "pm_score": 1, "selected": false, "text": "<p>You can trigger your web-service-calling code by using this: <a href=\"http://codex.wordpress.org/Plugin...
2014/09/19
[ "https://wordpress.stackexchange.com/questions/161977", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59971/" ]
I want to call some web service when i publish a post. I want to add a checkbox so as to decide whether to call or not call after publishing. I have found the code to call both REST and SOAP web services but i dont know: 1. How to add a checkbox in the "new post" admin page. 2. How to invoke a function that contains ...
1. To add a checkbox you need to use the [`add_meta_box`](http://codex.wordpress.org/Function_Reference/add_meta_box) function, with this you can create a metabox for the new post screen. You have to create a function that generates the checkbox element, and that's it. 2. You can use the action [`publish_post`](http://...
161,980
<p>I have a custom post type for a <em>timeline activities</em>.</p> <p>each post of them has a custom field type of <strong>DATE</strong>. field name :<code>activity-date</code></p> <p>I'm using <a href="https://wordpress.org/plugins/types/" rel="nofollow noreferrer">TYPES plugin</a> for <strong>Custom Post Type</st...
[ { "answer_id": 161978, "author": "Steve Claridge", "author_id": 1941, "author_profile": "https://wordpress.stackexchange.com/users/1941", "pm_score": 1, "selected": false, "text": "<p>You can trigger your web-service-calling code by using this: <a href=\"http://codex.wordpress.org/Plugin...
2014/09/19
[ "https://wordpress.stackexchange.com/questions/161980", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/52831/" ]
I have a custom post type for a *timeline activities*. each post of them has a custom field type of **DATE**. field name :`activity-date` I'm using [TYPES plugin](https://wordpress.org/plugins/types/) for **Custom Post Type** and **Custom Fields** I would like to order these posts by the custom date field, I tried ...
1. To add a checkbox you need to use the [`add_meta_box`](http://codex.wordpress.org/Function_Reference/add_meta_box) function, with this you can create a metabox for the new post screen. You have to create a function that generates the checkbox element, and that's it. 2. You can use the action [`publish_post`](http://...
161,989
<p>I am trying to fix a site which has several redirects that seem to have been added via a plugin called <a href="https://wordpress.org/support/plugin/peters-login-redirect" rel="nofollow">Peters plugin redirect</a>. The plugin has since been deactivated and delated but the redirects loop is stil present. I have tried...
[ { "answer_id": 161978, "author": "Steve Claridge", "author_id": 1941, "author_profile": "https://wordpress.stackexchange.com/users/1941", "pm_score": 1, "selected": false, "text": "<p>You can trigger your web-service-calling code by using this: <a href=\"http://codex.wordpress.org/Plugin...
2014/09/19
[ "https://wordpress.stackexchange.com/questions/161989", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34045/" ]
I am trying to fix a site which has several redirects that seem to have been added via a plugin called [Peters plugin redirect](https://wordpress.org/support/plugin/peters-login-redirect). The plugin has since been deactivated and delated but the redirects loop is stil present. I have tried the following: * deactivati...
1. To add a checkbox you need to use the [`add_meta_box`](http://codex.wordpress.org/Function_Reference/add_meta_box) function, with this you can create a metabox for the new post screen. You have to create a function that generates the checkbox element, and that's it. 2. You can use the action [`publish_post`](http://...
162,002
<p>I was able to upgrade Wordpress 4.0 on my local machine, and I also just updated some plugins on the production machine, but when I try to update Wordpress 4.0 on the production machine, it is asking for my FTP credentials. Why is it asking for these when it never needed them before?</p> <p>Could CloudFlare have an...
[ { "answer_id": 162076, "author": "Chloe", "author_id": 57947, "author_profile": "https://wordpress.stackexchange.com/users/57947", "pm_score": 3, "selected": true, "text": "<p>I had to also change the owner of the root web directory.</p>\n\n<pre><code>chown apache:apache . # or chown a...
2014/09/19
[ "https://wordpress.stackexchange.com/questions/162002", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57947/" ]
I was able to upgrade Wordpress 4.0 on my local machine, and I also just updated some plugins on the production machine, but when I try to update Wordpress 4.0 on the production machine, it is asking for my FTP credentials. Why is it asking for these when it never needed them before? Could CloudFlare have anything to ...
I had to also change the owner of the root web directory. ``` chown apache:apache . # or chown apache:apache /var/www/html ``` --- Edit by Otto: Chloe, as you asked for more information than I could reasonably put into a comment, I'm appending this on to your answer. I hope that is okay. If not, feel free to reve...
162,016
<p>I am a newbie in WordPress theme development. I have a WordPress site on online. I create a new home page for my wp site and I want to use it my wp site instead of old home page. And I want that the other pages would stay same as before. In that case, what should I do? Please share the details information.</p> <p>A...
[ { "answer_id": 162021, "author": "Domain", "author_id": 26523, "author_profile": "https://wordpress.stackexchange.com/users/26523", "pm_score": 0, "selected": false, "text": "<p>you don't need to create child theme to assign a page as Home page. <br><br>\nGoto Wordpress dashboard (wp-adm...
2014/09/20
[ "https://wordpress.stackexchange.com/questions/162016", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59990/" ]
I am a newbie in WordPress theme development. I have a WordPress site on online. I create a new home page for my wp site and I want to use it my wp site instead of old home page. And I want that the other pages would stay same as before. In that case, what should I do? Please share the details information. And if anyb...
You should use custom template for this purpose. Create a new file homepage.php and write the below code. ``` <?php /* Template Name: Homepage */ ?> <?php <!--Your code goes here--> ?> ``` Then, create a new page in admin panel like HOME and in right sidebar select your "homepage" template you...
162,038
<p>I am making a theme. I can insert logo by editing in header file but how it can be dynamiccaly from wordpress dashboard</p>
[ { "answer_id": 162021, "author": "Domain", "author_id": 26523, "author_profile": "https://wordpress.stackexchange.com/users/26523", "pm_score": 0, "selected": false, "text": "<p>you don't need to create child theme to assign a page as Home page. <br><br>\nGoto Wordpress dashboard (wp-adm...
2014/09/20
[ "https://wordpress.stackexchange.com/questions/162038", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59996/" ]
I am making a theme. I can insert logo by editing in header file but how it can be dynamiccaly from wordpress dashboard
You should use custom template for this purpose. Create a new file homepage.php and write the below code. ``` <?php /* Template Name: Homepage */ ?> <?php <!--Your code goes here--> ?> ``` Then, create a new page in admin panel like HOME and in right sidebar select your "homepage" template you...
162,050
<p>I've created a custom meta box called 'Location Map' and want to provide a functionality to the client to simply copy paste the location's google map's iframe embed code so that it directly appears on the front-end. The value just doesn't store. Below is the code to save the meta box.</p> <pre><code>/* Save the met...
[ { "answer_id": 162114, "author": "Tomás Cot", "author_id": 57843, "author_profile": "https://wordpress.stackexchange.com/users/57843", "pm_score": 1, "selected": true, "text": "<p>I tried your code and it works:</p>\n\n<p>I changed the <code>wp_verify_nonce</code> function, because that ...
2014/09/20
[ "https://wordpress.stackexchange.com/questions/162050", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33650/" ]
I've created a custom meta box called 'Location Map' and want to provide a functionality to the client to simply copy paste the location's google map's iframe embed code so that it directly appears on the front-end. The value just doesn't store. Below is the code to save the meta box. ``` /* Save the meta box's post m...
I tried your code and it works: I changed the `wp_verify_nonce` function, because that wasn't working for me. I added an action instead of what it had. Now, for this to work, you have to create a nonce field with a code like this, of course that you can change the names if you want. ``` //this goes in the function th...
162,067
<p>I want to add a custom post divider to separate my posts. I'm using the Enfold theme in WordPress.org. I've searched for the answer to my question but I don't understand the coding language.</p> <p>I understand that WordPress uses a post loop. And somehow I can include code within the loop to produce my custom divi...
[ { "answer_id": 162114, "author": "Tomás Cot", "author_id": 57843, "author_profile": "https://wordpress.stackexchange.com/users/57843", "pm_score": 1, "selected": true, "text": "<p>I tried your code and it works:</p>\n\n<p>I changed the <code>wp_verify_nonce</code> function, because that ...
2014/09/20
[ "https://wordpress.stackexchange.com/questions/162067", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60011/" ]
I want to add a custom post divider to separate my posts. I'm using the Enfold theme in WordPress.org. I've searched for the answer to my question but I don't understand the coding language. I understand that WordPress uses a post loop. And somehow I can include code within the loop to produce my custom divider. I don...
I tried your code and it works: I changed the `wp_verify_nonce` function, because that wasn't working for me. I added an action instead of what it had. Now, for this to work, you have to create a nonce field with a code like this, of course that you can change the names if you want. ``` //this goes in the function th...
162,109
<p>I use a theme that have a character limit for shortpost and show [...] at the end of character limit.</p> <p>I want to remove this, so I search for <code>the_excerpt();</code> and replace with <code>the_content();</code></p> <p>The problem solve with normal content but still have problem with image post type and t...
[ { "answer_id": 162111, "author": "Tomás Cot", "author_id": 57843, "author_profile": "https://wordpress.stackexchange.com/users/57843", "pm_score": 0, "selected": false, "text": "<p>You should add this to your <code>functions.php</code></p>\n\n<pre><code> function custom_excerpt_more( ...
2014/09/21
[ "https://wordpress.stackexchange.com/questions/162109", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59942/" ]
I use a theme that have a character limit for shortpost and show [...] at the end of character limit. I want to remove this, so I search for `the_excerpt();` and replace with `the_content();` The problem solve with normal content but still have problem with image post type and there is `<?php the_excerpt(); ?>` that ...
The codex is your friend and should be your first stop :-) The `[...]` is added by [`the_excerpt()`](http://codex.wordpress.org/Function_Reference/the_excerpt#For_versions_2.9_and_higher_of_WordPress). There is a filter supplied called the [`excerpt_more`](http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt...
162,138
<p>I'm creating a system, where some custom post drafts are being prepared, and after certain actions taken by moderators it is being automatically published.</p> <p>So, first I create post draft like that:</p> <pre><code>$newpost = array( 'post_title' =&gt; 'Raport '.date("Y-m-d"), 'post_content' =&gt; ...
[ { "answer_id": 162156, "author": "DrewAPicture", "author_id": 33309, "author_profile": "https://wordpress.stackexchange.com/users/33309", "pm_score": 0, "selected": false, "text": "<p>When drafts are published, the permalink is rewritten from the title of the post. Originally I thought m...
2014/09/21
[ "https://wordpress.stackexchange.com/questions/162138", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15834/" ]
I'm creating a system, where some custom post drafts are being prepared, and after certain actions taken by moderators it is being automatically published. So, first I create post draft like that: ``` $newpost = array( 'post_title' => 'Raport '.date("Y-m-d"), 'post_content' => 'Add your content here', ...
Although the name of the function `wp_publish_post()` suggests that it can be used to publish a post it should obviously not be used to publish a draft post programmatically. The way to do so is to use `wp_update_post()` and set the post status manually to `publish`: ``` <?php // Update post with the ID 42 $postData...
162,146
<p>How do I get the [View details] link to appear on the Plugin admin page in the Description area? </p> <p>The plugin is working fine, the version and authors (with links) show up fine, but no [View details] like most other plugins.</p> <p>Perhaps I'm asking the wrong question, but I'm working on a plugin and I wou...
[ { "answer_id": 162149, "author": "DrewAPicture", "author_id": 33309, "author_profile": "https://wordpress.stackexchange.com/users/33309", "pm_score": 4, "selected": true, "text": "<p>The 'View details' link in the installed plugins list table is only shown for plugins that are hosted in ...
2014/09/21
[ "https://wordpress.stackexchange.com/questions/162146", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59620/" ]
How do I get the [View details] link to appear on the Plugin admin page in the Description area? The plugin is working fine, the version and authors (with links) show up fine, but no [View details] like most other plugins. Perhaps I'm asking the wrong question, but I'm working on a plugin and I would like to show th...
The 'View details' link in the installed plugins list table is only shown for plugins that are hosted in the WordPress.org plugin repository. If you take a look at the [source](https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-plugins-list-table.php#L522) for `WP_Plugins_List_Table->single_ro...
162,147
<p>I'm currently developing a bus route planner, using Wordpress as my CMS. I've added some JQuery code to add support for ajax (so visitors can use the route planner and load the route without having to go to another page), but it's not working.</p> <p>On closer inspection using Chrome's Inspect Element, Wordpress ap...
[ { "answer_id": 162148, "author": "DrewAPicture", "author_id": 33309, "author_profile": "https://wordpress.stackexchange.com/users/33309", "pm_score": 3, "selected": true, "text": "<p>The post editor is really not meant for inserting functional code like JavaScript into the page.</p>\n\n<...
2014/09/21
[ "https://wordpress.stackexchange.com/questions/162147", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60010/" ]
I'm currently developing a bus route planner, using Wordpress as my CMS. I've added some JQuery code to add support for ajax (so visitors can use the route planner and load the route without having to go to another page), but it's not working. On closer inspection using Chrome's Inspect Element, Wordpress appears to b...
The post editor is really not meant for inserting functional code like JavaScript into the page. Anything you put through the post editor will get run through [`wpautop()`](https://developer.wordpress.org/reference/functions/wpautop/) before output, which is what adds the paragraph tags -- even if you enter it via the...
162,150
<p>I'm working on a script to easily move js and css scripts to the footer using the add_data function in $wp_scripts and $wp_styles. I know for scripts that if the group is greater than 0 the script call will be moved to the footer (first foreach below does that). However, setting the group for styles doesn't have the...
[ { "answer_id": 162483, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 4, "selected": true, "text": "<p>I don't know what your exact reason is for this, but you should scrap the idea of moving styles to the f...
2014/09/21
[ "https://wordpress.stackexchange.com/questions/162150", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25029/" ]
I'm working on a script to easily move js and css scripts to the footer using the add\_data function in $wp\_scripts and $wp\_styles. I know for scripts that if the group is greater than 0 the script call will be moved to the footer (first foreach below does that). However, setting the group for styles doesn't have the...
I don't know what your exact reason is for this, but you should scrap the idea of moving styles to the footer. If you though of a gain in speed, you might gain a unnoticable amount, if any, but that will be at the cost of other bigger things. Styles should always be added inside the `<head></head>` tag. The reason is ...
162,162
<p>Trying to learn more about creating my own themes and not using any plugins I wanted an ability to display all the images in a post excluding the thumbnail in my <code>single-foobar.php</code> file and I can do that with:</p> <pre><code>&lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $thumb...
[ { "answer_id": 162165, "author": "Bernie", "author_id": 48370, "author_profile": "https://wordpress.stackexchange.com/users/48370", "pm_score": 4, "selected": true, "text": "<p>Try removing (image), like this:</p>\n\n<pre><code>&lt;?php \n$content = get_the_content();\n$content = preg_re...
2014/09/22
[ "https://wordpress.stackexchange.com/questions/162162", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25271/" ]
Trying to learn more about creating my own themes and not using any plugins I wanted an ability to display all the images in a post excluding the thumbnail in my `single-foobar.php` file and I can do that with: ``` <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $thumb_ID = get_post_thumbnail_id(...
Try removing (image), like this: ``` <?php $content = get_the_content(); $content = preg_replace("/<img[^>]+\>/i", " ", $content); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); echo $content; ?> ```
162,170
<p>As title implies, I cannot seem to get $wpdb->get_results to give results. Running the "raw" query is successful, but this seems to be failing for some strange unknown reason.</p> <pre><code> global $wpdb; $sql = "SELECT * FROM something aki, somethingelse akb, ...
[ { "answer_id": 219111, "author": "NoOne", "author_id": 82471, "author_profile": "https://wordpress.stackexchange.com/users/82471", "pm_score": 2, "selected": false, "text": "<p>Use <code>$wpdb-&gt;show_errors( true )</code> before the query and see what error comes back. </p>\n\n<p>My pr...
2014/09/22
[ "https://wordpress.stackexchange.com/questions/162170", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57524/" ]
As title implies, I cannot seem to get $wpdb->get\_results to give results. Running the "raw" query is successful, but this seems to be failing for some strange unknown reason. ``` global $wpdb; $sql = "SELECT * FROM something aki, somethingelse akb, somethingel...
Use `$wpdb->show_errors( true )` before the query and see what error comes back. My problem (because I've experienced the same thing) was that I should use `$wpdb->posts` instead of `wp_posts` inside the query. The prefix of the tables can change from WP installation to installation or even in the same installation d...
162,171
<p>I asked my question on stackoverflow but I did not get any answer, may be because it's the question related to Wordpress.So I am asking it here.</p> <p>I am using <code>wp_insert_post</code> function to insert my posts, but it is not working fine for me.</p> <p>Here is my post_content </p> <pre><code>$content = '...
[ { "answer_id": 162185, "author": "jzatt", "author_id": 22620, "author_profile": "https://wordpress.stackexchange.com/users/22620", "pm_score": 1, "selected": false, "text": "<p>As Joshua suggested in his comment, your code isn't escaped properly.</p>\n\n<p>Just before \"See Original Arti...
2014/09/22
[ "https://wordpress.stackexchange.com/questions/162171", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26188/" ]
I asked my question on stackoverflow but I did not get any answer, may be because it's the question related to Wordpress.So I am asking it here. I am using `wp_insert_post` function to insert my posts, but it is not working fine for me. Here is my post\_content ``` $content = '<div class="snippet"> <strong>Wordp...
As Joshua suggested in his comment, your code isn't escaped properly. Just before "See Original Article" (in both snippets) you have `target='_blank'` on your links with single quotes. Replace that with double quotes `target="_blank"`
162,172
<p>I'm trying to fetch posts from current week.</p> <pre><code>&lt;?php $args = array( 'date_query' =&gt; array( array( 'year' =&gt; date( 'Y' ), 'week' =&gt; date( 'W' ), ), ), 'post_type' =&gt; 'stars', 'posts_per_page' =&gt; 99, '...
[ { "answer_id": 162173, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 0, "selected": false, "text": "<p>It might be because a new week has been started and WordPress is trying to get posts from last Sunday (whi...
2014/09/22
[ "https://wordpress.stackexchange.com/questions/162172", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12611/" ]
I'm trying to fetch posts from current week. ``` <?php $args = array( 'date_query' => array( array( 'year' => date( 'Y' ), 'week' => date( 'W' ), ), ), 'post_type' => 'stars', 'posts_per_page' => 99, 'order' => 'DEC', ); $loo...
You can try: ``` 'date_query' => array( array( 'year' => date( 'Y' ), 'week' => strftime( '%U' ), ), ), ``` where [`%U`](http://fr2.php.net/manual/en/function.strftime.php) is: > > Week number of the given year, starting with the first Sunday as the > first week > > > or ``` 'date_qu...
162,175
<p>I'm trying to create a single page where I display a few posts on one page. So far so good. Works all fine. Now I display posts in a foreach loop where I check if they are connnected to the page.</p> <p>What I need ist something like <code>wp_get_post_terms($post-&gt;ID);</code> but that doens't work. There are <co...
[ { "answer_id": 162177, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 2, "selected": false, "text": "<p>Try <code>get_the_term_list</code></p>\n\n<pre><code>&lt;?php echo get_the_term_list( $post-&gt;ID, 'taxon...
2014/09/22
[ "https://wordpress.stackexchange.com/questions/162175", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57245/" ]
I'm trying to create a single page where I display a few posts on one page. So far so good. Works all fine. Now I display posts in a foreach loop where I check if they are connnected to the page. What I need ist something like `wp_get_post_terms($post->ID);` but that doens't work. There are `custom registered_taxonomy...
Ooh, thank's for the advices and help (Robert + Peter). The Term confused myself :) This worked for me: ``` $taxonomies=get_taxonomies('','names'); wp_get_post_terms($post->ID, $taxonomies, array("fields" => "names")); ```
162,189
<p>I am using the following code to hide a menu item when a customer is not logged and show it when a customer is logged in.</p> <pre><code>.hide-item-not-login{ display: none !important; } .logged-in .hide-item-not-login{ display: block !important; } </code></pre> <p>I applied the class <code>hide-item-not-login</c...
[ { "answer_id": 162177, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 2, "selected": false, "text": "<p>Try <code>get_the_term_list</code></p>\n\n<pre><code>&lt;?php echo get_the_term_list( $post-&gt;ID, 'taxon...
2014/09/22
[ "https://wordpress.stackexchange.com/questions/162189", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37470/" ]
I am using the following code to hide a menu item when a customer is not logged and show it when a customer is logged in. ``` .hide-item-not-login{ display: none !important; } .logged-in .hide-item-not-login{ display: block !important; } ``` I applied the class `hide-item-not-login` to my menu item and it works fin...
Ooh, thank's for the advices and help (Robert + Peter). The Term confused myself :) This worked for me: ``` $taxonomies=get_taxonomies('','names'); wp_get_post_terms($post->ID, $taxonomies, array("fields" => "names")); ```
162,240
<p>I'm developing some plugin where I would like to enable custom pages. In my case some custom page would contain a form like contact form (not literally). When user will fill out this form and send it, there should be the next step which will require more information. Lets say that the first page with form would be l...
[ { "answer_id": 162449, "author": "david.binda", "author_id": 14022, "author_profile": "https://wordpress.stackexchange.com/users/14022", "pm_score": 0, "selected": false, "text": "<p>I once used a solution described here: <a href=\"http://scott.sherrillmix.com/blog/blogger/creating-a-bet...
2014/09/22
[ "https://wordpress.stackexchange.com/questions/162240", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59732/" ]
I'm developing some plugin where I would like to enable custom pages. In my case some custom page would contain a form like contact form (not literally). When user will fill out this form and send it, there should be the next step which will require more information. Lets say that the first page with form would be loca...
When you visit a frontend page, WordPress will query the database and if your page does not exist in the database, that query is not needed and is just a waste of resources. Luckily, WordPress offers a way to handle frontend requests in a custom way. That is done thanks to the [`'do_parse_request'`](https://developer....
162,276
<p>I have ajax method, user can trigger the same from either dashboard or from front-end. I just want to get from where the ajax is triggered. Is there any way to find?</p> <p>I tried <code>is_admin</code> method but it always returns <code>true</code></p> <pre><code>add_action( 'wp_ajax_get_something', 'get_somethin...
[ { "answer_id": 162449, "author": "david.binda", "author_id": 14022, "author_profile": "https://wordpress.stackexchange.com/users/14022", "pm_score": 0, "selected": false, "text": "<p>I once used a solution described here: <a href=\"http://scott.sherrillmix.com/blog/blogger/creating-a-bet...
2014/09/23
[ "https://wordpress.stackexchange.com/questions/162276", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20324/" ]
I have ajax method, user can trigger the same from either dashboard or from front-end. I just want to get from where the ajax is triggered. Is there any way to find? I tried `is_admin` method but it always returns `true` ``` add_action( 'wp_ajax_get_something', 'get_something'); add_action( 'wp_ajax_nopriv_get_someth...
When you visit a frontend page, WordPress will query the database and if your page does not exist in the database, that query is not needed and is just a waste of resources. Luckily, WordPress offers a way to handle frontend requests in a custom way. That is done thanks to the [`'do_parse_request'`](https://developer....
162,288
<p>I'm writing a plugin. There is a button, that triggers an ajax-request to an action I added in my plugin page:</p> <p>Head of my plugin PHP file:</p> <pre><code>add_action('wp_ajax_update_nav_items', 'update_nav_items' ); add_action('wp_ajax_nopriv_update_nav_items', 'update_nav_items' ); wp_enqueue_script( 'add...
[ { "answer_id": 162292, "author": "lippoliv", "author_id": 60107, "author_profile": "https://wordpress.stackexchange.com/users/60107", "pm_score": 0, "selected": false, "text": "<p>Your AJAX Requests requires an JSON to be returned. But I think your function doesn't return valid JSON.</p>...
2014/09/23
[ "https://wordpress.stackexchange.com/questions/162288", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60102/" ]
I'm writing a plugin. There is a button, that triggers an ajax-request to an action I added in my plugin page: Head of my plugin PHP file: ``` add_action('wp_ajax_update_nav_items', 'update_nav_items' ); add_action('wp_ajax_nopriv_update_nav_items', 'update_nav_items' ); wp_enqueue_script( 'addItemToNav', plugin_di...
Change your wp\_localize\_script-Call to the right Action: ``` wp_localize_script( 'addItemToNav', 'menuItems', array( // URL to wp-admin/admin-ajax.php to process the request 'ajaxurl' => admin_url( 'admin-ajax.php' ), // generate a nonce with a unique ID "myajax-post-comment-nonce" 'postComm...
162,324
<p>Today I have faced an weird problem regarding WordPress menus. Here is the register function of my menus -</p> <pre><code>function register_adaptive_menus() { register_nav_menus(array( 'top-menu' =&gt; __( 'Top Menu', 'adaptive-framework' ), 'main-menu' =&gt; __( 'Main Menu', 'adaptive-framework' ) )); } add_action...
[ { "answer_id": 162331, "author": "hereswhatidid", "author_id": 3032, "author_profile": "https://wordpress.stackexchange.com/users/3032", "pm_score": 1, "selected": false, "text": "<p>There's a typo in your arguments. Instead of <code>'theme-location'</code> it should be <code>'theme_loc...
2014/09/23
[ "https://wordpress.stackexchange.com/questions/162324", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60116/" ]
Today I have faced an weird problem regarding WordPress menus. Here is the register function of my menus - ``` function register_adaptive_menus() { register_nav_menus(array( 'top-menu' => __( 'Top Menu', 'adaptive-framework' ), 'main-menu' => __( 'Main Menu', 'adaptive-framework' ) )); } add_action( 'init', 'register_...
There's a typo in your arguments. Instead of `'theme-location'` it should be `'theme_location'`. Here is [the Codex as reference](http://codex.wordpress.org/Function_Reference/wp_nav_menu#Usage_.28Showing_Default_Values.29).
162,334
<p>I have two sets of posts - some have a Custom Field (true/false). So the ones which have a Custom Field (for this, let's just call it <code>custom_field</code>) value of <code>true</code>, go in one set, and the others (the ones with <code>false</code>, or more commonly, where the <code>custom_field</code> doesn't e...
[ { "answer_id": 162331, "author": "hereswhatidid", "author_id": 3032, "author_profile": "https://wordpress.stackexchange.com/users/3032", "pm_score": 1, "selected": false, "text": "<p>There's a typo in your arguments. Instead of <code>'theme-location'</code> it should be <code>'theme_loc...
2014/09/23
[ "https://wordpress.stackexchange.com/questions/162334", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27548/" ]
I have two sets of posts - some have a Custom Field (true/false). So the ones which have a Custom Field (for this, let's just call it `custom_field`) value of `true`, go in one set, and the others (the ones with `false`, or more commonly, where the `custom_field` doesn't exist on that post) go in the other set. When ...
There's a typo in your arguments. Instead of `'theme-location'` it should be `'theme_location'`. Here is [the Codex as reference](http://codex.wordpress.org/Function_Reference/wp_nav_menu#Usage_.28Showing_Default_Values.29).
162,337
<p>I tried to change text using the below code</p> <pre><code>function ctxtlearn_gettext( $ctxttranslation, $ctxttext ) { $ctxttrans = array_values(changeTxt_setting('trans',true)); $ctxtdirty = false; $ctxtstrings_map = array(); $ctxttext_words = explode( ' ', $ctxttext ); foreach($ctxttrans as $ctxt...
[ { "answer_id": 162664, "author": "Diogo Gomes", "author_id": 60124, "author_profile": "https://wordpress.stackexchange.com/users/60124", "pm_score": 2, "selected": false, "text": "<p>You are exploding the text with <code>explode( ' ', $ctxttext )</code>.<br>\nTherefore you are translatin...
2014/09/23
[ "https://wordpress.stackexchange.com/questions/162337", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18746/" ]
I tried to change text using the below code ``` function ctxtlearn_gettext( $ctxttranslation, $ctxttext ) { $ctxttrans = array_values(changeTxt_setting('trans',true)); $ctxtdirty = false; $ctxtstrings_map = array(); $ctxttext_words = explode( ' ', $ctxttext ); foreach($ctxttrans as $ctxtmytrans) { ...
I itself found the answer.. below code is working ``` add_filter( 'gettext', 'wps_translate_words_array' ); add_filter( 'ngettext', 'wps_translate_words_array' ); function wps_translate_words_array( $translated ) { $words = array( // 'word to translate' = > 'translation' ...
162,352
<p>i need to get only sub category ID. i already get sub category id but it coming with main category id too</p> <p>bellow is code </p> <pre><code>&lt;?php while ( have_posts() ) : the_post(); ?&gt; &lt;option value=".&lt;?php foreach((get_the_category()) as $category) { echo $category-&gt;cat_ID . ' '. $c...
[ { "answer_id": 162353, "author": "Michelle", "author_id": 16, "author_profile": "https://wordpress.stackexchange.com/users/16", "pm_score": 1, "selected": false, "text": "<p>I think you need to wrap it in an additional <code>if</code> statement to weed out categories that don't have pare...
2014/09/23
[ "https://wordpress.stackexchange.com/questions/162352", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38766/" ]
i need to get only sub category ID. i already get sub category id but it coming with main category id too bellow is code ``` <?php while ( have_posts() ) : the_post(); ?> <option value=".<?php foreach((get_the_category()) as $category) { echo $category->cat_ID . ' '. $category->cat_name ; } ?>">...
As you only want a `select` form field that has a categories children, then simply go with [`wp_list_categories()`](http://queryposts.com/function/wp_list_categories/) ``` wp_list_categories( array( 'child_of' => 'your parent cat ID', ) ); ``` Depending on your use case, you could as well use * [`get_the_catego...
162,366
<p>I am in need of putting an array of all images attached to a post into a custom field so that I can display they on the fly using my template's existing functions.</p> <p>I have gotten this real close and am successfully able to set the value of the custom meta field <code>_et_used_images</code> with the contents o...
[ { "answer_id": 162353, "author": "Michelle", "author_id": 16, "author_profile": "https://wordpress.stackexchange.com/users/16", "pm_score": 1, "selected": false, "text": "<p>I think you need to wrap it in an additional <code>if</code> statement to weed out categories that don't have pare...
2014/09/23
[ "https://wordpress.stackexchange.com/questions/162366", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60140/" ]
I am in need of putting an array of all images attached to a post into a custom field so that I can display they on the fly using my template's existing functions. I have gotten this real close and am successfully able to set the value of the custom meta field `_et_used_images` with the contents of the array returned ...
As you only want a `select` form field that has a categories children, then simply go with [`wp_list_categories()`](http://queryposts.com/function/wp_list_categories/) ``` wp_list_categories( array( 'child_of' => 'your parent cat ID', ) ); ``` Depending on your use case, you could as well use * [`get_the_catego...
162,376
<p>I use WordPress with TinyMCE in Chinese.</p> <p>It needs double white spaces in the beginning of each paragraph. But the editor will automatically removing all spaces(white space and <code>nbsp;</code> code) in the beginning of the paragraph when I toggle the editor between WYSIWYG mode and HTML mode.</p> <p>When ...
[ { "answer_id": 162353, "author": "Michelle", "author_id": 16, "author_profile": "https://wordpress.stackexchange.com/users/16", "pm_score": 1, "selected": false, "text": "<p>I think you need to wrap it in an additional <code>if</code> statement to weed out categories that don't have pare...
2014/09/24
[ "https://wordpress.stackexchange.com/questions/162376", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60148/" ]
I use WordPress with TinyMCE in Chinese. It needs double white spaces in the beginning of each paragraph. But the editor will automatically removing all spaces(white space and `nbsp;` code) in the beginning of the paragraph when I toggle the editor between WYSIWYG mode and HTML mode. When I used WordPress 3.8, I coul...
As you only want a `select` form field that has a categories children, then simply go with [`wp_list_categories()`](http://queryposts.com/function/wp_list_categories/) ``` wp_list_categories( array( 'child_of' => 'your parent cat ID', ) ); ``` Depending on your use case, you could as well use * [`get_the_catego...
162,380
<p>I have started posting YouTube videos as posts. I simply copy and paste the URL and WordPress figures out how to embed it. I like this workflow, but I don't like the embed code that WordPress generates. It seems that WordPress generates a code that allows suggested videos to appear at the end. I would like my embed ...
[ { "answer_id": 162382, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 1, "selected": false, "text": "<p>Here is the YouTube shortcode.</p>\n\n<pre><code>// youtube shortcode.\nfunction sc_youtube_single( $att, ...
2014/09/24
[ "https://wordpress.stackexchange.com/questions/162380", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60152/" ]
I have started posting YouTube videos as posts. I simply copy and paste the URL and WordPress figures out how to embed it. I like this workflow, but I don't like the embed code that WordPress generates. It seems that WordPress generates a code that allows suggested videos to appear at the end. I would like my embed cod...
Something like this should do the trick and force rel=0 for all YouTube oembed results. ``` add_filter('oembed_dataparse','youtube_force_rel',10,3); function youtube_force_rel($return, $data, $url) { if ($data->provider_name == 'YouTube') { return str_replace('feature=oembed', 'feature=oembed&#038;rel=0', ...
162,409
<p>I am trying to create a <em>list less</em> <code>wp_nav_menu</code>. Below is the desired output:</p> <pre><code>&lt;nav class="nav header-nav"&gt; &lt;a href="#" class="nav-link nav-active"&gt;Home&lt;/a&gt; &lt;a href="#" class="nav-link"&gt;About&lt;/a&gt; &lt;a href="#" class="nav-link"&gt;Contact&lt;/a&g...
[ { "answer_id": 162414, "author": "Rohil_PHPBeginner", "author_id": 59321, "author_profile": "https://wordpress.stackexchange.com/users/59321", "pm_score": 0, "selected": false, "text": "<p>Following may be the solution that you are looking for.</p>\n\n<pre><code> &lt;nav&gt;&lt;a&gt;\n ...
2014/09/24
[ "https://wordpress.stackexchange.com/questions/162409", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60166/" ]
I am trying to create a *list less* `wp_nav_menu`. Below is the desired output: ``` <nav class="nav header-nav"> <a href="#" class="nav-link nav-active">Home</a> <a href="#" class="nav-link">About</a> <a href="#" class="nav-link">Contact</a> </nav> ``` I can get pretty close following [Remove LI Elements From ...
You already mentioned in your question that u had removed `li` from the menu. so may be this will work. in this walker u can give the class in the Appearance ->menu css options (On the top right of the screen click on 'Screen Options' on the bottom row - make sure 'CSS Classes' is checked.) ``` class Class_Name_Wa...
162,419
<p>I want to restrict my users to be able to comment only once per post but be able to reply to existing comments. How can I do that?</p> <p>I found this code which will do the half trick. With this code the comment form is hidden if they already comment in that post but they cant reply to existing comments. </p> <pr...
[ { "answer_id": 162437, "author": "lippoliv", "author_id": 60107, "author_profile": "https://wordpress.stackexchange.com/users/60107", "pm_score": 0, "selected": false, "text": "<p>If it hasn't to be \"hacker-safe\" you can realize it via JS.\nDisplay comment_form everytime, also if the u...
2014/09/24
[ "https://wordpress.stackexchange.com/questions/162419", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60172/" ]
I want to restrict my users to be able to comment only once per post but be able to reply to existing comments. How can I do that? I found this code which will do the half trick. With this code the comment form is hidden if they already comment in that post but they cant reply to existing comments. ``` <?php global ...
So after some time I done exactly what I wanted and I thought it would be nice to share. So in `functions.php` add ``` function c_parent_comment_counter($pid,$uid){ global $wpdb; $query = "SELECT COUNT(comment_post_id) AS count FROM $wpdb->comments WHERE <code>comment_approved</code> = 1 AND <code>comment_po...
162,420
<p>I've been researching this for the last 3 days. I'm triyng to limit the maximum amount of posts retrieved by <code>get_posts()</code>.</p> <p>I have this chunk of code:</p> <pre><code>// all filters should be applied here $args = array( 'nopaging' =&gt; true, 'post_type' =&...
[ { "answer_id": 162421, "author": "Jonathan", "author_id": 59963, "author_profile": "https://wordpress.stackexchange.com/users/59963", "pm_score": 3, "selected": false, "text": "<p>You can use <code>posts_per_page</code> or <code>numberposts</code>.</p>\n\n<p><a href=\"http://codex.wordpr...
2014/09/24
[ "https://wordpress.stackexchange.com/questions/162420", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7349/" ]
I've been researching this for the last 3 days. I'm triyng to limit the maximum amount of posts retrieved by `get_posts()`. I have this chunk of code: ``` // all filters should be applied here $args = array( 'nopaging' => true, 'post_type' => get_option('ip_slug'), 'posts_...
I have solved this problem, I have used the `posts_per_page` parameter with a value of `100` and used [jPages](http://luis-almeida.github.io/jPages/) for jQuery pagination. **Explanation:** As I needed to pull a limited number of posts - in my case, `210` - I wanted to use both pagination and a query limit. As this se...
162,450
<p>I am trying to add some data in WordPress Custom Field and via adding more direct records/data in <code>wp_postmeta</code> table via SQL query. There are four column as mentioned below...</p> <ul> <li>'meta_id' - A unique id for each entry.</li> <li>'post_id' - The ID of the post for this metadata.</li> <li>'meta_k...
[ { "answer_id": 162451, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 3, "selected": true, "text": "<p><code>meta_id</code> in <code>postmeta</code> table is just an <strong>AUTO_INCREMENT</strong> id for t...
2014/09/24
[ "https://wordpress.stackexchange.com/questions/162450", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/52859/" ]
I am trying to add some data in WordPress Custom Field and via adding more direct records/data in `wp_postmeta` table via SQL query. There are four column as mentioned below... * 'meta\_id' - A unique id for each entry. * 'post\_id' - The ID of the post for this metadata. * 'meta\_key' - The name of the 'key'. * 'meta...
`meta_id` in `postmeta` table is just an **AUTO\_INCREMENT** id for the table, you can easily inspect that: ![meta_id - AUTO INCREMENT](https://i.stack.imgur.com/BXfkl.png) So, your guess is correct, you can leave it. ### EDIT Avoid raw SQL statements and introduce `$wpdb` for SQL purposes. And for postmeta ins...
162,477
<p>I have problem with looping and WP_Query. Any idea how i can implement the multiple carouselitems please check what html output should be in html</p> <p>So basically one of my goal is each div have a pages </p> <pre><code>&lt;div class="col-sm-6 col-md-3"&gt;&lt;/div&gt; </code></pre> <p>should have get all pages...
[ { "answer_id": 162503, "author": "Diogo Gomes", "author_id": 60124, "author_profile": "https://wordpress.stackexchange.com/users/60124", "pm_score": 1, "selected": false, "text": "<p>You should reset the query after your active slider.\nSo place this code after your first loop (after end...
2014/09/25
[ "https://wordpress.stackexchange.com/questions/162477", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60201/" ]
I have problem with looping and WP\_Query. Any idea how i can implement the multiple carouselitems please check what html output should be in html So basically one of my goal is each div have a pages ``` <div class="col-sm-6 col-md-3"></div> ``` should have get all pages from parents which is "Destinations". So i...
You should reset the query after your active slider. So place this code after your first loop (after endwhile; endif; ): ``` //Reset Query wp_reset_postdata(); ``` Also try setting the paged atribute: ``` $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; // WP_Query arguments $args = array ( 'p...
162,487
<p>I made a plugin and trying to install on wordpress.org but Wordpress is giving me error message that ## Calling core loading files directly is incorrect.</p> <p>I am using a cron file in my plugin.This cron can be set via CPanel also. That's why I have to include <strong>'wp-config.php'</strong> and I am including ...
[ { "answer_id": 162503, "author": "Diogo Gomes", "author_id": 60124, "author_profile": "https://wordpress.stackexchange.com/users/60124", "pm_score": 1, "selected": false, "text": "<p>You should reset the query after your active slider.\nSo place this code after your first loop (after end...
2014/09/25
[ "https://wordpress.stackexchange.com/questions/162487", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26188/" ]
I made a plugin and trying to install on wordpress.org but Wordpress is giving me error message that ## Calling core loading files directly is incorrect. I am using a cron file in my plugin.This cron can be set via CPanel also. That's why I have to include **'wp-config.php'** and I am including this as ``` include '...
You should reset the query after your active slider. So place this code after your first loop (after endwhile; endif; ): ``` //Reset Query wp_reset_postdata(); ``` Also try setting the paged atribute: ``` $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; // WP_Query arguments $args = array ( 'p...
162,491
<p>Please ignore my poor English.</p> <p>I have custom post type <code>(order)</code>. and its working like charm,</p> <p>But default post type <code>(pages)</code> list are not displaying in <code>wp-admin</code> side. </p> <p>You can see More information in attached screenshots.</p> <p>Please help me guys to figu...
[ { "answer_id": 162500, "author": "Diogo Gomes", "author_id": 60124, "author_profile": "https://wordpress.stackexchange.com/users/60124", "pm_score": 2, "selected": false, "text": "<p>You probably have an action to 'pre_get_posts' that it's excluding the page post-type.\nPaste that code h...
2014/09/25
[ "https://wordpress.stackexchange.com/questions/162491", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33512/" ]
Please ignore my poor English. I have custom post type `(order)`. and its working like charm, But default post type `(pages)` list are not displaying in `wp-admin` side. You can see More information in attached screenshots. Please help me guys to figure out what is the problem. **For Order Post Type:-** ![enter i...
`order` is a reserved term, the best - I know of - overview over those can be found here: [Codex: `register_taxonomy()` - Reserved Terms](http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms). The list is in it's relevance not restricted to taxonomies. The introduction to it does make it clear...
162,508
<p>I am trying to create a square thumbnail with auto crop with size of 300px 300px. I only get the width of 300px but the height is auto, i think is not cropping.</p> <p>I tried this:</p> <pre><code>add_image_size( 'custom_image_size', 300, 300, true ); the_post_thumbnail('custom_image_size'); </code></pre> <p>and...
[ { "answer_id": 162512, "author": "lippoliv", "author_id": 60107, "author_profile": "https://wordpress.stackexchange.com/users/60107", "pm_score": 0, "selected": false, "text": "<p>As the two comments above said: The Uploaded Image has to be larger than 300px * 300px to get 300px * 300px ...
2014/09/25
[ "https://wordpress.stackexchange.com/questions/162508", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/52334/" ]
I am trying to create a square thumbnail with auto crop with size of 300px 300px. I only get the width of 300px but the height is auto, i think is not cropping. I tried this: ``` add_image_size( 'custom_image_size', 300, 300, true ); the_post_thumbnail('custom_image_size'); ``` and this ``` set_post_thumbnail_siz...
So i followed this link [how-to-get-larger-images-in-a-wordpress-gallery](http://amethystwebsitedesign.com/how-to-get-larger-images-in-a-wordpress-gallery/) and i changed the Thumbnail size to 300px with 300px from SETTINGS -> MEDIA, and then run a Regenerate Thumbnails. Now the thumbnails are ok by using the code ```...
162,517
<p>I am wondering wether it's possible to use Apaches <code>.htaccess</code> to rewrite a folder name - using a WordPress function.</p> <p>Lets say I have a url like:</p> <pre><code>http://example.com/folder1/folder2/page.php </code></pre> <p>Now I want to rewrite the url to (for example)</p> <pre><code>http://exam...
[ { "answer_id": 172994, "author": "Juergen", "author_id": 30605, "author_profile": "https://wordpress.stackexchange.com/users/30605", "pm_score": -1, "selected": false, "text": "<p>Thanks, just what I needed after chaning the foldername (aka customer type name) I got too many 404. so I di...
2014/09/25
[ "https://wordpress.stackexchange.com/questions/162517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57129/" ]
I am wondering wether it's possible to use Apaches `.htaccess` to rewrite a folder name - using a WordPress function. Lets say I have a url like: ``` http://example.com/folder1/folder2/page.php ``` Now I want to rewrite the url to (for example) ``` http://example.com/testing/folder2/page.php ``` The `folder1` is...
You can do rewrites in wordpress by using the `add_rewrite_rule()` function. Please see: <https://codex.wordpress.org/Rewrite_API/add_rewrite_rule>
162,537
<p>I made my first Wordpress plugin and I would get that crease a datatable in worpress databases. I tried the next code buy I get nothing:</p> <pre><code>register_activation_hook(__FILE__, 'rating_install'); register_deactivation_hook(__FILE__, 'rating_uninstall'); function rating_install(){ //Funcion que genera la i...
[ { "answer_id": 172994, "author": "Juergen", "author_id": 30605, "author_profile": "https://wordpress.stackexchange.com/users/30605", "pm_score": -1, "selected": false, "text": "<p>Thanks, just what I needed after chaning the foldername (aka customer type name) I got too many 404. so I di...
2014/09/25
[ "https://wordpress.stackexchange.com/questions/162537", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60178/" ]
I made my first Wordpress plugin and I would get that crease a datatable in worpress databases. I tried the next code buy I get nothing: ``` register_activation_hook(__FILE__, 'rating_install'); register_deactivation_hook(__FILE__, 'rating_uninstall'); function rating_install(){ //Funcion que genera la instalacion del...
You can do rewrites in wordpress by using the `add_rewrite_rule()` function. Please see: <https://codex.wordpress.org/Rewrite_API/add_rewrite_rule>
162,560
<p>I have a plugin that works as a standard POST but not as an AJAX POST request.</p> <p>I am getting a not a function error in Firebug with this function:</p> <p><em>TypeError: jQuery(...).ajaxSubmit is not a function</em></p> <pre><code>jQuery(this).ajaxSubmit(options); </code></pre> <p>This magic came to the res...
[ { "answer_id": 162603, "author": "fischi", "author_id": 15680, "author_profile": "https://wordpress.stackexchange.com/users/15680", "pm_score": 2, "selected": false, "text": "<p><code>ajaxSubmit</code> isn't a core jQuery function.</p>\n\n<p>It seems that you have to either include a jQu...
2014/09/25
[ "https://wordpress.stackexchange.com/questions/162560", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60226/" ]
I have a plugin that works as a standard POST but not as an AJAX POST request. I am getting a not a function error in Firebug with this function: *TypeError: jQuery(...).ajaxSubmit is not a function* ``` jQuery(this).ajaxSubmit(options); ``` This magic came to the rescue: <http://codeimpossible.com/2010/01/13/sol...
You have to add `jquery.form.min.js` it work for me , Hope it works for you.
162,616
<p>I'm using wp_get_attachment_image_src to retrieve image URL.</p> <p>Codex is simple for this function and starting from an ID on my database I used <code>wp_get_attachment_image_src</code> in this way:</p> <pre><code>$image_url = wp_get_attachment_image_src(2447); echo $image_url[0]; </code></pre> <p>where 2447 ...
[ { "answer_id": 162617, "author": "Rohil_PHPBeginner", "author_id": 59321, "author_profile": "https://wordpress.stackexchange.com/users/59321", "pm_score": 0, "selected": false, "text": "<p>Try in this way and let me know if it works or not ..</p>\n\n<pre><code>&lt;?php\n$my_attachment = ...
2014/09/26
[ "https://wordpress.stackexchange.com/questions/162616", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33504/" ]
I'm using wp\_get\_attachment\_image\_src to retrieve image URL. Codex is simple for this function and starting from an ID on my database I used `wp_get_attachment_image_src` in this way: ``` $image_url = wp_get_attachment_image_src(2447); echo $image_url[0]; ``` where 2447 is an ID of an attachment in my wp\_post...
**In function passing a attachment id or thumbnail id NOT post id.** Try this ``` <?php global $post; $attch_id = get_post_thumbnail_id( $post->ID ); $url = wp_get_attachment_image_src($attch_id); echo "<img src='".$url[0]."' />"; ?> ``` I hope is useful.
162,618
<p>I'm using this custom function to get the default avatar from my server instead of gravatar:</p> <pre><code>if(!function_exists('custom_avatar')){ function custom_avatar($avatar_defaults){ $new_default_icon = 'http://localhost/gv/wp-content/images/mystery-man.png'; $avatar_defaults[$new_default_...
[ { "answer_id": 162617, "author": "Rohil_PHPBeginner", "author_id": 59321, "author_profile": "https://wordpress.stackexchange.com/users/59321", "pm_score": 0, "selected": false, "text": "<p>Try in this way and let me know if it works or not ..</p>\n\n<pre><code>&lt;?php\n$my_attachment = ...
2014/09/26
[ "https://wordpress.stackexchange.com/questions/162618", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59227/" ]
I'm using this custom function to get the default avatar from my server instead of gravatar: ``` if(!function_exists('custom_avatar')){ function custom_avatar($avatar_defaults){ $new_default_icon = 'http://localhost/gv/wp-content/images/mystery-man.png'; $avatar_defaults[$new_default_icon] = 'Custo...
**In function passing a attachment id or thumbnail id NOT post id.** Try this ``` <?php global $post; $attch_id = get_post_thumbnail_id( $post->ID ); $url = wp_get_attachment_image_src($attch_id); echo "<img src='".$url[0]."' />"; ?> ``` I hope is useful.
162,619
<p>I am using revolution slider plugin. I got above error while executing one of my front end form. This is my code in that file..</p> <pre><code>&lt;?php class UniteDBRev{ private $wpdb; private $lastRowID; /** * * constructor - set database object */ public function __construct(){ ...
[ { "answer_id": 162617, "author": "Rohil_PHPBeginner", "author_id": 59321, "author_profile": "https://wordpress.stackexchange.com/users/59321", "pm_score": 0, "selected": false, "text": "<p>Try in this way and let me know if it works or not ..</p>\n\n<pre><code>&lt;?php\n$my_attachment = ...
2014/09/26
[ "https://wordpress.stackexchange.com/questions/162619", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58671/" ]
I am using revolution slider plugin. I got above error while executing one of my front end form. This is my code in that file.. ``` <?php class UniteDBRev{ private $wpdb; private $lastRowID; /** * * constructor - set database object */ public function __construct(){ global $w...
**In function passing a attachment id or thumbnail id NOT post id.** Try this ``` <?php global $post; $attch_id = get_post_thumbnail_id( $post->ID ); $url = wp_get_attachment_image_src($attch_id); echo "<img src='".$url[0]."' />"; ?> ``` I hope is useful.
162,639
<p>For some reason my by author disappeared and I cant turn it back on. I know where I want to put it on single.php at the end of the post, but I can't figure out what code I have to put in for it to display.</p>
[ { "answer_id": 162617, "author": "Rohil_PHPBeginner", "author_id": 59321, "author_profile": "https://wordpress.stackexchange.com/users/59321", "pm_score": 0, "selected": false, "text": "<p>Try in this way and let me know if it works or not ..</p>\n\n<pre><code>&lt;?php\n$my_attachment = ...
2014/09/26
[ "https://wordpress.stackexchange.com/questions/162639", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60289/" ]
For some reason my by author disappeared and I cant turn it back on. I know where I want to put it on single.php at the end of the post, but I can't figure out what code I have to put in for it to display.
**In function passing a attachment id or thumbnail id NOT post id.** Try this ``` <?php global $post; $attch_id = get_post_thumbnail_id( $post->ID ); $url = wp_get_attachment_image_src($attch_id); echo "<img src='".$url[0]."' />"; ?> ``` I hope is useful.
162,643
<p>I have a custom theme with just a name in its <code>style.css</code>. I've activated it in admin which shows it just fine. </p> <p>In the <code>index.php</code> just <code>&lt;?php wp_head(); ?&gt;</code> and it doesn't output the line that is supposed to include my main stylesheet <code>style.css</code>:</p> <pre...
[ { "answer_id": 162644, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": -1, "selected": false, "text": "<p>You should add your .js and .css files, like this. in your <code>header.php</code></p>\n\n<pre><code>&lt;...
2014/09/26
[ "https://wordpress.stackexchange.com/questions/162643", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15816/" ]
I have a custom theme with just a name in its `style.css`. I've activated it in admin which shows it just fine. In the `index.php` just `<?php wp_head(); ?>` and it doesn't output the line that is supposed to include my main stylesheet `style.css`: ```css <link rel='stylesheet' id='my-theme' href='~/wp-content/them...
Actually you shouldn't add JS and CSS files to your `header.php`, but make use of the functions [`wp_enqueue_script()`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) and [`wp_enqueue_style()`](http://codex.wordpress.org/Function_Reference/wp_enqueue_style) to add them there. Example taken from the ...
162,668
<p>I have set a user metadata named <code>achievements</code> which is an array containing various numeric values. Using <code>WP_User_Query</code>, I want to order the list by a specific key within this array named <code>points</code>. </p> <p>The following:</p> <pre><code>$args = array( 'order' =&gt; 'DESC', ...
[ { "answer_id": 162669, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>You could save the values with the <strong>separate</strong> user meta keys: </p>\n\n<pre><code>x1, ..., x6, p...
2014/09/26
[ "https://wordpress.stackexchange.com/questions/162668", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24875/" ]
I have set a user metadata named `achievements` which is an array containing various numeric values. Using `WP_User_Query`, I want to order the list by a specific key within this array named `points`. The following: ``` $args = array( 'order' => 'DESC', 'orderby' => 'meta_value_num', 'meta_key' => 'achie...
You could save the values with the **separate** user meta keys: ``` x1, ..., x6, points ``` instead of the array: ``` achievements ``` to simplify your `WP_User_Query()` usage and not having to deal with *serialized arrays* as user meta values. *But I guess you've already considered this setup and wanted to av...
162,678
<p>I know the specifics of using dbDelta and I've read the documentation (<a href="http://codex.wordpress.org/Creating_Tables_with_Plugins" rel="nofollow">http://codex.wordpress.org/Creating_Tables_with_Plugins</a>), read other answers to the question I'm asking, but I'm just not seeing what I'm doing wrong. When I var...
[ { "answer_id": 162699, "author": "Justin Bell", "author_id": 60176, "author_profile": "https://wordpress.stackexchange.com/users/60176", "pm_score": 1, "selected": false, "text": "<p>If you're throwing an error on your SQL statement, you should refer to <a href=\"http://codex.wordpress.o...
2014/09/26
[ "https://wordpress.stackexchange.com/questions/162678", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50740/" ]
I know the specifics of using dbDelta and I've read the documentation (<http://codex.wordpress.org/Creating_Tables_with_Plugins>), read other answers to the question I'm asking, but I'm just not seeing what I'm doing wrong. When I var\_dump the result of dbDelta, I get no errors, just "`array(1) { [0]=> string(48) "Add...
This is invalid. `PRIMARY KEY id (id)` Should just be: `PRIMARY KEY (id)` Unlike other KEYs, PRIMARY KEYs don't have identifiers or names. They don't need them, because you can only have one.
162,686
<p>I am trying to make single pages for each individual portfolio piece. I created custom posts &amp; field types, but it only seems to allow one featured picture per post. Should I be adding my pictures in a different way? Or is there an option to add more featured images?</p> <p>Also, I am trying to make a carousel ...
[ { "answer_id": 162697, "author": "Justin Bell", "author_id": 60176, "author_profile": "https://wordpress.stackexchange.com/users/60176", "pm_score": 0, "selected": false, "text": "<p>I don't see that you've actually asked for your featured image in the template. Throw in a call to <a hr...
2014/09/26
[ "https://wordpress.stackexchange.com/questions/162686", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60305/" ]
I am trying to make single pages for each individual portfolio piece. I created custom posts & field types, but it only seems to allow one featured picture per post. Should I be adding my pictures in a different way? Or is there an option to add more featured images? Also, I am trying to make a carousel with these ima...
It's an interesting task. We can make a custom Slider Menu in Dashboard then featured images can be upload from there so that those images can be called dynamically in slider. **First** we have to make **Theme Support and register Post Type** in functions.php ``` add_theme_support( 'post-thumbnails', array( 'post', '...
162,692
<p>I am developing a widget plugin and want to add a textarea with WYSIWYG editor in widget settings. </p> <p>Any help would be highly appreciated.</p> <p>Thanks.</p>
[ { "answer_id": 162722, "author": "Sayani Kundu", "author_id": 60321, "author_profile": "https://wordpress.stackexchange.com/users/60321", "pm_score": -1, "selected": false, "text": "<p>You can try plugins like this:</p>\n\n<p><a href=\"https://wordpress.org/plugins/wp-editor-widget/scree...
2014/09/26
[ "https://wordpress.stackexchange.com/questions/162692", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58787/" ]
I am developing a widget plugin and want to add a textarea with WYSIWYG editor in widget settings. Any help would be highly appreciated. Thanks.
Embedding WYSIWYG Editor in Custom widget needs the declaration of the fields under a form function, this will create a WYSIWYG Editor in your widget. You can define your parameter, what all features you want to show. ``` public function form( $instance ) { $rand = rand( 0, 999 ); $ed_id = $this->get_fie...
162,703
<p>I have a query (see below) that gives a list of 10 news items ordered by the meta value "event_date" and filtered so that only posts earlier than today are displayed. This query is taking two seconds to process, so I am looking for a simple way to cache the results to get the load time faster. I already use WPEngine...
[ { "answer_id": 162707, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 4, "selected": true, "text": "<p>You can use transient cache to cache your custom query. Here is a simple code to <code>set_transient</code>...
2014/09/27
[ "https://wordpress.stackexchange.com/questions/162703", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45635/" ]
I have a query (see below) that gives a list of 10 news items ordered by the meta value "event\_date" and filtered so that only posts earlier than today are displayed. This query is taking two seconds to process, so I am looking for a simple way to cache the results to get the load time faster. I already use WPEngine s...
You can use transient cache to cache your custom query. Here is a simple code to `set_transient` cache for your query for 12 hours. In 12 hours WordPress will not make new query but fetch posts from transient. On expiration, it will save new query in transient again for next 12 hours. I have been using transient for m...
162,735
<p>It seems that WordPress Development is building a knowledge-base about the best functions out there. Thanks a bunch this helped already a lot! </p> <p>I found a function (find it down here) that offers a simple menu decision in a box for each page of your wordpress theme. A magic bag trick, kudos to H Peter Pfeufer...
[ { "answer_id": 162726, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 1, "selected": true, "text": "<p>This is caused by the line break between the first image in the post and the body content of the post. Just...
2014/09/27
[ "https://wordpress.stackexchange.com/questions/162735", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60326/" ]
It seems that WordPress Development is building a knowledge-base about the best functions out there. Thanks a bunch this helped already a lot! I found a function (find it down here) that offers a simple menu decision in a box for each page of your wordpress theme. A magic bag trick, kudos to H Peter Pfeufer! but how...
This is caused by the line break between the first image in the post and the body content of the post. Just delete the one line of space between the two and it will working fine.
162,741
<p>I am trying to get some data from WordPress database tables in a plugin. For that, I am using the below code...</p> <pre><code>global $wpdb; $findID = $wpdb-&gt;get_var("SELECT ID FROM wp_posts WHERE post_name = 'hello-world'"); echo $findID; </code></pre> <p>But it not giving me the post ID in <code>echo</code>? ...
[ { "answer_id": 162749, "author": "Muhammad Hassan", "author_id": 52859, "author_profile": "https://wordpress.stackexchange.com/users/52859", "pm_score": 2, "selected": false, "text": "<p>I found the solution and the correct query to fetch one data from WordPress database is below one.</p...
2014/09/27
[ "https://wordpress.stackexchange.com/questions/162741", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/52859/" ]
I am trying to get some data from WordPress database tables in a plugin. For that, I am using the below code... ``` global $wpdb; $findID = $wpdb->get_var("SELECT ID FROM wp_posts WHERE post_name = 'hello-world'"); echo $findID; ``` But it not giving me the post ID in `echo`? Is there anything wrong...???
Just to clarify the [`get_var()`](http://codex.wordpress.org/Class_Reference/wpdb#SELECT_a_Variable) method of [`$wpdb`](http://codex.wordpress.org/Class_Reference/wpdb) does work just fine in this context: ``` global $wpdb; $helloworld_id = $wpdb->get_var("SELECT ID FROM wp_posts WHERE post_name = 'hello-world'"); ec...