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
90,310
<pre><code>&lt;h1&gt;&lt;?php the_category(' &amp;bull; '); ?&gt; » &lt;a href="&lt;?php the_permalink(); ?&gt;" class="my-title-class"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h1&gt; </code></pre> <p>How to add <code>class="my-category-class"</code> to the links, produces by <code>the_category</code> function? </...
[ { "answer_id": 90317, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>You can use <code>the_category</code> filter to hook a callback function like this:</p>\n\n<pre><code>add_filt...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90310", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22622/" ]
``` <h1><?php the_category(' &bull; '); ?> » <a href="<?php the_permalink(); ?>" class="my-title-class"><?php the_title(); ?></a></h1> ``` How to add `class="my-category-class"` to the links, produces by `the_category` function?
You can use `the_category` filter to hook a callback function like this: ``` add_filter('the_category','add_class_to_category',10,3); function add_class_to_category( $thelist, $separator, $parents){ $class_to_add = 'my-category-class'; return str_replace('<a href="', '<a class="' . $class_to_add . '" href="',...
90,311
<p>How can I turn off email notifications for the user and admin when a new user is registered?</p> <p>I've seen a few suggestions and plugins but none appear to work. One was to take the function from one of the plugins:</p> <pre><code>if ( !function_exists('wp_new_user_notification') ) : /** * Notify the blog admi...
[ { "answer_id": 90313, "author": "Eugene Manuilov", "author_id": 8170, "author_profile": "https://wordpress.stackexchange.com/users/8170", "pm_score": 3, "selected": false, "text": "<p>Function <code>wp_new_user_notification</code> is pluggable. It means that you can override it by declar...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90311", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
How can I turn off email notifications for the user and admin when a new user is registered? I've seen a few suggestions and plugins but none appear to work. One was to take the function from one of the plugins: ``` if ( !function_exists('wp_new_user_notification') ) : /** * Notify the blog admin of a new user, norm...
Function `wp_new_user_notification` is pluggable. It means that you can override it by declaring your version of this function in your plugin/theme. So, if you wish to disable all notifications completely, do it like this: ``` if ( !function_exists( 'wp_new_user_notification' ) ) : function wp_new_user_notification( ...
90,315
<p>Does someone know if it's possible to display a specific sidebar per user-role ? (only accessible if the user is logged as the specific role related to the specific sidebar )?</p> <p>What I want is to have one "profile-like" page in the front end with a custom sidebar per role (with custom nav, custom content, cust...
[ { "answer_id": 90319, "author": "tfrommen", "author_id": 27722, "author_profile": "https://wordpress.stackexchange.com/users/27722", "pm_score": 1, "selected": true, "text": "<p>You could either read the role of the current user, then show the desired sidebar elements, or (what I'd prefe...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90315", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28727/" ]
Does someone know if it's possible to display a specific sidebar per user-role ? (only accessible if the user is logged as the specific role related to the specific sidebar )? What I want is to have one "profile-like" page in the front end with a custom sidebar per role (with custom nav, custom content, custom links.....
You could either read the role of the current user, then show the desired sidebar elements, or (what I'd prefer) check for certain capabilities. **User Role** ``` global $current_user; $roles = $current_user->roles; $role = array_shift( $roles ); switch ( $role ) { case ... } ``` **Capabilities** ``` if ( curr...
90,321
<p>I'm using the following to get the date of each post:</p> <pre><code>while (have_posts()) : the_post(); //some html &lt;li class="icon-date"&gt;&lt;?php the_date('Y-m-d');?&gt;&lt;/li&gt; &lt;li class="icon-time"&gt;&lt;?php the_date('H:i:s');?&gt;&lt;/li&gt; </code></pre> <p>However, I am only getting the date fo...
[ { "answer_id": 90322, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 6, "selected": true, "text": "<p>I ran into the same problem several times, following changes worked for me in the past:</p>\n\n<pre><code>w...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90321", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22622/" ]
I'm using the following to get the date of each post: ``` while (have_posts()) : the_post(); //some html <li class="icon-date"><?php the_date('Y-m-d');?></li> <li class="icon-time"><?php the_date('H:i:s');?></li> ``` However, I am only getting the date for first post why is that?
I ran into the same problem several times, following changes worked for me in the past: ``` while (have_posts()) : the_post(); //some html <li class="icon-date"><?php echo get_the_date( 'Y-m-d' ); ?></li> <li class="icon-time"><?php the_time( 'H:i:s' ); ?></li> ``` Instead of `the_date()`, use `get_the_date()`. T...
90,341
<p>I'm using wp-usersonline plugin with user links, when you click for subscribers it goes to a not found page but works fine for authors, im thinking is there a way to redirect subscribers to a profile page and change the link into <a href="http://domain.com/member/profile=ID" rel="nofollow">http://domain.com/member/p...
[ { "answer_id": 90322, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 6, "selected": true, "text": "<p>I ran into the same problem several times, following changes worked for me in the past:</p>\n\n<pre><code>w...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90341", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28736/" ]
I'm using wp-usersonline plugin with user links, when you click for subscribers it goes to a not found page but works fine for authors, im thinking is there a way to redirect subscribers to a profile page and change the link into <http://domain.com/member/profile=ID>. I found some scripts that will redirect to specifi...
I ran into the same problem several times, following changes worked for me in the past: ``` while (have_posts()) : the_post(); //some html <li class="icon-date"><?php echo get_the_date( 'Y-m-d' ); ?></li> <li class="icon-time"><?php the_time( 'H:i:s' ); ?></li> ``` Instead of `the_date()`, use `get_the_date()`. T...
90,344
<p>I've a situation where I cannot get correct post count from category... and I've tried everything but customizing wp_list_categories with walker.</p> <p>So I've category hierarchy:</p> <pre><code>cat1 cat2 (total 8) cat3 (total 5) cat4 (total 3) </code></pre> <p>All posts are under cat2 and cat3-cat4. I'm di...
[ { "answer_id": 90704, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>I get total count of 16. Which is double the real amount, obviously\n counting twice.</p>\...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90344", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I've a situation where I cannot get correct post count from category... and I've tried everything but customizing wp\_list\_categories with walker. So I've category hierarchy: ``` cat1 cat2 (total 8) cat3 (total 5) cat4 (total 3) ``` All posts are under cat2 and cat3-cat4. I'm displaying cat1 and want to show ...
Checking Daniel Llewellyn code and WordPress' WP\_Query reference, I realized that we need to pass an array of array within the tax\_query parameter. Otherwise, it'd just return all post counts. Here is the little modified code: ``` if ( ! function_exists( 'ipt_kb_total_cat_post_count' ) ) : /** * Simple function t...
90,360
<p>I am trying to make widgets accept php, but without resorting to plugins.</p> <p>So far I have enabled php for the widget_text but cant make it work for widget_title.</p> <p>I am using the following code in functions.php:</p> <pre><code>add_filter('widget_text','execute_php',100); function execute_php($html){ ...
[ { "answer_id": 90385, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 2, "selected": true, "text": "<p>You can use the filter <code>widget_title</code> and a \"virtual\" shortcode. Of course, as <a href=\"https:/...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90360", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26678/" ]
I am trying to make widgets accept php, but without resorting to plugins. So far I have enabled php for the widget\_text but cant make it work for widget\_title. I am using the following code in functions.php: ``` add_filter('widget_text','execute_php',100); function execute_php($html){ if(strpos($html,"<"."?ph...
You can use the filter `widget_title` and a "virtual" shortcode. Of course, as [One Trick Pony](https://wordpress.stackexchange.com/questions/90360/how-to-make-widget-title-accept-php#comment122246_90360) points out, the "why" (and the "what") is essential to find a proper solution... Supposing the widget title was `T...
90,376
<p>I want to call a function, whenever any user update their profile. How to do that?</p>
[ { "answer_id": 90378, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 3, "selected": false, "text": "<p>You can do this using either the <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/personal_op...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90376", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28744/" ]
I want to call a function, whenever any user update their profile. How to do that?
It seems as if the hook [`personal_options_update`](http://codex.wordpress.org/Plugin_API/Action_Reference/personal_options_update) might be what you're looking for. ``` add_action( 'personal_options_update', 'my_custom_func' ); function my_custom_func( $user_id /* if you need that */ ) { ... } ```
90,392
<p>In my WordPress site, I made a custom page template, which contained a custom query [using <code>WP_Query()</code>]. With that query, I can perfectly get the posts of a certain category. But I want to show the page contents along with the queried posts.</p> <p>Thing will be like:<br/> ---------------------------</p...
[ { "answer_id": 90395, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 6, "selected": true, "text": "<p>I'm using two loops. First loop is to show the page content, and the second loop is to show the queried ...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90392", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22728/" ]
In my WordPress site, I made a custom page template, which contained a custom query [using `WP_Query()`]. With that query, I can perfectly get the posts of a certain category. But I want to show the page contents along with the queried posts. Thing will be like: --------------------------- Page Heading -----------...
I'm using two loops. First loop is to show the page content, and the second loop is to show the queried post contents. I commented into the codes where necessary. I emphasized into the loops, as [Deckster0](http://wordpress.org/support/profile/deckster0) said [in WordPress support](http://wordpress.org/support/topic/ho...
90,393
<p>I'm making a child theme for TwentyTwelve, but my host is caching my files, so I'm not seeing the changes I do to my style.css file.</p> <p>Is there a way to version the stylesheet for my child theme?</p> <p>How is TwentyTwelve even adding the stylesheet? I don't see it in header.php.</p> <p>Thanks</p>
[ { "answer_id": 90398, "author": "coopersita", "author_id": 21258, "author_profile": "https://wordpress.stackexchange.com/users/21258", "pm_score": 0, "selected": false, "text": "<p>Ok, so what I did to fix it, is add a functions.php to my child-theme, and added the following:</p>\n\n<pre...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90393", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21258/" ]
I'm making a child theme for TwentyTwelve, but my host is caching my files, so I'm not seeing the changes I do to my style.css file. Is there a way to version the stylesheet for my child theme? How is TwentyTwelve even adding the stylesheet? I don't see it in header.php. Thanks
How it's **NOT** done in WordPress ---------------------------------- The following example is the **opposite** of how one should do it. Bad practice following: ``` <style type="text/css"> <!-- /* ... Definitions that are hard to override or get rid off are here ... */ --> </style> ``` This is another example how y...
90,394
<p>I feel like this should be easy but for some reason I can't get this to work?</p> <p>I have several similar but distinct colors in list of products. I need to be able to grap the label to show to the end user (so they see orange instead of m_orange) but I also need the value to be distinct so I can apply the approp...
[ { "answer_id": 90406, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": false, "text": "<p>You can try this </p>\n\n<pre><code>$field = get_field_object('color'); \n$colors = get_field('color'); // arr...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90394", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28756/" ]
I feel like this should be easy but for some reason I can't get this to work? I have several similar but distinct colors in list of products. I need to be able to grap the label to show to the end user (so they see orange instead of m\_orange) but I also need the value to be distinct so I can apply the appropriate cla...
You can try this ``` $field = get_field_object('color'); $colors = get_field('color'); // array of selected color values foreach($colors as $color){ echo "selected color: ". $color. " with label: " . $field['choices'][ $color ]; } ``` where the labels are fetched by `get_field_object` according to the link yo...
90,410
<p>I know this question might be too broad, but I'm looking for a bit of direction. My client has a woocommerce store with 30-40 products. For whatever reason they do not want to sell online anymore, but they want to retain the product pages, information, etc. on their website.</p> <p>Is there a way, using hooks or o...
[ { "answer_id": 90993, "author": "Ewout", "author_id": 26106, "author_profile": "https://wordpress.stackexchange.com/users/26106", "pm_score": 6, "selected": true, "text": "<p>luckily woocommerce has many hooks, this removes prices and buttons:</p>\n\n<pre><code>remove_action( 'woocommerc...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90410", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23384/" ]
I know this question might be too broad, but I'm looking for a bit of direction. My client has a woocommerce store with 30-40 products. For whatever reason they do not want to sell online anymore, but they want to retain the product pages, information, etc. on their website. Is there a way, using hooks or otherwise, t...
luckily woocommerce has many hooks, this removes prices and buttons: ``` remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_single_product_summary', 'wo...
90,413
<p>How would I edit the following code, so that only 2 of the posts are echoed instead of 3</p> <pre><code> &lt;?php global $more; $more = false; # some wordpress wtf logic $num_of_posts = $wp_query-&gt;post_count; $current = -1; ...
[ { "answer_id": 90993, "author": "Ewout", "author_id": 26106, "author_profile": "https://wordpress.stackexchange.com/users/26106", "pm_score": 6, "selected": true, "text": "<p>luckily woocommerce has many hooks, this removes prices and buttons:</p>\n\n<pre><code>remove_action( 'woocommerc...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90413", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28622/" ]
How would I edit the following code, so that only 2 of the posts are echoed instead of 3 ``` <?php global $more; $more = false; # some wordpress wtf logic $num_of_posts = $wp_query->post_count; $current = -1; ...
luckily woocommerce has many hooks, this removes prices and buttons: ``` remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_single_product_summary', 'wo...
90,415
<p>I'm working on a site for a client who is using version 2.0.1 of WooCommerce plugin and I'm lost as to how I can create new page templates for it.</p> <p>With previous versions of the plugin is was simple, you just copied files from the "templates" folder into your theme folder and boom! But now, that folder is gon...
[ { "answer_id": 90993, "author": "Ewout", "author_id": 26106, "author_profile": "https://wordpress.stackexchange.com/users/26106", "pm_score": 6, "selected": true, "text": "<p>luckily woocommerce has many hooks, this removes prices and buttons:</p>\n\n<pre><code>remove_action( 'woocommerc...
2013/03/11
[ "https://wordpress.stackexchange.com/questions/90415", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18547/" ]
I'm working on a site for a client who is using version 2.0.1 of WooCommerce plugin and I'm lost as to how I can create new page templates for it. With previous versions of the plugin is was simple, you just copied files from the "templates" folder into your theme folder and boom! But now, that folder is gone. The Wo...
luckily woocommerce has many hooks, this removes prices and buttons: ``` remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_single_product_summary', 'wo...
90,445
<p>I have a site that will have some custom roles (capabilities), and I would like to have archives that list authors based on their role.</p> <p>authors.php list the profile of one author, but there is no template for listing authors, right?</p> <p>Is a custom template the only way to do this? I would rather not hav...
[ { "answer_id": 90993, "author": "Ewout", "author_id": 26106, "author_profile": "https://wordpress.stackexchange.com/users/26106", "pm_score": 6, "selected": true, "text": "<p>luckily woocommerce has many hooks, this removes prices and buttons:</p>\n\n<pre><code>remove_action( 'woocommerc...
2013/03/12
[ "https://wordpress.stackexchange.com/questions/90445", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21258/" ]
I have a site that will have some custom roles (capabilities), and I would like to have archives that list authors based on their role. authors.php list the profile of one author, but there is no template for listing authors, right? Is a custom template the only way to do this? I would rather not have empty pages tha...
luckily woocommerce has many hooks, this removes prices and buttons: ``` remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_single_product_summary', 'wo...
90,453
<p>I have a cron job set to remove a (sometimes large) number of posts from my database. Of course, I also need to remove all associated data such as custom fields. </p> <p>This is the function I'm currently running, but it's taking a bit long to delete everything.</p> <p>Would it maybe be more efficient to make a di...
[ { "answer_id": 90993, "author": "Ewout", "author_id": 26106, "author_profile": "https://wordpress.stackexchange.com/users/26106", "pm_score": 6, "selected": true, "text": "<p>luckily woocommerce has many hooks, this removes prices and buttons:</p>\n\n<pre><code>remove_action( 'woocommerc...
2013/03/12
[ "https://wordpress.stackexchange.com/questions/90453", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
I have a cron job set to remove a (sometimes large) number of posts from my database. Of course, I also need to remove all associated data such as custom fields. This is the function I'm currently running, but it's taking a bit long to delete everything. Would it maybe be more efficient to make a direct SQL query? ...
luckily woocommerce has many hooks, this removes prices and buttons: ``` remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_single_product_summary', 'wo...
90,458
<p>I am working with <a href="http://html5blank.com/" rel="nofollow">HTML5 Blank</a> and I can't seem to get jquery to stop being called in wp_footer(). I have tried adding this to the bottom of my functions file:</p> <pre><code>function theme_slug_dequeue_footer_jquery() { wp_dequeue_script( 'jquery' ); } add_action...
[ { "answer_id": 90474, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 2, "selected": true, "text": "<p>If your working with a blank theme why don't you just remove or comment out the <code>wp_enqueue_script('jquery');</...
2013/03/12
[ "https://wordpress.stackexchange.com/questions/90458", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27454/" ]
I am working with [HTML5 Blank](http://html5blank.com/) and I can't seem to get jquery to stop being called in wp\_footer(). I have tried adding this to the bottom of my functions file: ``` function theme_slug_dequeue_footer_jquery() { wp_dequeue_script( 'jquery' ); } add_action( 'wp_footer', 'theme_slug_dequeue_foot...
If your working with a blank theme why don't you just remove or comment out the `wp_enqueue_script('jquery');` in the theme functions.php? Otherwise your action hook is wrong, use, ``` add_action('wp_print_scripts','theme_slug_dequeue_footer_jquery'); function theme_slug_dequeue_footer_jquery() { wp_dequeue_scrip...
90,485
<p>I'm trying to display posts from specific categories. And I believe I have the correct code:</p> <pre><code>&lt;?php if ( in_category('11') ) { ?&gt; &lt;div class="post"&gt; &lt;h2&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt; &lt;div ...
[ { "answer_id": 90494, "author": "Horttcore", "author_id": 1379, "author_profile": "https://wordpress.stackexchange.com/users/1379", "pm_score": -1, "selected": false, "text": "<p>I assume that you are using this template on a page.\nSo you forgot to query posts for the categories.\n<code...
2013/03/12
[ "https://wordpress.stackexchange.com/questions/90485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28782/" ]
I'm trying to display posts from specific categories. And I believe I have the correct code: ``` <?php if ( in_category('11') ) { ?> <div class="post"> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <div class="entry"> <?php the_content(); ?> <...
Take a look at [multiple loops](http://codex.wordpress.org/The_Loop#Multiple_Loops) for examples And also look at the [content.php](https://github.com/braddalton/WordPress/blob/master/wp-content/themes/twentyfourteen/content.php) file in the Twenty Fourteen theme ``` <?php // The Query $category_query = new WP_Quer...
90,496
<p>I am using following code to display images in home page:</p> <pre><code>if ( has_post_thumbnail() ) {the_post_thumbnail('postbox-thumb') </code></pre> <p>But the output of the above code does not have height and width of the img tag. Please help me in solving this problem.</p> <p>Current sample output:</p> <pre...
[ { "answer_id": 90497, "author": "Horttcore", "author_id": 1379, "author_profile": "https://wordpress.stackexchange.com/users/1379", "pm_score": 2, "selected": false, "text": "<p>In the 2nd attribute of <code>the_post_thumbnail()</code> you can give additional attributes for the image.</p...
2013/03/12
[ "https://wordpress.stackexchange.com/questions/90496", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28789/" ]
I am using following code to display images in home page: ``` if ( has_post_thumbnail() ) {the_post_thumbnail('postbox-thumb') ``` But the output of the above code does not have height and width of the img tag. Please help me in solving this problem. Current sample output: ``` <img alt="Kiran inspects coal mine" c...
In the 2nd attribute of `the_post_thumbnail()` you can give additional attributes for the image. ``` the_post_thumbnail( 'postbox-thumb', array( 'width' => 100, 'height' => 100 ) ) ``` I've just checked it again the width and height are set in the latest WP Versions, so you might have just to update your WordPress i...
90,505
<p>I like the idea of enabling any user of my website to suggest edits to a page. Much like the edit system on Stack Exchange but different in that anyone should be able to edit, not just registered users. All edits would go through an approval process.</p> <p>How could I implement that?</p>
[ { "answer_id": 90997, "author": "revo", "author_id": 26909, "author_profile": "https://wordpress.stackexchange.com/users/26909", "pm_score": 3, "selected": false, "text": "<p>My idea is something simple. </p>\n\n<ul>\n<li><p>You can make an <code>Edit Suggestion</code> link at bottom of ...
2013/03/12
[ "https://wordpress.stackexchange.com/questions/90505", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/252/" ]
I like the idea of enabling any user of my website to suggest edits to a page. Much like the edit system on Stack Exchange but different in that anyone should be able to edit, not just registered users. All edits would go through an approval process. How could I implement that?
Diff the post content, title and author ======================================= As had to do something related some month ago, here's the easiest and most future proof way (that I could fine) to check if there's a change made to the content or title or if the author changed: ``` // Update Title '' !== wp_text_diff( ...
90,512
<p>I have user <code>display_name</code> and with this I want to get the <code>id</code> of that user.</p> <p>So, how can I get the user id?</p>
[ { "answer_id": 90516, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 3, "selected": false, "text": "<p>You can use the following function:</p>\n\n<pre><code>function get_user_id_by_display_name( $display_name ...
2013/03/12
[ "https://wordpress.stackexchange.com/questions/90512", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27912/" ]
I have user `display_name` and with this I want to get the `id` of that user. So, how can I get the user id?
You can use the following function: ``` function get_user_id_by_display_name( $display_name ) { global $wpdb; if ( ! $user = $wpdb->get_row( $wpdb->prepare( "SELECT `ID` FROM $wpdb->users WHERE `display_name` = %s", $display_name ) ) ) return false; return $user->ID; } ``` This is t...
90,517
<p>Good day</p> <p>I am using the <a href="http://wordpress.org/support/view/plugin-reviews/easy-table" rel="nofollow">easy table plugin</a> and I have a problem with floats with it: Any content I add below the table floats to the right of the table.</p> <p>Now I can solve this by using a</p> <pre><code>&lt;div styl...
[ { "answer_id": 90516, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 3, "selected": false, "text": "<p>You can use the following function:</p>\n\n<pre><code>function get_user_id_by_display_name( $display_name ...
2013/03/12
[ "https://wordpress.stackexchange.com/questions/90517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27604/" ]
Good day I am using the [easy table plugin](http://wordpress.org/support/view/plugin-reviews/easy-table) and I have a problem with floats with it: Any content I add below the table floats to the right of the table. Now I can solve this by using a ``` <div style="clear: both"></div> ``` but isn't there a more 'user...
You can use the following function: ``` function get_user_id_by_display_name( $display_name ) { global $wpdb; if ( ! $user = $wpdb->get_row( $wpdb->prepare( "SELECT `ID` FROM $wpdb->users WHERE `display_name` = %s", $display_name ) ) ) return false; return $user->ID; } ``` This is t...
90,535
<p>I want all my users (contributors and authors too) but the admin to be redirected to the homepage if they try to view mysite.com/wp-admin/. Contributors and Authors must be able to add and edit posts as usual, along with others they've to be forced to be redirected... I've already removed the link to the dashboard....
[ { "answer_id": 90587, "author": "Miguel", "author_id": 34323, "author_profile": "https://wordpress.stackexchange.com/users/34323", "pm_score": 3, "selected": false, "text": "<p>I been using this code for a while I think it was originaly on a plugin called wp block admin but this works. Y...
2013/03/12
[ "https://wordpress.stackexchange.com/questions/90535", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27309/" ]
I want all my users (contributors and authors too) but the admin to be redirected to the homepage if they try to view mysite.com/wp-admin/. Contributors and Authors must be able to add and edit posts as usual, along with others they've to be forced to be redirected... I've already removed the link to the dashboard... I...
Unfortunately none of the above codes worked for me as they just redirected non admin to homepage even if I wanted authors and contributors to be able to add/edit and delete their posts... I've ended removing the boxes in the dashboard and I solved (partially) my issue. I added this in functions.php ``` function disa...
90,574
<p>I'm occasionally facing this problem and not sure what causes it, any ideas?</p> <pre><code>&lt;?php get_header(); ?&gt; &lt;div class="content" role="main"&gt; &lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt; &lt;?php get_template_part( 'loop', 'index' ); ?&gt; &lt;/div&gt; &lt;?php...
[ { "answer_id": 90580, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 4, "selected": true, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/the_title\"><code>the_title</code></a> is a Loop tag. ...
2013/03/12
[ "https://wordpress.stackexchange.com/questions/90574", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
I'm occasionally facing this problem and not sure what causes it, any ideas? ``` <?php get_header(); ?> <div class="content" role="main"> <h1><?php the_title(); ?></h1> <?php get_template_part( 'loop', 'index' ); ?> </div> <?php get_footer(); ?> ``` For a normal page the\_title return...
[`the_title`](http://codex.wordpress.org/Function_Reference/the_title) is a Loop tag. It "Displays or returns the title of the current post" and it is supposed to be used *inside* the Loop, not outside of it. What you are doing-- calling it outside the Loop-- is not quite correct, and you are getting inconsistent res...
90,603
<p>Am hoping someone can help me pull out a single custom category name and show it on my custom post page. I've created a new custom post type 'Itinerary' as well as some new custom categories (terms):</p> <p>Experience</p> <ul> <li>Water Sports</li> <li>Hiking Adventures</li> <li>Mountain Biking ...</li> </ul> <p>...
[ { "answer_id": 90607, "author": "Genxer", "author_id": 25951, "author_profile": "https://wordpress.stackexchange.com/users/25951", "pm_score": 1, "selected": false, "text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/get_term_children\" rel=\"nofollow\">get_te...
2013/03/12
[ "https://wordpress.stackexchange.com/questions/90603", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28837/" ]
Am hoping someone can help me pull out a single custom category name and show it on my custom post page. I've created a new custom post type 'Itinerary' as well as some new custom categories (terms): Experience * Water Sports * Hiking Adventures * Mountain Biking ... Destination * Australia * Canada * South America...
You can use [get\_term\_children](http://codex.wordpress.org/Function_Reference/get_term_children) function. For Example: ``` <?php $termID = 10; $taxonomyName = "region"; $termchildren = get_term_children( $termID, $taxonomyName ); echo '<ul>'; foreach ($termchildren as $child) { $term = get_term_by( 'id', $chi...
90,606
<p>I absolutely hate this error. And do not understand it at all.</p> <p>So this is my code, what you want to focus on is the foreach loop:</p> <pre><code>public function reset_theme_options(){ if($this-&gt;is_theme_options_array()){ foreach($this-&gt;_theme_option['admin_options'] as $option_name=&gt;$va...
[ { "answer_id": 90609, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>When you redirect via <code>wp_safe_redirect</code>, this is done by sending a header to the browser containing the...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90606", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27670/" ]
I absolutely hate this error. And do not understand it at all. So this is my code, what you want to focus on is the foreach loop: ``` public function reset_theme_options(){ if($this->is_theme_options_array()){ foreach($this->_theme_option['admin_options'] as $option_name=>$value){ if($value !=...
The actual way to get around this is to put the following in your functions.php file: ``` function callback($buffer){ return $buffer; } function add_ob_start(){ ob_start("callback"); } function flush_ob_end(){ ob_end_flush(); } add_action('init', 'add_ob_start'); add_action('wp_footer', 'flush_ob_end');...
90,610
<p>I think my problem is partially a javascript problem, but if someone knows of a better way to do this I'd love to hear it.</p> <p>Basically the goal is to "save the client from themselves" by not allowing them to move around certain menu items in the custom menu. For SEO reasons. Whether that makes sense or not is ...
[ { "answer_id": 90609, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>When you redirect via <code>wp_safe_redirect</code>, this is done by sending a header to the browser containing the...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90610", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20813/" ]
I think my problem is partially a javascript problem, but if someone knows of a better way to do this I'd love to hear it. Basically the goal is to "save the client from themselves" by not allowing them to move around certain menu items in the custom menu. For SEO reasons. Whether that makes sense or not is beside the...
The actual way to get around this is to put the following in your functions.php file: ``` function callback($buffer){ return $buffer; } function add_ob_start(){ ob_start("callback"); } function flush_ob_end(){ ob_end_flush(); } add_action('init', 'add_ob_start'); add_action('wp_footer', 'flush_ob_end');...
90,617
<p>I'm having major trouble getting the screenshots to show in my plugin.</p> <p>I have validated the readme file and placed the screenshots in both the <code>/trunk</code> and <code>/tags/1.0</code> directories (1.0 is stable). I have looked at many search results and quite a few existing plugins to see what I'm doin...
[ { "answer_id": 90726, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 2, "selected": false, "text": "<p>Given that the <code>readme.txt</code> was ok and there was no apparent problem with the image files, I'm in...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90617", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28842/" ]
I'm having major trouble getting the screenshots to show in my plugin. I have validated the readme file and placed the screenshots in both the `/trunk` and `/tags/1.0` directories (1.0 is stable). I have looked at many search results and quite a few existing plugins to see what I'm doing different but I'm failing to s...
Given that the `readme.txt` was ok and there was no apparent problem with the image files, I'm inclined to think it was a bug in the system, and in such cases it should be reported to `plugins@wordpress.org`. Anyway, [since december 2012](http://make.wordpress.org/plugins/2012/09/13/last-december-we-added-header-image...
90,641
<p>I would like to create <a href="https://codex.wordpress.org/Shortcode_API" rel="noreferrer"><code>shortcodes</code></a>, but some tutorials write about to use <a href="https://codex.wordpress.org/Function_Reference/add_action" rel="noreferrer"><code>add_action</code></a>:</p> <pre><code>add_action( 'init', 'registe...
[ { "answer_id": 90643, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 3, "selected": true, "text": "<p>If you take a look at <a href=\"http://codex.wordpress.org/Function_Reference/add_shortcode\" rel=\"nofollo...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90641", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28731/" ]
I would like to create [`shortcodes`](https://codex.wordpress.org/Shortcode_API), but some tutorials write about to use [`add_action`](https://codex.wordpress.org/Function_Reference/add_action): ``` add_action( 'init', 'register_shortcodes'); ``` But I read another tutorial where the author didn't use it, only put t...
If you take a look at [the Codex page about `add_shortcode()`](http://codex.wordpress.org/Function_Reference/add_shortcode) you won't see anything about the need of an `add_action()` before you can use `add_shortcode()`. So, you can just put your `add_shortcode()` directly into your `functions.php`. This is what I do ...
90,649
<p>This code adds an extra class to all my menu items:</p> <pre><code>add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2); function special_nav_class($classes, $item){ $classes[] = 'btn'; return $classes; } </code></pre> <p>How do I confine this filter to my main menu (in theme location 'primary-menu'...
[ { "answer_id": 90650, "author": "jianostack", "author_id": 20326, "author_profile": "https://wordpress.stackexchange.com/users/20326", "pm_score": 1, "selected": false, "text": "<p>You don't need to modify your functions.php. Just go into your template file and find wp_nav_menu and add '...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90649", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28858/" ]
This code adds an extra class to all my menu items: ``` add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2); function special_nav_class($classes, $item){ $classes[] = 'btn'; return $classes; } ``` How do I confine this filter to my main menu (in theme location 'primary-menu')? Regards, Daniel
I was also trying to solve this problem and while searching for a solution, discovered that the [`nav_menu_css_class` filter actually excepts a third parameter](https://wordpress.stackexchange.com/questions/89934/does-the-nav-menu-css-class-filter-accept-2-or-3-arguments). This is an object containing variables related...
90,652
<p>Here is my problem:</p> <p>For my articles, I use a custom post type "exhibitions" and posts for all other news. I am displaying them in one query ['post_type' = array('exhibitions','posts')].</p> <p>The <strong>orderby parameter</strong> for posts should be their <em>publish date</em>, for exhibitions it should b...
[ { "answer_id": 90658, "author": "Marc Dingena", "author_id": 28660, "author_profile": "https://wordpress.stackexchange.com/users/28660", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if you mean you want to display 2 post types on the same page, both using a different sortin...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90652", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28718/" ]
Here is my problem: For my articles, I use a custom post type "exhibitions" and posts for all other news. I am displaying them in one query ['post\_type' = array('exhibitions','posts')]. The **orderby parameter** for posts should be their *publish date*, for exhibitions it should be *custom meta value* (end date of t...
To the best of my knowledge, you cannot sort a query by two different parameters without an additional iteration over the retrieved posts. Since that ideally should be avoided, let me suggest a different approach: How about incorporating an additional meta value "sort\_date", or the like? And then, in your saving rou...
90,655
<p>I want when any user open the post it count the <code>post view</code>. Currently i am using my custom function which is</p> <pre><code>&lt;?php setPostViews(get_the_ID()); ?&gt; </code></pre> <p>But the problem is that when user refresh the page it also count the <code>post view</code>. So how can i stop this add...
[ { "answer_id": 90667, "author": "Marc Dingena", "author_id": 28660, "author_profile": "https://wordpress.stackexchange.com/users/28660", "pm_score": 1, "selected": false, "text": "<p>One way to stop this would be to remember if this visitor has seen this page in the last x minutes. You c...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90655", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27912/" ]
I want when any user open the post it count the `post view`. Currently i am using my custom function which is ``` <?php setPostViews(get_the_ID()); ?> ``` But the problem is that when user refresh the page it also count the `post view`. So how can i stop this adding views on page refresh.
One way to stop this would be to remember if this visitor has seen this page in the last x minutes. You can tackle that in multiple ways: * Use a cookie * Save visitor IP * Use sessions Personally, I find using sessions just for counting pages is a bit silly. Cookies can be a good solution, and you can set an expir...
90,660
<p>When user open any post, then on the right side they can see related <code>posts</code> to that post. But currently in related <code>posts</code> my current open post also showing, how i can <code>exclude</code> that post which is currently open.</p>
[ { "answer_id": 90664, "author": "Marc Dingena", "author_id": 28660, "author_profile": "https://wordpress.stackexchange.com/users/28660", "pm_score": 1, "selected": false, "text": "<p>If you could give us some code snippets of what you are currently using, it would help us formulate an an...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90660", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27912/" ]
When user open any post, then on the right side they can see related `posts` to that post. But currently in related `posts` my current open post also showing, how i can `exclude` that post which is currently open.
Use the parameter `'post__not_in'` to exclude post IDs: ``` $posts = new WP_Query( array ( 'post__not_in' => array(get_the_ID()) // exclude current post ID ) ); ```
90,682
<p>I have added some extra fields like first_name,middle name,last_name etc into the custom registration form. I want to add those details int the DB also. Now only username,email,Display name and user_nice name are inserted into the db. How can i add the extra fields added in the front end to the DB?</p> <p>Following...
[ { "answer_id": 90685, "author": "sandip patil", "author_id": 17555, "author_profile": "https://wordpress.stackexchange.com/users/17555", "pm_score": -1, "selected": false, "text": "<p>You need to save those to usermeta table with key,value pair..</p>\n" }, { "answer_id": 90686, ...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90682", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28044/" ]
I have added some extra fields like first\_name,middle name,last\_name etc into the custom registration form. I want to add those details int the DB also. Now only username,email,Display name and user\_nice name are inserted into the db. How can i add the extra fields added in the front end to the DB? Following is the...
Why the downvotes for using user meta? That's how I do it, I store all the extra profile stuff in `wp_usermeta` table by utilizing [`update_user_meta`](http://codex.wordpress.org/Function_Reference/update_user_meta). ``` <?php // first validate all $_POST data $validated = $this->validate_and_sanitize(); $username =...
90,689
<p>Is it possible to import tumblr post to wordpress WMS without automatic publication? My wordpress site has a multi-account. And I'd like to be able to check post, modify if needed before online publication. and Does someone know in what format tumblr posts are exported? Thanks for your help !!!</p>
[ { "answer_id": 90685, "author": "sandip patil", "author_id": 17555, "author_profile": "https://wordpress.stackexchange.com/users/17555", "pm_score": -1, "selected": false, "text": "<p>You need to save those to usermeta table with key,value pair..</p>\n" }, { "answer_id": 90686, ...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90689", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28874/" ]
Is it possible to import tumblr post to wordpress WMS without automatic publication? My wordpress site has a multi-account. And I'd like to be able to check post, modify if needed before online publication. and Does someone know in what format tumblr posts are exported? Thanks for your help !!!
Why the downvotes for using user meta? That's how I do it, I store all the extra profile stuff in `wp_usermeta` table by utilizing [`update_user_meta`](http://codex.wordpress.org/Function_Reference/update_user_meta). ``` <?php // first validate all $_POST data $validated = $this->validate_and_sanitize(); $username =...
90,691
<p>I've developed a php app and I'd like that it's restricted to WP users (use WP like a private area). Is there a way to use WP <code>is_user_logged_in</code> function in a custom file (i.e. <code>www.mysite.com/app.php</code>)? where should I put the folder with the app ? I tried but the page is not recognized.. (<c...
[ { "answer_id": 90693, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>This is impossible to answer definitively without a better description, but I am assuming that <code>app.php<...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90691", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28875/" ]
I've developed a php app and I'd like that it's restricted to WP users (use WP like a private area). Is there a way to use WP `is_user_logged_in` function in a custom file (i.e. `www.mysite.com/app.php`)? where should I put the folder with the app ? I tried but the page is not recognized.. (`.htaccess`?)
This is impossible to answer definitively without a better description, but I am assuming that `app.php` is a completely distinct piece of code. In which case, WordPress can't really manage access to it. You will need to incorporate it into WordPress. While this is not the only way to do it I would advise: 1. Create a...
90,699
<p>How to get the meta value by meta key</p> <p>I want to get the value by the meta key. This is what I have tried so far:</p> <pre><code> $args = array( 'post_type' =&gt; 'post', 'post_status' =&gt; 'publish', 'posts_per_page' =&gt; -1, 'meta_key' =&gt; 'picture_upload_1' ); $dbResult = new WP_Quer...
[ { "answer_id": 90707, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 4, "selected": true, "text": "<p><code>WP_Query</code> selects posts and not meta value that is way you are not getting the value.\nYou can use...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90699", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28220/" ]
How to get the meta value by meta key I want to get the value by the meta key. This is what I have tried so far: ``` $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_key' => 'picture_upload_1' ); $dbResult = new WP_Query($args); var_dump($dbResult); ...
`WP_Query` selects posts and not meta value that is way you are not getting the value. You can use the returned post ID to get the value something like: ``` $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 1, 'meta_key' => 'picture_upload_1' ); $dbResult = new WP_Qu...
90,713
<p>Is there a way to disable account activation for WPMU then log the user in and redirect them to another page?</p> <p>I am running on WPMU with BuddyPress.</p>
[ { "answer_id": 90714, "author": "Kirill Fuchs", "author_id": 16500, "author_profile": "https://wordpress.stackexchange.com/users/16500", "pm_score": 1, "selected": false, "text": "<p>In a WPMU setup the account information is sent to the wp_signup table before being passed to the wp_user...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90713", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16500/" ]
Is there a way to disable account activation for WPMU then log the user in and redirect them to another page? I am running on WPMU with BuddyPress.
In a WPMU setup the account information is sent to the wp\_signup table before being passed to the wp\_users table. an easy fix for this is: ``` function your_disable_activation( $user, $user_email, $key, $meta = '' ) { // Activate the user $user_id = wpmu_activate_signup( $key ); wp_set_auth_cookie( $us...
90,727
<p>If I use:</p> <pre><code>add_image_size('main_image', 750, 375, true); </code></pre> <p>to add additional thumbnail size. Then how can i get that size if i have only key <code>main_image</code>.</p>
[ { "answer_id": 90730, "author": "david.binda", "author_id": 14022, "author_profile": "https://wordpress.stackexchange.com/users/14022", "pm_score": 3, "selected": true, "text": "<p>This is answered here: <a href=\"https://wordpress.stackexchange.com/questions/36493/get-post-thumbnail-siz...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90727", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26806/" ]
If I use: ``` add_image_size('main_image', 750, 375, true); ``` to add additional thumbnail size. Then how can i get that size if i have only key `main_image`.
This is answered here: [Get post thumbnail size](https://wordpress.stackexchange.com/questions/36493/get-post-thumbnail-size) ``` global $_wp_additional_image_sizes; // Output width echo $_wp_additional_image_sizes['main_image']['width']; // Output height echo $_wp_additional_image_sizes['main_image']['height']; ```
90,740
<p>I just discovered a new meta field on the newly created custom post type page. The meta name is slug, and it's under the wp editor field. What's that, and how can I remove it?</p>
[ { "answer_id": 90744, "author": "waqas", "author_id": 28887, "author_profile": "https://wordpress.stackexchange.com/users/28887", "pm_score": 2, "selected": false, "text": "<p>on the top right of the page where you edit your post or page you will see two buttons:\n[Screen options] and [H...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90740", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27914/" ]
I just discovered a new meta field on the newly created custom post type page. The meta name is slug, and it's under the wp editor field. What's that, and how can I remove it?
You can remove the slug metabox from a post type with remove\_meta\_box: ``` add_action( 'add_meta_boxes', 'my_add_meta_boxes' ); function my_add_meta_boxes() { remove_meta_box( 'slugdiv', 'my_post_type', 'normal' ); } ```
90,741
<p>Here is what i want to do: For a <strong>specific date</strong> i want the <strong>number of posts</strong> from a certain <strong>tag</strong>.</p> <p>For example: on <strong>14th March</strong> i have a certain <strong>number</strong> of posts tagged "<strong>jazz</strong>". I want to plot that <strong>number</st...
[ { "answer_id": 90743, "author": "kovshenin", "author_id": 1316, "author_profile": "https://wordpress.stackexchange.com/users/1316", "pm_score": 1, "selected": false, "text": "<p>You can do that with a custom SQL query, something along the lines of:</p>\n\n<pre><code>global $wpdb;\n$resul...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90741", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28887/" ]
Here is what i want to do: For a **specific date** i want the **number of posts** from a certain **tag**. For example: on **14th March** i have a certain **number** of posts tagged "**jazz**". I want to plot that **number** on y-axis of a chart *(dont worry about how i make the chart, i just want to get the number)* a...
You can do that with a custom SQL query, something along the lines of: ``` global $wpdb; $results = $wpdb->get_results( "SELECT DATE(post_date) AS d, COUNT(*) AS c FROM $wpdb->posts WHERE post_status = 'publish' GROUP BY d" ); ``` You'll get an array of objects where d is the date and c is the number of posts publis...
90,758
<p>I hope this doesn't come across as very dumb (to some extend it is, however), but I am having a hard time dealing with the <a href="http://wordpress.org/extend/plugins/sidebar-generator/" rel="nofollow">Sidebar Generator</a>. In the description it is stated that "Now supports themes with multiple sidebars.". If I un...
[ { "answer_id": 90762, "author": "waqas", "author_id": 28887, "author_profile": "https://wordpress.stackexchange.com/users/28887", "pm_score": 1, "selected": false, "text": "<p>from wordpress codex: <a href=\"http://codex.wordpress.org/Function_Reference/fetch_feed\" rel=\"nofollow\">http...
2013/03/13
[ "https://wordpress.stackexchange.com/questions/90758", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28893/" ]
I hope this doesn't come across as very dumb (to some extend it is, however), but I am having a hard time dealing with the [Sidebar Generator](http://wordpress.org/extend/plugins/sidebar-generator/). In the description it is stated that "Now supports themes with multiple sidebars.". If I understand this correctly, it w...
It sounds like your source feed is showing only 10 posts. So, regardless of what you pit for get\_item\_quantity, only 10 posts will show, max. If you're pulling posts from a WordPress site, you can adjust how many posts are included in the RSS feed in Settings -> Reading. Change this value: "Syndication feeds show t...
90,776
<p>i have customized my .html as a custom wp theme. i have these scripts in my header.php:</p> <pre><code>&lt;script type='text/javascript' src="scripts/jquery-1.8.2.js"&gt;&lt;/script&gt; &lt;script type='text/javascript' src='scripts/jquery.easing.1.3.js'&gt;&lt;/script&gt; &lt;script type='text/javascript' src='scr...
[ { "answer_id": 90778, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<h1>Probable Cause</h1>\n\n<p>I strongly suspect that you do not call <a href=\"http://codex.wordpress.org/Fun...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90776", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28902/" ]
i have customized my .html as a custom wp theme. i have these scripts in my header.php: ``` <script type='text/javascript' src="scripts/jquery-1.8.2.js"></script> <script type='text/javascript' src='scripts/jquery.easing.1.3.js'></script> <script type='text/javascript' src='scripts/jquery.hoverIntent.minified.js'></sc...
Probable Cause ============== I strongly suspect that you do not call [**`wp_head()`**](http://codex.wordpress.org/Function_Reference/wp_head) in your `header.php` file, immediately before the closing HTML `</head>` tag: ``` <?php wp_head(); ?> </head> ``` You must call this template tag, in order to fire the `wp_h...
90,786
<p>I'm using the Wordpress Bootstrap theme as my base theme.</p> <p>It uses the following code to add the class "active" to any links in the header if the user is currently on that page:</p> <pre><code>add_filter('nav_menu_css_class', 'add_active_class', 10, 2 ); function add_active_class($classes, $item) { if(...
[ { "answer_id": 90787, "author": "tfrommen", "author_id": 27722, "author_profile": "https://wordpress.stackexchange.com/users/27722", "pm_score": 0, "selected": false, "text": "<p>When using the nav menu, the parent menu item as well as the ancestor menu items are provided with the respec...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90786", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27621/" ]
I'm using the Wordpress Bootstrap theme as my base theme. It uses the following code to add the class "active" to any links in the header if the user is currently on that page: ``` add_filter('nav_menu_css_class', 'add_active_class', 10, 2 ); function add_active_class($classes, $item) { if($item->menu_item_pare...
Not the cleanest solution, but I use something like this for a few instances of current page menu highlighting for pages that aren't child/parent related in any way: ``` <?php if (is_page('tutorials-by-topic') { ?> <script type="text/javascript"> jQuery(function($) { $(document).ready(function() { $('#menu-main-menu l...
90,811
<p>I'm having trouble finishing off this code that I adapted from Cosmoslabs excellent tutorial. Everything is working (listing and pagination etc) except the search function whic is returning nothing i.e. no users are listed when I try to filter by a keyword.</p> <p>Can anyone see what the problem might be?</p> <p>T...
[ { "answer_id": 90814, "author": "david.binda", "author_id": 14022, "author_profile": "https://wordpress.stackexchange.com/users/14022", "pm_score": 0, "selected": false, "text": "<p>I'll extend my comment. From the codex, it seems to me, that your might be missing also <strong>search_col...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90811", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2685/" ]
I'm having trouble finishing off this code that I adapted from Cosmoslabs excellent tutorial. Everything is working (listing and pagination etc) except the search function whic is returning nothing i.e. no users are listed when I try to filter by a keyword. Can anyone see what the problem might be? Thanks for any poi...
This worked for me. ``` $user_query = new WP_User_Query( array( 'search' => '*example.net*', 'search_columns' => array('user_url') )); $authors = $user_query->get_results(); ``` The wild card to be used in the search string is '\*' and not '%'. Also you have to include the 'search\_columns' parameter with the follo...
90,819
<p>I would like to display a list of the top 10 authors based on the amount of posts that they have, and then sort them on last name. To my knowledge, this is not trivial since the last name of a user resides in the user meta table.</p> <p>I have been succesful in writing the code to achieve what I'm looking for, plea...
[ { "answer_id": 90814, "author": "david.binda", "author_id": 14022, "author_profile": "https://wordpress.stackexchange.com/users/14022", "pm_score": 0, "selected": false, "text": "<p>I'll extend my comment. From the codex, it seems to me, that your might be missing also <strong>search_col...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90819", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4567/" ]
I would like to display a list of the top 10 authors based on the amount of posts that they have, and then sort them on last name. To my knowledge, this is not trivial since the last name of a user resides in the user meta table. I have been succesful in writing the code to achieve what I'm looking for, please see the...
This worked for me. ``` $user_query = new WP_User_Query( array( 'search' => '*example.net*', 'search_columns' => array('user_url') )); $authors = $user_query->get_results(); ``` The wild card to be used in the search string is '\*' and not '%'. Also you have to include the 'search\_columns' parameter with the follo...
90,820
<p>How to add version of <code>style.css</code> in WordPress like below i can do in Joomla.</p> <pre><code>&lt;link rel="stylesheet" href="/templates/example/css/style.css?v=1.2"&gt; </code></pre> <p>i know that the <code>style.css</code> will load dynamically. please help me to how to do that. </p>
[ { "answer_id": 90824, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 5, "selected": true, "text": "<p>Version number is a parameter of <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_style\...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90820", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27337/" ]
How to add version of `style.css` in WordPress like below i can do in Joomla. ``` <link rel="stylesheet" href="/templates/example/css/style.css?v=1.2"> ``` i know that the `style.css` will load dynamically. please help me to how to do that.
Version number is a parameter of [`wp_enqueue_style()`](http://codex.wordpress.org/Function_Reference/wp_enqueue_style). As per the Codex, here are all the parameters that `wp_enqueue_style` accepts. ``` wp_enqueue_style( $handle, $src, $deps, $ver, $media ); ``` So for example to load a stylesheet with a version n...
90,825
<p>I have a few pages listed in my top menu. these are: contacts, My account and messages. I have added a map to the "Pages Sidebar" tab in admin. But it seems to add the map to all 3 pages listed above but I only want it to appear on the contact page and not the other 2 as in the other 2 I would like something else (a...
[ { "answer_id": 90824, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 5, "selected": true, "text": "<p>Version number is a parameter of <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_style\...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90825", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26975/" ]
I have a few pages listed in my top menu. these are: contacts, My account and messages. I have added a map to the "Pages Sidebar" tab in admin. But it seems to add the map to all 3 pages listed above but I only want it to appear on the contact page and not the other 2 as in the other 2 I would like something else (an a...
Version number is a parameter of [`wp_enqueue_style()`](http://codex.wordpress.org/Function_Reference/wp_enqueue_style). As per the Codex, here are all the parameters that `wp_enqueue_style` accepts. ``` wp_enqueue_style( $handle, $src, $deps, $ver, $media ); ``` So for example to load a stylesheet with a version n...
90,830
<pre><code>&lt;?php /*template name: my template*/ ?&gt; &lt;?php get_header(); ?&gt; &lt;?php get_header(); ?&gt; &lt;?php echo do_shortcode('[STORE-LOCATOR]'); ?&gt; &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt; &lt;?php the_content(); ?&gt; &lt;?php endwhile; else: ?&gt; &lt;p&gt;&lt...
[ { "answer_id": 90824, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 5, "selected": true, "text": "<p>Version number is a parameter of <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_style\...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90830", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28921/" ]
``` <?php /*template name: my template*/ ?> <?php get_header(); ?> <?php get_header(); ?> <?php echo do_shortcode('[STORE-LOCATOR]'); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>...
Version number is a parameter of [`wp_enqueue_style()`](http://codex.wordpress.org/Function_Reference/wp_enqueue_style). As per the Codex, here are all the parameters that `wp_enqueue_style` accepts. ``` wp_enqueue_style( $handle, $src, $deps, $ver, $media ); ``` So for example to load a stylesheet with a version n...
90,843
<p>I have created a custom post type, but I want to remove the View link from actions, in the listing of the custom post. </p> <p>I have tried this snippet </p> <pre><code> add_filter( 'post_row_actions',array(&amp;$this, 'remove_row_actions', 10, 1)); public function remove_row_actions($action){ unset($a...
[ { "answer_id": 90846, "author": "david.binda", "author_id": 14022, "author_profile": "https://wordpress.stackexchange.com/users/14022", "pm_score": 2, "selected": true, "text": "<p>You've got typo in your add_filter. Try this:</p>\n\n<pre><code>add_filter( 'post_row_actions',array(&amp;$...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90843", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28220/" ]
I have created a custom post type, but I want to remove the View link from actions, in the listing of the custom post. I have tried this snippet ``` add_filter( 'post_row_actions',array(&$this, 'remove_row_actions', 10, 1)); public function remove_row_actions($action){ unset($action['view']); re...
You've got typo in your add\_filter. Try this: ``` add_filter( 'post_row_actions',array(&$this, 'remove_row_actions'), 10, 1); public function remove_row_actions($action){ unset($action['view']); return $action; } ```
90,852
<p>I altered the following code from Ashfame:</p> <pre><code>add_action('pre_get_posts', 'block_cat_query' ); function block_cat_query() { global $wp_query; if( is_home() || is_search() || is_tag() ) { $wp_query-&gt;query_vars['cat'] = '3'; } } </code></pre> <p>This code DOES work to filter posts from category...
[ { "answer_id": 90846, "author": "david.binda", "author_id": 14022, "author_profile": "https://wordpress.stackexchange.com/users/14022", "pm_score": 2, "selected": true, "text": "<p>You've got typo in your add_filter. Try this:</p>\n\n<pre><code>add_filter( 'post_row_actions',array(&amp;$...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90852", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28929/" ]
I altered the following code from Ashfame: ``` add_action('pre_get_posts', 'block_cat_query' ); function block_cat_query() { global $wp_query; if( is_home() || is_search() || is_tag() ) { $wp_query->query_vars['cat'] = '3'; } } ``` This code DOES work to filter posts from category #3 only on the home, search ...
You've got typo in your add\_filter. Try this: ``` add_filter( 'post_row_actions',array(&$this, 'remove_row_actions'), 10, 1); public function remove_row_actions($action){ unset($action['view']); return $action; } ```
90,856
<p>I have made a custom post type named as: slider, in my plugin class, I am adding a filter which calls the method remove_row_action that unsets view links from actions</p> <pre><code> add_filter('post_row_actions', array(&amp;$this, 'remove_row_actions'), 10, 1); public function remove_row_actions($action) { ...
[ { "answer_id": 90859, "author": "david.binda", "author_id": 14022, "author_profile": "https://wordpress.stackexchange.com/users/14022", "pm_score": 2, "selected": false, "text": "<p>Yes, you're right. There is a clever way. post_row_actions filter can accept also second param $post from ...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90856", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28220/" ]
I have made a custom post type named as: slider, in my plugin class, I am adding a filter which calls the method remove\_row\_action that unsets view links from actions ``` add_filter('post_row_actions', array(&$this, 'remove_row_actions'), 10, 1); public function remove_row_actions($action) { if (isset($...
Yes, you're right. There is a clever way. post\_row\_actions filter can accept also second param $post from which you can get it's post\_type. See the code: ``` add_filter( 'post_row_actions', array( $this, 'remove_row_actions' ), 10, 2); public function remove_row_actions( $action, $post ) { if ( 'slider' === get...
90,877
<p>I'm looking for a way to chose what images sizes get generated by image. With all the image sizes I have plus a lot of images, in the end I have a whole lot of server space being used up for nothing.</p> <p>Is there a way to either?</p> <ul> <li>at upload, select what image sizes get generated for a specific image...
[ { "answer_id": 94640, "author": "Griffin", "author_id": 10036, "author_profile": "https://wordpress.stackexchange.com/users/10036", "pm_score": 2, "selected": false, "text": "<p>Picking which image sizes to generate on a per-upload basis is definitely going to be a bit involved. However,...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90877", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19337/" ]
I'm looking for a way to chose what images sizes get generated by image. With all the image sizes I have plus a lot of images, in the end I have a whole lot of server space being used up for nothing. Is there a way to either? * at upload, select what image sizes get generated for a specific image * after upload, go t...
Picking which image sizes to generate on a per-upload basis is definitely going to be a bit involved. However, if you're okay with just entirely removing default image sizes, you have a couple of options, as described in [this article](http://www.studiograsshopper.ch/code-snippets/remove-wordpress-defaultmedia-image-si...
90,884
<p>I built a custom search with the following code:</p> <p><strong>functions.php</strong></p> <pre><code>function template_chooser($template) { global $wp_query; $post_type = get_query_var('post_type'); if( $wp_query-&gt;is_search &amp;&amp; $post_type == 'products' ) { return locate_templ...
[ { "answer_id": 94640, "author": "Griffin", "author_id": 10036, "author_profile": "https://wordpress.stackexchange.com/users/10036", "pm_score": 2, "selected": false, "text": "<p>Picking which image sizes to generate on a per-upload basis is definitely going to be a bit involved. However,...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90884", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27891/" ]
I built a custom search with the following code: **functions.php** ``` function template_chooser($template) { global $wp_query; $post_type = get_query_var('post_type'); if( $wp_query->is_search && $post_type == 'products' ) { return locate_template('archive-search.php'); // redirect to a...
Picking which image sizes to generate on a per-upload basis is definitely going to be a bit involved. However, if you're okay with just entirely removing default image sizes, you have a couple of options, as described in [this article](http://www.studiograsshopper.ch/code-snippets/remove-wordpress-defaultmedia-image-si...
90,901
<p>When i put special characters in text field on wordpress themes option then it's gonna add some slash characters Like if I put </p> <pre><code>It's </code></pre> <p>then its show </p> <pre><code>It\'s. </code></pre> <p>How i solve that?</p>
[ { "answer_id": 90907, "author": "Androliyah", "author_id": 17636, "author_profile": "https://wordpress.stackexchange.com/users/17636", "pm_score": -1, "selected": false, "text": "<p>You need to escape the apostrophe yourself. Two ways to escape apostrophes is to do this:</p>\n\n<pre><cod...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90901", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28946/" ]
When i put special characters in text field on wordpress themes option then it's gonna add some slash characters Like if I put ``` It's ``` then its show ``` It\'s. ``` How i solve that?
Wordpress always adds slash before quotes as the first step in processing input. You should strip those slashes before saving data into the DB. use `stripslashes` for strings or `stripslashes_deep` in case you are handling arrays.
90,923
<p>This code works perfectly</p> <pre><code>function exclude_category( $query ) { if ( $query-&gt;is_home() &amp;&amp; $query-&gt;is_main_query() ) { $query-&gt;set( 'cat', '-1' ); } } add_action( 'pre_get_posts', 'exclude_category' ); </code></pre> <p>But this code does not work at all</p> <pre><cod...
[ { "answer_id": 90924, "author": "tfrommen", "author_id": 27722, "author_profile": "https://wordpress.stackexchange.com/users/27722", "pm_score": 4, "selected": true, "text": "<p><code>$caid</code> is unknown inside the function, unless declared global.</p>\n\n<pre><code>$caid = '-1';\nfu...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90923", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28956/" ]
This code works perfectly ``` function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '-1' ); } } add_action( 'pre_get_posts', 'exclude_category' ); ``` But this code does not work at all ``` $caid = "-1"; function exclude_category( $query ) { ...
`$caid` is unknown inside the function, unless declared global. ``` $caid = '-1'; function exclude_category( $query ) { global $caid; if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', $caid ); } } add_action( 'pre_get_posts', 'exclude_category' ); ``` **// Edit** Do you...
90,934
<p>So, I'm using a custom post type archive and generating a JavaScript-based filtering interface for sorting through results.</p> <p>Here's an example: <a href="http://www.inverity.org/sermons/" rel="nofollow">http://www.inverity.org/sermons/</a></p> <p>Now, what I'd like to do is pass in variables to my script to a...
[ { "answer_id": 91962, "author": "Andy Jacobs", "author_id": 23850, "author_profile": "https://wordpress.stackexchange.com/users/23850", "pm_score": 0, "selected": false, "text": "<p>I'm taking some shots in the dark, here.</p>\n\n<p>The first place I would look is your register_taxonomy ...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90934", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1766/" ]
So, I'm using a custom post type archive and generating a JavaScript-based filtering interface for sorting through results. Here's an example: <http://www.inverity.org/sermons/> Now, what I'd like to do is pass in variables to my script to allow for filtering based on URL parameters. This works: <http://www.inverit...
I had the same problem on my large project that I currently work on. It's case when you have collision between taxonomy and post-type slugs. Problem is that you can filter by taxonomy with adding `?taxonomy_name=term_slug` and also you can see the custom post by adding `?post_type=custom_post_slug`. So, that's the same...
90,937
<p>i have attacment.php like this. </p> <pre><code>&lt;?php if ( $attachments = get_children( array( 'post_type' =&gt; 'attachment', 'post_mime_type'=&gt;'image', 'numberposts' =&gt; 1, 'post_status' =&gt; null, 'post_parent' =&gt; $post-&gt;ID ))); foreach ($attachments as $attachment) { echo wp_get...
[ { "answer_id": 90943, "author": "tfrommen", "author_id": 27722, "author_profile": "https://wordpress.stackexchange.com/users/27722", "pm_score": 1, "selected": false, "text": "<p>Although it is not WP-specific, here's how to <em>force</em> the user to download an image:</p>\n\n<pre><code...
2013/03/14
[ "https://wordpress.stackexchange.com/questions/90937", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28903/" ]
i have attacment.php like this. ``` <?php if ( $attachments = get_children( array( 'post_type' => 'attachment', 'post_mime_type'=>'image', 'numberposts' => 1, 'post_status' => null, 'post_parent' => $post->ID ))); foreach ($attachments as $attachment) { echo wp_get_attachment_link( $attachment->ID, '...
It is possible by using the plugin: <http://wordpress.org/extend/plugins/download-shortcode/> I am here to assist you since I am using the same functionnality in my website (force dowloading of post attachements)
90,942
<p>I have what seems to be a rather troubling issue with the get_theme_mod function in the latest version of Wordpress. Only on particular servers (of which meet all Wordpress requirements) the function won't return the saved value that I can see stored in the database. However if I specify a default value for the func...
[ { "answer_id": 90966, "author": "Dwayne Charrington", "author_id": 1687, "author_profile": "https://wordpress.stackexchange.com/users/1687", "pm_score": 2, "selected": false, "text": "<p>I never worked out why get_theme_mod did not work, I however did find a nifty little fix to resolve t...
2013/03/15
[ "https://wordpress.stackexchange.com/questions/90942", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1687/" ]
I have what seems to be a rather troubling issue with the get\_theme\_mod function in the latest version of Wordpress. Only on particular servers (of which meet all Wordpress requirements) the function won't return the saved value that I can see stored in the database. However if I specify a default value for the funct...
I had the same issue.. using `type=option` and then `get_option` din't work either. Testing with another option item and works.. and testing with `MYTHEMENAME_THEME_OPTION` without the bracket for item and got an Array so I guess is the right way. So just a tip for those who found this post but still got blank value...
90,958
<p>In WordPress, Custom Post Types do not have Sticky functionality as a core feature. It is possible, I'm sure, to create it in certain cases—and I'm working on a project that requires it for <code>archive-{customposttype}.php</code> templates.</p> <p>I have downloaded and installed a plugin, called <a href="http://w...
[ { "answer_id": 103253, "author": "user34211", "author_id": 34211, "author_profile": "https://wordpress.stackexchange.com/users/34211", "pm_score": 0, "selected": false, "text": "<p>I'm implementing sticky posts in two custom post types, and I've just had a look at the plugin you mention ...
2013/03/15
[ "https://wordpress.stackexchange.com/questions/90958", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27222/" ]
In WordPress, Custom Post Types do not have Sticky functionality as a core feature. It is possible, I'm sure, to create it in certain cases—and I'm working on a project that requires it for `archive-{customposttype}.php` templates. I have downloaded and installed a plugin, called [Sticky Custom Post Types](http://word...
I think the answer to your questions lies on the following webpage. Its author (Tareq Hasan) faced the same problem as we do and found a solution. <https://tareq.co/2013/01/sticky-posts-in-custom-post-type-archives/> Basically, you need to install the plugin you already have (Sticky Custom Post Types) and add a filt...
90,978
<p>I have used to below function to register a new 'guide' content type:</p> <pre><code>add_action( 'init', 'guide_post_type' ); function guide_post_type() { register_post_type('guides', array( 'label' =&gt; 'Guides', 'description' =&gt; '', 'public' =&gt; true, 'show_ui' =&gt; t...
[ { "answer_id": 90983, "author": "revo", "author_id": 26909, "author_profile": "https://wordpress.stackexchange.com/users/26909", "pm_score": 1, "selected": false, "text": "<p>For displaying posts from a custom post type you can use a <code>wp_query()</code> object. In your case this is w...
2013/03/15
[ "https://wordpress.stackexchange.com/questions/90978", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23772/" ]
I have used to below function to register a new 'guide' content type: ``` add_action( 'init', 'guide_post_type' ); function guide_post_type() { register_post_type('guides', array( 'label' => 'Guides', 'description' => '', 'public' => true, 'show_ui' => true, 'show_in_menu...
For displaying posts from a custom post type you can use a `wp_query()` object. In your case this is what you want : ``` <?php $arg = array( 'post_type' => 'guide', // this can be an array : array('guide','guide1',...) 'posts_per_page' => 10, 'order' => 'DESC', // 'c...
91,002
<p>I am using the front end form submission. It works on localhost perfectly, but it's not working when my site is live. It shows the "success message", but originally it's not logged in. This is my code:</p> <pre><code>if ( 'POST' == $_SERVER['REQUEST_METHOD'] &amp;&amp; !empty( $_POST['action'] ) &amp;&amp; $_POST['...
[ { "answer_id": 90983, "author": "revo", "author_id": 26909, "author_profile": "https://wordpress.stackexchange.com/users/26909", "pm_score": 1, "selected": false, "text": "<p>For displaying posts from a custom post type you can use a <code>wp_query()</code> object. In your case this is w...
2013/03/15
[ "https://wordpress.stackexchange.com/questions/91002", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27912/" ]
I am using the front end form submission. It works on localhost perfectly, but it's not working when my site is live. It shows the "success message", but originally it's not logged in. This is my code: ``` if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'log-in' ) : ...
For displaying posts from a custom post type you can use a `wp_query()` object. In your case this is what you want : ``` <?php $arg = array( 'post_type' => 'guide', // this can be an array : array('guide','guide1',...) 'posts_per_page' => 10, 'order' => 'DESC', // 'c...
91,005
<p><strong>What I'm trying to do:</strong><br> I want to display <code>the_excerpt</code>, but I have a maximum of <code>x</code> characters <code>the_excerpt</code> may use, but I don't want to display a couple of characters of a word, only whole words.</p> <p><strong>Some more information:</strong><br> This code is ...
[ { "answer_id": 91006, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 0, "selected": false, "text": "<p>After some puzzling, I found this solution:</p>\n\n<pre><code>$limit_characters = 120;\n\nfunction new_exc...
2013/03/15
[ "https://wordpress.stackexchange.com/questions/91005", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24806/" ]
**What I'm trying to do:** I want to display `the_excerpt`, but I have a maximum of `x` characters `the_excerpt` may use, but I don't want to display a couple of characters of a word, only whole words. **Some more information:** This code is on a non-single/non-permalink web page such as archives, categories, fr...
``` add_filter('wp_trim_excerpt', function($text){ $max_length = 140; if(mb_strlen($text, 'UTF-8') > $max_length){ $split_pos = mb_strpos(wordwrap($text, $max_length), "\n", 0, 'UTF-8'); $text = mb_substr($text, 0, $split_pos, 'UTF-8'); } return $text; }); ``` This should take into account...
91,027
<p>I am using this snip of code to get rss feed on my dashboard as widget. It becomes problematic when it displays 5-6 different rss feeds which makes me run down deep. </p> <p>How can I add 6 different feeds in a single dashboard widget with scroll bar?</p> <p>Thanks</p> <pre><code> add_action('wp_dashboard_setu...
[ { "answer_id": 91031, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 3, "selected": true, "text": "<p>Yes, @toscho is right, the <code>url</code> works with an array of feeds adresses. And if you have 5/6 feeds,...
2013/03/15
[ "https://wordpress.stackexchange.com/questions/91027", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24411/" ]
I am using this snip of code to get rss feed on my dashboard as widget. It becomes problematic when it displays 5-6 different rss feeds which makes me run down deep. How can I add 6 different feeds in a single dashboard widget with scroll bar? Thanks ``` add_action('wp_dashboard_setup', 'my_dashboard_widgets');...
Yes, @toscho is right, the `url` works with an array of feeds adresses. And if you have 5/6 feeds, the total of items should be 20/24. For clear separation, I think it's better to run the `wp_widget_rss_output` function `n` number of times, and prepare a previous array with titles and addresses and iterate through it....
91,037
<p>I have created a custom post type, but I do not want it to have a permalink. By default, after entering the post title, it creates a permalink. I do not need them to be generated.</p> <p>From my reading, it is said that custom post type will have a permalink and there is no way of disabling it. Is there a way that ...
[ { "answer_id": 91048, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 4, "selected": true, "text": "<pre><code>&lt;?php\n add_filter('get_sample_permalink_html', 'my_hide_permalinks');\n function my_hide_pe...
2013/03/15
[ "https://wordpress.stackexchange.com/questions/91037", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28220/" ]
I have created a custom post type, but I do not want it to have a permalink. By default, after entering the post title, it creates a permalink. I do not need them to be generated. From my reading, it is said that custom post type will have a permalink and there is no way of disabling it. Is there a way that I can prev...
``` <?php add_filter('get_sample_permalink_html', 'my_hide_permalinks'); function my_hide_permalinks($in){ global $post; if($post->post_type == 'my_post_type') $out = preg_replace('~<div id="edit-slug-box".*</div>~Ui', '', $in); return $out; } ``` This will remove: * P...
91,049
<p>I want to perform an action when I delete one of my custom post types, which hook should I use:</p> <pre><code>wp_trash_mycpt </code></pre> <p>or </p> <pre><code>trash_mycpt </code></pre> <p>My action should run solely when <strong><code>mycpt</code></strong> is in the <code>'publish', 'draft' or 'future'</code>...
[ { "answer_id": 91052, "author": "montrealist", "author_id": 8105, "author_profile": "https://wordpress.stackexchange.com/users/8105", "pm_score": 4, "selected": false, "text": "<p>The <a href=\"https://developer.wordpress.org/reference/hooks/wp_trash_post/\" rel=\"noreferrer\"><code>wp_t...
2013/03/15
[ "https://wordpress.stackexchange.com/questions/91049", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
I want to perform an action when I delete one of my custom post types, which hook should I use: ``` wp_trash_mycpt ``` or ``` trash_mycpt ``` My action should run solely when **`mycpt`** is in the `'publish', 'draft' or 'future'` state and moves towards the 'trash' state. When it is removed from trash itself the...
The [`wp_trash_post`](https://developer.wordpress.org/reference/hooks/wp_trash_post/) hook might be what you're looking for: > > Fires before a post is sent to the trash. > > > Also, there's the [`trashed_post`](https://developer.wordpress.org/reference/hooks/trashed_post/) hook: > > Fires after a post is sent ...
91,050
<p>I am attempting to update a large array of feeds into WordPress, using fetch_feeds. As can be expected, when going over 50 feeds the server is starting to time out. I would still like to update the feeds in bulk but without crashing the server. </p> <p>Can you suggest a method through which I can break things down?...
[ { "answer_id": 91429, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 1, "selected": false, "text": "<p>You've tried to extend the script's maximum execution time with <a href=\"http://php.net/manual/en/functio...
2013/03/15
[ "https://wordpress.stackexchange.com/questions/91050", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
I am attempting to update a large array of feeds into WordPress, using fetch\_feeds. As can be expected, when going over 50 feeds the server is starting to time out. I would still like to update the feeds in bulk but without crashing the server. Can you suggest a method through which I can break things down? Maybe us...
You can try using wp cron functions, programing a feed import every 10 minutes or so, until you have nothing left in queue. Example code: ``` <?php register_activation_hook( __FILE__, 'wp1903_schedule_cron' ); function wp1903_schedule_cron() { $counter = 0; $feeds = array( 'http://example.com/feed1',...
91,056
<p>I need to be able to show some informations only to the author in his profile viewable in the front end, for istance I need to add a text under the avatar that only the author, if logged in, can see. This text will inform them that they can change the avatar anytime by adding it in their profile page... I could also...
[ { "answer_id": 91429, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 1, "selected": false, "text": "<p>You've tried to extend the script's maximum execution time with <a href=\"http://php.net/manual/en/functio...
2013/03/15
[ "https://wordpress.stackexchange.com/questions/91056", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27309/" ]
I need to be able to show some informations only to the author in his profile viewable in the front end, for istance I need to add a text under the avatar that only the author, if logged in, can see. This text will inform them that they can change the avatar anytime by adding it in their profile page... I could also ad...
You can try using wp cron functions, programing a feed import every 10 minutes or so, until you have nothing left in queue. Example code: ``` <?php register_activation_hook( __FILE__, 'wp1903_schedule_cron' ); function wp1903_schedule_cron() { $counter = 0; $feeds = array( 'http://example.com/feed1',...
91,071
<p>If the contributor has already published two or more posts I show a maximum of 5 of them in the post-single.php using this code</p> <pre><code>&lt;?php echo do_shortcode('[latestbyauthor show="5"]'); ?&gt; </code></pre> <p>I have a text that introduces the code (other posts by the same author)</p> <p>This works f...
[ { "answer_id": 91074, "author": "David Gard", "author_id": 10097, "author_profile": "https://wordpress.stackexchange.com/users/10097", "pm_score": 0, "selected": false, "text": "<p>You could run a query to grab an array of the number of posts by each author, and then check that array. Th...
2013/03/15
[ "https://wordpress.stackexchange.com/questions/91071", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27309/" ]
If the contributor has already published two or more posts I show a maximum of 5 of them in the post-single.php using this code ``` <?php echo do_shortcode('[latestbyauthor show="5"]'); ?> ``` I have a text that introduces the code (other posts by the same author) This works fine if the contributor really has publi...
Simpler than using the `$wpdb` class would be to use [`count_user_posts()`](http://codex.wordpress.org/Function_Reference/count_user_posts). For instance: ``` $min_posts = 2; if( count_user_posts( $post->post_author ) >= $min_posts ) { // display the user's posts } ``` This assumes you're in The Loop, or at the ...
91,090
<p>How to set htaccess to such examples in a Wordpress Multisite:</p> <ul> <li>domain.com - redirect to - www.domain.com</li> <li>sudomain.domain.com - no redirect</li> </ul> <p>I have a <code>Error 310 (net::ERR_TOO_MANY_REDIRECTS)</code> when my <code>.htaccess</code> file looks like this:</p> <pre><code>RewriteEn...
[ { "answer_id": 91096, "author": "Jimbo", "author_id": 5962, "author_profile": "https://wordpress.stackexchange.com/users/5962", "pm_score": 2, "selected": false, "text": "<p>Try:</p>\n\n<pre><code>RewriteEngine on\nRewriteCond %{HTTP_HOST} !^$\nRewriteCond %{HTTP_HOST} !^www\\. [NC]\...
2013/03/15
[ "https://wordpress.stackexchange.com/questions/91090", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29009/" ]
How to set htaccess to such examples in a Wordpress Multisite: * domain.com - redirect to - www.domain.com * sudomain.domain.com - no redirect I have a `Error 310 (net::ERR_TOO_MANY_REDIRECTS)` when my `.htaccess` file looks like this: ``` RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{...
Try: ``` RewriteEngine on RewriteCond %{HTTP_HOST} !^$ RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^/(.*) http://www.%{HTTP_HOST}/$1 [L,R=301] ```
91,101
<p>When using the 'fields' => 'ids' parameter, is it better to create a new WP_Query in the code below rather than doing get_posts?</p> <p>How would the loop look if I used WP_Query?</p> <pre><code>function myplugin_delete_image_items( $postid ) { $args = array( 'post_type' =&gt; 'myplugin_image_item...
[ { "answer_id": 91102, "author": "Jimbo", "author_id": 5962, "author_profile": "https://wordpress.stackexchange.com/users/5962", "pm_score": 1, "selected": false, "text": "<p>If you use WP_Query and create a new object you wont touch the main query keeping it clean. Its safe to use anywhe...
2013/03/15
[ "https://wordpress.stackexchange.com/questions/91101", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
When using the 'fields' => 'ids' parameter, is it better to create a new WP\_Query in the code below rather than doing get\_posts? How would the loop look if I used WP\_Query? ``` function myplugin_delete_image_items( $postid ) { $args = array( 'post_type' => 'myplugin_image_item', 'cache_re...
[`get_posts()`](http://queryposts.com/function/get_posts) simply uses a `WPQuery` object and sets a few default values. In general the values it sets make it *mildly* more performant. But I wouldn't worry to much about it. `get_posts()` is simplier so as a rule of thumb if you don't need any of the more involved featu...
91,124
<p>If I add a custom post type (example code below), in the admin page for the new custom post type the posts are sorted by ID by default. Is there a way to set the default sort order to the post title instead (only for this new custom post type)?</p> <pre><code> $labels = array( 'name' =&gt; 'States', 'si...
[ { "answer_id": 91128, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 4, "selected": false, "text": "<p>You could force the order via <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\" rel=...
2013/03/16
[ "https://wordpress.stackexchange.com/questions/91124", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24064/" ]
If I add a custom post type (example code below), in the admin page for the new custom post type the posts are sorted by ID by default. Is there a way to set the default sort order to the post title instead (only for this new custom post type)? ``` $labels = array( 'name' => 'States', 'singular_name' => 'S...
You could force the order via [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts): ``` function wpa_order_states( $query ){ if( !is_admin() ) return; $screen = get_current_screen(); if( 'edit' == $screen->base && 'states' == $screen->post_type && !isset(...
91,139
<pre><code>&lt;div class="single_post"&gt; &lt;?php // The Query query_posts( $args ); // The Loop if(have_posts()) : while ( have_posts() ) : the_post(); ?&gt; &lt;div class="left_date"&gt; &lt;h1&gt;&lt;?php the_time('d') ?&gt;&lt;/h1&gt; &lt;p&gt;&lt;?php the_time('M')...
[ { "answer_id": 91128, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 4, "selected": false, "text": "<p>You could force the order via <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\" rel=...
2013/03/16
[ "https://wordpress.stackexchange.com/questions/91139", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26275/" ]
``` <div class="single_post"> <?php // The Query query_posts( $args ); // The Loop if(have_posts()) : while ( have_posts() ) : the_post(); ?> <div class="left_date"> <h1><?php the_time('d') ?></h1> <p><?php the_time('M') ?></p> <span class="year"><p><?php the_time...
You could force the order via [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts): ``` function wpa_order_states( $query ){ if( !is_admin() ) return; $screen = get_current_screen(); if( 'edit' == $screen->base && 'states' == $screen->post_type && !isset(...
91,160
<p>I want to display a list of events with dates in upcoming order. Ex: </p> <ul> <li><ol> <li>23 March, 2013, </li> </ol></li> <li><ol> <li>30 March, 2013</li> </ol></li> </ul> <p>Below is the query I'm using to filter out posts from my database:</p> <pre><code>query_posts( 'post_type=myevents&amp;meta_key=_da...
[ { "answer_id": 91128, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 4, "selected": false, "text": "<p>You could force the order via <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\" rel=...
2013/03/16
[ "https://wordpress.stackexchange.com/questions/91160", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29042/" ]
I want to display a list of events with dates in upcoming order. Ex: * 1. 23 March, 2013, * 1. 30 March, 2013 Below is the query I'm using to filter out posts from my database: ``` query_posts( 'post_type=myevents&meta_key=_datepicker&orderby=meta_value&order=ASC&showposts=20' ); ``` But this doesn't work. I...
You could force the order via [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts): ``` function wpa_order_states( $query ){ if( !is_admin() ) return; $screen = get_current_screen(); if( 'edit' == $screen->base && 'states' == $screen->post_type && !isset(...
91,166
<p>I've been looking around the net for a long time on how to disable WordPress from creating multiple thumbnails.</p> <p>I've seen in most tutorials to set all the images to 0 in the media section. I have done that, but going to my uploads folder and it still creates multiple images.</p> <p>I can't find any solution...
[ { "answer_id": 91167, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 2, "selected": false, "text": "<p>If I remember right you have to <code>unset</code> all the defaults and add the new <code>Size</code> there:...
2013/03/16
[ "https://wordpress.stackexchange.com/questions/91166", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28662/" ]
I've been looking around the net for a long time on how to disable WordPress from creating multiple thumbnails. I've seen in most tutorials to set all the images to 0 in the media section. I have done that, but going to my uploads folder and it still creates multiple images. I can't find any solution for this. The re...
To built on Max Yudin's answer you should use the `intermediate_image_sizes_advanced` filter, and not `image_size_names_choose`. Add to functions.php ``` function add_image_insert_override($sizes){ unset( $sizes['thumbnail']); unset( $sizes['medium']); unset( $sizes['large']); return $sizes; } add_filt...
91,196
<p>I have my wordpress site in a root folder like this "www.mysite/myblog/"</p> <p>so to get to the blog you have to go to "www.mysite/myblog/"</p> <p>I'm wanting to make it so that a user can go to "www.mysite" and it hits the blog. What do I need to do. All my images and everything have the ".../myblog/" path. I do...
[ { "answer_id": 91167, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 2, "selected": false, "text": "<p>If I remember right you have to <code>unset</code> all the defaults and add the new <code>Size</code> there:...
2013/03/17
[ "https://wordpress.stackexchange.com/questions/91196", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13952/" ]
I have my wordpress site in a root folder like this "www.mysite/myblog/" so to get to the blog you have to go to "www.mysite/myblog/" I'm wanting to make it so that a user can go to "www.mysite" and it hits the blog. What do I need to do. All my images and everything have the ".../myblog/" path. I don't want to have ...
To built on Max Yudin's answer you should use the `intermediate_image_sizes_advanced` filter, and not `image_size_names_choose`. Add to functions.php ``` function add_image_insert_override($sizes){ unset( $sizes['thumbnail']); unset( $sizes['medium']); unset( $sizes['large']); return $sizes; } add_filt...
91,202
<p>I want to replace below class with <code>active</code> class in menu:</p> <pre><code>.current-menu-item </code></pre> <p>and</p> <pre><code>.current_page_item </code></pre> <p>I am already using a menu callback which add a class <code>dropdown</code> in child menu:</p> <pre><code>class foundation_navigation ext...
[ { "answer_id": 91207, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 3, "selected": true, "text": "<p>Add this line at top of your display element function:</p>\n\n<pre><code>add_filter('nav_menu_css_class...
2013/03/17
[ "https://wordpress.stackexchange.com/questions/91202", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26385/" ]
I want to replace below class with `active` class in menu: ``` .current-menu-item ``` and ``` .current_page_item ``` I am already using a menu callback which add a class `dropdown` in child menu: ``` class foundation_navigation extends Walker_Nav_Menu { function start_lvl(&$output, $depth) { $indent = str_r...
Add this line at top of your display element function: ``` add_filter('nav_menu_css_class', 'add_active_class_to_nav_menu'); ``` Add this line at bottom of your display element function: ``` remove_filter('nav_menu_css_class', 'add_active_class_to_nav_menu'); ``` Add this function somewhere in your themes `functi...
91,208
<p>My problem is that i don't know how to set up a echo I think. I need it to just wrap a if statement correctly around the code below Please Help...Thanks SO much</p> <pre><code> &lt;?php global $post; if(get_post_type($post-&gt;ID) == 'videos') { &lt;video class="video" width="&lt;?php echo get_field('width');...
[ { "answer_id": 91207, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 3, "selected": true, "text": "<p>Add this line at top of your display element function:</p>\n\n<pre><code>add_filter('nav_menu_css_class...
2013/03/17
[ "https://wordpress.stackexchange.com/questions/91208", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27789/" ]
My problem is that i don't know how to set up a echo I think. I need it to just wrap a if statement correctly around the code below Please Help...Thanks SO much ``` <?php global $post; if(get_post_type($post->ID) == 'videos') { <video class="video" width="<?php echo get_field('width'); ?>" height="<?php echo get...
Add this line at top of your display element function: ``` add_filter('nav_menu_css_class', 'add_active_class_to_nav_menu'); ``` Add this line at bottom of your display element function: ``` remove_filter('nav_menu_css_class', 'add_active_class_to_nav_menu'); ``` Add this function somewhere in your themes `functi...
91,232
<p>I am including jQuery in my <code>header.php</code> file like this:</p> <pre><code>&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" &gt;&lt;/script&gt; </code></pre> <p>But when doing this, it breaks my home page slider, it breaks my google maps ultimate plugins and some other things. Wh...
[ { "answer_id": 91234, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 2, "selected": false, "text": "<p>jQuery is included in WordPress by default. There is no need to add it to a theme's header file manually....
2013/03/17
[ "https://wordpress.stackexchange.com/questions/91232", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27604/" ]
I am including jQuery in my `header.php` file like this: ``` <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script> ``` But when doing this, it breaks my home page slider, it breaks my google maps ultimate plugins and some other things. When I exclude it, no custom jQuery runs on my page...
You *should not* include jQuery manually. jQuery is included in WordPress by default, but isn't loaded on every page unless a plugin or theme requests it. This can be done using: ``` add_action('wp_enqueue_scripts','my_scripts'); function my_scripts() { wp_enqueue_script('jquery'); } ``` Here is function referen...
91,236
<p>I have form that i'm using to update user profile from front end and i have country select.</p> <pre><code>&lt;form method=&quot;post&quot; id=&quot;adduser&quot; action=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt; &lt;select id=&quot;te&quot; name=&quot;usercountry_id&quot;&gt; &lt;option value=&quo...
[ { "answer_id": 91234, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 2, "selected": false, "text": "<p>jQuery is included in WordPress by default. There is no need to add it to a theme's header file manually....
2013/03/17
[ "https://wordpress.stackexchange.com/questions/91236", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28694/" ]
I have form that i'm using to update user profile from front end and i have country select. ``` <form method="post" id="adduser" action="<?php the_permalink(); ?>"> <select id="te" name="usercountry_id"> <option value="1">Country 1</option> <option value="2">Country 2</option> </select> <...
You *should not* include jQuery manually. jQuery is included in WordPress by default, but isn't loaded on every page unless a plugin or theme requests it. This can be done using: ``` add_action('wp_enqueue_scripts','my_scripts'); function my_scripts() { wp_enqueue_script('jquery'); } ``` Here is function referen...
91,249
<p>In my website I have three custom post types: scripts, scenes and plugins. When visiting the archive page of a single post type (i.e. by going to mysite.com/plugins) you correctly see all the posts of that type. </p> <p><strong>In archive.php, how can I find out which custom post type the user is looking at right n...
[ { "answer_id": 91254, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 5, "selected": true, "text": "<p>There are a several of ways to do this. Put:</p>\n\n<pre><code>var_dump($wp_query-&gt;query,get_queried_object...
2013/03/17
[ "https://wordpress.stackexchange.com/questions/91249", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/821/" ]
In my website I have three custom post types: scripts, scenes and plugins. When visiting the archive page of a single post type (i.e. by going to mysite.com/plugins) you correctly see all the posts of that type. **In archive.php, how can I find out which custom post type the user is looking at right now?** I tried t...
There are a several of ways to do this. Put: ``` var_dump($wp_query->query,get_queried_object()); die; ``` In your `archive.php` and you should see two of those ways. `$wp_query->query` will have `post_type` component for custom post types. That will not be there for `post` post types. `get_queried_object` will ret...
91,253
<p>is it possible to use <code>add_filter</code> or something similar to add the <code>slug</code> of the category as classname to the <code>the_category()</code> function?</p> <p>Right now when using <code>the_category()</code> the output looks like this …</p> <pre><code>&lt;ul class="post-categories"&gt; &lt;li...
[ { "answer_id": 91260, "author": "Ralf912", "author_id": 16589, "author_profile": "https://wordpress.stackexchange.com/users/16589", "pm_score": 4, "selected": true, "text": "<p>First locate <code>the_category()</code> in the <a href=\"http://codex.wordpress.org/Function_Reference/the_cat...
2013/03/17
[ "https://wordpress.stackexchange.com/questions/91253", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
is it possible to use `add_filter` or something similar to add the `slug` of the category as classname to the `the_category()` function? Right now when using `the_category()` the output looks like this … ``` <ul class="post-categories"> <li> <a href="http://mysite.com/something" title="" rel="category tag...
First locate `the_category()` in the [Codex](http://codex.wordpress.org/Function_Reference/the_category). Scroll down to the bottom of the page to "Source Code". There is a link "`the_categfory()` is located in ...". Click the link, you will be redirected to the [source code](http://core.trac.wordpress.org/browser/tags...
91,265
<p>I have a custom post type and used get_next_post() and get_previous_post() to create a simple pagination. However i need to create a pagination loop (if that is the correct term). If i'm on the first post i need to browse back to the last post and if i'm on the last post i need to browse to the first post. Is there ...
[ { "answer_id": 91324, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": true, "text": "<p>Here is one idea for the <em>previous post circle</em>:</p>\n\n<pre><code>$next_post = get_next_post();\n$prev_...
2013/03/17
[ "https://wordpress.stackexchange.com/questions/91265", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28147/" ]
I have a custom post type and used get\_next\_post() and get\_previous\_post() to create a simple pagination. However i need to create a pagination loop (if that is the correct term). If i'm on the first post i need to browse back to the last post and if i'm on the last post i need to browse to the first post. Is there...
Here is one idea for the *previous post circle*: ``` $next_post = get_next_post(); $prev_post = get_previous_post_circle(); ``` where we have defined this function: ``` function get_previous_post_circle($in_same_cat = false, $excluded_categories = ''){ $prev_post = get_previous_post($in_same_cat,$excluded_categ...
91,295
<p>I am writing a plugin that enables subscribed users to submit posts of a custom type, and I am trying to implement this feature via shortcodes. Now the problem is that instead of inserting one post, my code inserts hundreds of them, until PHP runs out of memory... Here is an ultraminimal code that reproduces the iss...
[ { "answer_id": 91324, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": true, "text": "<p>Here is one idea for the <em>previous post circle</em>:</p>\n\n<pre><code>$next_post = get_next_post();\n$prev_...
2013/03/18
[ "https://wordpress.stackexchange.com/questions/91295", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26945/" ]
I am writing a plugin that enables subscribed users to submit posts of a custom type, and I am trying to implement this feature via shortcodes. Now the problem is that instead of inserting one post, my code inserts hundreds of them, until PHP runs out of memory... Here is an ultraminimal code that reproduces the issue:...
Here is one idea for the *previous post circle*: ``` $next_post = get_next_post(); $prev_post = get_previous_post_circle(); ``` where we have defined this function: ``` function get_previous_post_circle($in_same_cat = false, $excluded_categories = ''){ $prev_post = get_previous_post($in_same_cat,$excluded_categ...
91,299
<p>As it is, WordPress displays by default <strong>all</strong> the pages/posts in the pages/posts list in the admin area, no matter what their publishing status is. </p> <p>I have a lot of drafts, but usually I'm much more interested in editing the published pages/posts, therefore getting only to display them require...
[ { "answer_id": 94371, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 3, "selected": false, "text": "<p>I'm not sure if there's another way, but manipulating the global variable <code>$submenu</code> can make thi...
2013/03/18
[ "https://wordpress.stackexchange.com/questions/91299", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29096/" ]
As it is, WordPress displays by default **all** the pages/posts in the pages/posts list in the admin area, no matter what their publishing status is. I have a lot of drafts, but usually I'm much more interested in editing the published pages/posts, therefore getting only to display them requires another click and ful...
I'm not sure if there's another way, but manipulating the global variable `$submenu` can make this work. The following is just a manual hack (I'm not aware of any hook) and may fail on non-standard submenus set ups. The regular Post post type has a unique address and the rest of types has another one, hence two `forea...
91,307
<pre><code>function set_copyright_options() { delete_option('ptechsolcopy_notice'); delete_option('ptechsolcopy_reserved'); add_option('ptechsolcopy_notice','Copyright &amp;copy;'); add_option('ptechsolcopy_reserved','All Rights Reserved'); } register_activation_hook(__FILE__, 'set_copyright_options')...
[ { "answer_id": 91310, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 3, "selected": true, "text": "<p>You could make another function with will (re)set the default option values:</p>\n\n<pre><code>function wps...
2013/03/18
[ "https://wordpress.stackexchange.com/questions/91307", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29099/" ]
``` function set_copyright_options() { delete_option('ptechsolcopy_notice'); delete_option('ptechsolcopy_reserved'); add_option('ptechsolcopy_notice','Copyright &copy;'); add_option('ptechsolcopy_reserved','All Rights Reserved'); } register_activation_hook(__FILE__, 'set_copyright_options'); ``` Hi ...
You could make another function with will (re)set the default option values: ``` function wpse_91307_set_option_defaults() { $options = array( 'ptechsolcopy_notice' => 'Copyright &copy;', 'ptechsolcopy_reserved' => 'All Rights Reserved' ); foreach ( $options as $option => $default_value ) { if ( !...
91,330
<p>As the title says, I'd like to restrict back-end access to certain pages for certain users. </p> <p>While doing a site with 45-50 pages, I realised it would be a much better user experience if the Page menu only listed those pages which the user should be able to change/update.</p> <p>I've tried the plugins below ...
[ { "answer_id": 91356, "author": "BoBoz", "author_id": 6179, "author_profile": "https://wordpress.stackexchange.com/users/6179", "pm_score": 4, "selected": true, "text": "<p>This code seems to work well for me (in functions.php): </p>\n\n<pre><code>$user_id = get_current_user_id();\nif ($...
2013/03/18
[ "https://wordpress.stackexchange.com/questions/91330", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6179/" ]
As the title says, I'd like to restrict back-end access to certain pages for certain users. While doing a site with 45-50 pages, I realised it would be a much better user experience if the Page menu only listed those pages which the user should be able to change/update. I've tried the plugins below to no avail. Adva...
This code seems to work well for me (in functions.php): ``` $user_id = get_current_user_id(); if ($user_id == 2) { add_filter( 'parse_query', 'exclude_pages_from_admin' ); } function exclude_pages_from_admin($query) { global $pagenow,$post_type; if (is_admin() && $pagenow=='edit.php' && $post_type =='pag...
91,357
<p>Link images to post.</p> <p>Hi all</p> <p>I'm sure this is simple but I can't see how to do it.</p> <p>I know how to add images to a post - Click in the post, Add Media, choose thumbnail.</p> <p>This gives me an thumbnail in the post. </p> <p>I think what I want to do is link thumbnails to the post so I can con...
[ { "answer_id": 91356, "author": "BoBoz", "author_id": 6179, "author_profile": "https://wordpress.stackexchange.com/users/6179", "pm_score": 4, "selected": true, "text": "<p>This code seems to work well for me (in functions.php): </p>\n\n<pre><code>$user_id = get_current_user_id();\nif ($...
2013/03/18
[ "https://wordpress.stackexchange.com/questions/91357", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17373/" ]
Link images to post. Hi all I'm sure this is simple but I can't see how to do it. I know how to add images to a post - Click in the post, Add Media, choose thumbnail. This gives me an thumbnail in the post. I think what I want to do is link thumbnails to the post so I can control where the thumbnails appear on th...
This code seems to work well for me (in functions.php): ``` $user_id = get_current_user_id(); if ($user_id == 2) { add_filter( 'parse_query', 'exclude_pages_from_admin' ); } function exclude_pages_from_admin($query) { global $pagenow,$post_type; if (is_admin() && $pagenow=='edit.php' && $post_type =='pag...
91,373
<p>I have made a custom image.php for a gallery plugin I'm creating. My dilemma is that I currently have to have my customized image.php in the theme folder for it to work. Is there a way to tell Wordpress to utilize a template file outside of the theme folder to process attachments? </p>
[ { "answer_id": 116094, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>Filter <code>attachment_template</code> and return your custom path. For details, see <code>wp-includes/template.php<...
2013/03/18
[ "https://wordpress.stackexchange.com/questions/91373", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28619/" ]
I have made a custom image.php for a gallery plugin I'm creating. My dilemma is that I currently have to have my customized image.php in the theme folder for it to work. Is there a way to tell Wordpress to utilize a template file outside of the theme folder to process attachments?
Filter `attachment_template` and return your custom path. For details, see `wp-includes/template.php`, function `get_query_template()`. Sample code: ``` add_filter( 'attachment_template', function( $template ) { global $post; // inspect $post object to determine the correct template // and change the fil...
91,387
<p>I'd like to display all posts within a given price range. For example: When a user inputs 100 and 1000 (in two separate form fields) - my site will display all posts that have a custom field called price that has a numeric value between 100 and 1000.</p> <p>Found this under the documentation for WP Query; however, ...
[ { "answer_id": 91416, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 4, "selected": true, "text": "<p>Use the <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\"><code>pre_get_posts</code><...
2013/03/18
[ "https://wordpress.stackexchange.com/questions/91387", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29075/" ]
I'd like to display all posts within a given price range. For example: When a user inputs 100 and 1000 (in two separate form fields) - my site will display all posts that have a custom field called price that has a numeric value between 100 and 1000. Found this under the documentation for WP Query; however, I'm unsure...
Use the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action to detect some filter vars in the URL and filter the query accordingly. For example, say your form sets `price_low` and `price_high` GET vars, so the URL looks like: ``` domain.com/?price_low=100&price_high=1000 ``...
91,402
<p>I'm getting this error with my custom post metabox. The custom post and metabox works fine, but if i have debug on and when i try to save any other page or post, i will get an error:</p> <blockquote> <p>Notice: Undefined index: at_nonce in /Users/jay/site/wp-content/themes/mytheme/dogs-post-type.php on line 5...
[ { "answer_id": 91405, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 0, "selected": false, "text": "<p>at_nonce doesn't exist when saving any other post type - hence the notice. You should only check the nonce if...
2013/03/18
[ "https://wordpress.stackexchange.com/questions/91402", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29138/" ]
I'm getting this error with my custom post metabox. The custom post and metabox works fine, but if i have debug on and when i try to save any other page or post, i will get an error: > > Notice: Undefined index: at\_nonce in > /Users/jay/site/wp-content/themes/mytheme/dogs-post-type.php on line > 53 > > > Notice:...
These are your problem lines: ``` if ( $_POST && !wp_verify_nonce($_POST['at_nonce'], __FILE__) ) { return; } ``` You check to see that `$_POST` is set, but you don't check `$_POST['at_nonce']`. If `$_POST` is set but that key is not then you will get a `Notice`. It is a simple fix: ``` if ( isset($_POST['at_no...
91,410
<p>I figured out I can filter posts by format just by doing /type/{format} e.g. /type/gallery/ in the url.</p> <p>Looking for a way to filter by categories on top of this, something like /type/gallery/category/installation or /type/gallery/art. </p> <p>I've figured out the query, but I don't know how to handle the ur...
[ { "answer_id": 91996, "author": "Pat", "author_id": 12920, "author_profile": "https://wordpress.stackexchange.com/users/12920", "pm_score": 1, "selected": false, "text": "<p>I am doing something similar, but for member pages. I was able to use the code in my answer linked here which pars...
2013/03/19
[ "https://wordpress.stackexchange.com/questions/91410", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4258/" ]
I figured out I can filter posts by format just by doing /type/{format} e.g. /type/gallery/ in the url. Looking for a way to filter by categories on top of this, something like /type/gallery/category/installation or /type/gallery/art. I've figured out the query, but I don't know how to handle the url bit: ``` $gall...
I ended up with this: ``` function when_rewrite_rules( $wp_rewrite ) { $newrules = array(); $new_rules['type/([^/]+)/category/([^/]+)/?$'] = 'index.php?post_format=$matches[1]&category_name=$matches[2]'; $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_filter('generate_rewrite_rules','when_rewrite_rul...
91,411
<p>I have a page on my site that is not a page in WordPress. How can I add it to the header?</p> <p>EDIT: The page is .php. It is outside of the theme structure.</p>
[ { "answer_id": 91996, "author": "Pat", "author_id": 12920, "author_profile": "https://wordpress.stackexchange.com/users/12920", "pm_score": 1, "selected": false, "text": "<p>I am doing something similar, but for member pages. I was able to use the code in my answer linked here which pars...
2013/03/19
[ "https://wordpress.stackexchange.com/questions/91411", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17824/" ]
I have a page on my site that is not a page in WordPress. How can I add it to the header? EDIT: The page is .php. It is outside of the theme structure.
I ended up with this: ``` function when_rewrite_rules( $wp_rewrite ) { $newrules = array(); $new_rules['type/([^/]+)/category/([^/]+)/?$'] = 'index.php?post_format=$matches[1]&category_name=$matches[2]'; $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_filter('generate_rewrite_rules','when_rewrite_rul...
91,439
<p>I'm trying to put my frontend form into a variable or a shortcode so I can wrap another shortcode around it (specifically <a href="http://wordpress.org/support/plugin/bainternet-posts-creation-limits" rel="nofollow">Bainternet Post Creation Limits</a>).</p> <p>My form has PHP code in it so I'm not exactly sure how ...
[ { "answer_id": 91441, "author": "Mike Madern", "author_id": 24806, "author_profile": "https://wordpress.stackexchange.com/users/24806", "pm_score": 0, "selected": false, "text": "<p>I made such a script for our own company.</p>\n\n<p><strong>My case:</strong></p>\n\n<p>I needed a script ...
2013/03/19
[ "https://wordpress.stackexchange.com/questions/91439", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7408/" ]
I'm trying to put my frontend form into a variable or a shortcode so I can wrap another shortcode around it (specifically [Bainternet Post Creation Limits](http://wordpress.org/support/plugin/bainternet-posts-creation-limits)). My form has PHP code in it so I'm not exactly sure how to do this. I have tried creating ot...
Fetching the data ================= To fetch your posts, you'd utilize the [`HTTP_API`](http://codex.wordpress.org/HTTP_API), [`fetch_feed()`](http://codex.wordpress.org/Function_Reference/fetch_feed) or [SimplePie](http://simplepie.org/wiki/plugins/start). This completely depends on how and from where you're going to...
91,455
<p>I am writing a widget who's form elements have a click event attached to. I bind it using jQuery.</p> <p>However, after clicking <code>save</code>, the bindings gets lost. That is, clicking those elements doesn't trigger the function anymore. </p> <p>I tried using the <code>on()</code> jQuery method, as suggested ...
[ { "answer_id": 92462, "author": "Lea Cohen", "author_id": 373, "author_profile": "https://wordpress.stackexchange.com/users/373", "pm_score": 1, "selected": true, "text": "<p>Because the input box is getting rebuilt (or the entire form), I followed advice given me elsewhere, and instead ...
2013/03/19
[ "https://wordpress.stackexchange.com/questions/91455", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/373/" ]
I am writing a widget who's form elements have a click event attached to. I bind it using jQuery. However, after clicking `save`, the bindings gets lost. That is, clicking those elements doesn't trigger the function anymore. I tried using the `on()` jQuery method, as suggested [here](https://wordpress.stackexchange....
Because the input box is getting rebuilt (or the entire form), I followed advice given me elsewhere, and instead of binding on() to an input box, I bind it higher up and use event delegation: ``` jQuery('#widgets-right').on('click','.icon_buttons input',function(){ openPanel(jQuery(this),jQuery(this).index()); }...
91,468
<p>I have a CPT that I want to list the post in the frontend of my website, so i've created a page that I assigned a template so i'll be able to modify the way it look. </p> <p>Here is my template declaration :</p> <pre><code>/* Template Name: Book's author */ </code></pre> <p>Further I have my loop. In my wp-ad...
[ { "answer_id": 91472, "author": "Dan Ștefancu", "author_id": 20950, "author_profile": "https://wordpress.stackexchange.com/users/20950", "pm_score": 0, "selected": false, "text": "<p>Set in options » reading that page as static frontpage. Also, read more about template hierarchy on codex...
2013/03/19
[ "https://wordpress.stackexchange.com/questions/91468", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10501/" ]
I have a CPT that I want to list the post in the frontend of my website, so i've created a page that I assigned a template so i'll be able to modify the way it look. Here is my template declaration : ``` /* Template Name: Book's author */ ``` Further I have my loop. In my wp-admin under page i've changed the t...
What you are doing, if I understand correctly, is overly complicated, is a bit of a hack around the Core functionality of CPTs, and is probably less efficient than letting the Core handle it. WordPress will generate an index listing for your post type if you register it appropriately. That is, if you [register it](htt...
91,478
<p>I'd like to setup:</p> <pre><code>www.mydomain.com/a-page/ www.mydomain.com/blog/category_name/ www.mydomain.com/blog/category_name/post_name/ www.mydomain.com/custom_post/post_name/ </code></pre> <p>How would I do it? Thanks in advance</p>
[ { "answer_id": 91479, "author": "Andrew Hendrie", "author_id": 29075, "author_profile": "https://wordpress.stackexchange.com/users/29075", "pm_score": 0, "selected": false, "text": "<p>In your WordPress dashboard, go to Settings / Permalinks. Click custom structure, and leave /%post-name...
2013/03/19
[ "https://wordpress.stackexchange.com/questions/91478", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29166/" ]
I'd like to setup: ``` www.mydomain.com/a-page/ www.mydomain.com/blog/category_name/ www.mydomain.com/blog/category_name/post_name/ www.mydomain.com/custom_post/post_name/ ``` How would I do it? Thanks in advance
In Options » Permalinks just add a base for post permastruct. Ex: `/blog/%postname%/`. Make sure that your custom post types are registered with `'with_front'` => `false` in rewrite argument. See: <http://codex.wordpress.org/Function_Reference/register_post_type>
91,496
<p>I need to get video and content from recent posts in specific category called "Video" and show it on my sidebar.</p> <p>The problem is when I need to have limited text content. so, when I use <code>the_content();</code> I can see video within sidebar, but when I use <code>the_excerpt();</code> to limit text, video ...
[ { "answer_id": 96585, "author": "5wpthemes", "author_id": 31815, "author_profile": "https://wordpress.stackexchange.com/users/31815", "pm_score": 0, "selected": false, "text": "<p>In youy loop just past this snippet of code.</p>\n\n<pre><code>&lt;?php query_posts('cat=6&amp;showposts=2')...
2013/03/19
[ "https://wordpress.stackexchange.com/questions/91496", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29174/" ]
I need to get video and content from recent posts in specific category called "Video" and show it on my sidebar. The problem is when I need to have limited text content. so, when I use `the_content();` I can see video within sidebar, but when I use `the_excerpt();` to limit text, video is gone. The code I have is doi...
If you're video embeds are always the same, I like the solution proposed by 5wpthemes, but if you want to avoid having to use a custom field ( and more specifically, remembering to do it), you could also try the code below ( which also requires the code to be very similar in every post ). ``` <?php $my_query = new WP ...
91,506
<p>I strongly need to edit some parts of the comments left by the users, I want to add a link to the commenter's author.php page if he/she is a registered user by placing a text link somewhere next to his/her name. I've this code <code>&lt;?php wp_list_comments(); ?&gt;</code> but I wonder if it's possible to have the ...
[ { "answer_id": 91518, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 0, "selected": false, "text": "<p>the function <a href=\"http://codex.wordpress.org/Function_Reference/wp_list_comments\" rel=\"nofollow\"><code>w...
2013/03/19
[ "https://wordpress.stackexchange.com/questions/91506", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27309/" ]
I strongly need to edit some parts of the comments left by the users, I want to add a link to the commenter's author.php page if he/she is a registered user by placing a text link somewhere next to his/her name. I've this code `<?php wp_list_comments(); ?>` but I wonder if it's possible to have the full code instead to...
This function replaces the comment author's link with the comment author's profile page, if the comment author is a registered user. Otherwise, the standard WordPress comment author link is displayed. This function is not mine and [has been found googling](http://forum.graphene-theme.com/graphene-support/comment-autho...
91,511
<p>I have this in my functions.php</p> <pre><code>function remove_quick_edit( $actions ) { unset($actions['inline hide-if-no-js']); return $actions; } add_filter('post_row_actions','remove_quick_edit',10,1); </code></pre> <p>to remove the quick edit link in the backend when scrolling the list of published pos...
[ { "answer_id": 91526, "author": "jfacemyer", "author_id": 12660, "author_profile": "https://wordpress.stackexchange.com/users/12660", "pm_score": 5, "selected": true, "text": "<p>Use <code>current_user_can</code> to wrap the <code>add_filter</code> call:</p>\n\n<pre><code>if ( current_us...
2013/03/19
[ "https://wordpress.stackexchange.com/questions/91511", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27309/" ]
I have this in my functions.php ``` function remove_quick_edit( $actions ) { unset($actions['inline hide-if-no-js']); return $actions; } add_filter('post_row_actions','remove_quick_edit',10,1); ``` to remove the quick edit link in the backend when scrolling the list of published posts. It works like a charm...
Use `current_user_can` to wrap the `add_filter` call: ``` if ( current_user_can('manage_options') ) { } else { add_filter('post_row_actions','remove_quick_edit',10,1); } ``` `manage_options` is an Admin capability. If the current user can do it, he's an admin (on a vanilla WP installation). See: <http://codex....