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
67,750
<pre><code>&lt;?php /* Template Name: second */ ?&gt; &lt;?php get_header(); ?&gt; &lt;?php query_posts(array('post_type'=&gt;'event')); ?&gt; &lt;?php if(have_posts()) while(have_posts()) : the_post(); ?&gt; &lt;div id="post-&lt;?php the_ID(); ?&gt;" class="entry"&gt; &lt;div class="thumbnail"&gt;&...
[ { "answer_id": 67747, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p>Put the template file in your theme and add the following comment to the top of your file after the \n\n<pre><...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67750", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21314/" ]
``` <?php /* Template Name: second */ ?> <?php get_header(); ?> <?php query_posts(array('post_type'=>'event')); ?> <?php if(have_posts()) while(have_posts()) : the_post(); ?> <div id="post-<?php the_ID(); ?>" class="entry"> <div class="thumbnail"><?php the_post_thumbnail('full'); ?></div> <h1 ...
Put the template file in your theme and add the following comment to the top of your file after the ``` /** * Template Name: This is the name of your template */ ``` WordPress will pick this up and in the page templates dropdown you will see "This is the name of your template" listed as an option
67,763
<p>I am trying to work out how to use the wp_handle_upload function for a custom plugin so that i can specify my own own upload directory. The code so far takes a file from my plugin settings page and uploads to the folder uploads folder with the year and month. </p> <p>I came across this link which I thought might ha...
[ { "answer_id": 68035, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>I don't remember doing exactly this in practice, but most (all?) upload path handling goes through <a href=\"http://...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67763", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21318/" ]
I am trying to work out how to use the wp\_handle\_upload function for a custom plugin so that i can specify my own own upload directory. The code so far takes a file from my plugin settings page and uploads to the folder uploads folder with the year and month. I came across this link which I thought might have some ...
Here's a complete example for how we do it in Easy Digital Downloads: ``` /** * Set Upload Directory * * Sets the upload dir to edd. This function is called from * edd_change_downloads_upload_dir() * * @since 1.0 * @return array Upload directory information */ function edd_set_upload_dir( $upload ) { $uploa...
67,771
<p>my shortcode output won't appear where I put it, but rather at the top of the content (top of the post/page content).</p> <p>And here is my code </p> <pre><code>function service_shortcode_index() { global $content; $output = include ( TEMPLATEPATH . '/service.php' ); return $output; } add_shortcode('service_mid',...
[ { "answer_id": 67775, "author": "Joseph Leedy", "author_id": 8554, "author_profile": "https://wordpress.stackexchange.com/users/8554", "pm_score": 5, "selected": true, "text": "<p>I think your problem is with the <code>$output = include ....</code> statement. <code>include()</code> retur...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67771", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17703/" ]
my shortcode output won't appear where I put it, but rather at the top of the content (top of the post/page content). And here is my code ``` function service_shortcode_index() { global $content; $output = include ( TEMPLATEPATH . '/service.php' ); return $output; } add_shortcode('service_mid', 'service_shortcode_i...
I think your problem is with the `$output = include ....` statement. `include()` returns true or false based whether it was successful - not the content of the file being included. Use output buffering to get the content. ``` function service_shortcode_index() { global $content; ob_start(); include ( TEMPL...
67,782
<p>I've implemented a way to show the Twitter feed without a plugin. It's worked for weeks(months even, on a different site), but is now giving me trouble. Here is the error:</p> <p>Fatal error: Call to undefined method WP_Error::get_item_quantity() in ... home.php on line 27</p> <p>Line 27: $maxitems = $rss->get_ite...
[ { "answer_id": 67787, "author": "Eric Holmes", "author_id": 23454, "author_profile": "https://wordpress.stackexchange.com/users/23454", "pm_score": 1, "selected": false, "text": "<p>I would say you are probably receiving a WP_Error on first run.</p>\n\n<p>around the <code>$maxitems</code...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67782", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14606/" ]
I've implemented a way to show the Twitter feed without a plugin. It's worked for weeks(months even, on a different site), but is now giving me trouble. Here is the error: Fatal error: Call to undefined method WP\_Error::get\_item\_quantity() in ... home.php on line 27 Line 27: $maxitems = $rss->get\_item\_quantity(3...
I would say you are probably receiving a WP\_Error on first run. around the `$maxitems` and `$rss_items` lines, add: ``` if( ! is_wp_error( $rss ) ) { $maxitems = $rss->get_item_quantity(3); $rss_items = $rss->get_items(0, $maxitems); } ``` As seen in the [example](http://codex.wordpress.org/Function_Refere...
67,792
<p>I have filtered posts, pages and custom_post_types based on $current_user custom usermeta field values using pre_get_posts().</p> <p>Is there a similar method/function to alter get_users() based on $current_user custom field values? I've searched quite a bit but came up empty handed.</p> <p>For example, let's assu...
[ { "answer_id": 67799, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p>There's the <code>pre_user_query</code> action called in the <code>prepare_query()</code> method of the <code>WP_Us...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67792", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21327/" ]
I have filtered posts, pages and custom\_post\_types based on $current\_user custom usermeta field values using pre\_get\_posts(). Is there a similar method/function to alter get\_users() based on $current\_user custom field values? I've searched quite a bit but came up empty handed. For example, let's assume I want ...
There's the `pre_user_query` action called in the `prepare_query()` method of the `WP_User_Query` class defined in `wp-includes/user.php`: ``` do_action_ref_array( 'pre_user_query', array( &$this ) ); ```
67,794
<p>I am trying to add action hook in functions.php only if the page is <code>home.php</code> but the following does not work</p> <pre><code>if ( is_page_template("home.php") ) { // do stuff } </code></pre> <p>To make sure that file being used is <code>home.php</code> I do this</p> <pre><code>global $template; echo...
[ { "answer_id": 67807, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 4, "selected": true, "text": "<p>Use <code>is_home</code> instead, as <code>is_page_template</code> will not work for <code>home.php</code> as its ...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67794", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17269/" ]
I am trying to add action hook in functions.php only if the page is `home.php` but the following does not work ``` if ( is_page_template("home.php") ) { // do stuff } ``` To make sure that file being used is `home.php` I do this ``` global $template; echo $template; ```
Use `is_home` instead, as `is_page_template` will not work for `home.php` as its technically not a page template in the traditional sense. ``` add_action('template_redirect', 'are_we_home_yet', 10); function are_we_home_yet(){ if ( is_home() ) { //your logic here } } ``` Revised: ======== ``` ad...
67,802
<p>I am wondering what the most efficient method is to add a javascript file specifically for a post and/or page.</p> <p>Here are a few solutions I came up with:</p> <ul> <li>Switch to HTML editing view and post your JavaScript in there (pretty bad solution)</li> <li>Custom fields with the specific JavaScript for tha...
[ { "answer_id": 67808, "author": "Nicole", "author_id": 8337, "author_profile": "https://wordpress.stackexchange.com/users/8337", "pm_score": 2, "selected": false, "text": "<p>What I would do is either place in the footer or header and use php conditionals.</p>\n\n<p>For example:</p>\n\n<...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67802", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21329/" ]
I am wondering what the most efficient method is to add a javascript file specifically for a post and/or page. Here are a few solutions I came up with: * Switch to HTML editing view and post your JavaScript in there (pretty bad solution) * Custom fields with the specific JavaScript for that post/page in the key & val...
I think the best balance between efficiency, and using proper wordpress methods for adding javascript would be adding something along these lines to your themes functions.php file. For Example: **functions.php:** ``` function load_scripts() { global $post; if( is_page() || is_single() ) { switch(...
67,809
<p>I'm writing a plugin and i wanted to i18n correctly text which i'm storing in the db or in an external file. How should i do that?As of now we are generating pot files with wordpress and so all the Translatable text is in calls </p> <pre><code>__( 'text', 'plugin_name'); </code></pre> <p>But there is some text i w...
[ { "answer_id": 67808, "author": "Nicole", "author_id": 8337, "author_profile": "https://wordpress.stackexchange.com/users/8337", "pm_score": 2, "selected": false, "text": "<p>What I would do is either place in the footer or header and use php conditionals.</p>\n\n<p>For example:</p>\n\n<...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67809", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13205/" ]
I'm writing a plugin and i wanted to i18n correctly text which i'm storing in the db or in an external file. How should i do that?As of now we are generating pot files with wordpress and so all the Translatable text is in calls ``` __( 'text', 'plugin_name'); ``` But there is some text i would like to store in the ...
I think the best balance between efficiency, and using proper wordpress methods for adding javascript would be adding something along these lines to your themes functions.php file. For Example: **functions.php:** ``` function load_scripts() { global $post; if( is_page() || is_single() ) { switch(...
67,813
<p>Is there a way I can allow the user to attach images as attachments to a post without allowing him to insert them within the text itself? Ideally the Upload Media button remains the same but the image is not inserted within the text.</p> <p>The reason is I don't want users to start creating their own layouts and I ...
[ { "answer_id": 67818, "author": "Ben HartLenn", "author_id": 6645, "author_profile": "https://wordpress.stackexchange.com/users/6645", "pm_score": 2, "selected": true, "text": "<p>One way to do this would be to simply hide the upload/insert media button: and, then add featured image supp...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67813", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21333/" ]
Is there a way I can allow the user to attach images as attachments to a post without allowing him to insert them within the text itself? Ideally the Upload Media button remains the same but the image is not inserted within the text. The reason is I don't want users to start creating their own layouts and I want the t...
One way to do this would be to simply hide the upload/insert media button: and, then add featured image support for your themes posts, so a user can still attach images to the post. Hide upload/insert media button for your theme in: **functions.php**: ``` function hideUploadInsert($hook) { if($hook != 'post.php' ...
67,819
<p><a href="http://urbanpalate.com/blog/" rel="nofollow">Live site</a></p> <p>I'm using <code>&lt;?php comments_number( $zero, $one, $more ); ?&gt;</code> on <code>home.php</code> to display number of comments in the post-meta. Problem is, it's not showing the number despite there being one comment on that post. Any i...
[ { "answer_id": 67821, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 1, "selected": false, "text": "<p>you need to replace <code>$zero</code>, <code>$one</code>, and <code>$more</code> with your own code;\nread the ...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67819", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14606/" ]
[Live site](http://urbanpalate.com/blog/) I'm using `<?php comments_number( $zero, $one, $more ); ?>` on `home.php` to display number of comments in the post-meta. Problem is, it's not showing the number despite there being one comment on that post. Any ideas what's causing the problem? Here's post-meta for `index.ph...
You need to change the code you're using from ``` <div class="post-meta"> <p><?php the_date(); ?> | <?php the_tags('tags:', ', ', '<br />'); ?> | <?php comments_number( $zero, $one, $more ); ?> comments</p> <?php comments_template(); ?> </div><!-- end post-meta --> ``` to ``` <div class="post-meta"> <p>...
67,823
<p>I am using the query_posts function to list a 10 specific posts which lookup by post id.</p> <p>I have an array which looks like this..</p> <pre><code>Array ( [0] =&gt; 17983 [1] =&gt; 17932 [2] =&gt; 18030 [3] =&gt; 18016 [4] =&gt; 17972 [5] =&gt; 18013 [6] =&gt; 18035 [7] =&gt; 17...
[ { "answer_id": 67824, "author": "Xhynk", "author_id": 13724, "author_profile": "https://wordpress.stackexchange.com/users/13724", "pm_score": -1, "selected": false, "text": "<p>First of all, don't use <code>query_posts()</code>, use <a href=\"http://codex.wordpress.org/Class_Reference/WP...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67823", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19527/" ]
I am using the query\_posts function to list a 10 specific posts which lookup by post id. I have an array which looks like this.. ``` Array ( [0] => 17983 [1] => 17932 [2] => 18030 [3] => 18016 [4] => 17972 [5] => 18013 [6] => 18035 [7] => 17959 [8] => 18020 [9] => 18039 ) ```...
If the query is only for a *small number* of posts, then as linked to by Alex you can sort in php. However, this does not scale well. As suggested by Kovshenin - a better alternative is to use `posts_orderby` filter: ``` $post_ids = array(83,24,106,2283,14); $args = array( 'post_type' => 'post', 'post__in' =...
67,875
<p>I want to how can I hide the home in the menu without setting show_home in functions.php to false, I just want to do is hide it in a specific page. How can I do this? I am using the Twenty-Eleven Theme.</p>
[ { "answer_id": 67882, "author": "zadubz", "author_id": 15326, "author_profile": "https://wordpress.stackexchange.com/users/15326", "pm_score": 1, "selected": false, "text": "<p>Wordpress adds a unique class for each page in the body tag, you can use that class to target specific elements...
2012/10/11
[ "https://wordpress.stackexchange.com/questions/67875", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21353/" ]
I want to how can I hide the home in the menu without setting show\_home in functions.php to false, I just want to do is hide it in a specific page. How can I do this? I am using the Twenty-Eleven Theme.
Wordpress adds a unique class for each page in the body tag, you can use that class to target specific elements on your page through CSS. ``` .page-id-32 .menu-item-31 {display:none;} ```
67,876
<p>Is there any way to find out how much of disk space has been used by Media Library? My blog's media files stored in a separate folder named "media" rather than the default "wp-content/uploads".</p> <p>Thanks</p>
[ { "answer_id": 71054, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 4, "selected": true, "text": "<p>Using <a href=\"https://stackoverflow.com/a/8348396/1287812\">this StackOverflow Answer</a>, I came up with a...
2012/10/11
[ "https://wordpress.stackexchange.com/questions/67876", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18800/" ]
Is there any way to find out how much of disk space has been used by Media Library? My blog's media files stored in a separate folder named "media" rather than the default "wp-content/uploads". Thanks
Using [this StackOverflow Answer](https://stackoverflow.com/a/8348396/1287812), I came up with a Dashboard Widget that displays the following: ![Folder Sizes Dashboard Widget](https://i.stack.imgur.com/UnSnY.png) I extended the OP request for the `uploads` dir size (default or custom location) and added `wp-conten...
67,906
<p>I'm on a Category.php page which does the loop like this:</p> <pre><code>&lt;?php while ($wp_query-&gt;have_posts()) : $wp_query-&gt;the_post(); ?&gt; </code></pre> <p>I usually do a custom loop like this:</p> <pre><code>&lt;?php //Define the Loop $temp = $wp_query; $wp_query= null; $wp_query = new WP...
[ { "answer_id": 67908, "author": "Shane", "author_id": 10555, "author_profile": "https://wordpress.stackexchange.com/users/10555", "pm_score": 0, "selected": false, "text": "<p>If it's the main loop, you could use <code>query_posts</code> to add the <code>orderby</code> variable.</p>\n\n<...
2012/10/11
[ "https://wordpress.stackexchange.com/questions/67906", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10298/" ]
I'm on a Category.php page which does the loop like this: ``` <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?> ``` I usually do a custom loop like this: ``` <?php //Define the Loop $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('posts_per_page=2&ord...
You can use the `pre_get_posts` action hook to set the order on your category archive like so: ``` add_action('pre_get_posts', 'filter_category_orderby'); function filter_category_orderby( $query ){ if( $query->is_category()){ $query->set('orderby', 'title'); } } ``` just paste this snippet in your ...
67,919
<p>I want to create a template for selecting 5 specific posts to be displayed on a WordPress page. </p> <p>Essentially I must be able to query 5 exact posts to be displayed on a Wordpress Page using a WP page template and a custom filed to choose the exact 5 post ids.</p> <p>EDIT: I have this code thanks to this site...
[ { "answer_id": 67920, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>The front-end output is controlled by theme, so you would need to study it for appropriate markup to reuse.</p>\n\n<...
2012/10/11
[ "https://wordpress.stackexchange.com/questions/67919", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15955/" ]
I want to create a template for selecting 5 specific posts to be displayed on a WordPress page. Essentially I must be able to query 5 exact posts to be displayed on a Wordpress Page using a WP page template and a custom filed to choose the exact 5 post ids. EDIT: I have this code thanks to this site. But now I need ...
Here's a (rudimentary) page for a loop I made in a webapp on WP a long time ago. I just upload this, create a page, and select "Updates Page" from the page template, and it loads in the 5 posts from the `WP_Query()` results. If you want to load 5 EXACT posts, just replace your loop where mine is. ``` <?php include(CH...
67,922
<p>I've been working on localhost and everything looks fine but then when I uploaded my Wordpress theme online, all of the jQuery plugin functions are undefined!</p> <p>One solution that worked (which I haven't tested a lot so I still don't know if it will work in the long run) is to import the javascript file from th...
[ { "answer_id": 67925, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 3, "selected": true, "text": "<p>You can use <code>$</code> but it is advised you don't. Use <code>jQuery</code> or something like the example in you...
2012/10/11
[ "https://wordpress.stackexchange.com/questions/67922", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6969/" ]
I've been working on localhost and everything looks fine but then when I uploaded my Wordpress theme online, all of the jQuery plugin functions are undefined! One solution that worked (which I haven't tested a lot so I still don't know if it will work in the long run) is to import the javascript file from the plugin's...
You can use `$` but it is advised you don't. Use `jQuery` or something like the example in your link, if you must use `$` you can do so like this; ``` $.noConflict(); jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this function }); //$ will cause problems if put here:) ...
67,929
<p>I'm looking for ways to prevent "private" and "draft" pages from appearing (to non-logged-in admins) in a site's Primary Navigation menu which is based on a custom menu - other than manually removing such pages from the WP custom menu and then dragging them back when they are published, that is.</p> <p>FWIW, I'm su...
[ { "answer_id": 72960, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 2, "selected": false, "text": "<p>The easiest solution is to add a specific class to the menu items that you want to hide. And then hide them ...
2012/10/11
[ "https://wordpress.stackexchange.com/questions/67929", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74/" ]
I'm looking for ways to prevent "private" and "draft" pages from appearing (to non-logged-in admins) in a site's Primary Navigation menu which is based on a custom menu - other than manually removing such pages from the WP custom menu and then dragging them back when they are published, that is. FWIW, I'm surprised th...
I used this as a solution for hiding draft pages. You can hide the (draft page) menu items with the li.draft class. ``` add_filter('nav_menu_css_class' , 'nav_menu_add_post_status_class' , 10 , 2); function nav_menu_add_post_status_class($classes, $item){ $post_status = get_post_status($item->object_id); $clas...
67,945
<p>For registered users to my blog, if they click on the dashboard, they get an alert suggesting that they tell the site administrator (me) that the new version of WordPress is available. </p> <p>All I want is to hide dashboard alerts from the subscribers. Where can I find the code to change this?</p> <p>I found a ...
[ { "answer_id": 67952, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 3, "selected": false, "text": "<p><em>Updating</em> this answer the original code below will remove the nag screen but it will ping the server for up...
2012/10/11
[ "https://wordpress.stackexchange.com/questions/67945", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21371/" ]
For registered users to my blog, if they click on the dashboard, they get an alert suggesting that they tell the site administrator (me) that the new version of WordPress is available. All I want is to hide dashboard alerts from the subscribers. Where can I find the code to change this? I found a site [here](http://...
you can include some custom css in your functions.php that hides the update\_nag (notifications) element dependent on user capability: ``` add_action('admin_head','admin_css'); function admin_css() { if(!current_user_can('administrator'))//not and admin { echo '<style>'; echo '.update_nag{display:none}'; ...
67,971
<p>I want pass current user cookies in <a href="http://codex.wordpress.org/Function_API/wp_remote_get" rel="nofollow noreferrer">wp_remote_get</a> function to get a Draft Post Preview page content. </p> <p>I check already the questions:</p> <ul> <li><a href="https://wordpress.stackexchange.com/questions/4486/what-url...
[ { "answer_id": 68003, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 0, "selected": false, "text": "<p>What's the scenario here, you're trying to retrieve a draft post preview from your current installation, located ...
2012/10/12
[ "https://wordpress.stackexchange.com/questions/67971", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12669/" ]
I want pass current user cookies in [wp\_remote\_get](http://codex.wordpress.org/Function_API/wp_remote_get) function to get a Draft Post Preview page content. I check already the questions: * [What URL do you pass to wp\_remote\_get to load the body of the current post's preview?](https://wordpress.stackexchange.co...
I rarely deal with cookies and not sure about complete mechanics there, but here is basic working example of passing current user's cookies to retrieve preview page source: ``` $preview_link = set_url_scheme( get_permalink( $post->ID ) ); $preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'pre...
67,987
<p>How can I make an external PHP library available with my plugin.</p> <p>Where the library files need to be placed?</p>
[ { "answer_id": 68003, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 0, "selected": false, "text": "<p>What's the scenario here, you're trying to retrieve a draft post preview from your current installation, located ...
2012/10/12
[ "https://wordpress.stackexchange.com/questions/67987", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1378/" ]
How can I make an external PHP library available with my plugin. Where the library files need to be placed?
I rarely deal with cookies and not sure about complete mechanics there, but here is basic working example of passing current user's cookies to retrieve preview page source: ``` $preview_link = set_url_scheme( get_permalink( $post->ID ) ); $preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'pre...
67,993
<p>I attempted to make a minor change to a function in the Twenty Eleven theme (wordpress 3.4.2)</p> <p>I get this error message:</p> <pre><code>Fatal error: Cannot redeclare twentyeleven_widgets_init() (previously declared in /home/labfocus/public_html/wp-content/themes/twentyeleven-child/functions.php:10) in /home/...
[ { "answer_id": 68008, "author": "paulruescher", "author_id": 11814, "author_profile": "https://wordpress.stackexchange.com/users/11814", "pm_score": 2, "selected": false, "text": "<p>Why exactly are you trying to redeclare that function? </p>\n\n<p>You can either edit the original funct...
2012/10/12
[ "https://wordpress.stackexchange.com/questions/67993", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2469/" ]
I attempted to make a minor change to a function in the Twenty Eleven theme (wordpress 3.4.2) I get this error message: ``` Fatal error: Cannot redeclare twentyeleven_widgets_init() (previously declared in /home/labfocus/public_html/wp-content/themes/twentyeleven-child/functions.php:10) in /home/labfocus/public_html/...
Why exactly are you trying to redeclare that function? You can either edit the original function, or, better yet, use [remove\_action](http://codex.wordpress.org/Function_Reference/remove_action) to remove `add_action( 'widgets_init', 'twentyeleven_widgets_init' );` and then reattach your own function `add_action('wi...
68,002
<p>I think the problem essentially relates to sql query structure and I am not an expert....</p> <p>I need to search for posts (custom post type) by 2 parameters:</p> <ol> <li><p>pd_city</p></li> <li><p>pd_country</p></li> </ol> <p>Please note that meta_query relation is 'OR' so if either of above two is LIKE we sho...
[ { "answer_id": 69157, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>That is complicated :)</p>\n\n<p>I was going to suggest that you may not need to have the <code>array( 'key' ...
2012/10/12
[ "https://wordpress.stackexchange.com/questions/68002", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13076/" ]
I think the problem essentially relates to sql query structure and I am not an expert.... I need to search for posts (custom post type) by 2 parameters: 1. pd\_city 2. pd\_country Please note that meta\_query relation is 'OR' so if either of above two is LIKE we should have some results. Third key (is\_sponsored) i...
The culprit ----------- The culprit of the matter is meta queries not supporting different and/or nested relations - a shortcoming by the way, that has driven me nuts before as well. In a recent instance with a search scenario also. What you want to do simply cannot be accomplished with `WP_Query` as well as one loop...
68,012
<p>I would like to add a download button link for the full-sized image on the prettyPhoto lightbox when a user views a photo on my site.</p> <p>Currently I use the <a href="http://wordpress.org/extend/plugins/prettyphoto-media/" rel="nofollow">prettyPhoto Media</a> plugin on my site, and I have also used this code (ta...
[ { "answer_id": 69226, "author": "Nathan", "author_id": 21392, "author_profile": "https://wordpress.stackexchange.com/users/21392", "pm_score": 1, "selected": true, "text": "<p>So the best option for me, being that I am not a programmer, was just to change plugins. I used <a href=\"http:/...
2012/10/12
[ "https://wordpress.stackexchange.com/questions/68012", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21392/" ]
I would like to add a download button link for the full-sized image on the prettyPhoto lightbox when a user views a photo on my site. Currently I use the [prettyPhoto Media](http://wordpress.org/extend/plugins/prettyphoto-media/) plugin on my site, and I have also used this code (taken from [this post](http://oikos.or...
So the best option for me, being that I am not a programmer, was just to change plugins. I used [this plugin](http://wordpress.org/extend/plugins/wp-jquery-lightbox/) and got the results I needed (it already has a download link).
68,034
<p>I have a custom post type called 'product' with a registered taxonomy 'product-type'.</p> <p>I want to display all post from a particular taxonomy from custom post type. In my case I want to display all the posts from 'product' post type with a term of 'software'.</p> <pre><code> &lt;?php $args = array( ...
[ { "answer_id": 68036, "author": "anu", "author_id": 490, "author_profile": "https://wordpress.stackexchange.com/users/490", "pm_score": 2, "selected": false, "text": "<p>If you look at the <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters\" rel=\"nofollow\...
2012/10/12
[ "https://wordpress.stackexchange.com/questions/68034", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21399/" ]
I have a custom post type called 'product' with a registered taxonomy 'product-type'. I want to display all post from a particular taxonomy from custom post type. In my case I want to display all the posts from 'product' post type with a term of 'software'. ``` <?php $args = array( 'post_type' => 'produc...
If you look at the [documentation for WP\_Query taxonomy parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters), you'll see that the tax\_query is an array of arrays. So: ``` 'tax_query' => array( array( 'taxonomy' => 'product-type', 'terms' => array('software'), ...
68,052
<p>When trying to add a checkbox to the theme customizer it seems to be 'always' selected. If you try to deselect it you cannot, almost as if there is some JS code forcing it to stay selected.</p> <p>I am using serialized theme options and everything is hooked up correctly. Code is similar to the following (triggered ...
[ { "answer_id": 89637, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 3, "selected": false, "text": "<p>Checkbox is possible. A example, I hope this help you.</p>\n\n<p>At first you must define the setting, via <code>a...
2012/10/12
[ "https://wordpress.stackexchange.com/questions/68052", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8961/" ]
When trying to add a checkbox to the theme customizer it seems to be 'always' selected. If you try to deselect it you cannot, almost as if there is some JS code forcing it to stay selected. I am using serialized theme options and everything is hooked up correctly. Code is similar to the following (triggered via the 'c...
Checkbox is possible. A example, I hope this help you. At first you must define the setting, via `add_setting`, important is the param `type` with value `option`. After this control the field via `add_control`and set the param `type` to `checkbox`. Alternative it is possible to use `select`. If I add a default value v...
68,067
<p>Is there an argument for get_terms which I can fetch terms that only have say over 2 posts associated with it? <br>I have a terms page which lists all my terms for 'artists', the page is huge but a lot of these terms that only have one post so I would like to show only significant terms.</p>
[ { "answer_id": 89637, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 3, "selected": false, "text": "<p>Checkbox is possible. A example, I hope this help you.</p>\n\n<p>At first you must define the setting, via <code>a...
2012/10/12
[ "https://wordpress.stackexchange.com/questions/68067", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19527/" ]
Is there an argument for get\_terms which I can fetch terms that only have say over 2 posts associated with it? I have a terms page which lists all my terms for 'artists', the page is huge but a lot of these terms that only have one post so I would like to show only significant terms.
Checkbox is possible. A example, I hope this help you. At first you must define the setting, via `add_setting`, important is the param `type` with value `option`. After this control the field via `add_control`and set the param `type` to `checkbox`. Alternative it is possible to use `select`. If I add a default value v...
68,069
<p>I'm trying to make my links like this:</p> <pre><code>site.com/article-sample-post </code></pre> <p>as "article" is a fixed prefix and "sample-post" is the post slug..</p> <p>but that prefix affect the category link structure making it :</p> <pre><code>site.com/article-category/sample-cat </code></pre> <p>which...
[ { "answer_id": 68076, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": true, "text": "<p>If you want to remove the category base <code>/category/</code>, you can install the <a href=\"http://wordpress.org/...
2012/10/12
[ "https://wordpress.stackexchange.com/questions/68069", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16505/" ]
I'm trying to make my links like this: ``` site.com/article-sample-post ``` as "article" is a fixed prefix and "sample-post" is the post slug.. but that prefix affect the category link structure making it : ``` site.com/article-category/sample-cat ``` which is not desired! my question: does there any simple hac...
If you want to remove the category base `/category/`, you can install the [WP no category base plugin](http://wordpress.org/extend/plugins/wp-no-category-base/) which will add a new set of rewrite rules for categories. the side-effect of this is that you can set your post permalinks to `/article-%postname%/` and it wil...
68,079
<p>On my main site I have used the search widget in the sidebar.</p> <p>However, the mobile theme I am using (<a href="http://en.blog.wordpress.com/2011/11/02/new-mobile-theme-minileven/" rel="nofollow">minileven</a>) already has a search box built into its menu bar. This results in a second search box in the sidebar...
[ { "answer_id": 68083, "author": "Phantasmix", "author_id": 18862, "author_profile": "https://wordpress.stackexchange.com/users/18862", "pm_score": 3, "selected": true, "text": "<ul>\n<li>Add a class .hide with property <code>display: none;</code> - specify only for mobile viewports, not ...
2012/10/12
[ "https://wordpress.stackexchange.com/questions/68079", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/961/" ]
On my main site I have used the search widget in the sidebar. However, the mobile theme I am using ([minileven](http://en.blog.wordpress.com/2011/11/02/new-mobile-theme-minileven/)) already has a search box built into its menu bar. This results in a second search box in the sidebar (which appears after the post conten...
* Add a class .hide with property `display: none;` - specify only for mobile viewports, not in desktop styles * assign the class to your widget or to the entire sidebar, as needed
68,090
<p>I'm having trouble configuring wp-config.php correctly in a staged server environment. I'm being told that I should be working in my stage environment for Wordpress with an example address of <a href="http://www-stage.website.com" rel="nofollow">http://www-stage.website.com</a>. It will then mirror to the production...
[ { "answer_id": 68093, "author": "Robbiegod", "author_id": 18119, "author_profile": "https://wordpress.stackexchange.com/users/18119", "pm_score": 0, "selected": false, "text": "<p>Who is your webhost?</p>\n\n<p>We use rackspace and when you setup Wordpress initially they give you a tempo...
2012/10/12
[ "https://wordpress.stackexchange.com/questions/68090", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21419/" ]
I'm having trouble configuring wp-config.php correctly in a staged server environment. I'm being told that I should be working in my stage environment for Wordpress with an example address of <http://www-stage.website.com>. It will then mirror to the production server at <http://website.com> as they use the same databa...
I would be very hesitant in having the same database for staging and live as any changes to the database would affect both sites (especially when using software like Wordpress where there is configuration in the database). The only time that I would think of pointing to the live database would be if I was doing theme d...
68,092
<p>The standard way of getting an excerpt is to use <code>the_excerpt()</code> or <code>get_the_excerpt()</code> template tags. I am trying to get just the actual content of the Excerpt field.</p> <p>If there is an excerpt, I want to display it in full (without being abridged or appending [...]). If there is no excerp...
[ { "answer_id": 68102, "author": "Tomas Buteler", "author_id": 5552, "author_profile": "https://wordpress.stackexchange.com/users/5552", "pm_score": 4, "selected": true, "text": "<p>Why don't you use the global <code>$post</code> variable? It contains an object with the content as it is o...
2012/10/12
[ "https://wordpress.stackexchange.com/questions/68092", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3564/" ]
The standard way of getting an excerpt is to use `the_excerpt()` or `get_the_excerpt()` template tags. I am trying to get just the actual content of the Excerpt field. If there is an excerpt, I want to display it in full (without being abridged or appending [...]). If there is no excerpt, I don't want anything to be d...
Why don't you use the global `$post` variable? It contains an object with the content as it is on the db row corresponding to that post. Here's how to use it: ``` global $post; // If for some reason it's readily accessible, invoke it if($post->post_excerpt != '') { echo($post->post_excerpt); } ``` Or: ``` $my_p...
68,097
<p>I'd like a way to target only blog-area pages for specific formatting. </p> <p>So far, </p> <pre><code>&lt;?php if (is_home() || is_single() || is_category() || is_archive() ) { ?&gt; </code></pre> <p>works okay, but is there a way to combine all of those into one single function to shorten it up a bit? so maybe ...
[ { "answer_id": 68098, "author": "mousesports", "author_id": 21329, "author_profile": "https://wordpress.stackexchange.com/users/21329", "pm_score": 2, "selected": true, "text": "<p>Based on what you described:</p>\n\n<pre><code>function is_blog()\n{\n return ( is_home() || is_single()...
2012/10/12
[ "https://wordpress.stackexchange.com/questions/68097", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19794/" ]
I'd like a way to target only blog-area pages for specific formatting. So far, ``` <?php if (is_home() || is_single() || is_category() || is_archive() ) { ?> ``` works okay, but is there a way to combine all of those into one single function to shorten it up a bit? so maybe in the functions it would set is\_blog(...
Based on what you described: ``` function is_blog() { return ( is_home() || is_single() || is_category() || is_archive() ); } ``` And then just call the is\_blog() function whenever needed. I also found this, which looks like a more specific way to do the same thing <https://gist.github.com/1189639>
69,155
<p>How do I approve a post directly from preview mode, instead of having to return to edit mode and/or "list of posts" mode? </p> <p>I'm script-matically uploading several (hundred) posts, but want to live preview them briefly before approval. </p>
[ { "answer_id": 69179, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 4, "selected": true, "text": "<p>Here is something i have laying around:</p>\n\n<pre><code>&lt;?php\n/*\nPlugin Name: Approve From preview\nPlu...
2012/10/13
[ "https://wordpress.stackexchange.com/questions/69155", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
How do I approve a post directly from preview mode, instead of having to return to edit mode and/or "list of posts" mode? I'm script-matically uploading several (hundred) posts, but want to live preview them briefly before approval.
Here is something i have laying around: ``` <?php /* Plugin Name: Approve From preview Plugin URI: http://en.bainternet.info Description: Approve from privew is Plugin that lets yo approve posts (draft and pending) from the preview itself. Version: 0.1 Author: Bainternet License: Copyright 2012 Bainternet (admin@b...
69,184
<p>I want to use the <code>get_option()</code> function of wordpress in one of my theme's files, which is not related to WP, it is just located in the same directory of the other theme files. I need this file because of some extra IPN paypal related actions, but I need some values from the options table that exists in ...
[ { "answer_id": 69186, "author": "Abdussamad", "author_id": 12839, "author_profile": "https://wordpress.stackexchange.com/users/12839", "pm_score": 2, "selected": false, "text": "<p>Turn your external file into a WordPress plugin. That way you'll have full access to WP core functions. </p...
2012/10/14
[ "https://wordpress.stackexchange.com/questions/69184", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22463/" ]
I want to use the `get_option()` function of wordpress in one of my theme's files, which is not related to WP, it is just located in the same directory of the other theme files. I need this file because of some extra IPN paypal related actions, but I need some values from the options table that exists in WP to be calle...
The shortest way is to load `wp-load.php` and abort the loading of the template engine (Note: You couldn't do that, if you'd be loading the header file, like you see it on many sites in the interweb). ``` # No need for the template engine define( 'WP_USE_THEMES', false ); # Load WordPress Core // Assuming we're in a s...
69,199
<pre><code> //Displaying latest post per author on front page function filter_where($where = '') { global $wpdb; $where .= " AND vipwp_posts.id = (select id from {$wpdb-&gt;prefix}posts p2 where p2.post_status = 'publish' and p2.post_author = {$wpdb-&gt;prefix}posts.post_author order by p2.post_date desc...
[ { "answer_id": 69186, "author": "Abdussamad", "author_id": 12839, "author_profile": "https://wordpress.stackexchange.com/users/12839", "pm_score": 2, "selected": false, "text": "<p>Turn your external file into a WordPress plugin. That way you'll have full access to WP core functions. </p...
2012/10/14
[ "https://wordpress.stackexchange.com/questions/69199", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22472/" ]
``` //Displaying latest post per author on front page function filter_where($where = '') { global $wpdb; $where .= " AND vipwp_posts.id = (select id from {$wpdb->prefix}posts p2 where p2.post_status = 'publish' and p2.post_author = {$wpdb->prefix}posts.post_author order by p2.post_date desc limit 0,1)";...
The shortest way is to load `wp-load.php` and abort the loading of the template engine (Note: You couldn't do that, if you'd be loading the header file, like you see it on many sites in the interweb). ``` # No need for the template engine define( 'WP_USE_THEMES', false ); # Load WordPress Core // Assuming we're in a s...
69,204
<p>As you can see into the code, the routine is to display the post which has an <code>id</code> of <code>266</code>. Now all I want is to limit the words displayed in the post content of that post. Let's say, I want to limit the words to a number of 300 and then add a read more link.</p> <p>This is the code I got so ...
[ { "answer_id": 69215, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>There're three filters that control the »more« link, depending on what function/Template Tag is in use. The bad thi...
2012/10/14
[ "https://wordpress.stackexchange.com/questions/69204", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24673/" ]
As you can see into the code, the routine is to display the post which has an `id` of `266`. Now all I want is to limit the words displayed in the post content of that post. Let's say, I want to limit the words to a number of 300 and then add a read more link. This is the code I got so far: ``` $post_id = 266; ...
I always have the same problem with post excerpt, post content. There're various hooks and functions for this purpose, like @kaiser pointed out. But sometimes they don't do exactly what I want. Here's my solution, I write my own function that take the post content, and truncate it into specified number of words: ``` ...
69,227
<p>I want to show the image only if there is info in the field. And the link around the image uses the info in the field. The mailto: field is coming up blank. So I'm guessing/hoping I'm doing something wrong with the way I'm printing/calling it. I would greatly appreciate any help. </p> <pre><code>&lt;?php $email =...
[ { "answer_id": 69229, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 1, "selected": false, "text": "<p>Change,</p>\n\n<pre><code>&lt;?php $email ?&gt;\n</code></pre>\n\n<p>to...</p>\n\n<pre><code>&lt;?php echo $email...
2012/10/15
[ "https://wordpress.stackexchange.com/questions/69227", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22477/" ]
I want to show the image only if there is info in the field. And the link around the image uses the info in the field. The mailto: field is coming up blank. So I'm guessing/hoping I'm doing something wrong with the way I'm printing/calling it. I would greatly appreciate any help. ``` <?php $email = types_render_field...
Change, ``` <?php $email ?> ``` to... ``` <?php echo $email; ?> ``` as you need to `echo` the result of what's held within `$email` as the function `types_render_field` would be using `return` within the function (if you dig into its core) to return the data instead of directly printing it to screen. ``` <?php $...
69,239
<p>Lets say, I create page1 and page2 in wordpress, in Page1 there is a hyperlink which takes me to page2. How do I ensure that visitor has clicked that hyperlink and have come to page2 and not directly on page2, by typing page2 url in the address bar.</p> <p>if someone has come directly to page2 I want them to be red...
[ { "answer_id": 69229, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 1, "selected": false, "text": "<p>Change,</p>\n\n<pre><code>&lt;?php $email ?&gt;\n</code></pre>\n\n<p>to...</p>\n\n<pre><code>&lt;?php echo $email...
2012/10/15
[ "https://wordpress.stackexchange.com/questions/69239", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20899/" ]
Lets say, I create page1 and page2 in wordpress, in Page1 there is a hyperlink which takes me to page2. How do I ensure that visitor has clicked that hyperlink and have come to page2 and not directly on page2, by typing page2 url in the address bar. if someone has come directly to page2 I want them to be redirected au...
Change, ``` <?php $email ?> ``` to... ``` <?php echo $email; ?> ``` as you need to `echo` the result of what's held within `$email` as the function `types_render_field` would be using `return` within the function (if you dig into its core) to return the data instead of directly printing it to screen. ``` <?php $...
69,250
<p>I currently have a members area for subscribers. I have already setup the ability for users to 'favourite' posts and add them to custom folders of their choice. Once they have added some posts to a specific folder, I want them to be able to click download where it will collate that folders posts into a pdf. Doesn't ...
[ { "answer_id": 69229, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 1, "selected": false, "text": "<p>Change,</p>\n\n<pre><code>&lt;?php $email ?&gt;\n</code></pre>\n\n<p>to...</p>\n\n<pre><code>&lt;?php echo $email...
2012/10/15
[ "https://wordpress.stackexchange.com/questions/69250", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21326/" ]
I currently have a members area for subscribers. I have already setup the ability for users to 'favourite' posts and add them to custom folders of their choice. Once they have added some posts to a specific folder, I want them to be able to click download where it will collate that folders posts into a pdf. Doesn't hav...
Change, ``` <?php $email ?> ``` to... ``` <?php echo $email; ?> ``` as you need to `echo` the result of what's held within `$email` as the function `types_render_field` would be using `return` within the function (if you dig into its core) to return the data instead of directly printing it to screen. ``` <?php $...
69,255
<p>Is there a function in wordpress that grabs all the users(user ids) who have commented on a post? I have the post id available.</p>
[ { "answer_id": 69258, "author": "Poulomi Nag", "author_id": 18286, "author_profile": "https://wordpress.stackexchange.com/users/18286", "pm_score": 2, "selected": false, "text": "<p>The following snippet is one way of doing it:</p>\n\n<pre><code>$args = array(\n'status' =&gt; 'approve',\...
2012/10/15
[ "https://wordpress.stackexchange.com/questions/69255", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18286/" ]
Is there a function in wordpress that grabs all the users(user ids) who have commented on a post? I have the post id available.
The get\_comments() answer by Poulomi Nag is correct. This will be somewhat more efficient. ``` global $wpdb, $post; $query = sprintf("SELECT user_id FROM {$wpdb->comments} JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$wpdb->comments}.comment_post_ID WHERE com...
69,261
<p>I am using <a href="http://wordpress.org/extend/plugins/woocommerce/" rel="nofollow">woocommerce plugin</a> for wordpress to make an eCommerce website. It is working fine with little bit customization. As I have configured shop page as the default product page so that in that page every product can be seen and a u...
[ { "answer_id": 69300, "author": "mirage", "author_id": 22505, "author_profile": "https://wordpress.stackexchange.com/users/22505", "pm_score": 0, "selected": false, "text": "<p>woocommerce has it's own css structure. If you want to style your woocommerce page you can define your custom.c...
2012/10/15
[ "https://wordpress.stackexchange.com/questions/69261", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6170/" ]
I am using [woocommerce plugin](http://wordpress.org/extend/plugins/woocommerce/) for wordpress to make an eCommerce website. It is working fine with little bit customization. As I have configured shop page as the default product page so that in that page every product can be seen and a user can buy product from that p...
You can add this to your body tag of your current theme `<body <?php body_class('class-name'); ?>>` and then specifically target the container. ``` body.post-id #yourdiv { border: 2px solid red; } ``` Always work for me.
69,264
<p>I have made a page template which shows linked subpages using this bit of code:</p> <pre><code>&lt;?php $mypages = get_pages( array( 'child_of' =&gt; $post-&gt;ID, 'sort_column' =&gt; 'menu_order', 'sort_or foreach( $mypages as $page ) { $content = $page-&gt;post_content; ...
[ { "answer_id": 69266, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 3, "selected": true, "text": "<p>Slightly modify these lines</p>\n\n<pre><code>$content = $page-&gt;post_content;\nif ( ! $content ) // ...
2012/10/15
[ "https://wordpress.stackexchange.com/questions/69264", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/961/" ]
I have made a page template which shows linked subpages using this bit of code: ``` <?php $mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'menu_order', 'sort_or foreach( $mypages as $page ) { $content = $page->post_content; if ( ! $content ) // Ch...
Slightly modify these lines ``` $content = $page->post_content; if ( ! $content ) // Check for empty page continue; $content = apply_filters( 'the_content', $content ); ``` to ``` $content = $page->post_excerpt; if ( ! $content ) // Check for empty excerpt content & fallback to full content $content = $pag...
69,274
<p>I am using Bootstrap with Wordpress and I want to implement the <a href="http://twitter.github.com/bootstrap/javascript.html#collapse" rel="nofollow">collapse</a> functionality in the content for single pages of a specific custom post type.</p> <p>I know I could create a shortcode, however, with hundereds of posts...
[ { "answer_id": 69276, "author": "Damien", "author_id": 17132, "author_profile": "https://wordpress.stackexchange.com/users/17132", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/the_title\" rel=\"nofollow\">From the Codex</a> you can...
2012/10/15
[ "https://wordpress.stackexchange.com/questions/69274", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22502/" ]
I am using Bootstrap with Wordpress and I want to implement the [collapse](http://twitter.github.com/bootstrap/javascript.html#collapse) functionality in the content for single pages of a specific custom post type. I know I could create a shortcode, however, with hundereds of posts shortcodes are not going to be ideal...
The script ---------- First you have to enqueue the script. We conditionally load it only for your custom post type and its archive(s). ``` // in your functions.php function wpse69274_enqueue_tbs_collapse() { if ( ! is_post_type_archive() AND 'YOUR_POST_TYPE' !== get_post_type() ) retu...
69,294
<p>I'm trying to show profile fields with <strong>checkboxes and drop-downs</strong> in the members directory loop.</p> <p><strong>Example: Next to each member in the directory I want to show the Gender they selected</strong></p> <p>This code works for text fields: </p> <pre><code>echo xprofile_get_field_data('Full ...
[ { "answer_id": 69368, "author": "mirage", "author_id": 22505, "author_profile": "https://wordpress.stackexchange.com/users/22505", "pm_score": 0, "selected": false, "text": "<p>Have a look at the new plugin \"Buddypress Xprofile Custom Fields Type\" <a href=\"http://wordpress.org/extend/...
2012/10/15
[ "https://wordpress.stackexchange.com/questions/69294", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17636/" ]
I'm trying to show profile fields with **checkboxes and drop-downs** in the members directory loop. **Example: Next to each member in the directory I want to show the Gender they selected** This code works for text fields: ``` echo xprofile_get_field_data('Full Name', bp_get_member_user_id()); ``` BUT **how do I ...
I believe xprofile\_get\_field\_data is unserializing the data for you, but it is still in an array. xprofile\_get\_field\_data can return an array or a comma-separated string. ``` xprofile_get_field_data( $field, $user_id = 0, $multi_format = 'array' ) ``` @param string $multi\_format * How should array data be...
69,302
<p>Is it possible to <strong>sort posts (custom post type) by category / taxonomy</strong> (name, desc)?</p> <p>For example my categories would be </p> <ul> <li>Season 2012 <ul> <li>some post </li> <li>some post </li> <li>some post </li> </ul></li> <li>Season 2011 <ul> <li>some post </li> <li>some post </li> <li>som...
[ { "answer_id": 69304, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 5, "selected": true, "text": "<p>One solution would be-</p>\n\n<pre><code>$terms = get_terms('taxonomy-name');\nforeach($terms as $term)...
2012/10/15
[ "https://wordpress.stackexchange.com/questions/69302", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17269/" ]
Is it possible to **sort posts (custom post type) by category / taxonomy** (name, desc)? For example my categories would be * Season 2012 + some post + some post + some post * Season 2011 + some post + some post + some post * Season 2010 * etc..
One solution would be- ``` $terms = get_terms('taxonomy-name'); foreach($terms as $term) { $posts = get_posts(array( 'post_type' => 'custom_post_type_name', 'tax_query' => array( array( 'taxonomy' => 'taxonomy-name', 'field' => 'slug',...
69,318
<p>I've been trying to set a different width and height using the <code>get_avatar</code> function. I need to set the author's avatar in <code>single.php</code> to 60x40 size.</p> <p>So let's say the gravatar looks like this:</p> <p><img src="https://i.stack.imgur.com/J8jtu.jpg" alt="enter image description here"></p...
[ { "answer_id": 69319, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<pre><code>apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);\n</code></pre>\n\n<p>So you can ...
2012/10/15
[ "https://wordpress.stackexchange.com/questions/69318", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13291/" ]
I've been trying to set a different width and height using the `get_avatar` function. I need to set the author's avatar in `single.php` to 60x40 size. So let's say the gravatar looks like this: ![enter image description here](https://i.stack.imgur.com/J8jtu.jpg) when set to 60x40, it would look like this (resized an...
As informed by @Rarst, apparently currently Gravatar only accepts one value for size. It is really unfortunate. However I managed to work-around this by facilitating `timthumb.php` and a function I found from here: [How to get gravatar url alone](https://wordpress.stackexchange.com/questions/46904/how-to-get-gravatar-u...
69,355
<p>I am currently trying to perform a custom query on the authors page (author.php). I have two custom fields for posts that I want to query against (post_photographer and post_videographer). </p> <p>What I am trying to do for the author's profile is get all the posts for the current user profile where the user is:</p...
[ { "answer_id": 69356, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": -1, "selected": false, "text": "<p>Either of these 2 filters should help you:</p>\n\n<ol>\n<li><a href=\"http://codex.wordpress.org/Plugi...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69355", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22523/" ]
I am currently trying to perform a custom query on the authors page (author.php). I have two custom fields for posts that I want to query against (post\_photographer and post\_videographer). What I am trying to do for the author's profile is get all the posts for the current user profile where the user is: * the aut...
For anyone who may have a similar need, I solved this the following way (on authors.php): First I get the author ID: ``` $author = get_user_by( 'slug', get_query_var( 'author_name' ) ); // ID is accessed this way: $author_id = $author->ID; ``` I then created a custom query: ``` $query = " ...
69,358
<p>I haven't set a limit to the number of revisions, which makes some of my post have more than 20 revisions, so how to delete these revisions?</p> <p>By the way, I am using WPMU and have many blogs, so how to delete WordPress revisions for all my blogs?</p>
[ { "answer_id": 69363, "author": "deathlock", "author_id": 13291, "author_profile": "https://wordpress.stackexchange.com/users/13291", "pm_score": 0, "selected": false, "text": "<p>To delete all of your Wordpress revisions, you could use this query:</p>\n\n<p><code>DELETE FROM wp_posts WH...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69358", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19266/" ]
I haven't set a limit to the number of revisions, which makes some of my post have more than 20 revisions, so how to delete these revisions? By the way, I am using WPMU and have many blogs, so how to delete WordPress revisions for all my blogs?
This is a much safer query to use and will remove related entries from the postmeta and term\_relationship, unlike *deathlocks* query in his answer. Change the {id} to the id of each blog posts table. You can combine this query to run all the post tables at once, but try this on one table first. I've used it many time...
69,359
<p>I have created a custom post type with an image gallery upload. Now I am trying to display the gallery on the front end. This is what I have so far that works to display 1 image, but if multiple images are uploaded all the URLs get stuck in the <code>src</code> tag. So I'm guessing I should loop through that array a...
[ { "answer_id": 69360, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>You should reorganize the way you store the images: Make the uploaded files children of that particular post, do not p...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69359", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18241/" ]
I have created a custom post type with an image gallery upload. Now I am trying to display the gallery on the front end. This is what I have so far that works to display 1 image, but if multiple images are uploaded all the URLs get stuck in the `src` tag. So I'm guessing I should loop through that array and spit out ea...
You should reorganize the way you store the images: Make the uploaded files children of that particular post, do not put them in a post meta field. Then get all the images with [`get_children()`](http://codex.wordpress.org/Function_Reference/get_children). Look at the built-in handler for the `[gallery]` shortcode for ...
69,365
<p>I'm initializing a variable with a value in the header.php file. I want access to that value in footer.php, but it doesn't exist upon checking. Example:</p> <p><strong>header.php</strong></p> <pre><code>$status = true; </code></pre> <p><strong>footer.php</strong></p> <pre><code>var_dump( $status ); // is null ...
[ { "answer_id": 69366, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>Avoid global variables, they could be overwritten by other code. You could use a helper function with a static internal...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69365", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17467/" ]
I'm initializing a variable with a value in the header.php file. I want access to that value in footer.php, but it doesn't exist upon checking. Example: **header.php** ``` $status = true; ``` **footer.php** ``` var_dump( $status ); // is null ``` What's a best practice for doing something in footer.php, or other...
Avoid global variables, they could be overwritten by other code. You could use a helper function with a static internal variable instead. Sample code: ``` function wpse_69365_var_storage( $var = NULL ) { static $internal; if ( NULL !== $var ) { $internal = $var; } return $internal; } // ...
69,369
<p>I need to run a function when a particular post or page is loaded. Is there any hook that lets me check whether a post is being displayed during page load ?</p>
[ { "answer_id": 69372, "author": "darronz", "author_id": 17084, "author_profile": "https://wordpress.stackexchange.com/users/17084", "pm_score": 1, "selected": false, "text": "<p>I've quite often used the following to load in custom meta boxes on pages (rather than custom posts).</p>\n\n<...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69369", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18286/" ]
I need to run a function when a particular post or page is loaded. Is there any hook that lets me check whether a post is being displayed during page load ?
You can use the `wp` hook and check the `global $wp_query` object or any conditional. ``` add_action( 'wp', 'wpse69369_special_thingy' ); function wpse69369_special_thingy() { if ( 'special_cpt' === get_post_type() AND is_singular() ) return print "Yo World!"; return printf( ...
69,395
<p>Im trying add a credit link to the footer of all the WP sites i make saying:</p> <p><em>Designed by ...</em></p> <p>While this is simple enough, i want to code it so that if this link is removed from the footer, the entire site shows an error or doesn't load up etc.</p> <p>Any one have ideas?</p>
[ { "answer_id": 69419, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 1, "selected": false, "text": "<p>While I believe the premise of this to be flawed and somewhat black-hat, it is a legit WP question albeit a...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69395", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21023/" ]
Im trying add a credit link to the footer of all the WP sites i make saying: *Designed by ...* While this is simple enough, i want to code it so that if this link is removed from the footer, the entire site shows an error or doesn't load up etc. Any one have ideas?
---------------- UPDATE ---------------- ---------------------------------------- I do some change of the code provide by @Rizier123 **Now it will accept to add a link in the citation varibale** You need to change the line of **preg\_match** ( Thanks goes to @Rizier123) by this : ``` if(!preg_match("/" . preg_quot...
69,406
<p>What I'm trying to do is getting Woocommerce categories and products randomly displayed on one page. The normal settings allow to display categories and products on the same page, but first come the categories and afterwards the products. This is the case because the categories come with the function <code>woocommer...
[ { "answer_id": 69413, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 0, "selected": false, "text": "<p>You should be able to combine the categories and the products array/objects and then shuffle them, and then l...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69406", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22534/" ]
What I'm trying to do is getting Woocommerce categories and products randomly displayed on one page. The normal settings allow to display categories and products on the same page, but first come the categories and afterwards the products. This is the case because the categories come with the function `woocommerce_produ...
as suggested by kaiser, my last working edit as solution: ok, inspired by @s\_ha\_dum answer i manged to get a solution: ``` //this 1. part is out of the woocommerce-template.php and part of the woocommerce_product_subcategories() $product_cat = get_term_by( 'slug', $product_cat_slug, 'product_cat' ); $product_catego...
69,416
<p>I'm trying to add some default content to my posts using this code in my functions.php:</p> <pre><code>add_filter( 'default_content', 'my_editor_content' ); function my_editor_content( $content ) { $content = "My html content."; return $content; } </code></pre> <p>It works fine, but I would like to add the content...
[ { "answer_id": 69418, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p><code>default_content</code> runs when a post is loaded into the editor, actually. You can check for categori...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69416", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22537/" ]
I'm trying to add some default content to my posts using this code in my functions.php: ``` add_filter( 'default_content', 'my_editor_content' ); function my_editor_content( $content ) { $content = "My html content."; return $content; } ``` It works fine, but I would like to add the content to some categories only. ...
`default_content` runs when a post is loaded into the editor, actually. You can check for categories when the post is saved, but you'd want the [`save_post`](http://adambrown.info/p/wp_hooks/hook/save_post) hook, probably. You want to check the `$_REQUEST` global. ``` add_filter( 'default_content', 'my_editor_content'...
69,428
<p>I use custom fields named 'url' to add another website url (like <code>http://www.youtube.com</code>), I want to rewrite the 'url' as <code>http://www.mysite.com/go/123</code>. </p> <p>I tried all rewrite plugins, no one could do this.</p> <p>Can I set post id as 123? Or can I set a random number as it?</p>
[ { "answer_id": 69418, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p><code>default_content</code> runs when a post is loaded into the editor, actually. You can check for categori...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69428", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22541/" ]
I use custom fields named 'url' to add another website url (like `http://www.youtube.com`), I want to rewrite the 'url' as `http://www.mysite.com/go/123`. I tried all rewrite plugins, no one could do this. Can I set post id as 123? Or can I set a random number as it?
`default_content` runs when a post is loaded into the editor, actually. You can check for categories when the post is saved, but you'd want the [`save_post`](http://adambrown.info/p/wp_hooks/hook/save_post) hook, probably. You want to check the `$_REQUEST` global. ``` add_filter( 'default_content', 'my_editor_content'...
69,435
<p>Typically I don't utilize comments on my sites, however I'm using the comments functionality as a sort of live-feed testimonials page. To do this, I've borrowed <code>comments.php</code> and the comments portion of <code>functions.php</code> from the TwentyEleven theme. What I'm currently struggling with is how the...
[ { "answer_id": 69439, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 2, "selected": true, "text": "<p>to remove it from the left. Delete the line containing <code>wp_list_comments</code> from comments.php<...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69435", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14606/" ]
Typically I don't utilize comments on my sites, however I'm using the comments functionality as a sort of live-feed testimonials page. To do this, I've borrowed `comments.php` and the comments portion of `functions.php` from the TwentyEleven theme. What I'm currently struggling with is how the comments/form are displa...
to remove it from the left. Delete the line containing `wp_list_comments` from comments.php to display user name add `comment_author();`, for email use `comment_author_email();` & for url use `if(get_comment_author_url()) comment_author_url();`. `comment_text()` is already there. These all go in the markup inside the...
69,436
<p>I have code in functions.php:</p> <pre><code>function string_limit_words($string, $word_limit) { $words = explode(' ', $string, ($word_limit + 1)); if(count($words) &gt; $word_limit) array_pop($words); return implode(' ', $words); } </code></pre> <p>but i need to limit excerpt in number of characters, coul...
[ { "answer_id": 69438, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>WordPress has a filter for that which is conveniently named excerpt_length and it accepts a number of chars s...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69436", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18000/" ]
I have code in functions.php: ``` function string_limit_words($string, $word_limit) { $words = explode(' ', $string, ($word_limit + 1)); if(count($words) > $word_limit) array_pop($words); return implode(' ', $words); } ``` but i need to limit excerpt in number of characters, could you help me with that?
I used this code in one of my last projects: ``` function ng_get_excerpt( $count ){ $permalink = get_permalink( $post->ID ); $excerpt = get_the_content(); $excerpt = strip_tags( $excerpt ); $excerpt = mb_substr( $excerpt, 0, $count ); $excerpt = mb_substr( $excerpt, 0, strripos( $excerpt, " " ) ); $excerpt...
69,445
<p>We have a multisite setup, the primary domain needs to have domain.com, www.domain.com and secure.domain.com mapped in wordpress so the primary site's content loads on them. The problem we are facing is everything except secure.domain.com works. secure.domain.com always ends up at: <a href="http://www.domain.com/w...
[ { "answer_id": 69454, "author": "Ipstenu", "author_id": 7886, "author_profile": "https://wordpress.stackexchange.com/users/7886", "pm_score": 2, "selected": false, "text": "<p>Do you have to have secure.domain.com function or can it redirect?</p>\n\n<p>The tl;dr is that you don't. The pr...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69445", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20603/" ]
We have a multisite setup, the primary domain needs to have domain.com, www.domain.com and secure.domain.com mapped in wordpress so the primary site's content loads on them. The problem we are facing is everything except secure.domain.com works. secure.domain.com always ends up at: <http://www.domain.com/wp-signup.php?...
In the end I just added the following to .htaccess ``` RewriteCond %{HTTP_HOST} ^secure\.domain\.net$ RewriteRule (.*) http://www.domain.net/$1 [P,L] ``` This appears to be working fine, but I'm not sure of what types of unforeseen effects it may have if any.
69,450
<p>I'm using the <a href="http://www.google.com/webfonts/specimen/Rosario" rel="nofollow">Rosario font</a> from the <a href="http://www.google.com/webfonts" rel="nofollow">Google Web Fonts</a> in my theme and I want to <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_style" rel="nofollow">enqueue the f...
[ { "answer_id": 69452, "author": "Zach", "author_id": 9605, "author_profile": "https://wordpress.stackexchange.com/users/9605", "pm_score": 4, "selected": true, "text": "<p>You should be able to just use <code>http://fonts.googleapis.com/css?family=Rosario:400,700,400italic</code> which i...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69450", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19620/" ]
I'm using the [Rosario font](http://www.google.com/webfonts/specimen/Rosario) from the [Google Web Fonts](http://www.google.com/webfonts) in my theme and I want to [enqueue the font](http://codex.wordpress.org/Function_Reference/wp_enqueue_style) so that if there was ever a plugin that used a fancy font that there woul...
You should be able to just use `http://fonts.googleapis.com/css?family=Rosario:400,700,400italic` which is the "combined" URL given by Google when selecting multiple weights/styles of a font. You can then just register the font once. You don't need to over-complicate the `$handle` either, something like `google-fonts-r...
69,461
<p>Is there a way of obtaining the user ID of the profile being edited in <code>wp-admin</code>? </p> <p>I know it's in the URL if you are editing a user, EX: <code>./wp-admin/user-edit.php?user_id=427</code>. Could always <code>$_GET['user_id']</code> to retrieve the user's ID, but what about when you're editing your...
[ { "answer_id": 69462, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>There is a global variable called … <code>$user_id</code> available on that page. Always.</p>\n\n<p>From <a href=\"http...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69461", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9579/" ]
Is there a way of obtaining the user ID of the profile being edited in `wp-admin`? I know it's in the URL if you are editing a user, EX: `./wp-admin/user-edit.php?user_id=427`. Could always `$_GET['user_id']` to retrieve the user's ID, but what about when you're editing your own profile in `wp-admin`? The user ID wou...
There is a global variable called … `$user_id` available on that page. Always. From [`user-edit.php`](https://core.trac.wordpress.org/browser/tags/4.4.1/src//wp-admin/user-edit.php#L13): ``` $user_id = (int) $user_id; $current_user = wp_get_current_user(); if ( ! defined( 'IS_PROFILE_PAGE' ) ) define( 'IS_PROFILE...
69,467
<p>I have no idea why, but recently, all new comments on my WordPress site have broken avatar image links. Here is a page that shows the issue: <a href="http://joshnh.com/2012/10/12/how-does-line-height-actually-work/#comments" rel="nofollow">http://joshnh.com/2012/10/12/how-does-line-height-actually-work/#comments</a>...
[ { "answer_id": 69462, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>There is a global variable called … <code>$user_id</code> available on that page. Always.</p>\n\n<p>From <a href=\"http...
2012/10/16
[ "https://wordpress.stackexchange.com/questions/69467", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10783/" ]
I have no idea why, but recently, all new comments on my WordPress site have broken avatar image links. Here is a page that shows the issue: <http://joshnh.com/2012/10/12/how-does-line-height-actually-work/#comments> Any idea why this is happening? I haven't installed any plugins recently, so why has it started playin...
There is a global variable called … `$user_id` available on that page. Always. From [`user-edit.php`](https://core.trac.wordpress.org/browser/tags/4.4.1/src//wp-admin/user-edit.php#L13): ``` $user_id = (int) $user_id; $current_user = wp_get_current_user(); if ( ! defined( 'IS_PROFILE_PAGE' ) ) define( 'IS_PROFILE...
69,470
<p>I'm developing a plugin, wherein one of the features is to switch out forms on a specific page by changing the shortcode within a custom field. </p> <p>within my plugin file: </p> <pre><code>function getShort() { global $post; $m = get_post_meta($post-&gt;ID, 'short', true); return $m; } </code></pre> ...
[ { "answer_id": 69492, "author": "ndm", "author_id": 20949, "author_profile": "https://wordpress.stackexchange.com/users/20949", "pm_score": 1, "selected": false, "text": "<p>Even though you're confident that this isn't the case, it sounds as if the value you are passing manually is not t...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69470", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22553/" ]
I'm developing a plugin, wherein one of the features is to switch out forms on a specific page by changing the shortcode within a custom field. within my plugin file: ``` function getShort() { global $post; $m = get_post_meta($post->ID, 'short', true); return $m; } ``` within my theme file: ``` $sho...
Make sure that the string in `$short` variable is between square brakets, like `[header]`. If it's not stored that way, make the call like this `echo do_shortcode('['.$short.']');`
69,488
<p>I'm trying to reduce my database queries. I don't have any sidebars or widgets set but I noticed the following query</p> <pre><code>SELECT option_value FROM wp_options WHERE option_name = 'widget_pages' LIMIT 1 </code></pre> <p>Similar queries happen for widget_calendar, widget_links, widget_tag_cloud, and widget_...
[ { "answer_id": 69489, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 3, "selected": true, "text": "<p>Does unregistering them the also disable the database queries?</p>\n\n<p>Goes in functions.php:</p>\n\n<pre><c...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69488", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7230/" ]
I'm trying to reduce my database queries. I don't have any sidebars or widgets set but I noticed the following query ``` SELECT option_value FROM wp_options WHERE option_name = 'widget_pages' LIMIT 1 ``` Similar queries happen for widget\_calendar, widget\_links, widget\_tag\_cloud, and widget\_nav\_menu. 5 databas...
Does unregistering them the also disable the database queries? Goes in functions.php: ``` //Unregister all Default Widgets function unregister_default_wp_widgets() { unregister_widget('WP_Widget_Pages'); unregister_widget('WP_Widget_Calendar'); unregister_widget('WP_Widget_Archives'); unregister_widg...
69,506
<p>Is this possible to do somehow?</p> <p>In some pages i use a custom box plugin and i don't need to show the content box on some of those pages. Is it possible to hide it by page template? Or ID if template is not possible?</p>
[ { "answer_id": 69507, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 2, "selected": false, "text": "<p>add this to functions.php</p>\n\n<pre><code>add_action('init', 'remove_content_editor');\n\nfunction r...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69506", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22530/" ]
Is this possible to do somehow? In some pages i use a custom box plugin and i don't need to show the content box on some of those pages. Is it possible to hide it by page template? Or ID if template is not possible?
I ended up using userabuser's answer with a small modification, because global $post doesn't seem to exist on init. You can instead just query for `post` in querystring, like so: ``` function remove_editor() { if (isset($_GET['post'])) { $id = $_GET['post']; $template = get_post_meta($id, '_wp_page...
69,515
<p>I used qTranslate in my site. Four language selections.</p> <pre><code>English Russian Turkish Arabic </code></pre> <p>But Arabic does not work. I tried this url: <code>site.com/ar</code> but it still does not work. Shows an error like the following:</p> <blockquote> <p>Warning: Cannot modify header information - he...
[ { "answer_id": 69640, "author": "Androliyah", "author_id": 17636, "author_profile": "https://wordpress.stackexchange.com/users/17636", "pm_score": 0, "selected": false, "text": "<p>...I can't see your site but anyway this problem occurs when you have BLANK spaces in the code. Make sure ...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69515", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22503/" ]
I used qTranslate in my site. Four language selections. ``` English Russian Turkish Arabic ``` But Arabic does not work. I tried this url: `site.com/ar` but it still does not work. Shows an error like the following: > > Warning: Cannot modify header information - headers already sent by > (output started at > /hom...
Not the first line but the last line could be it. Please check if you have a space after the last `?>` sign of your `header.php` file. Its better suggested that you just remove the last `?>` sign as well. So there wont be any headers already sent error generated. And this sort of error usually occurs when you include...
69,527
<p>I'd like to check if a registered sidebar has widget content - but can't seem to find a WP function for this - is_active_widget checks if it has content, but not if it exists or not.</p> <pre><code>function ql_widget( $widget, $widget_name, $element = 'sider' ){ if ( $widget ) { // widget name passed ## ...
[ { "answer_id": 69533, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 4, "selected": true, "text": "<p><code>wp_get_sidebars_widgets();</code> will return a list of all sidebars &amp; the widgets in each of...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69527", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7968/" ]
I'd like to check if a registered sidebar has widget content - but can't seem to find a WP function for this - is\_active\_widget checks if it has content, but not if it exists or not. ``` function ql_widget( $widget, $widget_name, $element = 'sider' ){ if ( $widget ) { // widget name passed ## // check ...
`wp_get_sidebars_widgets();` will return a list of all sidebars & the widgets in each of them. This can allow you to check for sidebars with no widgets
69,530
<p>i am trying to ban a spam bot IP from my wordpress, since the "limit login attempts" extension mails me multiple times every day, that the same IP is trying to login. so i added the following to the .htaccess file in the wordpress root:</p> <pre><code>order allow,deny allow from all deny from x.x.x.x </code></pre> ...
[ { "answer_id": 69578, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 2, "selected": false, "text": "<p>I think you've got it backwards. Try</p>\n\n<pre><code>order allow,deny\ndeny from x.x.x.x\nallow from all\n<...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69530", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22572/" ]
i am trying to ban a spam bot IP from my wordpress, since the "limit login attempts" extension mails me multiple times every day, that the same IP is trying to login. so i added the following to the .htaccess file in the wordpress root: ``` order allow,deny allow from all deny from x.x.x.x ``` with x.x.x.x being the...
I think you've got it backwards. Try ``` order allow,deny deny from x.x.x.x allow from all ``` That should block all URLs from that IP. And Limit Login Attempts <http://wordpress.org/extend/plugins/limit-login-attempts/> can be set to *not* email you with each lockout. Set the lockout timeouts to 9999 hours, too, w...
69,532
<p>I wrote WordPress plugin and want to include 2 extra Widgets with it...</p> <pre><code>if( !class_exists('plugin_name') ) { class plugin_name { // plugin code } } // include widgets code require_once( 'include/custom_functions.php' ); </code></pre> <p>...and Widgets (according to WP codex) sho...
[ { "answer_id": 69578, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 2, "selected": false, "text": "<p>I think you've got it backwards. Try</p>\n\n<pre><code>order allow,deny\ndeny from x.x.x.x\nallow from all\n<...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69532", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13076/" ]
I wrote WordPress plugin and want to include 2 extra Widgets with it... ``` if( !class_exists('plugin_name') ) { class plugin_name { // plugin code } } // include widgets code require_once( 'include/custom_functions.php' ); ``` ...and Widgets (according to WP codex) should be created like this w...
I think you've got it backwards. Try ``` order allow,deny deny from x.x.x.x allow from all ``` That should block all URLs from that IP. And Limit Login Attempts <http://wordpress.org/extend/plugins/limit-login-attempts/> can be set to *not* email you with each lockout. Set the lockout timeouts to 9999 hours, too, w...
69,535
<p>Is there a way to <strong>limit the creation of pages</strong> (custom post type) to a <strong>specific depth</strong> - e.g. level 1 (where 0 = parent, 1 = child, 2 = grand-child, etc.)?</p> <p>For example, let's create a 'Summer' recipe page (custom post type: Recipe) with a slug '/summer'. Let's now create a 'Pi...
[ { "answer_id": 69557, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 4, "selected": true, "text": "<pre><code>function my_test($a) {\n $a['depth'] = 1;\n return $a;\n}\nadd_action('page_attributes_dropdown_page...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69535", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21357/" ]
Is there a way to **limit the creation of pages** (custom post type) to a **specific depth** - e.g. level 1 (where 0 = parent, 1 = child, 2 = grand-child, etc.)? For example, let's create a 'Summer' recipe page (custom post type: Recipe) with a slug '/summer'. Let's now create a 'Pie' page (a child of 'Summer') with a...
``` function my_test($a) { $a['depth'] = 1; return $a; } add_action('page_attributes_dropdown_pages_args','my_test'); ``` Put that in a theme's function.php or in a plugin.
69,549
<p>I'm developing a site on a server that the client has access to as well and what I'd like to do is show <code>WP_DEBUG</code> only for administrators. Referencing <a href="http://yoast.com/wordpress-debug/">Yoast's article</a> on a way around this:</p> <pre><code>if ( isset($_GET['debug']) &amp;&amp; $_GET['debug']...
[ { "answer_id": 69552, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 5, "selected": true, "text": "<p>I don't think there is a universal URL hook. There are a lot of hooks and I may have missed it, but I don't th...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69549", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9605/" ]
I'm developing a site on a server that the client has access to as well and what I'd like to do is show `WP_DEBUG` only for administrators. Referencing [Yoast's article](http://yoast.com/wordpress-debug/) on a way around this: ``` if ( isset($_GET['debug']) && $_GET['debug'] == 'true') define('WP_DEBUG', true); `...
I don't think there is a universal URL hook. There are a lot of hooks and I may have missed it, but I don't think there is one. You can look through the hooks at [adambrown.info](http://adambrown.info/p/wp_hooks/version/3.4). There are a lot of URL hooks, but not a universal one. If I may suggest another solution: Log...
69,556
<p>I've been trying to create a sidebar widget to display recent comments from specific category. I'm having difficulties in determining how Wordpress knows from which categories the comments are. </p> <p>I have checked <a href="http://codex.wordpress.org/Function_Reference/get_comments" rel="nofollow">the codex on <c...
[ { "answer_id": 69552, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 5, "selected": true, "text": "<p>I don't think there is a universal URL hook. There are a lot of hooks and I may have missed it, but I don't th...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69556", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13291/" ]
I've been trying to create a sidebar widget to display recent comments from specific category. I'm having difficulties in determining how Wordpress knows from which categories the comments are. I have checked [the codex on `get_comments` function](http://codex.wordpress.org/Function_Reference/get_comments) but it doe...
I don't think there is a universal URL hook. There are a lot of hooks and I may have missed it, but I don't think there is one. You can look through the hooks at [adambrown.info](http://adambrown.info/p/wp_hooks/version/3.4). There are a lot of URL hooks, but not a universal one. If I may suggest another solution: Log...
69,586
<p>I'm trying to create a front-end registration form for my Wordpress website. The registration form is in the header, so any plugins I've seen don't work as they use shortcodes.</p> <p>Look at my website for a better explanation. I want the registration form to work in the dropdown box at the top of the page.</p>
[ { "answer_id": 69593, "author": "Nicole", "author_id": 8337, "author_profile": "https://wordpress.stackexchange.com/users/8337", "pm_score": 2, "selected": true, "text": "<p>If you were to use a plugin that uses shortcode you can call it in your template by using this in your template: <...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69586", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22588/" ]
I'm trying to create a front-end registration form for my Wordpress website. The registration form is in the header, so any plugins I've seen don't work as they use shortcodes. Look at my website for a better explanation. I want the registration form to work in the dropdown box at the top of the page.
If you were to use a plugin that uses shortcode you can call it in your template by using this in your template: ``` <?php echo do_shortcode ('[your-shortcode]'); ?> ``` You can also do something similar to this form / code below for a front end login: ``` <form method="post" action="<?php bloginfo('url') ?>/wp-lo...
69,595
<p>I am using this code for listing out all authors on the site in my sidebar. It works, except I also need to pull in their Gravatar image. It's working in a loop on the homepage with this</p> <pre><code>&lt;?php echo get_avatar( get_the_author_email(), '80' ); ?&gt; </code></pre> <p>but is there a way I can add it ...
[ { "answer_id": 69599, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 0, "selected": false, "text": "<p>use <code>&lt;?php echo get_avatar( $user-&gt;ID, '80' ); ?&gt;</code>, somewhere inside the <code>for...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69595", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19794/" ]
I am using this code for listing out all authors on the site in my sidebar. It works, except I also need to pull in their Gravatar image. It's working in a loop on the homepage with this ``` <?php echo get_avatar( get_the_author_email(), '80' ); ?> ``` but is there a way I can add it to this list as well? Also.. I c...
**Basic setup** ``` <?php $args = array( 'orderby' => 'nicename' ); $users = get_users( $args ); foreach ( $users as $user ) { $avatar = get_avatar( $user->ID, '80' ); echo '<li><a href="' . $user->user_url . '">' . $avatar . '<br />' . ...
69,602
<p>I'm having difficulties to set the featured image only in the first post of each category and the rest to displayed with the post title only. I manage until now to display the latest post from each category with thumbnail but i cannot find the way to make the first post only with thumbnail and the rest with titles. ...
[ { "answer_id": 69604, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 0, "selected": false, "text": "<p>Just before the <code>while ($my_query-&gt;have_posts())</code> add <code>$flag = false;</code>, then ...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69602", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22591/" ]
I'm having difficulties to set the featured image only in the first post of each category and the rest to displayed with the post title only. I manage until now to display the latest post from each category with thumbnail but i cannot find the way to make the first post only with thumbnail and the rest with titles. is ...
General notes ------------- 1. 1st of all: You don't have to use the (imho crappy) TimThumb thingy. There're much better things like my (freely available, open source) [»Dynamic image resize« plugin](https://github.com/franz-josef-kaiser/Dynamic-Image-Resize). 2. 2nd (and afaik), you can do this with on board stuff, l...
69,605
<p>Driving me nuts.</p> <p>I have a shortcode which works -fine- but for one detail. I won't post the entire thing, but it pulls the content of a post (works fine) then should echo a portion of it to a new DIV in the footer.</p> <p>I'm doing it this way because, apparently, you can't pass variables to an anonymous fu...
[ { "answer_id": 69608, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>Use a class, store the value you need in the footer in a member variable.</p>\n\n<p>Sample code, not tested:</p>\n\n<p...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69605", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17248/" ]
Driving me nuts. I have a shortcode which works -fine- but for one detail. I won't post the entire thing, but it pulls the content of a post (works fine) then should echo a portion of it to a new DIV in the footer. I'm doing it this way because, apparently, you can't pass variables to an anonymous function with add\_...
Use a class, store the value you need in the footer in a member variable. Sample code, not tested: ``` add_shortcode( 'tooltip', array ( 'WPSE_69605_Tooltip', 'shortcode_callback' ) ); class WPSE_69605_Tooltip { protected static $var = ''; public static function shortcode_callback( $atts, $content = '' ) ...
69,616
<p>Say I created a plugin that injects content (used as a shortcode) into a post. I'm trying to push that code for each post to the bottom of the page.</p> <p>This works fine, however when you are on an archive page with multiple posts using the same shortcode, there is an obvious conflict because the function names b...
[ { "answer_id": 69621, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p>I would wrap the whole thing in a class and put your data into a class var.</p>\n\n<pre><code>class WPA69616_Plugin...
2012/10/17
[ "https://wordpress.stackexchange.com/questions/69616", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2811/" ]
Say I created a plugin that injects content (used as a shortcode) into a post. I'm trying to push that code for each post to the bottom of the page. This works fine, however when you are on an archive page with multiple posts using the same shortcode, there is an obvious conflict because the function names become dupl...
I would wrap the whole thing in a class and put your data into a class var. ``` class WPA69616_Plugin { private $data = ''; public function __construct() { add_shortcode('my_shortcode', array($this, 'add_content')); add_action('wp_footer', array($this, 'output_content')); } public fun...
69,642
<p><strong>Background</strong>: Working on a Widget that uses a remote API using <code>wp_remote_post</code> to log into the service, once logged in storing the cookies received for the second request to query data with <code>wp_remote_get</code>.</p> <p><strong>Problem</strong>: The cookies from the first request are...
[ { "answer_id": 69690, "author": "ndm", "author_id": 20949, "author_profile": "https://wordpress.stackexchange.com/users/20949", "pm_score": 2, "selected": true, "text": "<p>AFAIK URL encoding the cookie value is still kind of a defacto standard, it's an ancient relict based on the old, u...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69642", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21446/" ]
**Background**: Working on a Widget that uses a remote API using `wp_remote_post` to log into the service, once logged in storing the cookies received for the second request to query data with `wp_remote_get`. **Problem**: The cookies from the first request are stored in the response as WP\_Http\_Cookie objects and th...
AFAIK URL encoding the cookie value is still kind of a defacto standard, it's an ancient relict based on the old, ugly [Netscape cookie specs](http://curl.haxx.se/rfc/cookie_spec.html), that basically says that semicolons, commas and whitespaces are disallowed, and should be encoded, for example using URL encoding. Nei...
69,664
<p>i've made a custom home-page (with a template) and i'm using three loops on this site: two category-loops and on the bottom of the site the main loop for the page (the page content). the problem is: the first loops are fine but the third (the main page loop) is looping the content from one of the other two loops, no...
[ { "answer_id": 69661, "author": "mirage", "author_id": 22505, "author_profile": "https://wordpress.stackexchange.com/users/22505", "pm_score": 0, "selected": false, "text": "<p>Have a look at pie-register <a href=\"http://wordpress.org/extend/plugins/pie-register/\" rel=\"nofollow\">http...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69664", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22611/" ]
i've made a custom home-page (with a template) and i'm using three loops on this site: two category-loops and on the bottom of the site the main loop for the page (the page content). the problem is: the first loops are fine but the third (the main page loop) is looping the content from one of the other two loops, not f...
You can also take a look on [Profile Builder Plugin](http://wordpress.org/plugins/profile-builder/), that allows you to customize your website by adding a front-end menu for all your users, giving them a more flexible way to modify their user profile or register new users (front-end user registration). You can add cust...
69,692
<p>I'd like page titles centred site wide especially for landing pages.</p> <p>Is this possible without centring posts titles and everything else on the site?</p>
[ { "answer_id": 69713, "author": "stealthyninja", "author_id": 1748, "author_profile": "https://wordpress.stackexchange.com/users/1748", "pm_score": 1, "selected": false, "text": "<p>Perhaps something like</p>\n\n<pre><code>$the_post_type = get_post_type( $post-&gt;ID );\n\nswitch ( $the_...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69692", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22628/" ]
I'd like page titles centred site wide especially for landing pages. Is this possible without centring posts titles and everything else on the site?
Perhaps something like ``` $the_post_type = get_post_type( $post->ID ); switch ( $the_post_type ) { case 'page': // you'll need something else to distinguish "landing" pages from normal ones // which would allow you to then set a flag for it if ( $some_condition ) $landing_page = true; ...
69,693
<p>I have about 50 custom fields I need to delete at once, going through each one and deleting one at a time would take too long because it takes about 4 seconds for a page to load and I just don't have time to do that.</p> <p>I need to delete them because I previously used a plugin called Advanced Custom Fields (ACF)...
[ { "answer_id": 69694, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 0, "selected": false, "text": "<p>For removing all, open phpmyadmin, go to wordpress database &amp; truncate the table wp_postmeta</p>\n...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69693", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22530/" ]
I have about 50 custom fields I need to delete at once, going through each one and deleting one at a time would take too long because it takes about 4 seconds for a page to load and I just don't have time to do that. I need to delete them because I previously used a plugin called Advanced Custom Fields (ACF), but appa...
You can use the SQL way. Go in your database tool, like phpMyAdmin or Adminer (also possible via Plugin in the WordPress back-end). Use the SQL area for creating custom queries. Before you start, create a backup of the database and also a single backup for the table `_postmeta`. Change the string `wpbeta_2` to your p...
69,700
<p>I have set up a simple mailer before I get the full implementation sorted. I've tried a few email addresses but am not receiving them even though it returns 'true'. I'm using wp_ajax as well if that makes a difference.</p> <p>functions.php</p> <pre> // Check for email return in share folders add_action( ...
[ { "answer_id": 69694, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 0, "selected": false, "text": "<p>For removing all, open phpmyadmin, go to wordpress database &amp; truncate the table wp_postmeta</p>\n...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69700", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21326/" ]
I have set up a simple mailer before I get the full implementation sorted. I've tried a few email addresses but am not receiving them even though it returns 'true'. I'm using wp\_ajax as well if that makes a difference. functions.php ``` // Check for email return in share folders add_action( 'wp_ajax_share_...
You can use the SQL way. Go in your database tool, like phpMyAdmin or Adminer (also possible via Plugin in the WordPress back-end). Use the SQL area for creating custom queries. Before you start, create a backup of the database and also a single backup for the table `_postmeta`. Change the string `wpbeta_2` to your p...
69,702
<p>Fristly, sorry for my bad english.<br> Secondly, I can't find a solution for my problem since 2 weeks. It's a simple things but I can't find how to do it.<br> I explain my problem :<br> I got 2 custom taxonomies call in a function "my_custom_init" :</p> <pre><code>register_taxonomy( 'directors', 'video', array( 'hi...
[ { "answer_id": 69715, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 2, "selected": true, "text": "<p>I think you can use <code>directors_row_actions</code> &amp; <code>clients_row_actions</code>.</p>\n\n<...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69702", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22632/" ]
Fristly, sorry for my bad english. Secondly, I can't find a solution for my problem since 2 weeks. It's a simple things but I can't find how to do it. I explain my problem : I got 2 custom taxonomies call in a function "my\_custom\_init" : ``` register_taxonomy( 'directors', 'video', array( 'hierarchical' => ...
I think you can use `directors_row_actions` & `clients_row_actions`. Also you can use `tag_row_actions` which is called for every taxonomy. It accepts 2 parameters, first being the actions & 2nd being the term object. You can use this term object to filter out which actions you want to change
69,716
<p>Alright, so i have a custom post type called Blurbs (translated, sort of). I want to add a static set of categories for the posts within Blurbs (i don't want the user to be able to create custom categories). I want two different types of categories; links and page-excerpts. I did some reading and came to the conclus...
[ { "answer_id": 69717, "author": "Macgyver", "author_id": 22586, "author_profile": "https://wordpress.stackexchange.com/users/22586", "pm_score": 0, "selected": false, "text": "<p>You should first use the menu to get to the taxonomy management page to add the static values you want to add...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69716", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22530/" ]
Alright, so i have a custom post type called Blurbs (translated, sort of). I want to add a static set of categories for the posts within Blurbs (i don't want the user to be able to create custom categories). I want two different types of categories; links and page-excerpts. I did some reading and came to the conclusion...
1. Make it `show_ui => false` Then to show it on the post edit screen add the box manually ``` add_action('add_meta_boxes', 'meta_boxes_function'); function meta_boxes_function() { add_meta_box('categoriesdiv', 'categories', 'post_categories_meta_box', 'blurb', 'side', null, array('taxonomy' => 'categories')); ...
69,721
<p>This has been addressed in <a href="https://wordpress.stackexchange.com/questions/12056/automatically-set-post-title-to-same-value-as-a-meta-box">another post</a>, but the solution was too specific to apply here.</p> <p>My goal is to use a metabox value (ecpt_name) as the post title so that the user only needs to i...
[ { "answer_id": 69724, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 2, "selected": false, "text": "<pre><code>&lt;?php\nadd_action( 'save_post', 'post_updated' );\n\nfunction post_updated( $post_id ) {\n\...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69721", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22641/" ]
This has been addressed in [another post](https://wordpress.stackexchange.com/questions/12056/automatically-set-post-title-to-same-value-as-a-meta-box), but the solution was too specific to apply here. My goal is to use a metabox value (ecpt\_name) as the post title so that the user only needs to input their name once...
``` <?php add_action( 'save_post', 'post_updated' ); function post_updated( $post_id ) { // verify post is not a revision & not an autosave if ( !wp_is_post_revision( $post_id ) && !(defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE) ) { // set the new post title $post['ID'] = $post_id; $p...
69,730
<p>I installed several plugins(buddypress-docs,achievement,bbpress), each one create capabilities for their own post_type. I would prefer to make all roles and capabilities unified into one system, Is there a solution to overwrite all existing caps and control all post_types? Eventually I would like to organize users b...
[ { "answer_id": 69724, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 2, "selected": false, "text": "<pre><code>&lt;?php\nadd_action( 'save_post', 'post_updated' );\n\nfunction post_updated( $post_id ) {\n\...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69730", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5210/" ]
I installed several plugins(buddypress-docs,achievement,bbpress), each one create capabilities for their own post\_type. I would prefer to make all roles and capabilities unified into one system, Is there a solution to overwrite all existing caps and control all post\_types? Eventually I would like to organize users by...
``` <?php add_action( 'save_post', 'post_updated' ); function post_updated( $post_id ) { // verify post is not a revision & not an autosave if ( !wp_is_post_revision( $post_id ) && !(defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE) ) { // set the new post title $post['ID'] = $post_id; $p...
69,734
<p>The problem I am having is when I allow users to filter posts it overpowers the database and things run extremely slow. I am unsure what the best way to query posts using meta values is. My site has a form that users can submit to filter posts based on checkboxes containing meta values. I currently have the site mak...
[ { "answer_id": 69752, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>I'd like to see what the actual generated SQL is that <code>WP_Query</code> is using, but for now.</p>\n\n<p>...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69734", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20695/" ]
The problem I am having is when I allow users to filter posts it overpowers the database and things run extremely slow. I am unsure what the best way to query posts using meta values is. My site has a form that users can submit to filter posts based on checkboxes containing meta values. I currently have the site making...
I'd like to see what the actual generated SQL is that `WP_Query` is using, but for now. ( You can use <http://wordpress.org/extend/plugins/debug-bar/> to easily view the SQL query ) Queries ordered by 'random' are inefficient. If you don't need that remove it. If you do need a random order, consider removing it anywa...
69,737
<p>This is a strange one. I host a website that is primarily for children. All posts are moderated. Users are required to enter a user name and location (State), but are not required to be registered and logged in to make a comment. Some users have started using a common user name, allowing them to see one another'...
[ { "answer_id": 69740, "author": "stealthyninja", "author_id": 1748, "author_profile": "https://wordpress.stackexchange.com/users/1748", "pm_score": 1, "selected": true, "text": "<p>Check in your theme's <code>comments.php</code> for the <code>wp_list_comments()</code> function. In the Tw...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69737", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22647/" ]
This is a strange one. I host a website that is primarily for children. All posts are moderated. Users are required to enter a user name and location (State), but are not required to be registered and logged in to make a comment. Some users have started using a common user name, allowing them to see one another's posts...
Check in your theme's `comments.php` for the `wp_list_comments()` function. In the Twenty Eleven theme, for example, uses a custom callback function which is in the `functions.php` file and outputs the template for comments. Within this comments template, you can then use **[`wp_get_comment_status()`](http://codex.wor...
69,753
<p>I'm a complete noob when it comes to Wordpress, but I've joined a company who use it as their website and they need an answer quickly. I want to know if I can I lock a post in position, so it always appears on the homepage ? I don't want to use a plug-in (preferably) Any suggestions or advice is greatly appreciated...
[ { "answer_id": 69740, "author": "stealthyninja", "author_id": 1748, "author_profile": "https://wordpress.stackexchange.com/users/1748", "pm_score": 1, "selected": true, "text": "<p>Check in your theme's <code>comments.php</code> for the <code>wp_list_comments()</code> function. In the Tw...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69753", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22654/" ]
I'm a complete noob when it comes to Wordpress, but I've joined a company who use it as their website and they need an answer quickly. I want to know if I can I lock a post in position, so it always appears on the homepage ? I don't want to use a plug-in (preferably) Any suggestions or advice is greatly appreciated. ...
Check in your theme's `comments.php` for the `wp_list_comments()` function. In the Twenty Eleven theme, for example, uses a custom callback function which is in the `functions.php` file and outputs the template for comments. Within this comments template, you can then use **[`wp_get_comment_status()`](http://codex.wor...
69,761
<p>Is there an efficient way to change a post status from 'published' to 'draft' when a user of a certain type tries to update their posts. I tried something along these lines</p> <pre><code>function change_post_status($post_id) { if(current_user_can('rolename')) { $current_post = get_post( $post_id, 'ARRAY_A'...
[ { "answer_id": 70608, "author": "Daniel", "author_id": 17098, "author_profile": "https://wordpress.stackexchange.com/users/17098", "pm_score": 0, "selected": false, "text": "<p>Have you tried to use \"wp_insert_post_data\" instead of \"pre_post_update\"?</p>\n" }, { "answer_id": ...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69761", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20695/" ]
Is there an efficient way to change a post status from 'published' to 'draft' when a user of a certain type tries to update their posts. I tried something along these lines ``` function change_post_status($post_id) { if(current_user_can('rolename')) { $current_post = get_post( $post_id, 'ARRAY_A' ); $curre...
So I ended up using the wp\_insert\_post\_data filter and came up with the following, which after testing, seems to be working properly. ``` add_filter('wp_insert_post_data', 'change_post_status', '99'); function change_post_status($data) { if( (current_user_can('role')) && ($data['post_type'] == 'custom_post_typ...
69,772
<p>I try to use this function i have created when a post is published for the first time.</p> <pre><code>function a_new_post($post){ $post_id = $post-&gt;ID; if ( !get_post_meta( $post_id, 'firstpublish', $single = true ) ) { // ...run code once update_post_meta( $post_id, 'firstpublish', true ); } ...
[ { "answer_id": 69802, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 5, "selected": true, "text": "<p>The correct action is <code>'draft_to_publish'</code>.</p>\n\n<p>To be sure you used the correct status try to get a li...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69772", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11861/" ]
I try to use this function i have created when a post is published for the first time. ``` function a_new_post($post){ $post_id = $post->ID; if ( !get_post_meta( $post_id, 'firstpublish', $single = true ) ) { // ...run code once update_post_meta( $post_id, 'firstpublish', true ); } } add_action( 'dr...
The correct action is `'draft_to_publish'`. To be sure you used the correct status try to get a list of all registered post statuses (including custom statuses) with: ``` <pre><?php print '- ' . implode( "\n- ", array_keys( get_post_stati() ) );?></pre> ``` On a vanilla installation you should get: * publish * fut...
69,776
<p>I wish to restrict the user from putting inline images in the article. I am using the <a href="http://wordpress.org/extend/plugins/attachments/" rel="nofollow noreferrer">Wordpress Attachments</a> plugin to allow the user to attach images, which I then position and stylize the way I want. </p> <p>I also managed to ...
[ { "answer_id": 69778, "author": "Phantasmix", "author_id": 18862, "author_profile": "https://wordpress.stackexchange.com/users/18862", "pm_score": 0, "selected": false, "text": "<p>If you aren't using Featured Image for much, it might be easier to set up a custom field for it. Where and ...
2012/10/18
[ "https://wordpress.stackexchange.com/questions/69776", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21333/" ]
I wish to restrict the user from putting inline images in the article. I am using the [Wordpress Attachments](http://wordpress.org/extend/plugins/attachments/) plugin to allow the user to attach images, which I then position and stylize the way I want. I also managed to remove the Upload/Insert link from the post thr...
You can do this via, ``` add_filter('image_send_to_editor', 'restrict_images'); function restrict_images($html){ return false; } ``` ...now consider the above function primitive, because it will restrict images for all post types. We can modify that on a `post_type` by `post_type` basis like so, ``` add_filter...
69,810
<p>I am using the hook <code>publish_post</code> to run my code where I need the post meta of the just published post. But the post meta value I am looking for is somehow not available at this point of execution. On checking the <code>wp_postmeta</code> table, I found that my meta key value hasn't been created yet. Als...
[ { "answer_id": 69828, "author": "stevejohnson", "author_id": 22681, "author_profile": "https://wordpress.stackexchange.com/users/22681", "pm_score": 2, "selected": false, "text": "<p>You seem to be concerned only with <strong>new</strong> posts (as previously-created posts will have the ...
2012/10/19
[ "https://wordpress.stackexchange.com/questions/69810", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18286/" ]
I am using the hook `publish_post` to run my code where I need the post meta of the just published post. But the post meta value I am looking for is somehow not available at this point of execution. On checking the `wp_postmeta` table, I found that my meta key value hasn't been created yet. Also, I want this to work fo...
Solved it! Used `save_post` to run `push_notification()` as well as to run the function `save_post_meta()` that saves my post meta. The problem occurred coz `push_notification()` gets fired before `save_post_meta()` due to which the meta wasn't being saved and therefore it remained inaccessible. Just changed priorities...
69,814
<p>I want to execute custom jquery code which shows login dialog to user if he clicks a button and he is not logged in. How could I do that?</p>
[ { "answer_id": 69816, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 6, "selected": false, "text": "<p>Check the <code>class</code> attribute for <code>body</code>: If the theme is using <code>body_class()</code> the body...
2012/10/19
[ "https://wordpress.stackexchange.com/questions/69814", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5814/" ]
I want to execute custom jquery code which shows login dialog to user if he clicks a button and he is not logged in. How could I do that?
In case you want to know if the user is logged in at the current moment, try this. The other answers check if the user is logged in or not when the page loaded, not the time when you're running the javascript. The user could have logged in in a separate tab, for instance. Put this in your javascript ``` var data = { ...
69,830
<p>I'm wondering why WordPress doesn't list PHP <code>array()</code> and any serialized data in Custom Fields in Admin Panel (for Pages, Posts etc.)? Only Custom Fields containing strings and numbers show up and can be edited by user manually.</p> <p>Edit: Why aren't post meta values displayed if they are stored as a ...
[ { "answer_id": 69850, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>There is no filter to change that behavior, you would have to <a href=\"https://wordpress.stackexchange.com/a/58305/73\...
2012/10/19
[ "https://wordpress.stackexchange.com/questions/69830", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21278/" ]
I'm wondering why WordPress doesn't list PHP `array()` and any serialized data in Custom Fields in Admin Panel (for Pages, Posts etc.)? Only Custom Fields containing strings and numbers show up and can be edited by user manually. Edit: Why aren't post meta values displayed if they are stored as a non-string value, mea...
There is no filter to change that behavior, you would have to [replace the entire metabox](https://wordpress.stackexchange.com/a/58305/73 "Replace example for the excerpt metabox"). On the other hand: I think there is no really simple way to show and to save those arrays. Example for a fictive meta key `'foo'`: ``` ...
69,838
<p>I hate to try to reinvent the wheel here, but none of the suggested post seem to work in answering my question. I am building a system for our 30 Under 30 honorees, which is basically setup as a portfolio of images. The types of post I am creating will be called "honorees", and the overall menu called "30 Under 30"...
[ { "answer_id": 69841, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 3, "selected": true, "text": "<p>Your post_type slug will default to the name of the post_type unless specified otherwise. So, in it's most basic f...
2012/10/19
[ "https://wordpress.stackexchange.com/questions/69838", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22682/" ]
I hate to try to reinvent the wheel here, but none of the suggested post seem to work in answering my question. I am building a system for our 30 Under 30 honorees, which is basically setup as a portfolio of images. The types of post I am creating will be called "honorees", and the overall menu called "30 Under 30". Th...
Your post\_type slug will default to the name of the post\_type unless specified otherwise. So, in it's most basic form you can set a custom base slug as follows, `'rewrite' => array( 'slug' => 'slug-name-here');` Currently, you have it set to `true` only. **Don't forget to visit your permalinks page in the dashboar...
69,840
<p>when i open any post then 1st image show my featured image. i want to increase this size . <a href="http://www.desyfun.tk/wp-content/uploads/2012/10/11.jpg" rel="nofollow">see it</a> or . i already try to increase from single.php to change this code </p> <pre><code>&lt;p&gt;&lt;img src="&lt;?php echo get_template_...
[ { "answer_id": 69842, "author": "Nicole", "author_id": 8337, "author_profile": "https://wordpress.stackexchange.com/users/8337", "pm_score": 2, "selected": false, "text": "<p>You can try something like this: </p>\n\n<pre><code>&lt;!-- The Post Thumbnail function is active by default, but...
2012/10/19
[ "https://wordpress.stackexchange.com/questions/69840", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22576/" ]
when i open any post then 1st image show my featured image. i want to increase this size . [see it](http://www.desyfun.tk/wp-content/uploads/2012/10/11.jpg) or . i already try to increase from single.php to change this code ``` <p><img src="<?php echo get_template_directory_uri(); ?>/images/thumbnails/thumbnail-leadi...
It's probably because the original image is not big enough. You can make the image display bigger via CSS : ``` .post_thumbnail{ height: 320px } ```
69,844
<p>I'm creating a function that displays the most viewed posts and would like to be able to show posts based on how old they are. Modifying the query is not really a problem. But since I can't pass any arguments to the function I can't modify the "-30 days" part.</p> <pre><code>function print_stuff($args) { add_fi...
[ { "answer_id": 69846, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<p>You can store the time range using some global/static/class variable &amp; then retrieve it from there...
2012/10/19
[ "https://wordpress.stackexchange.com/questions/69844", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20279/" ]
I'm creating a function that displays the most viewed posts and would like to be able to show posts based on how old they are. Modifying the query is not really a problem. But since I can't pass any arguments to the function I can't modify the "-30 days" part. ``` function print_stuff($args) { add_filter( 'posts_w...
You can set your own custom query vars in a query, then use that value to set a class variable that you later read in the filter: ``` class WPA69844_where { var $days; public function __construct(){ add_action( 'parse_query', array( $this, 'parse_query' ) ); } public function parse_query( $qu...
69,848
<p>I'm using the following function to create a custom excerpt for my homepage and categories pages so I can do it by character count and have a custom &quot;read more&quot;. However, I have captions shortcode showing up in my excerpt.</p> <blockquote> <p><strong>Example:</strong></p> <p>[caption id=&quot;attachment_46...
[ { "answer_id": 69846, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<p>You can store the time range using some global/static/class variable &amp; then retrieve it from there...
2012/10/19
[ "https://wordpress.stackexchange.com/questions/69848", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7662/" ]
I'm using the following function to create a custom excerpt for my homepage and categories pages so I can do it by character count and have a custom "read more". However, I have captions shortcode showing up in my excerpt. > > **Example:** > > > [caption id="attachment\_4656" align="aligncenter" width="450"] Crispy...
You can set your own custom query vars in a query, then use that value to set a class variable that you later read in the filter: ``` class WPA69844_where { var $days; public function __construct(){ add_action( 'parse_query', array( $this, 'parse_query' ) ); } public function parse_query( $qu...
69,856
<p>First, I need to ask if it's possible to create a photo gallery only with the featured images of the latest 6 posts? I assume it is possible but just want to make sure. </p> <p>I don't have much experience working directly with the wordpress gallery so could someone point me in the right direction for accomplishing...
[ { "answer_id": 69857, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 3, "selected": true, "text": "<pre><code>$query = new WP_Query(array('posts_per_page' =&gt; 6, 'meta_key' =&gt; '_thumbnail_id'));\nwhil...
2012/10/19
[ "https://wordpress.stackexchange.com/questions/69856", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13214/" ]
First, I need to ask if it's possible to create a photo gallery only with the featured images of the latest 6 posts? I assume it is possible but just want to make sure. I don't have much experience working directly with the wordpress gallery so could someone point me in the right direction for accomplishing this? Any...
``` $query = new WP_Query(array('posts_per_page' => 6, 'meta_key' => '_thumbnail_id')); while($query->have_posts()) : $query->the_post(); the_post_thumbnail(); endwhile; ``` This code gets 6 latest posts which have featured image available & show those 6 images on the page. It will skip those posts where ther...
69,867
<p>I have a widget sidebar, but I'd like dividers between them. I can achieve this in CSS using boring borders, but I have a png image I'd rather use instead.</p> <p>Is there a way to insert a divider after each widget item? (apart from the last one of course). I can do this in jQuery quite easily but I'd rather do it...
[ { "answer_id": 69868, "author": "Fabien Quatravaux", "author_id": 16975, "author_profile": "https://wordpress.stackexchange.com/users/16975", "pm_score": 0, "selected": false, "text": "<p>You could use the :after CSS pseudo class, it's <a href=\"http://css-tricks.com/browser-support-pseu...
2012/10/20
[ "https://wordpress.stackexchange.com/questions/69867", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18441/" ]
I have a widget sidebar, but I'd like dividers between them. I can achieve this in CSS using boring borders, but I have a png image I'd rather use instead. Is there a way to insert a divider after each widget item? (apart from the last one of course). I can do this in jQuery quite easily but I'd rather do it in the te...
``` 'after_widget' => '', ``` As far as I know, thats the best way to do it
69,925
<p>I use the <code>add_menu_page</code> function to add an new admin menu: </p> <pre><code>add_menu_page( 'Custom_menu', 'Custom_menu', 'edit_posts', 'custom_slug', '', 'wordpress_existing_icon', 5 ); </code></pre> <p>How to use one of WordPress' existing icons?</p> <p>For instance, if I ...
[ { "answer_id": 69934, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<p>When you call the <code>screen_icon</code> function, put the page id from which you want to get the ic...
2012/10/20
[ "https://wordpress.stackexchange.com/questions/69925", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4552/" ]
I use the `add_menu_page` function to add an new admin menu: ``` add_menu_page( 'Custom_menu', 'Custom_menu', 'edit_posts', 'custom_slug', '', 'wordpress_existing_icon', 5 ); ``` How to use one of WordPress' existing icons? For instance, if I would like to use the "Posts" WordPress icon...
`add_menu_page();` as far as I can tell does not work with `screen_icon` or the default CSS parameters. The `$icon` paramater only takes 2 options, an `url` or `div` (well 3 if you leave it empty), so that leaves you with these options: 1. Hard-code the link to the icons which are located in `wp-includes/images/wpicon...