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
131,952
<p>I am pretty new in WordPress theme development and I have some doubt about this WP function used to show my post in the homepage:</p> <pre><code> &lt;?php if ( have_posts() ) : // Start the Loop. while ( have_posts() ) : the_post(); /* * Include t...
[ { "answer_id": 131953, "author": "Manolo", "author_id": 36778, "author_profile": "https://wordpress.stackexchange.com/users/36778", "pm_score": 3, "selected": true, "text": "<p><code>get_template_part()</code> is including a template file from the active theme directory. </p>\n\n<p>For e...
2014/01/31
[ "https://wordpress.stackexchange.com/questions/131952", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29275/" ]
I am pretty new in WordPress theme development and I have some doubt about this WP function used to show my post in the homepage: ``` <?php if ( have_posts() ) : // Start the Loop. while ( have_posts() ) : the_post(); /* * Include the post format-sp...
`get_template_part()` is including a template file from the active theme directory. For example: `get_template_part('content')` will include the template `content.php` from the theme folder. When having two parameters, it will search for a template named `firstParameter-secondParameter.php`. So: ``` get_template_...
131,955
<p>I am trying to add a filter for get_avatar so I could implement an avatar alignment but when I do, I received <strong>expected 'add_filter' (T_STRING</strong></p> <p>First Approach</p> <pre><code>add_filter('get_avatar', 'remove_photo_class'); function remove_photo_class($avatar) { return str_replace(' avatar',...
[ { "answer_id": 131966, "author": "Chittaranjan", "author_id": 43031, "author_profile": "https://wordpress.stackexchange.com/users/43031", "pm_score": 0, "selected": false, "text": "<p>You can not directly put the <code>add_filter</code> hook inside a class. Considering 1st approach, put ...
2014/01/31
[ "https://wordpress.stackexchange.com/questions/131955", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44422/" ]
I am trying to add a filter for get\_avatar so I could implement an avatar alignment but when I do, I received **expected 'add\_filter' (T\_STRING** First Approach ``` add_filter('get_avatar', 'remove_photo_class'); function remove_photo_class($avatar) { return str_replace(' avatar', $image_align , $avatar); } ``...
You are dealing with a class. Most everything has to be inside a class method, not counting class variables/constants. Second, you the syntax is slightly different when adding a class method, rather than a function, to a hook. ``` function widget( $args, $instance ) { add_filter('get_avatar', array($this,'remove_...
131,967
<p>I am using this template: <a href="http://demo.undsgn.com/studiofolio/front-page/" rel="nofollow noreferrer">http://demo.undsgn.com/studiofolio/front-page/</a></p> <p>I tried to make some modifications because I need the homepage template to display an excerpt beneath each thumbnail. I copied the template called <c...
[ { "answer_id": 131985, "author": "Matthieu", "author_id": 43179, "author_profile": "https://wordpress.stackexchange.com/users/43179", "pm_score": 0, "selected": false, "text": "<p>If you want to select both template, you should use OR and not AND operator</p>\n\n<pre><code>$querystr = \"...
2014/01/31
[ "https://wordpress.stackexchange.com/questions/131967", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45966/" ]
I am using this template: <http://demo.undsgn.com/studiofolio/front-page/> I tried to make some modifications because I need the homepage template to display an excerpt beneath each thumbnail. I copied the template called `front-page.php`, renamed it to `front-page-excerpt.php` and made my modifications and it worked....
No idea why you're using clunky custom SQL, use a [meta query](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters) instead. ``` $pageposts = get_posts( array( 'posts_per_page' => -1, 'post_type' => 'page', 'post_status' => 'publish', 'meta_query' ...
131,997
<p>I use get_posts() to generate a menu of posts having the current page as the parent. This causes the post_id to be set to the first such post, instead of the original page's post_id. I.e. I want Wordpress to continue as if nothing happened after the query.</p> <p>This is the code I use in sidebar.php:</p> <pre><co...
[ { "answer_id": 131999, "author": "Shellbot", "author_id": 108, "author_profile": "https://wordpress.stackexchange.com/users/108", "pm_score": 0, "selected": false, "text": "<p>You need to reset the query after your if statement.</p>\n\n<p><code>&lt;?php wp_reset_postdata(); ?&gt;</code><...
2014/01/31
[ "https://wordpress.stackexchange.com/questions/131997", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24829/" ]
I use get\_posts() to generate a menu of posts having the current page as the parent. This causes the post\_id to be set to the first such post, instead of the original page's post\_id. I.e. I want Wordpress to continue as if nothing happened after the query. This is the code I use in sidebar.php: ``` $args = array( ...
the use of `$posts` might be interfering; try to change that to something else like `$menu_posts` or similar.
132,026
<p>I have this php function in xampp server using php 5.5, using a live server with php 5.3 I get no error. The error says</p> <blockquote> <p>Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\xampp\htdocs\wordpresstest\wp-content\plugins\Monetizer_Pro_Monetizer\Monet...
[ { "answer_id": 132029, "author": "stefano", "author_id": 23713, "author_profile": "https://wordpress.stackexchange.com/users/23713", "pm_score": 2, "selected": false, "text": "<p>I tried to run your code. The first trivial guess is that the curl operation</p>\n\n<pre><code>$response = cu...
2014/01/31
[ "https://wordpress.stackexchange.com/questions/132026", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44790/" ]
I have this php function in xampp server using php 5.5, using a live server with php 5.3 I get no error. The error says > > Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\xampp\htdocs\wordpresstest\wp-content\plugins\Monetizer\_Pro\_Monetizer\Monetizer.php:910 > ...
Andrew: As already mentioned, your curl call seems to be returning FALSE. It also appears than when you try to create a SimpleXML element with a boolean FALSE that it throws the exception you are seeing. I have also had problems accessing APIs via curl when on my localhost. I was able to solve it by adding this code: ...
132,027
<p>Using WP 3.8.1, I have a <code>Custom Post Type</code> which is called "<strong>Sport</strong>" and it has a Metdabox - medata data as <img src="https://i.stack.imgur.com/5u9Uh.png" alt="enter image description here"></p> <p>I do not need to set up online shopping but I world like to add Price of my products to an...
[ { "answer_id": 132028, "author": "gdaniel", "author_id": 30984, "author_profile": "https://wordpress.stackexchange.com/users/30984", "pm_score": 1, "selected": true, "text": "<p>You should focus on getting it to save first. </p>\n\n<p>There are endless amount of tutorials online on how t...
2014/01/31
[ "https://wordpress.stackexchange.com/questions/132027", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/42988/" ]
Using WP 3.8.1, I have a `Custom Post Type` which is called "**Sport**" and it has a Metdabox - medata data as ![enter image description here](https://i.stack.imgur.com/5u9Uh.png) I do not need to set up online shopping but I world like to add Price of my products to any Sport CPT and enable updating the Price in the...
You should focus on getting it to save first. There are endless amount of tutorials online on how to do it, but I would recommend using a plugin called Advanced Custom Fields. That let's you create custom fields in specific pages/posts, without writing any code. This plugin also provides you with functions to use on ...
132,063
<p>Using WordPress 3.8.1, I have a Custom post Type called "Map" and it contains a Metadata which is a Select options element as:</p> <pre><code>&lt;label for="my_meta_box_select"&gt;Countries&lt;/label&gt; &lt;select name="my_meta_box_select" id="my_meta_box_select"&gt; &lt;option value="asia" &lt;?php selected( $sel...
[ { "answer_id": 132077, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>You are trying to make sure that data is safe, but not validate it - that is make sure it is both safe and meaningf...
2014/02/01
[ "https://wordpress.stackexchange.com/questions/132063", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/42988/" ]
Using WordPress 3.8.1, I have a Custom post Type called "Map" and it contains a Metadata which is a Select options element as: ``` <label for="my_meta_box_select">Countries</label> <select name="my_meta_box_select" id="my_meta_box_select"> <option value="asia" <?php selected( $selected, 'asia' ); ?>>Asia</option> <opt...
You should scape data when displaying it, not when saving. To sanitize, I think the best choice in this case is [sanitize\_text\_field()](http://codex.wordpress.org/Function_Reference/sanitize_text_field) ``` if( isset( $_POST['my_meta_box_select'] ) ) { update_post_meta( $post_id, 'my_meta_box_select', sanitize_t...
132,064
<p>How can I do a query to return the post if the custom field array contains a date that is within the specified range? The query below is basically what I am after but it does not work...</p> <pre><code>// the income_dates array looks like this // a:3:{i:0;s:10:"2014-02-01";i:1;s:10:"2014-03-01";i:2;s:10:"2014-03-29...
[ { "answer_id": 132072, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 2, "selected": false, "text": "<p>I suggest don't store the meta values as <code>array</code> because (I think) is not what you need. I think y...
2014/02/01
[ "https://wordpress.stackexchange.com/questions/132064", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11827/" ]
How can I do a query to return the post if the custom field array contains a date that is within the specified range? The query below is basically what I am after but it does not work... ``` // the income_dates array looks like this // a:3:{i:0;s:10:"2014-02-01";i:1;s:10:"2014-03-01";i:2;s:10:"2014-03-29";} $today = ...
I suggest don't store the meta values as `array` because (I think) is not what you need. I think you really need to store each meta value individually with its own pair of key/value and not a single key with a serialized values. When done in this way, you can use the `BETWEEN` comparison: ``` $today = date("Y-m-d"); /...
132,066
<p>I have a Custom Post Type with a Metabox and an input Text field for adding "Price" to the posts. Now I would like to display the input value which can be like 49 or 59 like 49.00 or 59.00 so far I have this code to output the meta as:</p> <pre><code>$meta = get_post_custom($post-&gt;ID); echo '&lt;h5&gt; $'.$meta[...
[ { "answer_id": 132067, "author": "Rahil Wazir", "author_id": 36349, "author_profile": "https://wordpress.stackexchange.com/users/36349", "pm_score": 0, "selected": false, "text": "<p>You should use the php <a href=\"http://pk1.php.net/number_format\" rel=\"nofollow\">number_format</a> fu...
2014/02/01
[ "https://wordpress.stackexchange.com/questions/132066", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31793/" ]
I have a Custom Post Type with a Metabox and an input Text field for adding "Price" to the posts. Now I would like to display the input value which can be like 49 or 59 like 49.00 or 59.00 so far I have this code to output the meta as: ``` $meta = get_post_custom($post->ID); echo '<h5> $'.$meta['price'][0].'/h5'; ```...
WordPress core has [`number_format_i18n()`](http://queryposts.com/function/number_format_i18n/) function, which allows to set number of decimal digits and apploes appropriate formatting in line with site's locale. However note that it is not specific to *money* and there can be more peculiar requirements to handle suc...
132,088
<p>In the administration of my blog, I would like to prevent anyone (admin included) from deleting any user unless it is a simple subscriber.</p> <p>Basicaly, in the "users" section of the administration, I would like the option "delete" to only be visible under the subscribers, not under the administrators, editors, ...
[ { "answer_id": 132091, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 4, "selected": true, "text": "<p>If you mean the delete button on the user list at <code>/wp-admin/users.php</code>, then that button is creat...
2014/02/01
[ "https://wordpress.stackexchange.com/questions/132088", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22755/" ]
In the administration of my blog, I would like to prevent anyone (admin included) from deleting any user unless it is a simple subscriber. Basicaly, in the "users" section of the administration, I would like the option "delete" to only be visible under the subscribers, not under the administrators, editors, authors or...
If you mean the delete button on the user list at `/wp-admin/users.php`, then that button is created by the `WP_Users_List_Table` class [around (currently) line 256](https://core.trac.wordpress.org/browser/tags/3.8.1/src/wp-admin/includes/class-wp-users-list-table.php#L256). If you look a little further down-- a few li...
132,101
<p>I'm trying to get "string of text: Edit"</p> <p><code>&lt;?php echo 'string of text: ' . edit_post_link( 'Edit' ); ?&gt;</code></p> <p>but this outputs "Edit string of text:"</p> <p>How do I make it appear in the correct order? "string of text: Edit"</p>
[ { "answer_id": 132103, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": false, "text": "<p>Use the second parameter of <a href=\"http://codex.wordpress.org/Function_Reference/edit_post_link\" rel=\"nofollow\"...
2014/02/01
[ "https://wordpress.stackexchange.com/questions/132101", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19758/" ]
I'm trying to get "string of text: Edit" `<?php echo 'string of text: ' . edit_post_link( 'Edit' ); ?>` but this outputs "Edit string of text:" How do I make it appear in the correct order? "string of text: Edit"
Use the second parameter of [`edit_post_link()`](http://codex.wordpress.org/Function_Reference/edit_post_link), the `before` parameter: ``` <?php edit_post_link( 'Edit', 'string of text: ' ); ?> ```
132,109
<p>I was searching in documentation and online but it never mensioned anywhere. I want to add custom activity scope.</p> <p>For example here are: All members, My friends, My groups, My favorites, Mensions.</p> <p><a href="http://s020.radikal.ru/i720/1402/03/bfc6b5c9a3ba.png" rel="nofollow">http://s020.radikal.ru/i720...
[ { "answer_id": 134744, "author": "Domain", "author_id": 26523, "author_profile": "https://wordpress.stackexchange.com/users/26523", "pm_score": 0, "selected": false, "text": "<pre><code>// Set up Cutsom BP navigation\nfunction my_setup_nav() {\n global $bp;\n\n //Add new Menu I...
2014/02/01
[ "https://wordpress.stackexchange.com/questions/132109", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29076/" ]
I was searching in documentation and online but it never mensioned anywhere. I want to add custom activity scope. For example here are: All members, My friends, My groups, My favorites, Mensions. <http://s020.radikal.ru/i720/1402/03/bfc6b5c9a3ba.png> Like here, on profile I see "personal, Mensions, Favorite". this is...
What you want is something like the below class, provided in a gist by @boone-gorges. The code is for extending the groups stream with some tabs matching groupmeta. **Code:** ``` /** * This is a quick and dirty class to work around the fact that bp_has_groups() does not have a * meta_query parameter (or even an 'in' ...
132,128
<p>I'm working on my first theme, and I found out that I had to call <code>wp_header()</code> before <code>&lt;/head&gt;</code>.</p> <p>My header.php file has this:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;?php bloginfo('name'); ?&gt; | &lt;?php the_title(); ?&gt;&lt...
[ { "answer_id": 132135, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 3, "selected": true, "text": "<p>That \"extra stuff\" is for the Admin Bar. If it's messing up your layout, then you should correct the layout so th...
2014/02/01
[ "https://wordpress.stackexchange.com/questions/132128", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45358/" ]
I'm working on my first theme, and I found out that I had to call `wp_header()` before `</head>`. My header.php file has this: ``` <!DOCTYPE html> <html> <head> <title><?php bloginfo('name'); ?> | <?php the_title(); ?></title> <meta content='text/html;charset=utf-8' http-equiv='Content-Type'> ...
That "extra stuff" is for the Admin Bar. If it's messing up your layout, then you should correct the layout so that it doesn't mess it up.
132,148
<p>I'm using <strong>WooCommerce</strong> for a site that I'm currently working on. And I'm creating it for a language other than English. I do the translations by means of the <code>.po</code> file.</p> <p>The issue that I'm encountering is in the <strong>Checkout page</strong>. There is a table of <strong>order revi...
[ { "answer_id": 133358, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 3, "selected": false, "text": "<p>You have differents languages in your site, although your frontend is not multilingual, you serve one languag...
2014/02/02
[ "https://wordpress.stackexchange.com/questions/132148", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1044/" ]
I'm using **WooCommerce** for a site that I'm currently working on. And I'm creating it for a language other than English. I do the translations by means of the `.po` file. The issue that I'm encountering is in the **Checkout page**. There is a table of **order review** which upon page loaded seems to be refreshed by ...
I think I fixed the issue with the following extended function in my plugin: ``` function localize_backend( $locale ) { // set langauge if user is in admin area if( defined( 'WP_ADMIN' ) || ( isset( $_REQUEST['pwd'] ) && isset( $_REQUEST['kau-boys_backend_localization_language'] ) ) ){ // ajax call fro...
132,149
<p>I have a Genesis child theme that I bought, and it only supports two menus, a primary and a secondary. However, for what I would like to do with my site I need to have 6 menus all together. </p> <p>This is my website <a href="http://thenottypicalarmywife.com" rel="nofollow">http://thenottypicalarmywife.com</a></p> ...
[ { "answer_id": 132150, "author": "WordPress Mike", "author_id": 33921, "author_profile": "https://wordpress.stackexchange.com/users/33921", "pm_score": 0, "selected": false, "text": "<p>Create your menus in the admin, then use <code>&lt;?php wp_nav_menu( array('menu' =&gt; 'Menu Name' ))...
2014/02/02
[ "https://wordpress.stackexchange.com/questions/132149", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/46032/" ]
I have a Genesis child theme that I bought, and it only supports two menus, a primary and a secondary. However, for what I would like to do with my site I need to have 6 menus all together. This is my website <http://thenottypicalarmywife.com> This is what I want the menus to look like <http://livingwellspendingless...
Here's 2 options: **First:** The code goes in your child themes functions file and creates one extra menu which displays in the genesis\_after\_header position. There are 2 steps needed to add new nav menus. **One.** [Register the menu(s) using the init action hook NOT after\_theme\_setup](http://codex.wordpress.or...
132,158
<p>I'm trying to add Chosen.jquery to the WP Customize options panel, so I can have an autocomplete box there. Is there any way I can do that? I tried with <strong>admin_init</strong>, <strong>admin_footer</strong> and <strong>admin_print_footer_scripts</strong> actions, but none seems to work inside of the Customizer....
[ { "answer_id": 132150, "author": "WordPress Mike", "author_id": 33921, "author_profile": "https://wordpress.stackexchange.com/users/33921", "pm_score": 0, "selected": false, "text": "<p>Create your menus in the admin, then use <code>&lt;?php wp_nav_menu( array('menu' =&gt; 'Menu Name' ))...
2014/02/02
[ "https://wordpress.stackexchange.com/questions/132158", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/46037/" ]
I'm trying to add Chosen.jquery to the WP Customize options panel, so I can have an autocomplete box there. Is there any way I can do that? I tried with **admin\_init**, **admin\_footer** and **admin\_print\_footer\_scripts** actions, but none seems to work inside of the Customizer. Any thoughts?
Here's 2 options: **First:** The code goes in your child themes functions file and creates one extra menu which displays in the genesis\_after\_header position. There are 2 steps needed to add new nav menus. **One.** [Register the menu(s) using the init action hook NOT after\_theme\_setup](http://codex.wordpress.or...
132,170
<p>I'm using WP_Query to create 'latest posts' &amp; 'popular posts' sections on my home page. I'm trying to just pull 5 posts from 2 categories (9 &amp; 11) but it will only show posts from cat 9.</p> <p>Here's the php I'm using for 'latest posts'- </p> <pre><code>&lt;ul&gt; &lt;?php $cat = array(9...
[ { "answer_id": 132183, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 2, "selected": false, "text": "<p>According to the <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters\" r...
2014/02/02
[ "https://wordpress.stackexchange.com/questions/132170", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/46039/" ]
I'm using WP\_Query to create 'latest posts' & 'popular posts' sections on my home page. I'm trying to just pull 5 posts from 2 categories (9 & 11) but it will only show posts from cat 9. Here's the php I'm using for 'latest posts'- ``` <ul> <?php $cat = array(9,11); $showposts = 5; ...
According to the [Codex](http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters): > > **Show Posts From Several Categories** (Display posts that have these categories, using category id) would be: > > > `$query = new WP_Query( 'cat=9,11' );` > > > And, the Codex's Pagination Parameters says tha...
132,221
<p>I want to get all the posts for which the post_name(slug) is not set/empty as well as a meta_key does not exist.</p> <pre><code>$args = array ( 'post_type' =&gt; 'books', 'name' =&gt; '', 'post_status' =&gt; array('publish, draft'), 'posts_per_page' ...
[ { "answer_id": 132183, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 2, "selected": false, "text": "<p>According to the <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters\" r...
2014/02/03
[ "https://wordpress.stackexchange.com/questions/132221", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33249/" ]
I want to get all the posts for which the post\_name(slug) is not set/empty as well as a meta\_key does not exist. ``` $args = array ( 'post_type' => 'books', 'name' => '', 'post_status' => array('publish, draft'), 'posts_per_page' => -1, 'meta_quer...
According to the [Codex](http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters): > > **Show Posts From Several Categories** (Display posts that have these categories, using category id) would be: > > > `$query = new WP_Query( 'cat=9,11' );` > > > And, the Codex's Pagination Parameters says tha...
132,262
<p>I've created two administrator users X and Y. And now I need to remove capability of 'edit_plugins' from user Y.</p> <p>I've searched and found, <a href="http://goo.gl/LttuvX" rel="nofollow">http://goo.gl/LttuvX</a></p> <pre><code>$user = new WP_User( 'Y' ); $user-&gt;remove_cap('edit_plugins'); </code></pre> <p>...
[ { "answer_id": 132264, "author": "Brad Dalton", "author_id": 9884, "author_profile": "https://wordpress.stackexchange.com/users/9884", "pm_score": 0, "selected": false, "text": "<p>Try this by replacing the user@email.com </p>\n\n<pre><code>add_action('init', 'remove_specific_admin_cap')...
2014/02/03
[ "https://wordpress.stackexchange.com/questions/132262", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44168/" ]
I've created two administrator users X and Y. And now I need to remove capability of 'edit\_plugins' from user Y. I've searched and found, <http://goo.gl/LttuvX> ``` $user = new WP_User( 'Y' ); $user->remove_cap('edit_plugins'); ``` But it is not working please let me know how to do it. Previously I've created new...
If you want to specifically deny a capability from a user (not a role), you need to use the [`add_cap()`](https://developer.wordpress.org/reference/classes/wp_user/add_cap/) method and specify that the `$grant` parameter is false. ``` $user = new WP_User( 'Y' ); $user->add_cap( 'edit_plugins', false ); ```
132,288
<p>Anyone know of a way to trick WordPress into doing a header location redirect. I have to check whether users are logged in or not, and if not redirect them to our organizations authorization system which is an external site.</p> <p>I am getting output before my header() call, from WordPress outputting the queued sc...
[ { "answer_id": 132291, "author": "David", "author_id": 13037, "author_profile": "https://wordpress.stackexchange.com/users/13037", "pm_score": 1, "selected": false, "text": "<p>The primary issue you are most likely encountering is not calling your function soon enough in the WP load proc...
2014/02/03
[ "https://wordpress.stackexchange.com/questions/132288", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35090/" ]
Anyone know of a way to trick WordPress into doing a header location redirect. I have to check whether users are logged in or not, and if not redirect them to our organizations authorization system which is an external site. I am getting output before my header() call, from WordPress outputting the queued scripts. ``...
Your method is called too late. I don't know how you call this method but you need to run it ***before*** output is sent to the browser-- usually that means before `get_header()`. There are a number of hooks that can be used. For example (from <https://wordpress.stackexchange.com/a/131210/21376>): ``` add_action( 't...
132,293
<p>I'm trying to figure out the best way to go about this and I have part of my solution, but I can't figure out all of it.</p> <p>My ultimate goal is within a certain page template, to show the newest post from a CPT of a particular taxonomy, this seems to be the easiest and accomplished with this:</p> <pre><code>$a...
[ { "answer_id": 132294, "author": "David", "author_id": 13037, "author_profile": "https://wordpress.stackexchange.com/users/13037", "pm_score": 3, "selected": true, "text": "<p>This will most likely require two loops to the best of my knowledge. The second loop just needs to know to exclu...
2014/02/03
[ "https://wordpress.stackexchange.com/questions/132293", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5295/" ]
I'm trying to figure out the best way to go about this and I have part of my solution, but I can't figure out all of it. My ultimate goal is within a certain page template, to show the newest post from a CPT of a particular taxonomy, this seems to be the easiest and accomplished with this: ``` $args=array( 'post_...
This will most likely require two loops to the best of my knowledge. The second loop just needs to know to exclude the post you just queried. Something like the following should do the trick. ``` $first_id = 5; // This should be set in the previous loop to the post ID of the post returned by your first query. $args2 =...
132,307
<p>I'd like to have the content of the current single post loaded into the og:description meta property - but the <code>'. $content .'</code> doesn't output anything?</p> <p>This is what's in my header.php</p> <pre><code>if (is_single()) { $content = get_the_content(); $desc='&lt;meta property="og:description" conte...
[ { "answer_id": 132309, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 2, "selected": false, "text": "<p>See the codex page for <a href=\"http://codex.wordpress.org/Function_Reference/get_the_content\" re...
2014/02/03
[ "https://wordpress.stackexchange.com/questions/132307", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/30939/" ]
I'd like to have the content of the current single post loaded into the og:description meta property - but the `'. $content .'` doesn't output anything? This is what's in my header.php ``` if (is_single()) { $content = get_the_content(); $desc='<meta property="og:description" content="'. $content .'" />'; echo $desc...
`get_the_content()` must be inside [the loop](http://codex.wordpress.org/The_Loop), in header.php you can do this (don't forget to scape the content to use it as attribute): ``` if (is_single()) { while (have_posts()) { the_post(); $content = get_the_content(); $desc='<meta property="og:de...
132,325
<p>Which one is correct when adding actions/filters/etc.... Both methods work fine and I've seen people do things both ways, but I'm assuming one is correct. My gut tells me that wrapping the if statement around the action only is better but I'm not sure...</p> <p>Method A: Wrapping <code>if</code> around <code>add_ac...
[ { "answer_id": 132329, "author": "tfrommen", "author_id": 27722, "author_profile": "https://wordpress.stackexchange.com/users/27722", "pm_score": 4, "selected": true, "text": "<p>There is no real difference between the two methods.<br>\nWhen using method A, only the <strong>hooking</stro...
2014/02/03
[ "https://wordpress.stackexchange.com/questions/132325", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38123/" ]
Which one is correct when adding actions/filters/etc.... Both methods work fine and I've seen people do things both ways, but I'm assuming one is correct. My gut tells me that wrapping the if statement around the action only is better but I'm not sure... Method A: Wrapping `if` around `add_action`: ``` function unreg...
There is no real difference between the two methods. When using method A, only the **hooking** is bound to the condition (i.e., the function is defined no matter what), while in method B the **definition** of the function as well as the **hooking** is. Another thing is the following method (which you did not includ...
132,328
<p>I have successfully been using jpanelmenu in my wordpress themes for some time, loading jquery from the google api, like this:</p> <pre><code>if ( !is_admin() ) { // jQuery wp_deregister_script('jquery'); wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"), ...
[ { "answer_id": 132332, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 2, "selected": true, "text": "<p>To use the WordPress-bundled version, simply stop de-registering it and replacing it with the Google vers...
2014/02/03
[ "https://wordpress.stackexchange.com/questions/132328", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36242/" ]
I have successfully been using jpanelmenu in my wordpress themes for some time, loading jquery from the google api, like this: ``` if ( !is_admin() ) { // jQuery wp_deregister_script('jquery'); wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"), false); wp...
To use the WordPress-bundled version, simply stop de-registering it and replacing it with the Google version. ``` function wpa_132328_enqueue_scripts(){ if ( !is_admin() ) { // jQuery wp_enqueue_script('jquery'); // load jPanelMenu wp_enqueue_script('jpanelmenu', get_bloginfo('tem...
133,408
<p>I am using the following code to display pages on one page and would like to trim the content of each page on this display to 50 words and include images that are attached to the page. How do I go about doing this?</p> <pre><code> $args = array( 'post_type' =&gt; 'page', 'post_parent' =&gt...
[ { "answer_id": 133377, "author": "Towfiq", "author_id": 1905, "author_profile": "https://wordpress.stackexchange.com/users/1905", "pm_score": 1, "selected": true, "text": "<p>yes you can simply do all these with this plugin:\n<a href=\"http://wordpress.org/plugins/easy-digital-downloads/...
2014/02/04
[ "https://wordpress.stackexchange.com/questions/133408", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5416/" ]
I am using the following code to display pages on one page and would like to trim the content of each page on this display to 50 words and include images that are attached to the page. How do I go about doing this? ``` $args = array( 'post_type' => 'page', 'post_parent' => '6', 'o...
yes you can simply do all these with this plugin: <http://wordpress.org/plugins/easy-digital-downloads/>
133,414
<p>I'm writing a plugin that makes requests to the Facebook graph API. As I don't want my unit tests to actually make these requests, how would I overcome this? My method calls both <code>wp_remote_get</code> and <code>wp_remote_post</code>. Searching there does seem to be a way to mock functions using <code>runkit</co...
[ { "answer_id": 133426, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 2, "selected": false, "text": "<p>Take the results you get from a valid or invalid request, serialize them into strings, then add code that unserial...
2014/02/04
[ "https://wordpress.stackexchange.com/questions/133414", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8404/" ]
I'm writing a plugin that makes requests to the Facebook graph API. As I don't want my unit tests to actually make these requests, how would I overcome this? My method calls both `wp_remote_get` and `wp_remote_post`. Searching there does seem to be a way to mock functions using `runkit`, [here](https://github.com/tcz/p...
If you take a look at [`WP_HTTP->request()`](https://developer.wordpress.org/reference/classes/wp_http/request/) (which all related functions wrap) it provides a filter hook for the purpose of overriding making a request in favor of returning arbitrary data as response: ``` // Allow plugins to short-circuit the reques...
133,422
<p>I'm writing a plugin that works with taxonomy terms. It has, among other things, the capability to create new terms. I'm going to suppose that if users have custom taxonomies, they have taken care of having the singular and plural names set up and translated.</p> <p>The question is: How do I format my plugin messag...
[ { "answer_id": 133431, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": true, "text": "<p>You have to use a plural aware function like <code>_n()</code> or <code>_nx()</code>, because the words around the num...
2014/02/04
[ "https://wordpress.stackexchange.com/questions/133422", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26135/" ]
I'm writing a plugin that works with taxonomy terms. It has, among other things, the capability to create new terms. I'm going to suppose that if users have custom taxonomies, they have taken care of having the singular and plural names set up and translated. The question is: How do I format my plugin messages to use ...
You have to use a plural aware function like `_n()` or `_nx()`, because the words around the number might change in some languages depending on the amount items. For visible numbers use `number_format_i18n()` and `%s`, not `%d`. You cannot reuse the labels, because plural forms change depending on context in some l...
133,430
<p>In the paste below is the code for the template running the CPT archive page at <a href="http://www.m.angiemeekerdesigns.com/totd" rel="nofollow">http://www.m.angiemeekerdesigns.com/totd</a></p> <p>Everything about the page is working as expected except the pagination. What would like to happen is that when "Next P...
[ { "answer_id": 133469, "author": "mneil", "author_id": 46120, "author_profile": "https://wordpress.stackexchange.com/users/46120", "pm_score": 1, "selected": false, "text": "<p>First off, to me it looks like the first loop just grabs the first posts of post type tip of the day, and then ...
2014/02/04
[ "https://wordpress.stackexchange.com/questions/133430", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8822/" ]
In the paste below is the code for the template running the CPT archive page at <http://www.m.angiemeekerdesigns.com/totd> Everything about the page is working as expected except the pagination. What would like to happen is that when "Next Page" is clicked, Page 2 and forwards show the next posts from the CPT archive ...
First off, to me it looks like the first loop just grabs the first posts of post type tip of the day, and then the second loop grabs the rest minus the first, so unless I am misunderstanding the function of your loops, I would just do 1 loop, check if it is the first iteration, if so, grab the separate data for the fir...
133,433
<p>I have to get the last post from my Multisite network on WordPress. For now I use this code for display the last updated post after a cycle on each <code>blog_id</code>:</p> <pre><code>&lt;?php $blogs = get_last_updated(' ', 0, 1); foreach ($blogs AS $blog); switch_to_blog($blog["blog_id"]); $lastposts...
[ { "answer_id": 133440, "author": "fischi", "author_id": 15680, "author_profile": "https://wordpress.stackexchange.com/users/15680", "pm_score": 2, "selected": false, "text": "<p>The <code>orderby</code>-parameter should be <code>post_date</code> instead of date.</p>\n\n<p>your code would...
2014/02/04
[ "https://wordpress.stackexchange.com/questions/133433", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47153/" ]
I have to get the last post from my Multisite network on WordPress. For now I use this code for display the last updated post after a cycle on each `blog_id`: ``` <?php $blogs = get_last_updated(' ', 0, 1); foreach ($blogs AS $blog); switch_to_blog($blog["blog_id"]); $lastposts = get_posts('numberposts=1&...
The `orderby`-parameter should be `post_date` instead of date. your code would look something like this: ``` $blogs = get_last_updated(' ', 0, 1); foreach ($blogs AS $blog) { switch_to_blog($blog["blog_id"]); $args = array( 'orderby' => 'post_date', 'order' => 'DESC', ...
133,461
<p>In the script below, I'm attempting to dynamically add categories to a custom menu. Everything works great, except for the fact that the categories do not have hyperlinks. What am I missing in wp_update_nav_menu_item() below?</p> <pre><code> $cat_args=array( 'hierarchical' =&gt; 0, 'exclude' ...
[ { "answer_id": 133466, "author": "mneil", "author_id": 46120, "author_profile": "https://wordpress.stackexchange.com/users/46120", "pm_score": -1, "selected": false, "text": "<p>Well where you insert the menu items for the categories, your array does not contain the 'menu-item-url' key l...
2014/02/05
[ "https://wordpress.stackexchange.com/questions/133461", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6620/" ]
In the script below, I'm attempting to dynamically add categories to a custom menu. Everything works great, except for the fact that the categories do not have hyperlinks. What am I missing in wp\_update\_nav\_menu\_item() below? ``` $cat_args=array( 'hierarchical' => 0, 'exclude' => '1', ...
After using the Chrome inspector on the "Appearance > Menus" categories panel I was able to sniff out the hidden form values that are passed when one manually adds a category to a custom menu via the wizard: ``` <li> <label class="menu-item-title"> <input type="checkbox" class="menu-item-checkbox" name="me...
133,471
<p>I am looking for a way to delete a user when they logout and when session expires...whatever one happens first? Reason being is that all login authentication happens through an api to another company and checks if the user is a registered user with that company. Then the login will give them WP login authentication....
[ { "answer_id": 133554, "author": "David Labbe", "author_id": 38434, "author_profile": "https://wordpress.stackexchange.com/users/38434", "pm_score": 1, "selected": false, "text": "<p>So this is what I did...also keep in mind this is for a multisite and I am call calling this within a cla...
2014/02/05
[ "https://wordpress.stackexchange.com/questions/133471", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38434/" ]
I am looking for a way to delete a user when they logout and when session expires...whatever one happens first? Reason being is that all login authentication happens through an api to another company and checks if the user is a registered user with that company. Then the login will give them WP login authentication. Al...
So this is what I did...also keep in mind this is for a multisite and I am call calling this within a class. 'Client' is a custom user role that is create and given to users when they are created. ``` function delete_user() { global $current_user; if(in_array('client', $current_user->roles )){ ...
133,480
<p>I'm using mu-plugins, <a href="http://codex.wordpress.org/Must_Use_Plugins" rel="nofollow">http://codex.wordpress.org/Must_Use_Plugins</a>.</p> <p>These plugins are showing in plugins.php, <a href="http://d.pr/i/JIvX" rel="nofollow">http://d.pr/i/JIvX</a>.</p> <p>Is there any way to hide it?</p> <p>Thanks.</p>
[ { "answer_id": 133483, "author": "Jörn Lund", "author_id": 35723, "author_profile": "https://wordpress.stackexchange.com/users/35723", "pm_score": 0, "selected": false, "text": "<p>You can hook into the <code>views_plugins</code> filter and unset the mustuse item:</p>\n\n<pre><code>funct...
2014/02/05
[ "https://wordpress.stackexchange.com/questions/133480", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44168/" ]
I'm using mu-plugins, <http://codex.wordpress.org/Must_Use_Plugins>. These plugins are showing in plugins.php, <http://d.pr/i/JIvX>. Is there any way to hide it? Thanks.
The solution to this request is filtering `show_advanced_plugins`. This filter is called twice, once for `mustuse`- and once for `dropins`-plugins. The filter accepts two parameters, the first one being the standard value (`true`), and the second one being the type of the advanced plugin (Must-Use and Drop-In). So re...
133,482
<p>I am working on a theme and for some reason, <code>add_theme_support( 'post-formats', ... )</code> is not working.</p> <p>In my theme's <code>functions.php</code> I have the following near the top:</p> <pre><code>function mytheme_setup() { // ...other functions // Add post formats support add_theme_su...
[ { "answer_id": 133484, "author": "Brad Dalton", "author_id": 9884, "author_profile": "https://wordpress.stackexchange.com/users/9884", "pm_score": 2, "selected": true, "text": "<p>Add this to your child theme which over-rides what your parent theme supports.</p>\n\n<p><strong>Post Format...
2014/02/05
[ "https://wordpress.stackexchange.com/questions/133482", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44304/" ]
I am working on a theme and for some reason, `add_theme_support( 'post-formats', ... )` is not working. In my theme's `functions.php` I have the following near the top: ``` function mytheme_setup() { // ...other functions // Add post formats support add_theme_support( 'post-formats', array( 'asid...
Add this to your child theme which over-rides what your parent theme supports. **Post Formats for Posts** ``` add_action( 'after_setup_theme', 'wpsites_child_theme_posts_formats', 11 ); function wpsites_child_theme_posts_formats(){ add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', '...
133,486
<p>I have 2 meta fields for the posts, eg. <code>meta_value</code> and <code>meta_count</code>. Both are numbers.</p> <p>I want to divide <code>meta_value</code> by <code>meta_count</code> and based on the results I want to fetch the top 10 posts.</p> <p>So for example, post 1 has the meta_value 5, and meta_count 2. ...
[ { "answer_id": 133484, "author": "Brad Dalton", "author_id": 9884, "author_profile": "https://wordpress.stackexchange.com/users/9884", "pm_score": 2, "selected": true, "text": "<p>Add this to your child theme which over-rides what your parent theme supports.</p>\n\n<p><strong>Post Format...
2014/02/05
[ "https://wordpress.stackexchange.com/questions/133486", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38318/" ]
I have 2 meta fields for the posts, eg. `meta_value` and `meta_count`. Both are numbers. I want to divide `meta_value` by `meta_count` and based on the results I want to fetch the top 10 posts. So for example, post 1 has the meta\_value 5, and meta\_count 2. by dividing the result for that post will be 2.5. And the ...
Add this to your child theme which over-rides what your parent theme supports. **Post Formats for Posts** ``` add_action( 'after_setup_theme', 'wpsites_child_theme_posts_formats', 11 ); function wpsites_child_theme_posts_formats(){ add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', '...
133,490
<p>Firstly, I'm trying to display all tags from a taxonomy called 'group'. However, this taxonomy currently contains two tags, from which one of of them has multiple tagchildren.</p> <p>I'd lik to display all posts belonging to those children. So the final result should look something like this:</p> <ul> <li>Parent T...
[ { "answer_id": 133521, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>What you're searching for (from reading that you are wrapping terms in links) possibly is</p>\n\n<pre><code>echo g...
2014/02/05
[ "https://wordpress.stackexchange.com/questions/133490", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47147/" ]
Firstly, I'm trying to display all tags from a taxonomy called 'group'. However, this taxonomy currently contains two tags, from which one of of them has multiple tagchildren. I'd lik to display all posts belonging to those children. So the final result should look something like this: * Parent Tag A + Child tag -...
If anyone's interested, below is the solution that worked out for me. Credits go to Akshay Paghdar. ``` $taxonomyName = "group"; $terms = get_terms($taxonomyName,array('parent' => 0)); echo '<ul>'; foreach($terms as $term) { echo '<li><a href="'.get_term_link($term->slug,$taxonomyName).'">'.$term->name.'</a>'; ...
133,510
<p>Here's the scenario, I'm working on a site with 100s of of paged posts using the wp_link_pages tag.</p> <p>The issue I'm having is that they're things I want displayed on the main post that I don't want display of the paged parts of the post and vice versa. </p> <p>How can I achieve that? And is it possible to giv...
[ { "answer_id": 133513, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>Unfortunately there is no fork in <a href=\"http://codex.wordpress.org/Template_Hierarchy\" rel=\"nofollow\">Templa...
2014/02/05
[ "https://wordpress.stackexchange.com/questions/133510", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35798/" ]
Here's the scenario, I'm working on a site with 100s of of paged posts using the wp\_link\_pages tag. The issue I'm having is that they're things I want displayed on the main post that I don't want display of the paged parts of the post and vice versa. How can I achieve that? And is it possible to give the paged par...
In your single.php add this example code inside the loop: ``` <?php global $page; if ($page == 1) {?> <div style="color:red;">This text should only appear on first page of the post!!!</div> <?php } ?> ``` you can change the div with your thing that you wanted to display only on the first post page..
133,537
<p>I have 4 different menus on my website. </p> <p>Right now I'm using the solution to a problem I posted <a href="https://wordpress.stackexchange.com/a/129923/36334">here</a> in order for the menu to display using the CSS framework I'm making use of.</p> <p>Each of these menus has a number of child pages, and on the...
[ { "answer_id": 133539, "author": "NW Tech", "author_id": 5295, "author_profile": "https://wordpress.stackexchange.com/users/5295", "pm_score": 1, "selected": false, "text": "<p>Sure you can. I've done something similar with a couple of different ways.</p>\n\n<p>One way would be to create...
2014/02/05
[ "https://wordpress.stackexchange.com/questions/133537", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36334/" ]
I have 4 different menus on my website. Right now I'm using the solution to a problem I posted [here](https://wordpress.stackexchange.com/a/129923/36334) in order for the menu to display using the CSS framework I'm making use of. Each of these menus has a number of child pages, and on these child pages I'd like to d...
On each (child) page, get the top-most parent, then display the according menu. Here is a blue-print of what I just described (you may have to change this and that to make it behave like you want it to). Simply put the following code where you currently have your menu set up (in your `header.php` file, I suppose): ``...
133,555
<p>I'm building a WordPress site that is supposed to end up with a Danish backend. This works fine for core WordPress, but some plugin makes it really hard to make a complete translation.</p> <p>A problem I just found has to do with the relationship field in the ACF plugin. I love the plugin, but there seems to be one...
[ { "answer_id": 136386, "author": "Matias Vad", "author_id": 47517, "author_profile": "https://wordpress.stackexchange.com/users/47517", "pm_score": 0, "selected": false, "text": "<p>Simply change your <code>Post Type</code> to \"Forestilling\" instead of \"Production\".</p>\n\n<p>I know ...
2014/02/05
[ "https://wordpress.stackexchange.com/questions/133555", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38440/" ]
I'm building a WordPress site that is supposed to end up with a Danish backend. This works fine for core WordPress, but some plugin makes it really hard to make a complete translation. A problem I just found has to do with the relationship field in the ACF plugin. I love the plugin, but there seems to be one bad call ...
You should leave the post type name (and everything else that might need to be translated) in English. Then, in WPML, you can translate its name (labels, and slugs). If the main language of the site is Danish, you simply set this language as default language (not for WPML String Translation though, where I would keep...
133,630
<p>After setting up a multisite wordpress, I'd like to be able to redirect the root (front page) to one of the blogs. </p> <p>To understand the context, I'm talking about an NGO that organises events, while active the homepage should redirect there.</p> <p>The solution I found on a couple of forums involved manually ...
[ { "answer_id": 133633, "author": "pax", "author_id": 967, "author_profile": "https://wordpress.stackexchange.com/users/967", "pm_score": 0, "selected": false, "text": "<p>The solution I reached at the moment is using a different theme for the main (root) instance and just adding a php he...
2014/02/06
[ "https://wordpress.stackexchange.com/questions/133630", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/967/" ]
After setting up a multisite wordpress, I'd like to be able to redirect the root (front page) to one of the blogs. To understand the context, I'm talking about an NGO that organises events, while active the homepage should redirect there. The solution I found on a couple of forums involved manually changing the ID o...
This code goes in your child themes functions.php file. ``` add_action( 'template_redirect', 'wpsites_redirect_ms_front_page' ); function wpsites_redirect_ms_front_page() { if ( is_main_site() && is_front_page() ) { wp_redirect( 'http://www.example.dev/', 302 ); exit; } } ``` Something like...
133,634
<p>I have a Wordpress install in Network mode, with subdomains.</p> <p>sitex.example.com is displaying a white page, with nothing in the source code.</p> <p>Other network sites display fine.</p> <p>I renamed the theme the site was using, but it didn't pick up Twenty Twelve in response.</p> <p>A server response chec...
[ { "answer_id": 134191, "author": "LPH", "author_id": 47326, "author_profile": "https://wordpress.stackexchange.com/users/47326", "pm_score": 2, "selected": false, "text": "<p>The .htaccess does not have the information for caching so clear cache, network deactivate your caching plugin as...
2014/02/06
[ "https://wordpress.stackexchange.com/questions/133634", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
I have a Wordpress install in Network mode, with subdomains. sitex.example.com is displaying a white page, with nothing in the source code. Other network sites display fine. I renamed the theme the site was using, but it didn't pick up Twenty Twelve in response. A server response checker showed that the site is pro...
I network disabled a bunch of plugins. These plugins were running on the problem site. After this the problem disappeared.
133,649
<p>I have two links: Products and News.</p> <p>When i click on Products or News, it returns me an archive page that contains some posts, when i click on a post it returns me a single page of this post.</p> <p>In the menu I use this code on <code>&lt;li&gt;</code> to add a class called active if the page is home:</p> ...
[ { "answer_id": 133651, "author": "Brad Dalton", "author_id": 9884, "author_profile": "https://wordpress.stackexchange.com/users/9884", "pm_score": 3, "selected": true, "text": "<p>You could add conditional classes for each in your child theme functions file:</p>\n\n<p>Here's one example ...
2014/02/06
[ "https://wordpress.stackexchange.com/questions/133649", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64029/" ]
I have two links: Products and News. When i click on Products or News, it returns me an archive page that contains some posts, when i click on a post it returns me a single page of this post. In the menu I use this code on `<li>` to add a class called active if the page is home: ``` <li<?php if(is_home()) {?> class=...
You could add conditional classes for each in your child theme functions file: Here's one example you can modify to suit your own needs. ``` add_filter('nav_menu_css_class' , 'wpsites_nav_class' , 10 , 2); function wpsites_nav_class($classes, $item){ if( is_archive() && $item->title == "Products"){ $...
133,658
<p>I have the following code in my home.php</p> <pre><code>&lt;?php query_posts($query_string . '&amp;orderby=rand' . '&amp;cat=-182,-184'); ?&gt; </code></pre> <p>query_posts seems not the best solution. What would be the best way pre_get_post or WP Query.</p> <p>Highly appreciated if you could also write the corre...
[ { "answer_id": 133663, "author": "NW Tech", "author_id": 5295, "author_profile": "https://wordpress.stackexchange.com/users/5295", "pm_score": 1, "selected": false, "text": "<p>You will want to use <code>new WP_Query</code>. <a href=\"https://wordpress.stackexchange.com/questions/1753/wh...
2014/02/06
[ "https://wordpress.stackexchange.com/questions/133658", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47242/" ]
I have the following code in my home.php ``` <?php query_posts($query_string . '&orderby=rand' . '&cat=-182,-184'); ?> ``` query\_posts seems not the best solution. What would be the best way pre\_get\_post or WP Query. Highly appreciated if you could also write the correct code. Kind regards, Yves
[pre\_get\_posts](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) in your child themes functions file is the best in my opinion. ``` add_action( 'pre_get_posts', 'wpsites_custom_get_posts' ); function wpsites_custom_get_posts( $query ) { if( $query->is_main_query() && $query->is_home() ) { $qu...
133,674
<p>I'm using the <code>transition_post_status</code> hook to perform some operations after publishing a post. In some conditions I would like to show an error message in a red box under "Edit Post" and above "Post published":</p> <p><img src="https://i.stack.imgur.com/dRuVQ.png" alt="Post pushlished"></p> <p>How can ...
[ { "answer_id": 133675, "author": "Brad Dalton", "author_id": 9884, "author_profile": "https://wordpress.stackexchange.com/users/9884", "pm_score": 3, "selected": true, "text": "<p>I wouldn't use that hook. <a href=\"http://codex.wordpress.org/Function_Reference/_transition_post_status\" ...
2014/02/06
[ "https://wordpress.stackexchange.com/questions/133674", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20974/" ]
I'm using the `transition_post_status` hook to perform some operations after publishing a post. In some conditions I would like to show an error message in a red box under "Edit Post" and above "Post published": ![Post pushlished](https://i.stack.imgur.com/dRuVQ.png) How can I do that?
I wouldn't use that hook. [Here's why](http://codex.wordpress.org/Function_Reference/_transition_post_status) Try something like this using [admin\_notices](http://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices). ``` function wpsites_admin_notice() { $screen = get_current_screen(); if( 'post' == $scre...
133,685
<p>Ok, I think I have a simple fix here. I'm using ACF to link health reports to specific dogs on a breeder website. But, not all dogs have the same reports, and I don't want to show a dead link if no ACF value is available. So, I wanted to use an if statement but can't quite get it to work. Here's my code: </p> <...
[ { "answer_id": 133686, "author": "NW Tech", "author_id": 5295, "author_profile": "https://wordpress.stackexchange.com/users/5295", "pm_score": 0, "selected": false, "text": "<p>I'm using the same type of setup. However, I'm not using the <code>else</code> statement. Here's how mine looks...
2014/02/06
[ "https://wordpress.stackexchange.com/questions/133685", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35190/" ]
Ok, I think I have a simple fix here. I'm using ACF to link health reports to specific dogs on a breeder website. But, not all dogs have the same reports, and I don't want to show a dead link if no ACF value is available. So, I wanted to use an if statement but can't quite get it to work. Here's my code: ``` <?php ...
My guess is that your problem is that your field type is returning some non-empty value, even if it's not a URL. For instance, do you have "http://" set as a default value for that field in the admin? If that were the case you could need to use the following as your test: `if( $values || $values !== 'http://' )...` A...
133,716
<p>I had to switch around my Super Admins. I did it through the MySQL tables directly.</p> <p>I now have 1 official Super Admin for my network (which is what I want &amp; need) but WordPress shows that I have 2 Super Admins:</p> <pre><code>All (71) | Super Admins (2) </code></pre> <p>Where does WP store the SA count...
[ { "answer_id": 133718, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 2, "selected": false, "text": "<p>It's stored in the main site options table, under the \"site_admins\" key.</p>\n\n<p>Edit: As pointed out in the c...
2014/02/06
[ "https://wordpress.stackexchange.com/questions/133716", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I had to switch around my Super Admins. I did it through the MySQL tables directly. I now have 1 official Super Admin for my network (which is what I want & need) but WordPress shows that I have 2 Super Admins: ``` All (71) | Super Admins (2) ``` Where does WP store the SA count or the list of SA's?
It's stored in the main site options table, under the "site\_admins" key. Edit: As pointed out in the comments, the "site options" table in multisite is actually named PREFIX\_sitemeta, like "wp\_sitemeta". It's referred to as a site option internally, like `get_site_option('site_admins')`. To adjust this without edi...
133,728
<p>I'm trying to setup my Wordpress projects so that I can have <code>http://www.example.com/</code> as my site URL, say mapped to <code>/var/www/vhosts/www.example.com/</code> and in there, I would like to use the following structure:</p> <pre><code>/var/www/vhosts/www.example.com/wp-core/ /var/www/vhosts/www.example...
[ { "answer_id": 133718, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 2, "selected": false, "text": "<p>It's stored in the main site options table, under the \"site_admins\" key.</p>\n\n<p>Edit: As pointed out in the c...
2014/02/06
[ "https://wordpress.stackexchange.com/questions/133728", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47262/" ]
I'm trying to setup my Wordpress projects so that I can have `http://www.example.com/` as my site URL, say mapped to `/var/www/vhosts/www.example.com/` and in there, I would like to use the following structure: ``` /var/www/vhosts/www.example.com/wp-core/ /var/www/vhosts/www.example.com/wp-content/ /var/www/vhosts/www...
It's stored in the main site options table, under the "site\_admins" key. Edit: As pointed out in the comments, the "site options" table in multisite is actually named PREFIX\_sitemeta, like "wp\_sitemeta". It's referred to as a site option internally, like `get_site_option('site_admins')`. To adjust this without edi...
133,746
<p>I have a custom post type named "Products" and a taxonomy called "Usage". On my "Products" landing page I'd like to have custom content that can be edited via WYSIWYG by the client. Same goes for the taxonomy landing page. My thought was to create fake Pages and just pull the content via ID into my archive-products....
[ { "answer_id": 133757, "author": "markcbain", "author_id": 24573, "author_profile": "https://wordpress.stackexchange.com/users/24573", "pm_score": 0, "selected": false, "text": "<p>You could create normal pages, then apply custom templates which contain the appropriate custom loop to out...
2014/02/07
[ "https://wordpress.stackexchange.com/questions/133746", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24054/" ]
I have a custom post type named "Products" and a taxonomy called "Usage". On my "Products" landing page I'd like to have custom content that can be edited via WYSIWYG by the client. Same goes for the taxonomy landing page. My thought was to create fake Pages and just pull the content via ID into my archive-products.php...
First solution can be using the [Settings API](http://codex.wordpress.org/Settings_API) and create 2 fields *"Products Description"* and *"Usage Description"*, after that showing in your template that fields is easy like a: ``` $options = get_option('my_theme_options'); echo $options['prod_description']; // echo $opti...
133,752
<p>I have taxonomy color which is associated with a custom post type. I am listing all the post meta and the taxonomy in a table. I have a option in the table to search the posts matching the search value. </p> <p>when search key is entered it will do a ajax call to get the the posts.</p> <p>this is the query to ...
[ { "answer_id": 133777, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 2, "selected": false, "text": "<p><a href=\"https://core.trac.wordpress.org/browser/tags/3.8.1/src/wp-includes/taxonomy.php#L625\" re...
2014/02/07
[ "https://wordpress.stackexchange.com/questions/133752", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29259/" ]
I have taxonomy color which is associated with a custom post type. I am listing all the post meta and the taxonomy in a table. I have a option in the table to search the posts matching the search value. when search key is entered it will do a ajax call to get the the posts. this is the query to get all the posts mat...
The only option you have is to write your own SQL into the [`posts_clauses`](http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_clauses) filter, where you get an array of the `JOIN`, `WHERE`, `ORDER`, etc. clauses that you can alter, add to, remove, etc. One MAJOR MAJOR note on this, is ALWAYS use the global...
133,754
<p>Here is my loop</p> <pre><code> $my_query = new WP_Query(array( 'cat' =&gt; -399, 'posts_per_page' =&gt; 6, 'offset' =&gt; 5, 'paged' =&gt; (get_query_var('paged')) ? get_query_var('paged') : 1 )); if ( $my_query-&gt;have_posts()...
[ { "answer_id": 133759, "author": "Devin Walker", "author_id": 10798, "author_profile": "https://wordpress.stackexchange.com/users/10798", "pm_score": 4, "selected": true, "text": "<p>Try changing <code>$my_query</code> to <code>$wp_query</code> to see if that fixes the issue. I found tha...
2014/02/07
[ "https://wordpress.stackexchange.com/questions/133754", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8096/" ]
Here is my loop ``` $my_query = new WP_Query(array( 'cat' => -399, 'posts_per_page' => 6, 'offset' => 5, 'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1 )); if ( $my_query->have_posts() ) : while ( $my_query->have_...
Try changing `$my_query` to `$wp_query` to see if that fixes the issue. I found that when you rename the query it messes with the pagination. Also you should move the reset query after the pagination. Here's a loop I've verified works with pagination: ``` $args = array( 'posts_per_page' => 10, 'post_type' ...
133,779
<p>I'm trying to get wordpress post by filtering date and time, for example get post 01/02/2014 to 07/02/2014. thanks for the help me.</p>
[ { "answer_id": 133759, "author": "Devin Walker", "author_id": 10798, "author_profile": "https://wordpress.stackexchange.com/users/10798", "pm_score": 4, "selected": true, "text": "<p>Try changing <code>$my_query</code> to <code>$wp_query</code> to see if that fixes the issue. I found tha...
2014/02/07
[ "https://wordpress.stackexchange.com/questions/133779", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45710/" ]
I'm trying to get wordpress post by filtering date and time, for example get post 01/02/2014 to 07/02/2014. thanks for the help me.
Try changing `$my_query` to `$wp_query` to see if that fixes the issue. I found that when you rename the query it messes with the pagination. Also you should move the reset query after the pagination. Here's a loop I've verified works with pagination: ``` $args = array( 'posts_per_page' => 10, 'post_type' ...
133,797
<p>I have Post Object field set up for pages. What I want to do is to output title of the posts associated with the page as a class of the div surrounding the page listing. But, the code inside the foreach loop is not being executed. I've tried with setup_postdata($post) and without, per ACF documentation, the result i...
[ { "answer_id": 133799, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p>...would WordPress be able to render the website in less than one\n second...</p>\n</blockqu...
2014/02/07
[ "https://wordpress.stackexchange.com/questions/133797", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34571/" ]
I have Post Object field set up for pages. What I want to do is to output title of the posts associated with the page as a class of the div surrounding the page listing. But, the code inside the foreach loop is not being executed. I've tried with setup\_postdata($post) and without, per ACF documentation, the result is ...
> > ...would WordPress be able to render the website in less than one > second... > > > WordPress is perfectly scalable to the amount of content and user base you're describing. You just need the horsepower for httpd (apache/nginx) to be able show one second page loads and have the database server (mysql, maria)...
133,800
<p>I moved my wordpress installation from:</p> <blockquote> <p>/wordpress</p> </blockquote> <p>to</p> <blockquote> <p>/html/website</p> </blockquote> <p>The process was extremely traumatic and even though I followed the instructions closely the site went down a few minutes, after trying everything to get it bac...
[ { "answer_id": 133799, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p>...would WordPress be able to render the website in less than one\n second...</p>\n</blockqu...
2014/02/07
[ "https://wordpress.stackexchange.com/questions/133800", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2488/" ]
I moved my wordpress installation from: > > /wordpress > > > to > > /html/website > > > The process was extremely traumatic and even though I followed the instructions closely the site went down a few minutes, after trying everything to get it back up I got to the point that the site works but I cannot remo...
> > ...would WordPress be able to render the website in less than one > second... > > > WordPress is perfectly scalable to the amount of content and user base you're describing. You just need the horsepower for httpd (apache/nginx) to be able show one second page loads and have the database server (mysql, maria)...
133,801
<p>I have pieced together a breadcrumbs code that displays child pages/posts and is markedup for schema.</p> <p>The only thing this code doesn't have is a separator between each link. How can I add a separator in one instance, rather than adding the separator after each individual generated link?</p> <pre><code>funct...
[ { "answer_id": 133803, "author": "tfrommen", "author_id": 27722, "author_profile": "https://wordpress.stackexchange.com/users/27722", "pm_score": 2, "selected": true, "text": "<p>I'm not sure if you want it like this, however, this can be achieved by CSS.</p>\n\n<pre><code>.crumbs &gt; s...
2014/02/07
[ "https://wordpress.stackexchange.com/questions/133801", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
I have pieced together a breadcrumbs code that displays child pages/posts and is markedup for schema. The only thing this code doesn't have is a separator between each link. How can I add a separator in one instance, rather than adding the separator after each individual generated link? ``` function crumbs() { if ((...
I'm not sure if you want it like this, however, this can be achieved by CSS. ``` .crumbs > span > span + span { margin-left: 1em; } .crumbs > span > span + span:before { content: '|'; /* or something else */ *display: inline; display: inline-block; margin-left: -1em; width: 1em; text-align...
133,816
<p>The following code is in the same php script. But I get <code>Uncaught ReferenceError: jQuery is not defined</code> in chrome debugger. </p> <p>validate.js is in plugins/validate/validate.js</p> <p>I know this is the problem , as I tried validate.js when not using wordpress, by including it externally, &amp; it...
[ { "answer_id": 133817, "author": "1fixdotio", "author_id": 45728, "author_profile": "https://wordpress.stackexchange.com/users/45728", "pm_score": 3, "selected": true, "text": "<p>Just use <code>deps</code> parameter to include jQuery, change your code to:</p>\n\n<pre><code> function ...
2014/02/07
[ "https://wordpress.stackexchange.com/questions/133816", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
The following code is in the same php script. But I get `Uncaught ReferenceError: jQuery is not defined` in chrome debugger. validate.js is in plugins/validate/validate.js I know this is the problem , as I tried validate.js when not using wordpress, by including it externally, & it worked fine. I am using the code b...
Just use `deps` parameter to include jQuery, change your code to: ``` function add_my_css_and_my_js_files() { wp_register_script( 'validate', plugins_url( '/validate.js', __FILE__ ), array( 'jquery' ) ); wp_enqueue_script('validate'); } add_action( 'wp_enqueue_scripts', "add_my_css_and_my_j...
133,866
<p>I am trying to filter <code>the_content()</code> on single page, but it looks like it is creating an infinite loop. I want to know how to fix this. I want to override <code>the_content()</code>.</p> <p>Is there any other way to override single page content from plugin?</p> <pre><code>add_filter( 'the_content', 'ch...
[ { "answer_id": 133868, "author": "Sudeep K Rana", "author_id": 47179, "author_profile": "https://wordpress.stackexchange.com/users/47179", "pm_score": -1, "selected": false, "text": "<pre><code>add_filter( 'the_content', 'filter_content' );\nfunction filter_content( $content ){\n if (...
2014/02/08
[ "https://wordpress.stackexchange.com/questions/133866", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26385/" ]
I am trying to filter `the_content()` on single page, but it looks like it is creating an infinite loop. I want to know how to fix this. I want to override `the_content()`. Is there any other way to override single page content from plugin? ``` add_filter( 'the_content', 'change_single_content' ); function change_sin...
My guess is that `single-template.php` uses `the_content`. Now think about what happens: 1. Your filter causes `single-template.php` to load 2. `single-template.php` uses `the_content` 3. So `single-template.php` loads again 4. Which uses `the_content` 5. Which loads `single-template.php` 6. Which uses `the_content` 7...
133,867
<p>I'm trying to set up a list of categories with clickable links to that category. I've looked at:</p> <ul> <li><a href="https://wordpress.stackexchange.com/questions/28469/display-list-of-sub-categories-and-the-posts-they-contain-within-one-main-categ">Display list of Sub-Categories and the posts they contain, withi...
[ { "answer_id": 133871, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 2, "selected": false, "text": "<p>As per the linked WPSE thread, and the <a href=\"https://wordpress.stackexchange.com/a/28646/22728\">a...
2014/02/08
[ "https://wordpress.stackexchange.com/questions/133867", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47314/" ]
I'm trying to set up a list of categories with clickable links to that category. I've looked at: * [Display list of Sub-Categories and the posts they contain, within one main Category](https://wordpress.stackexchange.com/questions/28469/display-list-of-sub-categories-and-the-posts-they-contain-within-one-main-categ) ...
As per the linked WPSE thread, and the [accepted answer](https://wordpress.stackexchange.com/a/28646/22728), the code is (copied & pasted): ``` $categories = get_categories('child_of=31'); foreach ($categories as $category) { //Display the sub category information using $category values like $category->cat_nam...
133,879
<p>I've setup a WP MU site and I need to know how to sign up a user to a specific blog when they register. As it is now, if a visitor is visiting a specific site and they click the register button they are taken to the main network site and then they are given the option to register as a user or create their own blog. ...
[ { "answer_id": 134304, "author": "1.21 gigawatts", "author_id": 29247, "author_profile": "https://wordpress.stackexchange.com/users/29247", "pm_score": 2, "selected": true, "text": "<p>I think I found it, </p>\n\n<pre><code>&lt;?php add_user_to_blog( $blog_id, $user_id, $role ) ?&gt; \n<...
2014/02/08
[ "https://wordpress.stackexchange.com/questions/133879", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29247/" ]
I've setup a WP MU site and I need to know how to sign up a user to a specific blog when they register. As it is now, if a visitor is visiting a specific site and they click the register button they are taken to the main network site and then they are given the option to register as a user or create their own blog. I...
I think I found it, ``` <?php add_user_to_blog( $blog_id, $user_id, $role ) ?> ``` <http://codex.wordpress.org/Function_Reference/add_user_to_blog>
133,882
<p>I have installed a wordpress theme, i can see the .mo and .po <code>/public_html/wp-content/themes/themename/lang</code>, the language I want to use is available.</p> <p>Could you please advise on how to use a specific language? I don't want to change the admin language just the theme language.</p>
[ { "answer_id": 133883, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>You can filter the string for <code>locale</code>, it holds the current language. And you can exclude the admin from ...
2014/02/08
[ "https://wordpress.stackexchange.com/questions/133882", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47321/" ]
I have installed a wordpress theme, i can see the .mo and .po `/public_html/wp-content/themes/themename/lang`, the language I want to use is available. Could you please advise on how to use a specific language? I don't want to change the admin language just the theme language.
If anyone is still looking for that, here is what you should do since version 4.7 ``` function wp_noshor_redefine_locale($locale) { if( is_admin() ): switch_to_locale('en_US'); endif; } add_filter('init','wp_noshor_redefine_locale'); ``` This forces the dashboard to load in English, then you can go t...
133,892
<p>I want to add a custom post type (called pupil) into Wordpress when inserting a new user. The <code>wp_insert_user()</code> is used for creating new users.</p> <p>I have this code:</p> <pre><code>function register_user_pupil($user_id) { //Count nr of occurences in user-table for submitted email-adress $em...
[ { "answer_id": 133897, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": true, "text": "<p>I think you are making this a lot harder than it has to be.</p>\n\n<ol>\n<li>Run your code on <code>user_regi...
2014/02/08
[ "https://wordpress.stackexchange.com/questions/133892", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38848/" ]
I want to add a custom post type (called pupil) into Wordpress when inserting a new user. The `wp_insert_user()` is used for creating new users. I have this code: ``` function register_user_pupil($user_id) { //Count nr of occurences in user-table for submitted email-adress $email_form = $_POST['email']; ...
I think you are making this a lot harder than it has to be. 1. Run your code on `user_register` and `update_profile` 2. Check to see if the post exists, and create it if not 3. Done. WordPress should take care of the rest. Something like: ``` function register_user_pupil($user_id) { $current_user = new WP_User($us...
133,901
<p>I've created a WordPress site for a ProductCamp. Users register for the event on Eventbrite and then use the WordPress site to vote for breakout sessions. Is there a way to verify that a user is already an attendee in Eventbrite when they are signing up on WordPress?</p>
[ { "answer_id": 133897, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": true, "text": "<p>I think you are making this a lot harder than it has to be.</p>\n\n<ol>\n<li>Run your code on <code>user_regi...
2014/02/08
[ "https://wordpress.stackexchange.com/questions/133901", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47329/" ]
I've created a WordPress site for a ProductCamp. Users register for the event on Eventbrite and then use the WordPress site to vote for breakout sessions. Is there a way to verify that a user is already an attendee in Eventbrite when they are signing up on WordPress?
I think you are making this a lot harder than it has to be. 1. Run your code on `user_register` and `update_profile` 2. Check to see if the post exists, and create it if not 3. Done. WordPress should take care of the rest. Something like: ``` function register_user_pupil($user_id) { $current_user = new WP_User($us...
133,915
<p>I have a custom content type (event), within that type I have a custom date field, with the name: 'date'. In my template I am running the WP_Query to return a list of events. I would like to only get events that are in the future (according to my custom 'date' field) and then order the list by that same field.</p> ...
[ { "answer_id": 140459, "author": "Marc Miller", "author_id": 50007, "author_profile": "https://wordpress.stackexchange.com/users/50007", "pm_score": 1, "selected": false, "text": "<p>Here's what I did. I am using the Advance Custom Fields plugin for the custom fields. I followed the inst...
2014/02/08
[ "https://wordpress.stackexchange.com/questions/133915", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47334/" ]
I have a custom content type (event), within that type I have a custom date field, with the name: 'date'. In my template I am running the WP\_Query to return a list of events. I would like to only get events that are in the future (according to my custom 'date' field) and then order the list by that same field. I have...
I found the actual issue so I thought I'd update. ACF documentation says to use $today = date ('Ymd') to compare dates but you really need to use current\_time('Ymd') so I removed the functions.php code that I added and fixed the problem rather than work around it. Here's my query now ``` $event1 = current_time('Ym...
133,917
<p>I tried to get the next and previous URL, and create a navigation. But it seems to only retrieve the permalink from the two first posts (but not the others recents posts).</p> <p>I have 5 posts (ID = 25, 86, 80, 75, 45). When I am on the first post (ID = 25) and I click on previous post, I am going to post ID = 45,...
[ { "answer_id": 133948, "author": "Abdul Awal Uzzal", "author_id": 31449, "author_profile": "https://wordpress.stackexchange.com/users/31449", "pm_score": 0, "selected": false, "text": "<p>You should use &amp; for the navigation. \n<a href=\"http://codex.wordpress.org/Template_Tags/nex...
2014/02/08
[ "https://wordpress.stackexchange.com/questions/133917", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/42755/" ]
I tried to get the next and previous URL, and create a navigation. But it seems to only retrieve the permalink from the two first posts (but not the others recents posts). I have 5 posts (ID = 25, 86, 80, 75, 45). When I am on the first post (ID = 25) and I click on previous post, I am going to post ID = 45, and after...
You could use different code. As an example, this modified code from the Twenty Fourteen parent theme which i tested on other themes works well. Add this to a new file named template-tags.php ``` <?php if ( ! function_exists( 'wpsites_post_nav' ) ) : function wpsites_post_nav() { $previous = ( is_attachment() ) ? ...
133,918
<p>Using the following, or any other custom Walker_Nav_Menu seems to cause a blank navigation menu, I tried specifying the default to make sure I wasn't going crazy yet it still blanks the output... Any ideas on what is going wrong?</p> <pre><code>&lt;?php wp_nav_menu( array( 'theme_location' =&gt; 'primary', 'depth' ...
[ { "answer_id": 134022, "author": "adrian7", "author_id": 7171, "author_profile": "https://wordpress.stackexchange.com/users/7171", "pm_score": 0, "selected": false, "text": "<p>You should pass an actual object as 'walker' - not create one on the fly. The correct way to do it is:</p>\n\n<...
2014/02/08
[ "https://wordpress.stackexchange.com/questions/133918", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45653/" ]
Using the following, or any other custom Walker\_Nav\_Menu seems to cause a blank navigation menu, I tried specifying the default to make sure I wasn't going crazy yet it still blanks the output... Any ideas on what is going wrong? ``` <?php wp_nav_menu( array( 'theme_location' => 'primary', 'depth' => 3, 'walker' => ...
You need to make sure your menu is properly registered in your `functions.php` and then activated in the WP Dashboard. ``` add_action( 'init', register_nav_menu( 'navigation', __( 'Navigation' ) ) ); ``` Otherwise I was just facing a long list of empty bullet points. <http://codex.wordpress.org/Navigation_Menus>
133,923
<p>I use wp_title to generate some kind of breadcrumb and it works well, but in there I have the title of the <em>site</em>, and I want to delete that. It looks like this:</p> <p>Taxonomy1: City | Title of the site. I get that by using <code>&lt;?php wp_title(); ?&gt;</code>.</p> <p>How can I delete the title of the ...
[ { "answer_id": 133926, "author": "adrian7", "author_id": 7171, "author_profile": "https://wordpress.stackexchange.com/users/7171", "pm_score": 1, "selected": false, "text": "<p>Take a look in header.php of your theme. Some themes have the title output like this: </p>\n\n<pre><code>&lt;ti...
2014/02/08
[ "https://wordpress.stackexchange.com/questions/133923", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47338/" ]
I use wp\_title to generate some kind of breadcrumb and it works well, but in there I have the title of the *site*, and I want to delete that. It looks like this: Taxonomy1: City | Title of the site. I get that by using `<?php wp_title(); ?>`. How can I delete the title of the site in that output?
Take a look in header.php of your theme. Some themes have the title output like this: ``` <title><?php wp_title('|', true, 'right'); ?> | <?php echo get_bloginfo('name') ?></title> ``` So you'll have to remove the `| <?php echo get_bloginfo('name') ?>` part. However you should keep the title of the site in the `<t...
133,937
<p>I'm using ajax to post the form data. In the end I want to redirect to homepage. I'm trying following code, it does not work. It returns error 302. How can I redirect in the following function? Thanks.</p> <pre><code>add_action('wp_ajax_nopriv_custom_register', 'custom_register'); add_action('wp_ajax_custom_registe...
[ { "answer_id": 133939, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": false, "text": "<p>The AJAX request runs in the background. Redirects here do not affect the main page. And 302 is not an error, it is j...
2014/02/08
[ "https://wordpress.stackexchange.com/questions/133937", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41290/" ]
I'm using ajax to post the form data. In the end I want to redirect to homepage. I'm trying following code, it does not work. It returns error 302. How can I redirect in the following function? Thanks. ``` add_action('wp_ajax_nopriv_custom_register', 'custom_register'); add_action('wp_ajax_custom_register', 'custom_re...
The AJAX request runs in the background. Redirects here do not affect the main page. And 302 is not an error, it is just a status code. Your AJAX response should return either the URL and the status code to the calling page or just a number like 1. Then you handle the redirect in the calling page: ``` jQuery( documen...
133,958
<p>I am currently using a 'the_content' filter to add some HTML to the bottom of my posts and pages. </p> <p>But, I want to add another 'the_content' filter to a handful of specific pages (using page IDs).</p> <p>Is it ok to use multiple 'the_content' filters? </p> <p>here is my current code:</p> <pre><code>add_fi...
[ { "answer_id": 133960, "author": "tfrommen", "author_id": 27722, "author_profile": "https://wordpress.stackexchange.com/users/27722", "pm_score": 1, "selected": false, "text": "<p>Of course, you can&mdash;and that's exactly what filters are there for.</p>\n\n<p><code>the_content</code> a...
2014/02/09
[ "https://wordpress.stackexchange.com/questions/133958", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/39136/" ]
I am currently using a 'the\_content' filter to add some HTML to the bottom of my posts and pages. But, I want to add another 'the\_content' filter to a handful of specific pages (using page IDs). Is it ok to use multiple 'the\_content' filters? here is my current code: ``` add_filter( 'the_content', 'my_content_...
You can add as many page i.d's and conditional tags as you like. You can use [the\_content](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content) filter in as many functions as you like as long as they use different function names. However, when you add HTML or text content after posts, you need to use ...
133,987
<p>I'm just getting my feet wet with creating a custom post type (which is up and running). I'd like to display the CPT alongside other posts on my homepage... I can't figure it out for the life of me. I'm hoping someone can see the error of my ways before I pull more hair out. I'm sure it's a rookie mistake, I have b...
[ { "answer_id": 133965, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>Yes, you can import content from other single site installations into one multisite installation (network). Widgets, ...
2014/02/09
[ "https://wordpress.stackexchange.com/questions/133987", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47344/" ]
I'm just getting my feet wet with creating a custom post type (which is up and running). I'd like to display the CPT alongside other posts on my homepage... I can't figure it out for the life of me. I'm hoping someone can see the error of my ways before I pull more hair out. I'm sure it's a rookie mistake, I have been ...
Yes, you can import content from other single site installations into one multisite installation (network). Widgets, themes and plugins are set per site in a network. What you cannot do is using multiple *versions* of the same theme or plugin, eg. version 1.2 on one site and 1.3 on another. Before you do that, set up...
133,992
<p>I am testing ajax in wordpress, and it basically works but I do not want the url to be hardcoded, so I tried using <code>wp_localize_script</code> to get an object to use, but I get an error saying: "ReferenceError: WPURLS is not defined" when alerting the siteurl in <code>ajax_script.js</code>.</p> <p>functions.ph...
[ { "answer_id": 133996, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>You're calling <code>wp_localize_script</code> before the action that enqueues the script has run. Move the localiz...
2014/02/09
[ "https://wordpress.stackexchange.com/questions/133992", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37281/" ]
I am testing ajax in wordpress, and it basically works but I do not want the url to be hardcoded, so I tried using `wp_localize_script` to get an object to use, but I get an error saying: "ReferenceError: WPURLS is not defined" when alerting the siteurl in `ajax_script.js`. functions.php ``` function my_scripts_metho...
You're calling `wp_localize_script` before the action that enqueues the script has run. Move the localize into the enqueue action, after the script is enqueued. ``` function my_scripts_method() { wp_enqueue_script( 'ajax_script', get_stylesheet_directory_uri() . '/js/ajax_script.js', array(...
134,014
<p>I'm working on building out a custom theme and have been struggling with this one for a bit. I am trying to modify the HTML output of <code>the_post_thumbnail();</code> function. I need to do this because I am trying to support retina images on my site and would rather bake the functionality into my theme than load ...
[ { "answer_id": 134018, "author": "Simon", "author_id": 9458, "author_profile": "https://wordpress.stackexchange.com/users/9458", "pm_score": 0, "selected": false, "text": "<p>Maybe you could hook into <code>wp_get_attachment_image_attributes</code> : </p>\n\n<pre><code>function my_custom...
2014/02/09
[ "https://wordpress.stackexchange.com/questions/134014", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26011/" ]
I'm working on building out a custom theme and have been struggling with this one for a bit. I am trying to modify the HTML output of `the_post_thumbnail();` function. I need to do this because I am trying to support retina images on my site and would rather bake the functionality into my theme than load a plugin on th...
Ok, so I think I may have come to a solution. It doesn't seem as nice and easy as I'd like it to be, but then again major modifications to default Wordpress functionality sometimes requires drastic measures. :) This is my working solution to rewriting the HTML output for post thumbnails throughout my site to work with...
134,033
<p>I am having a site radhanath-swami.info. I logged as admin using "radhanath-swami.info/wp-admin".</p> <p>then i tried "radhanath-swami.info/wp-admin/theme-editor.php"</p> <pre><code> You do not have sufficient permissions to access this page. </code></pre> <p>I dont know what to do. I googled a lot but not much...
[ { "answer_id": 134040, "author": "Tarei SuperChur King", "author_id": 41448, "author_profile": "https://wordpress.stackexchange.com/users/41448", "pm_score": 1, "selected": true, "text": "<p>You can try enable the theme editor via WP-Config as shown here: <a href=\"http://www.wp-edge.com...
2014/02/10
[ "https://wordpress.stackexchange.com/questions/134033", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45834/" ]
I am having a site radhanath-swami.info. I logged as admin using "radhanath-swami.info/wp-admin". then i tried "radhanath-swami.info/wp-admin/theme-editor.php" ``` You do not have sufficient permissions to access this page. ``` I dont know what to do. I googled a lot but not much help. I dont have access to the s...
You can try enable the theme editor via WP-Config as shown here: <http://www.wp-edge.com/how-to-enabledisable-wordpress-theme-editor/> It's probably impossible if you don't have FTP access - but its possible that the theme editor was enabled previously via the theme funcitons.php and has since been disabled once you r...
134,036
<p>Is there a way to show custom page settings on specific page templates ONLY?</p> <p>For instance I have a settings field: "Custom Settings". I don't want this to show on the "Default Page Template". I only want it to display if we select the "Custom Page Settings Page Template".</p> <p>Here's my meta box code:</p>...
[ { "answer_id": 134047, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 2, "selected": true, "text": "<p>I typically use CSS and jQuery for this type of thing by hooking <code>admin_head</code>. This should be do...
2014/02/10
[ "https://wordpress.stackexchange.com/questions/134036", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35801/" ]
Is there a way to show custom page settings on specific page templates ONLY? For instance I have a settings field: "Custom Settings". I don't want this to show on the "Default Page Template". I only want it to display if we select the "Custom Page Settings Page Template". Here's my meta box code: ``` function cd_met...
I typically use CSS and jQuery for this type of thing by hooking `admin_head`. This should be done client-site as a user has an option to select your template or another one after DOM load. Basically, all you do is check if the value is set for `#page_template` and toggle `show/hide` if your template is selected or not...
134,049
<p>Have a function I use to print Open Graph tags in the header of each page I also have a plugin I use to post to Facebook which also puts in it's own set of basic OG Tags. Facebook doesn't like if a page as more than one og:url tag. The plugin only works on single pages so I want to not print my og:url tag when it is...
[ { "answer_id": 134039, "author": "Tarei SuperChur King", "author_id": 41448, "author_profile": "https://wordpress.stackexchange.com/users/41448", "pm_score": 1, "selected": false, "text": "<p>As this is a premium theme, I would recommend going back to the original developer for a improve...
2014/02/10
[ "https://wordpress.stackexchange.com/questions/134049", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26967/" ]
Have a function I use to print Open Graph tags in the header of each page I also have a plugin I use to post to Facebook which also puts in it's own set of basic OG Tags. Facebook doesn't like if a page as more than one og:url tag. The plugin only works on single pages so I want to not print my og:url tag when it is on...
As this is a premium theme, I would recommend going back to the original developer for a improvement request. You might find they are already implementing this or might be interested in your feedback and initiate the changes. <http://themeforest.net/item/medicenter-responsive-medical-health-template/4000598>
134,077
<p>I have a function that checks page specific and global settings to determine a class related to sidebars. I call the function from the archive.php template and try to check that <code>post_type</code> is 'post', however the <code>post_type</code> var isn't set.</p> <p>Relevant Code:</p> <pre><code>function get_sid...
[ { "answer_id": 134078, "author": "Eric Holmes", "author_id": 23454, "author_profile": "https://wordpress.stackexchange.com/users/23454", "pm_score": 1, "selected": false, "text": "<p>What type of page/post are you looking at when you echo this out? <code>post_type</code> does not get pop...
2014/02/10
[ "https://wordpress.stackexchange.com/questions/134077", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18322/" ]
I have a function that checks page specific and global settings to determine a class related to sidebars. I call the function from the archive.php template and try to check that `post_type` is 'post', however the `post_type` var isn't set. Relevant Code: ``` function get_sidebar_class() { global $wp_query; ec...
Query vars are... fun like that. Depending on which archive you are messing with [`get_post_type()`](http://queryposts.com/function/get_post_type/) just might be simple enough to do it (it gets type from actual post, not query). Otherwise you might want to go for [`get_queried_object()`](http://queryposts.com/function...
134,092
<p>To improve user experience, I want to make changes to the image meta fields in the Media Library: </p> <p><img src="https://i.stack.imgur.com/rvmtQ.jpg" alt="Image Meta Fields"></p> <p>As demonstrated above, I want to change the <code>Caption</code> field to <code>Source</code> and remove the <code>Alt Text</code>...
[ { "answer_id": 134098, "author": "Nathan Powell", "author_id": 27196, "author_profile": "https://wordpress.stackexchange.com/users/27196", "pm_score": 0, "selected": false, "text": "<p>I found this <a href=\"http://code.tutsplus.com/tutorials/creating-custom-fields-for-attachments-in-wor...
2014/02/10
[ "https://wordpress.stackexchange.com/questions/134092", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24875/" ]
To improve user experience, I want to make changes to the image meta fields in the Media Library: ![Image Meta Fields](https://i.stack.imgur.com/rvmtQ.jpg) As demonstrated above, I want to change the `Caption` field to `Source` and remove the `Alt Text` and `Description` field. How can I achieve this?
I don't know if this answer will be of much use given the age of this question now, but perhaps it will provide an answer sufficient that you can at least consider the question answered. I would point out this approach involves creating copies of WordPress functions, modifying them and repointing WP hooks (unhooking a...
134,106
<p>I'm trying to show a post thumbnail outside of the loop. The reason for this is that i want the featured image to show inside a custom page template, which will set the header image for the particular page for which the custom page template is set.</p> <p>I've tried the obvious <code>the_post_thumbnail();</code> an...
[ { "answer_id": 134108, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail\" rel=\"nofollow\"><code>get_...
2014/02/10
[ "https://wordpress.stackexchange.com/questions/134106", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26686/" ]
I'm trying to show a post thumbnail outside of the loop. The reason for this is that i want the featured image to show inside a custom page template, which will set the header image for the particular page for which the custom page template is set. I've tried the obvious `the_post_thumbnail();` and as expected, it did...
Take a look into the function single\_post\_title() in the general-template.php file and you will find following: ``` $_post = get_queried_object(); ``` and in that function you also see: ``` $_post->post_title ``` which gives you the title of the page outside of the loop. Now to get the Featured Image you simp...
134,120
<p>I have a website and I want to add automatically categories to my menu. I mean when I create new category it should appear in my menu. How I can make it?</p> <pre><code> &lt;?php wp_nav_menu( array( 'theme_location' =&gt; 'header', 'container' =&gt; '' ) ); ?&gt; Home | Categories | Contact category1 ...
[ { "answer_id": 134108, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail\" rel=\"nofollow\"><code>get_...
2014/02/10
[ "https://wordpress.stackexchange.com/questions/134120", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47413/" ]
I have a website and I want to add automatically categories to my menu. I mean when I create new category it should appear in my menu. How I can make it? ``` <?php wp_nav_menu( array( 'theme_location' => 'header', 'container' => '' ) ); ?> Home | Categories | Contact category1 category2 ...
Take a look into the function single\_post\_title() in the general-template.php file and you will find following: ``` $_post = get_queried_object(); ``` and in that function you also see: ``` $_post->post_title ``` which gives you the title of the page outside of the loop. Now to get the Featured Image you simp...
134,151
<p>In my theme has one shortcode tags to display tags of post and function to load content post. But in function doesn't include shortcode tag. Now I want to add it to function but i don't know how to do it. Hope everyone help me out. Thank in advance.</p> <p><strong>Shortcode tag</strong></p> <pre><code>function wwl...
[ { "answer_id": 134153, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>i wanna add shortcode tag into single post to display tags</p>\n</blockquote>\n\n<p>Paste <c...
2014/02/11
[ "https://wordpress.stackexchange.com/questions/134151", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38796/" ]
In my theme has one shortcode tags to display tags of post and function to load content post. But in function doesn't include shortcode tag. Now I want to add it to function but i don't know how to do it. Hope everyone help me out. Thank in advance. **Shortcode tag** ``` function wwl_post_tags( $atts ) { if( $tag...
> > i wanna add shortcode tag into single post to display tags > > > Paste `[post_tags]` into your post body via the [post editor on the backend](http://codex.wordpress.org/Writing_Posts). See: <http://codex.wordpress.org/Shortcode_API> If you want to do it automatically you could put a filter on `the_content` (...
134,155
<p>I'm using Ian Stewart's <a href="http://themeshaper.com/2010/06/03/sample-theme-options/" rel="nofollow noreferrer">Sample Theme Options</a> for a lightweight Theme Options panel.</p> <h3>INSERTION FAILED</h3> <p>I need to insert Multiple categories into db, where I used the following code:</p> <pre><code>&lt;select...
[ { "answer_id": 134162, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>The problem here is that you don’t allow PHP to read more than one value, because all values use the same name <code>s...
2014/02/11
[ "https://wordpress.stackexchange.com/questions/134155", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22728/" ]
I'm using Ian Stewart's [Sample Theme Options](http://themeshaper.com/2010/06/03/sample-theme-options/) for a lightweight Theme Options panel. ### INSERTION FAILED I need to insert Multiple categories into db, where I used the following code: ``` <select multiple="multiple" name="site_options[categorychoice]"> <?...
The problem here is that you don’t allow PHP to read more than one value, because all values use the same name `site_options[categorychoice]`, so they overwrite each other, and the last one wins. You need more brackets. Set the `name` attribute of your `select` element to `site_options[categorychoice][]`, and all valu...
134,172
<p>Im creating my own theme. When I have a clean wordpress installation, there are some default widgets in the sidebar (search, category, recent posts etc). I know that I can remove them from the sidebar by adding a widget to that sidebar, but I want them removed in the sidebar by default. Is there a way to do that wit...
[ { "answer_id": 238796, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 2, "selected": false, "text": "<p>This function will <a href=\"https://wordpress.stackexchange.com/questions/192159/remove-all-widgets-from-sideba...
2014/02/11
[ "https://wordpress.stackexchange.com/questions/134172", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15228/" ]
Im creating my own theme. When I have a clean wordpress installation, there are some default widgets in the sidebar (search, category, recent posts etc). I know that I can remove them from the sidebar by adding a widget to that sidebar, but I want them removed in the sidebar by default. Is there a way to do that withou...
This function will [disable all widgets](https://wordpress.stackexchange.com/questions/192159/remove-all-widgets-from-sidebar): ``` add_filter( 'sidebars_widgets', 'wpse134172_disable_all_widgets' ); function wpse134172_disable_all_widgets( $sidebars_widgets ) { if (true == true) { $sidebars_widgets = array( ...
134,193
<p>I'm creating a Wordpress theme that I'm hoping to sell on Themeforest. Now I know much about escaping user inputted data using functions like esc_html, esc_url and so on and I use them in the comments template and few other places in my theme. What I'm not sure about is whether I'm suppose to use these functions on ...
[ { "answer_id": 134202, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 0, "selected": false, "text": "<p>Yes you should escape. the DB is supposed to hold the raw value therefor you should assume it needs to be...
2014/02/11
[ "https://wordpress.stackexchange.com/questions/134193", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43834/" ]
I'm creating a Wordpress theme that I'm hoping to sell on Themeforest. Now I know much about escaping user inputted data using functions like esc\_html, esc\_url and so on and I use them in the comments template and few other places in my theme. What I'm not sure about is whether I'm suppose to use these functions on t...
YES. You always escape output that originally comes from user submitted data. To be safe, you always escape variable output, period.
134,209
<p>In my menu I have a page that is called <code>Campaign</code>.</p> <p>When the user enters to <code>Campaign</code> the page displays the last custom post type of <code>campaign-post</code>.</p> <p>In the sidebar of <code>Campaign</code> page, I'm displaying a list of all <code>campaign-post</code> custom posts.</...
[ { "answer_id": 134215, "author": "Sudeep K Rana", "author_id": 47179, "author_profile": "https://wordpress.stackexchange.com/users/47179", "pm_score": 3, "selected": true, "text": "<p>That's easy: You should use <code>$wp_query-&gt;current_post</code> to retrieve the index of your custom...
2014/02/11
[ "https://wordpress.stackexchange.com/questions/134209", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22933/" ]
In my menu I have a page that is called `Campaign`. When the user enters to `Campaign` the page displays the last custom post type of `campaign-post`. In the sidebar of `Campaign` page, I'm displaying a list of all `campaign-post` custom posts. The problem is that I don't know how to highlight (add `current` class) ...
That's easy: You should use `$wp_query->current_post` to retrieve the index of your custom query. In your case query will work something like this: ``` <ul class="post-list"> <?php $query = new WP_Query( array( 'post_type' => 'campaign-post' ) ); while ( $query->have_posts() ) : $query->the_post(); ...
134,223
<p>I’m having a problem with the popular Advanced Custom fields plugin, trying to update/append rows in repeater fields. I’m trying to migrate all data from one table into user meta and I keep getting the following error.</p> <p>Catchable fatal error: Object of class WP_Error could not be converted to string in C:\wam...
[ { "answer_id": 134224, "author": "Eckstein", "author_id": 23492, "author_profile": "https://wordpress.stackexchange.com/users/23492", "pm_score": 0, "selected": false, "text": "<p>I'm surprised you're not getting support from Elliot over at ACF, he is usually very responsive.</p>\n\n<p>W...
2014/02/11
[ "https://wordpress.stackexchange.com/questions/134223", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43733/" ]
I’m having a problem with the popular Advanced Custom fields plugin, trying to update/append rows in repeater fields. I’m trying to migrate all data from one table into user meta and I keep getting the following error. Catchable fatal error: Object of class WP\_Error could not be converted to string in C:\wamp\www\bac...
Solved!!! `$post_id = $pid;` needs to be `$post_id = "user_{$pid}";` Seems pretty obvious now as the id could be for anything. Chris
134,230
<p>With debugging set to on,</p> <pre><code>define('WP_DEBUG', true); </code></pre> <p>my instance of WordPress doesn't show any debugging info.</p> <p>After a lot of searching I figured that after I call <code>wp_debug_mode()</code> debug info shows correctly.</p> <p>Can anyone tell me why calling <code>wp_debug_m...
[ { "answer_id": 134240, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 3, "selected": true, "text": "<p>If ACF (or any other plugin) is active on the site you do not need to include its files as they are all be...
2014/02/11
[ "https://wordpress.stackexchange.com/questions/134230", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21061/" ]
With debugging set to on, ``` define('WP_DEBUG', true); ``` my instance of WordPress doesn't show any debugging info. After a lot of searching I figured that after I call `wp_debug_mode()` debug info shows correctly. Can anyone tell me why calling `wp_debug_mode()` is necessary, since the debugging [documentation ...
If ACF (or any other plugin) is active on the site you do not need to include its files as they are all being included in the wordpress initialization process. The only tricky part is that you don't know the order in which files are included and yours might be included before the ACF files are included, therefor you sh...
134,232
<p>I wanted to know if there was a way to modify the back-end of Wordpress to do 2 things:</p> <ul> <li>Make all tags' font the same size, so none are larger than the others</li> <li>Always show the most used tags when creating/editing a post</li> </ul> <p>This only applies to the back-end of Wordpress, not calling t...
[ { "answer_id": 134272, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>With <code>wp_tag_cloud</code> you can set the <code>smallest</code> and <code>largest</code> argument to th...
2014/02/11
[ "https://wordpress.stackexchange.com/questions/134232", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12294/" ]
I wanted to know if there was a way to modify the back-end of Wordpress to do 2 things: * Make all tags' font the same size, so none are larger than the others * Always show the most used tags when creating/editing a post This only applies to the back-end of Wordpress, not calling the tag cloud or any sort of front-e...
use this at functions.php ``` /* Tagcloud, change the font size */ function custom_tag_cloud_widget($args) { $args['largest'] = 13; //largest tag $args['smallest'] = 13; //smallest tag $args['unit'] = 'px'; //tag font unit return $args; } add_filter( 'widget_tag_cloud_args', 'custom_tag_cloud_widge...
134,241
<p>in my main plugin page i check if a certain page is visited if so, i load a certain template. in the following way:</p> <pre><code>add_filter( 'template_include', array($this, 'includeTemplate'), 99 ); public function includeTemplate($template){ global $wp_query; if(is_page() &amp;&amp; $wp_query-&gt;query...
[ { "answer_id": 134250, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": true, "text": "<p><code>the_header()</code> does not even seem to be native WP function?</p>\n\n<p>Technically getting header isn't wh...
2014/02/11
[ "https://wordpress.stackexchange.com/questions/134241", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41032/" ]
in my main plugin page i check if a certain page is visited if so, i load a certain template. in the following way: ``` add_filter( 'template_include', array($this, 'includeTemplate'), 99 ); public function includeTemplate($template){ global $wp_query; if(is_page() && $wp_query->query['pagename'] == 'my_page_...
`the_header()` does not even seem to be native WP function? Technically getting header isn't what really causes styles and scripts to load, it's [`wp_head()`](http://queryposts.com/function/wp_head/) call that should be made there (and [`wp_footer()`](http://queryposts.com/function/wp_footer/) call in footer). So they...
134,266
<p>I just started using <a href="http://gulpjs.com/" rel="nofollow">gulp.js</a> which is a task runner like Grunt and a lot of the sites I work on are using WordPress so I was wondering if anyone has some ideas about how to use the combined scripts that gulp will output with WordPress (or for that matter any file that ...
[ { "answer_id": 134390, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>This is unsolvable. There are no means of identifying what exactly third party code is loading, short of maintainin...
2014/02/12
[ "https://wordpress.stackexchange.com/questions/134266", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24814/" ]
I just started using [gulp.js](http://gulpjs.com/) which is a task runner like Grunt and a lot of the sites I work on are using WordPress so I was wondering if anyone has some ideas about how to use the combined scripts that gulp will output with WordPress (or for that matter any file that combines multiple files into ...
I've been messing around with it some more and the best way I can think of is to register the scripts that are going to be combined and set their source to false to prevent other plugins from loading them. I know it's not the best solution and is a little hacky but can't think of any other ways. Plus this will only wor...
134,318
<p>I am using Underscores.me for a project. I'd like to add the featured image (thumbnail) to the previous / next post links. They have a function which I'm trying to edit called <code>THEMENAME_post_nav()</code>. I am struggling to tweak this function to make it include the thumbnails. Can anyone help please? Here's t...
[ { "answer_id": 134323, "author": "toni_lehtimaki", "author_id": 47286, "author_profile": "https://wordpress.stackexchange.com/users/47286", "pm_score": 0, "selected": false, "text": "<blockquote>\n<pre><code> previous_post_link( '&lt;div class=\"nav-previous\"&gt;%link&lt;/div&gt;$prevth...
2014/02/12
[ "https://wordpress.stackexchange.com/questions/134318", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43094/" ]
I am using Underscores.me for a project. I'd like to add the featured image (thumbnail) to the previous / next post links. They have a function which I'm trying to edit called `THEMENAME_post_nav()`. I am struggling to tweak this function to make it include the thumbnails. Can anyone help please? Here's the code: ``` ...
I solved the problem by using `get_the_post_thumbnail()` instead of the variables `$prevthumbnail` and `$nextthumbnail`. ``` function THEMENAME_post_nav() { // Don't print empty markup if there's nowhere to navigate. $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', ...
134,338
<p>I know how to count comment per post, user and in total but i am<br> having problems getting <strong>the total amount of comments post in a specific post type</strong>. </p> <p>I guess i can loop trough all the posts and count each one<br> comments but i am looking for something faster and less<br> resource expens...
[ { "answer_id": 134342, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>How about direct sql with a simple subquery to first get all the post ids of your custom post type ex:</p>\n\...
2014/02/12
[ "https://wordpress.stackexchange.com/questions/134338", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7990/" ]
I know how to count comment per post, user and in total but i am having problems getting **the total amount of comments post in a specific post type**. I guess i can loop trough all the posts and count each one comments but i am looking for something faster and less resource expensive Appreciate your help ...
How about direct sql with a simple subquery to first get all the post ids of your custom post type ex: ``` function get_all_comments_of_post_type($post_type){ global $wpdb; $cc = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID in ( SELECT ID FROM $wpdb->post...
134,347
<p>I currently have a WP_query where I am getting posts from a specific set of authors. To this, I want to add specific categories as well. </p> <pre><code>$args = array( 'author__in' =&gt; $authors, 'posts_per_page' =&gt; 12, 'paged' =&gt; $paged ); </code></pre> <p>$authors is an array containing users' ids.</p> <...
[ { "answer_id": 134353, "author": "Sudeep K Rana", "author_id": 47179, "author_profile": "https://wordpress.stackexchange.com/users/47179", "pm_score": 1, "selected": false, "text": "<p>Is this what you are looking for?</p>\n\n<pre><code>$query = new wp_query($arr);\n $arr = array(\n ...
2014/02/12
[ "https://wordpress.stackexchange.com/questions/134347", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14128/" ]
I currently have a WP\_query where I am getting posts from a specific set of authors. To this, I want to add specific categories as well. ``` $args = array( 'author__in' => $authors, 'posts_per_page' => 12, 'paged' => $paged ); ``` $authors is an array containing users' ids. So, I need to query posts from both, au...
Is this what you are looking for? ``` $query = new wp_query($arr); $arr = array( 'author__in'=> array(2,4,6), //Authors's id's you like to include 'posts_per_page' => '12', 'paged' => $paged, 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => '...
134,355
<p>I have a centOS VPS (Apach+Nginx). Right now I use APC for w3 total plugin cache (disk enhanced for page cache). I have less than 25MB database.</p> <p>I can see several w3tc, APC cache errors. I think the main issue is Zend optimizer. What is the good option for wordperss database cache (eAccelerator, XCache)?</p>...
[ { "answer_id": 134353, "author": "Sudeep K Rana", "author_id": 47179, "author_profile": "https://wordpress.stackexchange.com/users/47179", "pm_score": 1, "selected": false, "text": "<p>Is this what you are looking for?</p>\n\n<pre><code>$query = new wp_query($arr);\n $arr = array(\n ...
2014/02/12
[ "https://wordpress.stackexchange.com/questions/134355", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26997/" ]
I have a centOS VPS (Apach+Nginx). Right now I use APC for w3 total plugin cache (disk enhanced for page cache). I have less than 25MB database. I can see several w3tc, APC cache errors. I think the main issue is Zend optimizer. What is the good option for wordperss database cache (eAccelerator, XCache)? Error. ``` ...
Is this what you are looking for? ``` $query = new wp_query($arr); $arr = array( 'author__in'=> array(2,4,6), //Authors's id's you like to include 'posts_per_page' => '12', 'paged' => $paged, 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => '...
134,360
<p>I need to make that administrator could'nt manage options, but it is not working...</p> <p>My code:</p> <pre><code>function set_capabilities() { $editor = get_role( 'administrator' ); $editor = remove_cap('manage_options'); } add_action( 'admin_init', 'set_capabilities' ); </code></pre> <p>What I do wro...
[ { "answer_id": 134353, "author": "Sudeep K Rana", "author_id": 47179, "author_profile": "https://wordpress.stackexchange.com/users/47179", "pm_score": 1, "selected": false, "text": "<p>Is this what you are looking for?</p>\n\n<pre><code>$query = new wp_query($arr);\n $arr = array(\n ...
2014/02/12
[ "https://wordpress.stackexchange.com/questions/134360", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11896/" ]
I need to make that administrator could'nt manage options, but it is not working... My code: ``` function set_capabilities() { $editor = get_role( 'administrator' ); $editor = remove_cap('manage_options'); } add_action( 'admin_init', 'set_capabilities' ); ``` What I do wrong ?
Is this what you are looking for? ``` $query = new wp_query($arr); $arr = array( 'author__in'=> array(2,4,6), //Authors's id's you like to include 'posts_per_page' => '12', 'paged' => $paged, 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => '...
134,391
<p>I'm writing some plugins that do background batch processing, i.e. operations that take longer than 30 seconds. I'm creating objects with the necessary job parameters set like this (this is a hugely simplified example):</p> <pre><code>class MyPlugin_Create_Terms { public $job_id; public $terms; public $...
[ { "answer_id": 134393, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>Store the object temporarily in the database, but implement <a href=\"http://www.php.net/manual/en/language.oop5.magic...
2014/02/12
[ "https://wordpress.stackexchange.com/questions/134391", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26135/" ]
I'm writing some plugins that do background batch processing, i.e. operations that take longer than 30 seconds. I'm creating objects with the necessary job parameters set like this (this is a hugely simplified example): ``` class MyPlugin_Create_Terms { public $job_id; public $terms; public $taxonomy; ...
Store the object temporarily in the database, but implement [`__sleep()` and `__wakeup()`](http://www.php.net/manual/en/language.oop5.magic.php#object.sleep) to avoid side effects. Alternatively, implement the [`Serializable` interface](http://www.php.net/manual/en/class.serializable.php) and prepare the data in its ...
134,392
<p>Writers on our large Wordpress installation love to use the the content searching functionality. As convenient as this functionality is, the complexity of its queries slows down our database considerably. Here's an example of an SQL query I found in our slow query log from just a few minutes ago:</p> <pre><code>S...
[ { "answer_id": 135018, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<h2>Altering the <code>WHERE</code> clause</h2>\n\n<p>There's a filter named <code>posts_search</code> that allows to...
2014/02/12
[ "https://wordpress.stackexchange.com/questions/134392", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10388/" ]
Writers on our large Wordpress installation love to use the the content searching functionality. As convenient as this functionality is, the complexity of its queries slows down our database considerably. Here's an example of an SQL query I found in our slow query log from just a few minutes ago: ``` SELECT SQL_CALC_F...
Altering the `WHERE` clause --------------------------- There's a filter named `posts_search` that allows to filter the SQL `WHERE` clause used for the query during search (when `WP_Query::is_search()` returns true and `WP_Query->s` is set): ``` add_filter( 'posts_search', 'wpse134392PostsSearchSQL', 20, 2 ); functio...
134,402
<p>Is it possible to dequeue scripts in IE7 only using functions.php? I have my scripts configured in the following way:</p> <pre><code>// JS function scripts() { // Register scripts &amp; styles wp_register_script( 'responsive_nav', get_template_directory_uri() . '/js/responsive-nav.js', '', '', false ); wp_reg...
[ { "answer_id": 134405, "author": "Shazzad", "author_id": 42967, "author_profile": "https://wordpress.stackexchange.com/users/42967", "pm_score": 2, "selected": true, "text": "<p>WordPress has built-in browser detection mechanism. And they set a global variable <code>$is_IE</code>.</p>\n\...
2014/02/12
[ "https://wordpress.stackexchange.com/questions/134402", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37548/" ]
Is it possible to dequeue scripts in IE7 only using functions.php? I have my scripts configured in the following way: ``` // JS function scripts() { // Register scripts & styles wp_register_script( 'responsive_nav', get_template_directory_uri() . '/js/responsive-nav.js', '', '', false ); wp_register_script( 'ini...
WordPress has built-in browser detection mechanism. And they set a global variable `$is_IE`. ``` function scripts() { global $is_IE; if( ! $is_IE ){ // Register scripts & styles // Enqueue } } add_action( 'wp_enqueue_scripts', 'scripts' ); ```
134,412
<p>Based on: <a href="http://codex.wordpress.org/Function_Reference/paginate_links" rel="nofollow">http://codex.wordpress.org/Function_Reference/paginate_links</a> how to make these links show as 01, 02, 03... rather than the normal single digit?</p> <p>thanks so much</p>
[ { "answer_id": 134405, "author": "Shazzad", "author_id": 42967, "author_profile": "https://wordpress.stackexchange.com/users/42967", "pm_score": 2, "selected": true, "text": "<p>WordPress has built-in browser detection mechanism. And they set a global variable <code>$is_IE</code>.</p>\n\...
2014/02/12
[ "https://wordpress.stackexchange.com/questions/134412", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5181/" ]
Based on: <http://codex.wordpress.org/Function_Reference/paginate_links> how to make these links show as 01, 02, 03... rather than the normal single digit? thanks so much
WordPress has built-in browser detection mechanism. And they set a global variable `$is_IE`. ``` function scripts() { global $is_IE; if( ! $is_IE ){ // Register scripts & styles // Enqueue } } add_action( 'wp_enqueue_scripts', 'scripts' ); ```
134,414
<p>Is there a way for me to replace the icons in the WordPress Dashboard with custom ones? I'm imagining there's got to be a way to do this with the <code>functions.php</code> or, more ideally, with a custom-built plugin, but I have no idea how to do that kind of stuff, and Google has failed me. In particular, I'm look...
[ { "answer_id": 134426, "author": "Sven", "author_id": 32946, "author_profile": "https://wordpress.stackexchange.com/users/32946", "pm_score": 4, "selected": true, "text": "<p>Yes, you can replace existing icons by overwriting them via CSS. </p>\n\n<p>Make sure to check if the existing ic...
2014/02/12
[ "https://wordpress.stackexchange.com/questions/134414", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24566/" ]
Is there a way for me to replace the icons in the WordPress Dashboard with custom ones? I'm imagining there's got to be a way to do this with the `functions.php` or, more ideally, with a custom-built plugin, but I have no idea how to do that kind of stuff, and Google has failed me. In particular, I'm looking to replace...
Yes, you can replace existing icons by overwriting them via CSS. Make sure to check if the existing icon is set via `img` or `background-image` and add some CSS to overwrite it with one of the available icons. You can find all available icons and the appropriate selector at the [Dashicons Website](http://melchoyce.gi...
134,415
<p>I see a lot of forum threads about the possibility of changing the default WordPress display name to First Name and Last Name. By default, the default display name of my theme is set the First Name and Last Name and I would like to set it back to the login name by default. I'd like to know the bit of code I have to ...
[ { "answer_id": 134421, "author": "gdaniel", "author_id": 30984, "author_profile": "https://wordpress.stackexchange.com/users/30984", "pm_score": 0, "selected": false, "text": "<p>Go to Users -> Your Profile\nFind the section called \"Display name publicly as\"\nSelect an option that fits...
2014/02/12
[ "https://wordpress.stackexchange.com/questions/134415", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36537/" ]
I see a lot of forum threads about the possibility of changing the default WordPress display name to First Name and Last Name. By default, the default display name of my theme is set the First Name and Last Name and I would like to set it back to the login name by default. I'd like to know the bit of code I have to add...
Based on this [this answer](https://stackoverflow.com/a/22257780/2593099): ``` add_action( 'wp_login', 'wpse_9326315_format_user_display_name_on_login' ); function wpse_9326315_format_user_display_name_on_login( $username ) { $user = get_user_by( 'login', $username ); $userdata = array( 'ID' => $use...
134,423
<p>I found a partial answer at: <a href="http://floatleft.com/notebook/wordpress-year-month-archives/" rel="nofollow">http://floatleft.com/notebook/wordpress-year-month-archives/</a></p> <p>This solution shows all months that have posts. Its not even that much code:</p> <pre><code>&lt;?php $year_prev = null; ...
[ { "answer_id": 134434, "author": "gdaniel", "author_id": 30984, "author_profile": "https://wordpress.stackexchange.com/users/30984", "pm_score": 2, "selected": true, "text": "<p>The code below will loop through everywhere year and check to see if each month has posts. If so, it will add ...
2014/02/12
[ "https://wordpress.stackexchange.com/questions/134423", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5181/" ]
I found a partial answer at: <http://floatleft.com/notebook/wordpress-year-month-archives/> This solution shows all months that have posts. Its not even that much code: ``` <?php $year_prev = null; $months = $wpdb->get_results( "SELECT DISTINCT MONTH( post_date ) AS month , ...
The code below will loop through everywhere year and check to see if each month has posts. If so, it will add a link to the month. If not, it will just print the month without a link. You will need to edit the actual link as I am not sure about your websites' permalink structure. ``` //Grab the earliest year available...
134,440
<p>I am using Justin Tadlock's <a href="https://wordpress.org/plugins/members/" rel="nofollow">Members</a> plugin 0.2.4.</p> <p>I have a custom user role "Author" that I am granting permission to post a Custom Post Type "blogpost". The Author can post and edit the CPT blogpost however cannot add categories as the chec...
[ { "answer_id": 134442, "author": "Brad Dalton", "author_id": 9884, "author_profile": "https://wordpress.stackexchange.com/users/9884", "pm_score": 1, "selected": false, "text": "<p>Maybe the name of your CPT needs to be changed </p>\n\n<pre><code>blogpost\n</code></pre>\n\n<p>You could a...
2014/02/13
[ "https://wordpress.stackexchange.com/questions/134440", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35436/" ]
I am using Justin Tadlock's [Members](https://wordpress.org/plugins/members/) plugin 0.2.4. I have a custom user role "Author" that I am granting permission to post a Custom Post Type "blogpost". The Author can post and edit the CPT blogpost however cannot add categories as the check-boxes are grayed out. Others have...
I had the same problem, a custom role couldn't assign categories to my CPT. When doing `register_taxonomy()`, I added these capabilities: ``` 'capabilities' => array ( 'manage_terms' => 'manage_options', //by default only admin 'edit_terms' => 'manage_options', ...
134,453
<p>I want to hide some menus on admin panel: Appearance, Plugins, and Tools.</p> <p>How to hide it without plugin?</p> <p>And how can I un-hide them later easily?</p>
[ { "answer_id": 134455, "author": "iyrin", "author_id": 33393, "author_profile": "https://wordpress.stackexchange.com/users/33393", "pm_score": 4, "selected": true, "text": "<p>You can do this with <a href=\"http://codex.wordpress.org/Function_Reference/remove_menu_page\" rel=\"noreferrer...
2014/02/13
[ "https://wordpress.stackexchange.com/questions/134453", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27234/" ]
I want to hide some menus on admin panel: Appearance, Plugins, and Tools. How to hide it without plugin? And how can I un-hide them later easily?
You can do this with [remove\_menu\_page](http://codex.wordpress.org/Function_Reference/remove_menu_page). Add the appropriate menu slug in your functions.php of your theme or your plugin. `<?php remove_menu_page( $menu_slug ) ?>` Note that users can still access these menus using a direct link. If you intend to blo...