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
44,905
<p>Now it shows something like this:</p> <ul> <li>March 2012</li> <li>February 2012</li> </ul> <p>But I want to show something like this</p> <ul> <li>03.2012</li> <li>02.2012</li> </ul> <p>or something in Turkish like this</p> <ul> <li>Mart 2012</li> <li>Şubat 2012</li> </ul>
[ { "answer_id": 44911, "author": "Geert", "author_id": 4936, "author_profile": "https://wordpress.stackexchange.com/users/4936", "pm_score": 1, "selected": false, "text": "<p>The WordPress Archive widget internally calls <a href=\"http://codex.wordpress.org/Function_Reference/wp_get_archi...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44905", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13702/" ]
Now it shows something like this: * March 2012 * February 2012 But I want to show something like this * 03.2012 * 02.2012 or something in Turkish like this * Mart 2012 * Şubat 2012
For archives you can use the get\_archives\_link filter like this: ``` add_filter('get_archives_link', 'translate_archive_month'); function translate_archive_month($list) { $patterns = array( '/January/', '/February/', '/March/', '/April/', '/May/', '/June/', '/July/', '/August/', '/September/', '/October...
44,927
<p>I really hope this is a facepalm moment, b/c i'm getting frustrated with this. Making a quick loop to show certain attachment images. lifted it almost straight from the codex but wp_get_attachment_image() isn't behaving like I'd expect. </p> <p>isn't the ID part of the wp_get_attachment_image the ID of the attac...
[ { "answer_id": 44934, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<h3>Problem debugging:</h3>\n\n<p>If you <code>var_export()</code> the result of <code>$image = wp_get_attachment_imag...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44927", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6477/" ]
I really hope this is a facepalm moment, b/c i'm getting frustrated with this. Making a quick loop to show certain attachment images. lifted it almost straight from the codex but wp\_get\_attachment\_image() isn't behaving like I'd expect. isn't the ID part of the wp\_get\_attachment\_image the ID of the attachment? ...
**solution:** the the face palm i was waiting on at some point i must've been debugging something and for who knows what reason i put a ``` function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) { return false; ``` right at the beginning of wp\_get\_attachment\_image this is all l...
44,950
<p>I am making a review system where i need to find update rating average when:</p> <ul> <li>A comment gets approved from pending/trash/spam.</li> <li>A comment gets upapprove from approve</li> <li>A admin post reviews (auto approved)</li> <li>A comment gets edited (from backend or frontend custom dashboard when user w...
[ { "answer_id": 45195, "author": "soulseekah", "author_id": 9480, "author_profile": "https://wordpress.stackexchange.com/users/9480", "pm_score": 3, "selected": true, "text": "<p>The <a href=\"http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/comment.php#L1348\" rel=\"nofollow...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44950", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3094/" ]
I am making a review system where i need to find update rating average when: * A comment gets approved from pending/trash/spam. * A comment gets upapprove from approve * A admin post reviews (auto approved) * A comment gets edited (from backend or frontend custom dashboard when user wants to edit/update/remove his alr...
The [`comment_post` hook](http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/comment.php#L1348) is called with a `$comment_id` as the first argument. You can see why your function is failing. Same goes for the [`edit_comment` hook](http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/comment.php#L1...
44,962
<p>I'd like to add a meta box to all my pages (not posts) but it looks like I am only able to add it for a specific post based on the codex?</p> <pre><code>add_meta_box( $id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args = null ); </code></pre>
[ { "answer_id": 44965, "author": "Steven", "author_id": 1447, "author_profile": "https://wordpress.stackexchange.com/users/1447", "pm_score": 2, "selected": true, "text": "<p>Try this. This is part of some code I use.</p>\n\n<pre><code> // Add meta boxes to Page\n add_meta_box( 'RelatedI...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44962", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2417/" ]
I'd like to add a meta box to all my pages (not posts) but it looks like I am only able to add it for a specific post based on the codex? ``` add_meta_box( $id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args = null ); ```
Try this. This is part of some code I use. ``` // Add meta boxes to Page add_meta_box( 'RelatedImage', __('Related images'), 'related_images_meta_box', 'page', 'normal', 'high' ); function related_images_meta_box($object) { $nonce = wp_create_nonce(plugin_basename( __FILE__ )); ?> <input type="hidden"...
44,963
<p>Im trying to use Isotope(<a href="http://isotope.metafizzy.co/" rel="nofollow">http://isotope.metafizzy.co/</a>) to filter my Wordpress posts, <a href="http://i44.tinypic.com/fco55k.jpg" rel="nofollow">http://i44.tinypic.com/fco55k.jpg</a> this is how my site looks like, i would like to filter posts depending on a ...
[ { "answer_id": 44974, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>First, wrap your post output in a <code>&lt;div&gt;</code>, and add the <a href=\"http://codex.wordpress.or...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44963", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13960/" ]
Im trying to use Isotope(<http://isotope.metafizzy.co/>) to filter my Wordpress posts, <http://i44.tinypic.com/fco55k.jpg> this is how my site looks like, i would like to filter posts depending on a post category so i need to add a class name to each post and then filter it using isotope ``` <li><a href="#" data-fi...
Not sure you got Isotope and filters working yet ?? There are 2 things I think you missed 1. the Filters need to be wrapped in a class (so that the jquery can be actioned by the click on the a links) like so: ``` <ul id="options"> <li><a href="#" data-filter="*">show all</a></li> <li><a href="#" data-filter=".web">w...
44,966
<p>I would like to add a select list in the <code>Page Attribute</code> box you see on the right side in the administration interface for pages.</p> <p>Does anyone know if that is possible?</p> <p>Or at least add a custom box below this box?</p>
[ { "answer_id": 44969, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 5, "selected": true, "text": "<p>There are no convenient hooks to add something to that box.</p>\n\n<p>You could do one of two things. </p>...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44966", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1447/" ]
I would like to add a select list in the `Page Attribute` box you see on the right side in the administration interface for pages. Does anyone know if that is possible? Or at least add a custom box below this box?
There are no convenient hooks to add something to that box. You could do one of two things. **1. Add a new Meta Box** You do this by hooking into the `add_meta_boxes` action and calling [`add_meta_box`](http://codex.wordpress.org/Function_Reference/add_meta_box). You can specify a callback function in your call to ...
44,978
<p>Is there a way that i can place a certain widget anywhere on the site?</p> <p><strong>For example</strong>: </p> <p>I'm using the text widget in my sidebar, for the title I put YouTube, and I placed the YouTube embed code in it. But I want that widget to go at the top of the site. How do I make this possible, whil...
[ { "answer_id": 44979, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/the_widget\" rel=\"nofollow\"><code>the_widget(...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44978", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13556/" ]
Is there a way that i can place a certain widget anywhere on the site? **For example**: I'm using the text widget in my sidebar, for the title I put YouTube, and I placed the YouTube embed code in it. But I want that widget to go at the top of the site. How do I make this possible, while still using the widgets menu...
Just register another widget area. Don’t take the name *sidebar* literally, you can use the fields anywhere on your page. In your theme’s `functions.php`: ``` add_action( 'after_setup_theme', 'register_multiple_widget_areas' ); function register_multiple_widget_areas() { register_sidebar( array( ...
44,986
<p>I have a post thumbnail set for standard posts (when an image is featured) but for image format posts I'd like to have a separate, dynamically resizing (i.e. image resizing in the functions php via add_image_size), thumbnail. I found this snippet from the codex:</p> <pre><code>if ( has_post_format( 'video' )) { ec...
[ { "answer_id": 44979, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/the_widget\" rel=\"nofollow\"><code>the_widget(...
2012/03/09
[ "https://wordpress.stackexchange.com/questions/44986", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12978/" ]
I have a post thumbnail set for standard posts (when an image is featured) but for image format posts I'd like to have a separate, dynamically resizing (i.e. image resizing in the functions php via add\_image\_size), thumbnail. I found this snippet from the codex: ``` if ( has_post_format( 'video' )) { echo 'this is t...
Just register another widget area. Don’t take the name *sidebar* literally, you can use the fields anywhere on your page. In your theme’s `functions.php`: ``` add_action( 'after_setup_theme', 'register_multiple_widget_areas' ); function register_multiple_widget_areas() { register_sidebar( array( ...
44,993
<p>reading the quicktags.dev.js i see in the comments</p> <pre><code> * Run quicktags(settings) to initialize it, where settings is an object containing up to 3 properties: * settings = { * id : 'my_id', the HTML ID of the textarea, required * buttons: '' Comma separated list of the names of...
[ { "answer_id": 46938, "author": "Fred Rocha", "author_id": 1450, "author_profile": "https://wordpress.stackexchange.com/users/1450", "pm_score": 3, "selected": true, "text": "<p>I have stumbled into this very same issue, and got the quicktags to work. </p>\n\n<p>Here's the code to add to...
2012/03/09
[ "https://wordpress.stackexchange.com/questions/44993", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6477/" ]
reading the quicktags.dev.js i see in the comments ``` * Run quicktags(settings) to initialize it, where settings is an object containing up to 3 properties: * settings = { * id : 'my_id', the HTML ID of the textarea, required * buttons: '' Comma separated list of the names of the default b...
I have stumbled into this very same issue, and got the quicktags to work. Here's the code to add to functions.php: ``` <?php add_action('admin_print_footer_scripts','my_admin_print_footer_scripts'); function my_admin_print_footer_scripts() { ?> <script type="text/javascript">/* <![CDATA[ */ var id = "myID"; // ...
45,004
<p>All</p> <p>In my application there is notification system, when user click on that icon I want to make ajax call. The problem id it works fine for admin user (Debug : 200 ok), but not for subscriber user (Debug : 301 moved permanently).</p> <p>Ajax call</p> <pre><code>$("#notifications-button").click(function() {...
[ { "answer_id": 45006, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": true, "text": "<p>The problem is a conflict with the plug-in <em>Role Scoper</em>. Deactivating the plug-in resolves the iss...
2012/03/09
[ "https://wordpress.stackexchange.com/questions/45004", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12261/" ]
All In my application there is notification system, when user click on that icon I want to make ajax call. The problem id it works fine for admin user (Debug : 200 ok), but not for subscriber user (Debug : 301 moved permanently). Ajax call ``` $("#notifications-button").click(function() { $.ajax({ type : 'P...
The problem is a conflict with the plug-in *Role Scoper*. Deactivating the plug-in resolves the issue. As an alternative to Role Scoper, (I do not offer this as a *recommendation*, simply a suggestion), there is the plug-in [Members](http://wordpress.org/extend/plugins/members/).
45,005
<p>i tried this shortcode:</p> <blockquote> <p>[gallery class="fancybox" link="file" columns="5"]</p> </blockquote> <p>But the class="fancybox" isn't been added to the a href tag of each image.</p> <p>How can i add class="fancybox" to each a href tag??</p> <p>ps: where is the source code of gallery?</p>
[ { "answer_id": 45021, "author": "TCattd", "author_id": 13975, "author_profile": "https://wordpress.stackexchange.com/users/13975", "pm_score": 5, "selected": true, "text": "<p>You can use javascript/jquery to solve this.</p>\n\n<p>When you insert a gallery in a wordpress posts, the whole...
2012/03/09
[ "https://wordpress.stackexchange.com/questions/45005", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9936/" ]
i tried this shortcode: > > [gallery class="fancybox" link="file" columns="5"] > > > But the class="fancybox" isn't been added to the a href tag of each image. How can i add class="fancybox" to each a href tag?? ps: where is the source code of gallery?
You can use javascript/jquery to solve this. When you insert a gallery in a wordpress posts, the whole gallery is wrapped by a div with id like "gallery-1" but also a class that's always "gallery". Also, every item is surrounded by two other "dl" and "dt", with class "gallery-item" and "gallery-icon" respectively. So...
45,033
<p>Hi I'm using some code to create a slideshow with lytebox functionality - the following code is used in the loop to pull each image attached to a post in sequence.</p> <p>It seems to be only pulling the large image, even thought I've set the value to medium - any ideas how I can get .wp_get_attachment_url($attachme...
[ { "answer_id": 45048, "author": "Mamaduka", "author_id": 888, "author_profile": "https://wordpress.stackexchange.com/users/888", "pm_score": 6, "selected": true, "text": "<p><code>wp_get_attachment_url()</code> will only return url to original attachment file, this function only accepts ...
2012/03/09
[ "https://wordpress.stackexchange.com/questions/45033", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6402/" ]
Hi I'm using some code to create a slideshow with lytebox functionality - the following code is used in the loop to pull each image attached to a post in sequence. It seems to be only pulling the large image, even thought I've set the value to medium - any ideas how I can get .wp\_get\_attachment\_url($attachment->ID,...
`wp_get_attachment_url()` will only return url to original attachment file, this function only accepts attachment id as parameter. Use [`wp_get_attachment_image_src()`](http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src) or [`wp_get_attachment_image()`](http://codex.wordpress.org/Function_Refere...
45,039
<p>I have a site with WP installed at /blog, and I'd like to just get a list of the latest blog posts to display on the site home page... that is to say, my custom (PHP) home page, NOT a Wordpress page.</p> <p>I found <a href="http://www.corvidworks.com/articles/wordpress-content-on-other-pages" rel="nofollow">this</a...
[ { "answer_id": 45042, "author": "soulseekah", "author_id": 9480, "author_profile": "https://wordpress.stackexchange.com/users/9480", "pm_score": 3, "selected": true, "text": "<p>You have several options.</p>\n\n<h2>XML-RPC</h2>\n\n<p><a href=\"http://codex.wordpress.org/XML-RPC_Support\"...
2012/03/09
[ "https://wordpress.stackexchange.com/questions/45039", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13981/" ]
I have a site with WP installed at /blog, and I'd like to just get a list of the latest blog posts to display on the site home page... that is to say, my custom (PHP) home page, NOT a Wordpress page. I found [this](http://www.corvidworks.com/articles/wordpress-content-on-other-pages), but it doesn't work-- the latest ...
You have several options. XML-RPC ------- <http://codex.wordpress.org/XML-RPC_Support> is the place to start. The API exposes a large number of methods to access WordPress data "outside" of the full WordPress context. Difficult to setup, connection requests overhead. wp-load.php ----------- Include `wp-load.php` to...
45,053
<p>I have the exact same files (except for wp-config) running on a local server and a test server, and in my functions.php I have this:</p> <pre><code> function len_scripts() { if (!is_admin()): wp_enqueue_script('jquery'); wp_enqueue_script('thickbox'); endif; } add_act...
[ { "answer_id": 45059, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>You don’t need to enqueue jQuery if you enqueue ThickBox already. See <a href=\"https://wordpress.stackexchange.com/a/...
2012/03/09
[ "https://wordpress.stackexchange.com/questions/45053", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7890/" ]
I have the exact same files (except for wp-config) running on a local server and a test server, and in my functions.php I have this: ``` function len_scripts() { if (!is_admin()): wp_enqueue_script('jquery'); wp_enqueue_script('thickbox'); endif; } add_action('wp_print_...
Reposting comment as answer: I came to find out that the theme was never calling `wp_footer();` which was stupid of me not to check since i didn't write the whole theme. Thickbox always goes on the footer.
45,054
<p>I have a custom "about" post:</p> <pre><code>function about_register() { $labels = array( 'name' =&gt; _x('About Page', 'post type general name'), 'singular_name' =&gt; _x('About Item', 'post type singular name'), 'add_new' =&gt; _x('Add New', 'About Item'), '...
[ { "answer_id": 45057, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>You named the custom post type <code>'custom_about_post'</code> not <code>'about'</code>. Rename the archive template ...
2012/03/09
[ "https://wordpress.stackexchange.com/questions/45054", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2417/" ]
I have a custom "about" post: ``` function about_register() { $labels = array( 'name' => _x('About Page', 'post type general name'), 'singular_name' => _x('About Item', 'post type singular name'), 'add_new' => _x('Add New', 'About Item'), 'add_new_item' => __('Ad...
You named the custom post type `'custom_about_post'` not `'about'`. Rename the archive template to `archive-custom_about_post.php` or better: rename the post type. As a rule of thumb: Avoid underscores in post type names. There are/were some issues, especially with templates. And why do you need a custom post type ju...
45,083
<p>How do I get only the first term of a custom post type.<br> I can get all - no problem. This what I am using to grab all of them </p> <pre><code>&lt;?php foreach ($terms as $term) {echo '&lt;a href="'.get_term_link($term-&gt;slug, 'sitecat').'"&gt;'.$term-&gt;name.'&lt;/a&gt;,';} ?&gt; &gt;&gt; &lt;a href="&lt;?p...
[ { "answer_id": 45085, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 6, "selected": true, "text": "<p>I'm not sure what you mean by 'first' taxonomy... but,</p>\n\n<pre><code>$terms = get_the_terms( $post-&gt...
2012/03/10
[ "https://wordpress.stackexchange.com/questions/45083", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7990/" ]
How do I get only the first term of a custom post type. I can get all - no problem. This what I am using to grab all of them ``` <?php foreach ($terms as $term) {echo '<a href="'.get_term_link($term->slug, 'sitecat').'">'.$term->name.'</a>,';} ?> >> <a href="<?php the_permalink(); ?>"><?php the_title('', ''); ?></...
I'm not sure what you mean by 'first' taxonomy... but, ``` $terms = get_the_terms( $post->ID, 'mytaxonomy' ); ``` returns an array of taxonomy term objects, so ``` $term = array_pop($terms); ``` Would give you the first term in the array. And then: ``` echo '<a href="'.get_term_link($term->slug, 'mytaxonomy').'"...
45,092
<p>I wrote a plugin to send an invitation to a friend and am submitting a form using AJAX and used the tips talked about in <a href="http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/" rel="nofollow">5 tips for using AJAX in wordpress</a> and another article referenced in the AJAX in plugins wordpress c...
[ { "answer_id": 45111, "author": "Heiner", "author_id": 13483, "author_profile": "https://wordpress.stackexchange.com/users/13483", "pm_score": 2, "selected": false, "text": "<p>I'm sure there is a more elegant approach (I'd love to know about!). Anyhow: I'd like to offer a solution.\nYou...
2012/03/10
[ "https://wordpress.stackexchange.com/questions/45092", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11465/" ]
I wrote a plugin to send an invitation to a friend and am submitting a form using AJAX and used the tips talked about in [5 tips for using AJAX in wordpress](http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/) and another article referenced in the AJAX in plugins wordpress codex page. I have now got th...
I'm sure there is a more elegant approach (I'd love to know about!). Anyhow: I'd like to offer a solution. You could create a default sidebar with default widgets and a custom sidebar with all available custom widgets. Then you use a combination of the following plugins: [simple fields](http://wordpress.org/extend/plug...
45,109
<p>Can anyone explain how to interpret and make sense of the active_plugins option_value string in WordPress. And then use this string/ array to disable and activate specific plugins?</p> <p>Here is an example:</p> <pre><code>a:8:{i:0;s:21:"adrotate/adrotate.php";i:1;s:19:"akismet/akismet.php";i:2;s:33:"better-relate...
[ { "answer_id": 45116, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 4, "selected": true, "text": "<p>That's a serialized array.</p>\n\n<pre><code>// Serialized:\na:8:{i:0;s:21:\"adrotate/adrotate.php\";i:1;s:19:\"akis...
2012/03/10
[ "https://wordpress.stackexchange.com/questions/45109", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1341/" ]
Can anyone explain how to interpret and make sense of the active\_plugins option\_value string in WordPress. And then use this string/ array to disable and activate specific plugins? Here is an example: ``` a:8:{i:0;s:21:"adrotate/adrotate.php";i:1;s:19:"akismet/akismet.php";i:2;s:33:"better-related/better-related.ph...
That's a serialized array. ``` // Serialized: a:8:{i:0;s:21:"adrotate/adrotate.php";i:1;s:19:"akismet/akismet.php";i:2;s:33:"better-related/better-related.php";i:3;s:17:"clicky/clicky.php";i:4;s:49:"custom-post-permalinks/custom-post-permalinks.php";i:5;s:32:"disqus-comment-system/disqus.php";i:6;s:33:"export-to-text/...
45,113
<p>What I would like to know is if it is possible to disable the edit post function in wordpress based on User's roles. I try to explain better. Let's take an 'Editor' as role example: I would like Editors, Authors.... but NOT ADMIN to be able to write posts only using Custom Fields instead of the 'classic' built in ed...
[ { "answer_id": 45117, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<ol>\n<li>You'll maybe want to use some Plugin to add a Custom Post Type.</li>\n<li>Then you can take another plugin t...
2012/03/10
[ "https://wordpress.stackexchange.com/questions/45113", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10067/" ]
What I would like to know is if it is possible to disable the edit post function in wordpress based on User's roles. I try to explain better. Let's take an 'Editor' as role example: I would like Editors, Authors.... but NOT ADMIN to be able to write posts only using Custom Fields instead of the 'classic' built in edit ...
You can remove post type support for the editor on a conditional basis. The following should work: ``` add_action( 'add_meta_boxes', 'wpse45113_remove_editor' ); function wpse45113_remove_editor() { // change the capability and post type to whatever is appropriate if ( ! current_user_can( 'install_plugins' ) )...
45,144
<p>I am looking to create a custom metabox with check-boxes that will serve to display item availability. I have included two sample images of what I am wishing to accomplish. Any Help would be much appreciated.</p> <p>Moreover, I am really just trying to figure out where to start on this problem. For more information...
[ { "answer_id": 45145, "author": "fxfuture", "author_id": 1063, "author_profile": "https://wordpress.stackexchange.com/users/1063", "pm_score": 0, "selected": false, "text": "<p>This is a great tutorial about adding custom meta boxes - <a href=\"http://www.netmagazine.com/tutorials/user-f...
2012/03/10
[ "https://wordpress.stackexchange.com/questions/45144", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14000/" ]
I am looking to create a custom metabox with check-boxes that will serve to display item availability. I have included two sample images of what I am wishing to accomplish. Any Help would be much appreciated. Moreover, I am really just trying to figure out where to start on this problem. For more information, I will b...
If you have created you custom post type you can add the metabox like this: ``` add_action( 'add_meta_boxes', 'add_dates' ); function add_dates() { add_meta_box('date_select', 'Dates', 'date_select', 'customposttype', 'side', 'default'); } function date_select() { global $post; echo '<input type="hidden"...
45,153
<p>Does anyone have any suggestions on how to limit the search in the WP admin area to just post titles? It's very frustrating to want to pull up a specific page, and get hundreds of results that have that word in the post content.</p>
[ { "answer_id": 45175, "author": "soulseekah", "author_id": 9480, "author_profile": "https://wordpress.stackexchange.com/users/9480", "pm_score": 2, "selected": false, "text": "<p>This is possible by altering the search query via the <code>posts_search</code> hook.</p>\n\n<p><a href=\"htt...
2012/03/10
[ "https://wordpress.stackexchange.com/questions/45153", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14004/" ]
Does anyone have any suggestions on how to limit the search in the WP admin area to just post titles? It's very frustrating to want to pull up a specific page, and get hundreds of results that have that word in the post content.
This is possible by altering the search query via the `posts_search` hook. <http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php#L2202> A default search query will look like this: `..AND (((wp_posts.post_title LIKE \'%search terms%\') OR (wp_posts.post_content LIKE \'%search terms%\')))` We need ...
45,154
<p>I want to call <code>wp_mail()</code> from a non-template PHP file, but when I do, it fails and I don't understand why. For example, let's say I have a PHP file that consists of only this:</p> <pre><code>&lt;?php echo 'hi'; $mail_sent = wp_mail('example@example.com', 'subject', 'message'); echo $mail_se...
[ { "answer_id": 45157, "author": "helenhousandi", "author_id": 2226, "author_profile": "https://wordpress.stackexchange.com/users/2226", "pm_score": 3, "selected": true, "text": "<p>The standalone script will not load WordPress, so it doesn't have a <code>wp_mail()</code> function. WordPr...
2012/03/10
[ "https://wordpress.stackexchange.com/questions/45154", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2400/" ]
I want to call `wp_mail()` from a non-template PHP file, but when I do, it fails and I don't understand why. For example, let's say I have a PHP file that consists of only this: ``` <?php echo 'hi'; $mail_sent = wp_mail('example@example.com', 'subject', 'message'); echo $mail_sent; ?> ``` If I load that ...
The standalone script will not load WordPress, so it doesn't have a `wp_mail()` function. WordPress has its own built-in Ajax handlers which you can leverage and have access to all WordPress functionality within those Ajax calls.
45,161
<p>I have a 3 level deep navigation menu which will show beside all pages on the site except the homepage. The issue is only 2 of my 3 levels are showing in the menu when displaying it using the wp_nav_menu. I've tried specifying the depth parameter and without it to no avail. I am using the <a href="http://www.rootsth...
[ { "answer_id": 45170, "author": "Dwayne Charrington", "author_id": 1687, "author_profile": "https://wordpress.stackexchange.com/users/1687", "pm_score": 3, "selected": true, "text": "<p>I finally solved the issue, it was due to a default value in the Roots theme overriding the depth para...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45161", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1687/" ]
I have a 3 level deep navigation menu which will show beside all pages on the site except the homepage. The issue is only 2 of my 3 levels are showing in the menu when displaying it using the wp\_nav\_menu. I've tried specifying the depth parameter and without it to no avail. I am using the [Roots theme](http://www.roo...
I finally solved the issue, it was due to a default value in the Roots theme overriding the depth parameter for a hook called wp\_nav\_menu\_args (which I didn't even know was a hook). The code can be found in the root directory of the theme in the "inc" folder, a file called roots-cleanup.php. **The original code loo...
45,162
<p>When changing the permalink structure on my site, I get a 404 error for every page except the home page. I've see other questions that mention resetting the permalink structure to get it work, but this doesn't work for me (using the default of ?p=123 does show the posts, but changing back to month and name 2012/03/s...
[ { "answer_id": 45163, "author": "Ruturaj", "author_id": 13540, "author_profile": "https://wordpress.stackexchange.com/users/13540", "pm_score": 0, "selected": false, "text": "<p>You need mod_rewrite support on your Server. Make sure your Server supports mod_rewrite and it's enabled. If y...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45162", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14007/" ]
When changing the permalink structure on my site, I get a 404 error for every page except the home page. I've see other questions that mention resetting the permalink structure to get it work, but this doesn't work for me (using the default of ?p=123 does show the posts, but changing back to month and name 2012/03/samp...
Are you wanting the site to render as www.thesite.com/news or www.thesite.com/wordpress/news If just www.thesite.com/news, try this change: ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /...
45,164
<p>Say that I want to make a post type called 'press' and it is mostly concerned with linking a title with a PDF document of a press clipping. I want to show all of these as an archive... so something like site.com/press but i don't want any single post template pages. so no site.com/press/article1 or site.com/press/...
[ { "answer_id": 45167, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 5, "selected": true, "text": "<h2>The fast way</h2>\n\n<p>In your .htaccess add a rule</p>\n\n<pre><code>RedirectMatch Permanent ^/press/.+ /press/\n</c...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45164", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6477/" ]
Say that I want to make a post type called 'press' and it is mostly concerned with linking a title with a PDF document of a press clipping. I want to show all of these as an archive... so something like site.com/press but i don't want any single post template pages. so no site.com/press/article1 or site.com/press/artic...
The fast way ------------ In your .htaccess add a rule ``` RedirectMatch Permanent ^/press/.+ /press/ ``` Plugin way ---------- Hook into `template_redirect` and redirect all requests to a single entry: ```php add_action( 'template_redirect', 'wpse_45164_redirect_press' ); function wpse_45164_redirect_press() { ...
45,165
<p>I have a file that can either be included in a plugin, or in a theme. What's the best way to get the URL of the file's folder (from within the file)?</p> <p>Edit:</p> <p>I'm now using this for now</p> <pre><code>home_url( '/' . str_replace( ABSPATH, "", dirname( __FILE__ ) ) ); </code></pre> <p>Let me know if th...
[ { "answer_id": 45166, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>See <a href=\"http://codex.wordpress.org/Determining_Plugin_and_Content_Directories\" rel=\"nofollow\">Determining Plu...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45165", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8310/" ]
I have a file that can either be included in a plugin, or in a theme. What's the best way to get the URL of the file's folder (from within the file)? Edit: I'm now using this for now ``` home_url( '/' . str_replace( ABSPATH, "", dirname( __FILE__ ) ) ); ``` Let me know if there's any problem with this / there's a ...
See [Determining Plugin and Content Directories](http://codex.wordpress.org/Determining_Plugin_and_Content_Directories). ``` plugins_url( 'filename', __FILE__ ); ``` … returns the full URI to the file in your plugin. For themes you use: ``` get_stylesheet_directory_uri() . '/path/to/file'; ```
45,184
<p>This is a question based on the comments from the answer <a href="https://wordpress.stackexchange.com/a/44044/6344">here</a>.</p> <p>I'm using the following code to create a couple of different search boxes for my website:</p> <pre><code>&lt;form action="&lt;?php echo home_url( '/glossary/' ); ?&gt;" method="get"&...
[ { "answer_id": 46208, "author": "fregante", "author_id": 1861, "author_profile": "https://wordpress.stackexchange.com/users/1861", "pm_score": 1, "selected": false, "text": "<p>You'll have to work on permalinks. I don't have time at the moment but you can find some info here: <a href=\"h...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45184", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
This is a question based on the comments from the answer [here](https://wordpress.stackexchange.com/a/44044/6344). I'm using the following code to create a couple of different search boxes for my website: ``` <form action="<?php echo home_url( '/glossary/' ); ?>" method="get"> <p style="font-size:12px;">SEARCH<st...
Most unfortunate, while my original solution was elegant I did not foresee this complication, and I apologise for the inconvenience. So, I provide an alternative solution. **Firstly to get your fancy search query:** Your markup will need to change, but this will intercept the URLs and rewrite them correctly internal...
45,190
<p>I would like to build on <a href="https://wordpress.stackexchange.com/a/43033/6344">this answer</a> so I can incorporate pagination and a couple of other features.</p> <p>We have over 1,600 entries in our Glossary so certain letters have far more than 20 (my max posts/page) entries.</p> <p>If a user clicks "A" or ...
[ { "answer_id": 45990, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 0, "selected": false, "text": "<p>i wrote about creating a custom 'glossary' taxonomy from post titles. it isn't perfect, but it might be ...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45190", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
I would like to build on [this answer](https://wordpress.stackexchange.com/a/43033/6344) so I can incorporate pagination and a couple of other features. We have over 1,600 entries in our Glossary so certain letters have far more than 20 (my max posts/page) entries. If a user clicks "A" or accesses "/dev/glossary/a" I...
Something like this should do the trick for ordering by title, and using pagination: ``` global $wp_rewrite, $wp_query; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <header class="entry-header"> <h1 class="entry-title"><?php the_title(); ?></h1> </header><!-- .entry-header --...
45,198
<p>I have this piece of ode in a buy template. I like to know what to add to get the child name of the category</p> <p>the mais display category is sponsor. but in the sponsor category, there is : gold, silver, platium... i want to get that "color" category an output it as <code>&lt;div class="cat-name"&gt;platium&lt;...
[ { "answer_id": 45990, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 0, "selected": false, "text": "<p>i wrote about creating a custom 'glossary' taxonomy from post titles. it isn't perfect, but it might be ...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45198", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3969/" ]
I have this piece of ode in a buy template. I like to know what to add to get the child name of the category the mais display category is sponsor. but in the sponsor category, there is : gold, silver, platium... i want to get that "color" category an output it as `<div class="cat-name">platium</div>` here is the code...
Something like this should do the trick for ordering by title, and using pagination: ``` global $wp_rewrite, $wp_query; if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <header class="entry-header"> <h1 class="entry-title"><?php the_title(); ?></h1> </header><!-- .entry-header --...
45,199
<p>I've set up a custom post type which has three custom meta fields: name, latitude, longitude. Each post already shows the name on an integrated map based on it's latitude and longitude. </p> <p>I now would like to add a page to my site which shows ALL the names on a map based on their latitude and longitude.</p> <...
[ { "answer_id": 45200, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 3, "selected": false, "text": "<p>This code will give you all the posts with a longitude, latitude, and name assigned. Then you can loop throug...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45199", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6828/" ]
I've set up a custom post type which has three custom meta fields: name, latitude, longitude. Each post already shows the name on an integrated map based on it's latitude and longitude. I now would like to add a page to my site which shows ALL the names on a map based on their latitude and longitude. I obviously kno...
If all of your custom post type posts have all meta fields that you need then you can use the `fields` argument and set it to `ids` which will work much faster for example: ``` //get your custom posts ids as an array $posts = get_posts(array( 'post_type' => 'your_post_type', 'post_status' => 'publish', '...
45,202
<p>In my custom query, every time I query for posts from a particular category using WP_Query() and the category has 10 posts for example, I seem to be missing a post. So querying for 10 posts only returns 9, querying for 11 posts only returns 10 and so on. Does anyone know why I am always missing one post in my query ...
[ { "answer_id": 45203, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 0, "selected": false, "text": "<p>It sounds like a browser caching issue possibly. If you're on a PC try holding down <code>Ctrl+Alt+F5</code...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45202", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3969/" ]
In my custom query, every time I query for posts from a particular category using WP\_Query() and the category has 10 posts for example, I seem to be missing a post. So querying for 10 posts only returns 9, querying for 11 posts only returns 10 and so on. Does anyone know why I am always missing one post in my query re...
It sounds like you have a filter running on that page that's adding an `offset` parameter to your WP\_Query. There aren't any really easy ways to search for all filters. The plugin [Hikari Hooks](http://wordpress.org/extend/plugins/hikari-hooks) is the simplest that I've seen. If you install and activate that plugin a...
45,208
<p>I am using the following code and everything in the user profile is updating except the user's email. </p> <p>In the template: </p> <pre><code>global $current_user, $wp_roles; get_currentuserinfo(); /* Load the registration file. */ require_once( ABSPATH . WPINC . '/registration.php' ); /* If profile was saved,...
[ { "answer_id": 45203, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 0, "selected": false, "text": "<p>It sounds like a browser caching issue possibly. If you're on a PC try holding down <code>Ctrl+Alt+F5</code...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45208", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2107/" ]
I am using the following code and everything in the user profile is updating except the user's email. In the template: ``` global $current_user, $wp_roles; get_currentuserinfo(); /* Load the registration file. */ require_once( ABSPATH . WPINC . '/registration.php' ); /* If profile was saved, update profile. */ if...
It sounds like you have a filter running on that page that's adding an `offset` parameter to your WP\_Query. There aren't any really easy ways to search for all filters. The plugin [Hikari Hooks](http://wordpress.org/extend/plugins/hikari-hooks) is the simplest that I've seen. If you install and activate that plugin a...
45,210
<p>Using the new <code>WP_Screen</code> class makes it pretty easy to add help text to a screen.</p> <pre><code>&lt;?php add_action( "load-{$somepage}", 'wpse_load_reading' ); function wpse_load_reading() { get_current_screen()-&gt;add_help_tab( array( 'id' =&gt; 'my-help-tab', 'title' =...
[ { "answer_id": 45213, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>I <em>guess</em> you have three chances:</p>\n\n<ol>\n<li>Use <code>WP_Screen-&gt;$_help_tabs</code> to reorder the...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45210", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6035/" ]
Using the new `WP_Screen` class makes it pretty easy to add help text to a screen. ``` <?php add_action( "load-{$somepage}", 'wpse_load_reading' ); function wpse_load_reading() { get_current_screen()->add_help_tab( array( 'id' => 'my-help-tab', 'title' => __( 'My Title' ), 'conte...
As @Mamaduka suggested, you can hook into `admin_head-{$page_hook}` and add the contextual help there. `admin_head` fires after the default contextual help tabs have been added. ``` <?php add_action( 'admin_head-options-reading.php', 'wpse45210_add_help' ); function wpse45210_add_help() { get_current_screen()->add...
45,221
<p>I want to display the current page number in the site. I want it to be conditional though so that it doesn't show up on the home/front page. Using the code below, the page number is being displayed at all.</p> <pre><code>&lt;?php $pageNumber = (get_query_var('paged')) ? get_query_var('paged') : 1; if(!is_f...
[ { "answer_id": 45222, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": true, "text": "<p>You want to use <a href=\"http://codex.wordpress.org/Function_Reference/is_paged\" rel=\"nofollow\"><code>...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45221", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14024/" ]
I want to display the current page number in the site. I want it to be conditional though so that it doesn't show up on the home/front page. Using the code below, the page number is being displayed at all. ``` <?php $pageNumber = (get_query_var('paged')) ? get_query_var('paged') : 1; if(!is_front_page()) { ...
You want to use [`is_paged`](http://codex.wordpress.org/Function_Reference/is_paged) which checks if the current page number is 2 or above (and returns true if it is). [`is_front_page`](http://codex.wordpress.org/Function_Reference/is_front_page) checks 'if the main page is a posts or a Page'. You've also used incorr...
45,224
<p>I would like admins to be able to delete users from the frontend with the click of a button. How could I use the wp_delete_users() function to create such a button on the frontend if the user ID is provided? </p>
[ { "answer_id": 45268, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": true, "text": "<p>You could use AJAX to request a custom 'action' and send the users' ID. Alternatively 'post' the action an...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45224", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9862/" ]
I would like admins to be able to delete users from the frontend with the click of a button. How could I use the wp\_delete\_users() function to create such a button on the frontend if the user ID is provided?
You could use AJAX to request a custom 'action' and send the users' ID. Alternatively 'post' the action and user ID to the same page. They are both essentially the same thing, but the former doesn't require the page to be reloaded. There are plenty of topics on this site that deal with AJAX, so I'll omit the details (...
45,227
<p>I am using</p> <pre><code>&lt;?php wp_nav_menu( array( 'theme_location' =&gt; 'header-menu', 'menu_class' =&gt; 'nav-bar', 'container' =&gt; 'nav' ) ); ?&gt; </code></pre> <p>to output my navigation menu list. Currently they automatically get classes added to them like <code>page-it...
[ { "answer_id": 45228, "author": "Anders Kitson", "author_id": 7653, "author_profile": "https://wordpress.stackexchange.com/users/7653", "pm_score": 2, "selected": false, "text": "<p>Ok I just added to my functions.php file went to appearance menus, changed screen options to allow classes...
2012/03/11
[ "https://wordpress.stackexchange.com/questions/45227", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7653/" ]
I am using ``` <?php wp_nav_menu( array( 'theme_location' => 'header-menu', 'menu_class' => 'nav-bar', 'container' => 'nav' ) ); ?> ``` to output my navigation menu list. Currently they automatically get classes added to them like `page-item-8`, `page-item-6`. I work on a local machin...
Ok I just added to my functions.php file went to appearance menus, changed screen options to allow classes. Then Added a individual class for each one. Awesome! ``` <?php function register_my_menus() { register_nav_menus( array('header-menu' => __( 'Header Menu' ) ) ); } add_action( 'init', 'register_my_menus'...
45,231
<p>Please tell me in simple terms starting from the dashboard of a 3.3.1 webpage how to get to the place where I put this meta tag google is requiring in order to verify my site.</p> <p>If you start with on the main page--Please explain how to get there. My main page is just a post. then I have other pages.</p> <p>I'...
[ { "answer_id": 45228, "author": "Anders Kitson", "author_id": 7653, "author_profile": "https://wordpress.stackexchange.com/users/7653", "pm_score": 2, "selected": false, "text": "<p>Ok I just added to my functions.php file went to appearance menus, changed screen options to allow classes...
2012/03/12
[ "https://wordpress.stackexchange.com/questions/45231", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14027/" ]
Please tell me in simple terms starting from the dashboard of a 3.3.1 webpage how to get to the place where I put this meta tag google is requiring in order to verify my site. If you start with on the main page--Please explain how to get there. My main page is just a post. then I have other pages. I've placed this me...
Ok I just added to my functions.php file went to appearance menus, changed screen options to allow classes. Then Added a individual class for each one. Awesome! ``` <?php function register_my_menus() { register_nav_menus( array('header-menu' => __( 'Header Menu' ) ) ); } add_action( 'init', 'register_my_menus'...
45,241
<p>I'm attempting to modify the latest version of the mystique theme, and would like to have it so when I select a background, the page will lock that background into page, but have the content scroll over top of it. Currently the content scrolls, but the background scrolls with it, leaving an awkward spot where the ba...
[ { "answer_id": 45242, "author": "TCattd", "author_id": 13975, "author_profile": "https://wordpress.stackexchange.com/users/13975", "pm_score": 3, "selected": true, "text": "<p>I think you're looking for css's fixed background:\n<a href=\"http://www.w3schools.com/css/css_background.asp\" ...
2012/03/12
[ "https://wordpress.stackexchange.com/questions/45241", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3051/" ]
I'm attempting to modify the latest version of the mystique theme, and would like to have it so when I select a background, the page will lock that background into page, but have the content scroll over top of it. Currently the content scrolls, but the background scrolls with it, leaving an awkward spot where the backg...
I think you're looking for css's fixed background: [W3 background definition](http://www.w3schools.com/css/css_background.asp) [Here's an example](http://www.w3schools.com/css/tryit.asp?filename=trycss_background-attachment) from W3. Something like this in CSS should work: ``` background: transparent url(images/bg.j...
45,320
<p>I'm using two plugins which use the_title, but one (while still completely functional) is showing an error on certain pages. </p> <p>Missing argument 2 for pfund_handle_title() in ...wp-content/plugins/personal-fundraiser/includes/user.php on line 639</p> <p>I'm told it's because it doesn't pass the second require...
[ { "answer_id": 45324, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 3, "selected": true, "text": "<p>I have this issue in some of my own plugins, and it's an easy fix. Basically, I label this a &quot;lazy developer&quo...
2012/03/12
[ "https://wordpress.stackexchange.com/questions/45320", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8822/" ]
I'm using two plugins which use the\_title, but one (while still completely functional) is showing an error on certain pages. Missing argument 2 for pfund\_handle\_title() in ...wp-content/plugins/personal-fundraiser/includes/user.php on line 639 I'm told it's because it doesn't pass the second required parameter of...
I have this issue in some of my own plugins, and it's an easy fix. Basically, I label this a "lazy developer" issue. It's a matter of someone adding a filter but not taking optional parameters into account. Step 1 - Edit the plugin file ============================= The code that's breaking starts around line 639 (ac...
45,326
<p>Im a bit lost on this simple problem so i thought id come and ask the pros. Ive just been told by my client that on their sites gallery, the name and description are on the same line.</p> <p>so for example if the picture is called ABC, and the description is "123".</p> <p>the output is "ABC-123" all on one line.so...
[ { "answer_id": 45547, "author": "Tom Auger", "author_id": 3687, "author_profile": "https://wordpress.stackexchange.com/users/3687", "pm_score": 3, "selected": false, "text": "<p>Let's assume that your theme is NOT rolling its own gallery shortcode, and let's assume that you're using the ...
2012/03/12
[ "https://wordpress.stackexchange.com/questions/45326", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12944/" ]
Im a bit lost on this simple problem so i thought id come and ask the pros. Ive just been told by my client that on their sites gallery, the name and description are on the same line. so for example if the picture is called ABC, and the description is "123". the output is "ABC-123" all on one line.so itd look like: ...
Well just in case, anyone is looking at this, i solved the problem by manually inserting a `<br/>` tag in the caption area. so for example if the pictures content has this sample text `"ABC-123"` which outputs this ``` -------- | Picture | -------- ABC-123 ``` then in the caption i entered something like this `AB...
45,332
<p>I am trying to write a plug-in to display the <a href="http://blog.runkeeper.com/new-feature/healthy-button-bookmarklet" rel="nofollow">RunKeeper Healthy button</a> on single posts, but my output has an extra space and double-quote when I look at the page source. What I'm trying to do with the button is open a new w...
[ { "answer_id": 45449, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 1, "selected": true, "text": "<p>I fixed this by switching the string concatenation to use PHP's echo instead of doing string concatenation. I also ...
2012/03/12
[ "https://wordpress.stackexchange.com/questions/45332", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I am trying to write a plug-in to display the [RunKeeper Healthy button](http://blog.runkeeper.com/new-feature/healthy-button-bookmarklet) on single posts, but my output has an extra space and double-quote when I look at the page source. What I'm trying to do with the button is open a new window via inline JavaScript. ...
I fixed this by switching the string concatenation to use PHP's echo instead of doing string concatenation. I also noticed I had a missing parenthesis in my original code (which didn't affect the result of the output where the single quote was turned into a double-quote). I still have no idea why I was getting a sing...
45,338
<p>I am using this code to call any custom menu and display: </p> <pre><code>&lt;?php wp_nav_menu( array( 'container' =&gt; 'none', 'container_class' =&gt; 'menu-header', 'theme_location' =&gt; 'primary', 'menu' =&gt; get_post_meta( $post-&gt;ID, 'MenuName', true) ) ); ?&gt; </code></pre> <p>At ...
[ { "answer_id": 45341, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 2, "selected": false, "text": "<p>the wp_nav_menu fallback is wp_page_menu() by default. you think you could change the fallback to a null...
2012/03/12
[ "https://wordpress.stackexchange.com/questions/45338", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14071/" ]
I am using this code to call any custom menu and display: ``` <?php wp_nav_menu( array( 'container' => 'none', 'container_class' => 'menu-header', 'theme_location' => 'primary', 'menu' => get_post_meta( $post->ID, 'MenuName', true) ) ); ?> ``` At the moment if there is no custom menu defined i...
Simply set it to a predefined core-function that returns `null` or `false`: ``` 'fallback_cb' => '__return_zero' // or 'fallback_cb' => '__return_false' ```
45,363
<p>I'm going to try to word this the best that I can. I apologize if it gets confusing. Anyway, I am creating pages for my website and when I go to create the pages, I want them to appear in a certain order on the website:</p> <p>Home About Services Photographs Logos Contact</p> <p>However, every time I create the ...
[ { "answer_id": 45368, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 0, "selected": false, "text": "<p>There is a \"Page Attributes\" meta box in the page editor that contains a Page Order option. Enter a number....
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45363", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14077/" ]
I'm going to try to word this the best that I can. I apologize if it gets confusing. Anyway, I am creating pages for my website and when I go to create the pages, I want them to appear in a certain order on the website: Home About Services Photographs Logos Contact However, every time I create the pages, they list in...
Create a [custom navigation menu](http://codex.wordpress.org/Navigation_Menus) and order the pages in `wp-admin/nav-menus.php`. You shouldn’t mess around with `wp_list_pages()` anymore. To get a *Home* link into the list of available pages add the following code to your theme’s `functions.php`: ``` add_filter( 'wp_pa...
45,365
<p>WordPress itself, in the <code>wp-content</code> folder, includes an empty PHP file which looks like this.</p> <pre><code>&lt;?php // Silence is golden. ?&gt; </code></pre> <p>Should plugins include an empty file like this as well to stop folks view viewing the contents of a directory? What about additional folde...
[ { "answer_id": 45366, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 5, "selected": true, "text": "<p>No, they should not. If a plugin has vulnerabilities just because someone might see its directory structure it is broke...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45365", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6035/" ]
WordPress itself, in the `wp-content` folder, includes an empty PHP file which looks like this. ``` <?php // Silence is golden. ?> ``` Should plugins include an empty file like this as well to stop folks view viewing the contents of a directory? What about additional folders in themes -- like an `includes` directory...
No, they should not. If a plugin has vulnerabilities just because someone might see its directory structure it is broken. *These* bugs should be fixed. [Security through obscurity](http://www.schneier.com/blog/archives/2008/06/security_throug_1.html) is a bug for itself. It’s up to the site owner to allow or forbid...
45,377
<p>I am trying to run the following jQuery to change the text of my username and password boxes so that they do not need a label (inside <code>&lt;script&gt;</code> tags):</p> <pre><code>jQuery(document).ready(function($) { $('#user_login1').val('Username'); $('#user_pass1').val('Password'); $('#user_login...
[ { "answer_id": 45514, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>Based on your Edit 3:</p>\n\n<blockquote>\n <p>In response to Chip Bennett here is the call found in funct...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45377", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10119/" ]
I am trying to run the following jQuery to change the text of my username and password boxes so that they do not need a label (inside `<script>` tags): ``` jQuery(document).ready(function($) { $('#user_login1').val('Username'); $('#user_pass1').val('Password'); $('#user_login1').focus(function(){ $...
This is what I had to do to get it to work Add the following right after `<head>` in `header.php` ``` <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> ``` Rem out any reference to `wp_enqueue_script('jquery')` Add this script just before the '' ``` ...
45,378
<p>I have a page, with a shortcode that get all the post from a categorie and put after the content of the page. For no apparent reason, the result of a WP_Query() in the shortcode APPEAR ALWAYS at the top of the page. If i put the shortcode a the top OR at the bottom, the post (3 of them) appear before the content of ...
[ { "answer_id": 45514, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>Based on your Edit 3:</p>\n\n<blockquote>\n <p>In response to Chip Bennett here is the call found in funct...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45378", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3969/" ]
I have a page, with a shortcode that get all the post from a categorie and put after the content of the page. For no apparent reason, the result of a WP\_Query() in the shortcode APPEAR ALWAYS at the top of the page. If i put the shortcode a the top OR at the bottom, the post (3 of them) appear before the content of th...
This is what I had to do to get it to work Add the following right after `<head>` in `header.php` ``` <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> ``` Rem out any reference to `wp_enqueue_script('jquery')` Add this script just before the '' ``` ...
45,390
<p>I'm new to wordpress plugin development, I read the whole documentation this afternoon <a href="http://codex.wordpress.org/Plugin_API/Filter_Reference" rel="nofollow">http://codex.wordpress.org/Plugin_API/Filter_Reference</a>, I tried to write some code, like this in plugin file:</p> <pre><code>add_filter('the_titl...
[ { "answer_id": 45383, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": false, "text": "<p>Use <a href=\"https://developer.wordpress.org/reference/functions/is_admin/\" rel=\"noreferrer\"><code>is_admin()</cod...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45390", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14086/" ]
I'm new to wordpress plugin development, I read the whole documentation this afternoon <http://codex.wordpress.org/Plugin_API/Filter_Reference>, I tried to write some code, like this in plugin file: ``` add_filter('the_title', 'my_own_function', 10, 2); ``` **Function is:** ``` function my_own_function($title, $pos...
Use [`is_admin()`](http://codex.wordpress.org/Function_Reference/is_admin). It checks if you're viewing an Admin page, means the backend.
45,398
<p>Some of the authors in my blog must always add their posts to a specific category each time they post.</p> <p>Sometimes they forget this so therefore I'm wondering if there are any ways to automatically check and fix this.</p> <p>Here's an example of my desired outcome:</p> <ul> <li>Posts by Author X should alway...
[ { "answer_id": 45401, "author": "WouterB", "author_id": 6828, "author_profile": "https://wordpress.stackexchange.com/users/6828", "pm_score": 0, "selected": false, "text": "<p>I'm assuming you aren't using custom post types. Below code successfully adds every new post (with publish_post ...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45398", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6011/" ]
Some of the authors in my blog must always add their posts to a specific category each time they post. Sometimes they forget this so therefore I'm wondering if there are any ways to automatically check and fix this. Here's an example of my desired outcome: * Posts by Author X should always be assigned to category A ...
The solution is quite simple. And is subdivided into two separate processes - querying the posts and modifying their category terms. **Querying the posts** [`get_posts`](http://codex.wordpress.org/Function_Reference/get_posts) is a function that returns posts. A full list of arguments can be seen in [WP\_Query parame...
45,411
<p>I can't get any help on the buddypress forums so I'm going to ask it here. I'm trying to use conditional tags so I can have a different sidebar for the profile page than the activity page. For some reason the way I have it setup in my sidebar.php still returns the default. Any suggestions?</p> <pre><code>&lt;?php ...
[ { "answer_id": 45429, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<h3>Read the comments</h3>\n<p>...for further explanation also read about <a href=\"http://codex.wordpress.org/Functio...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45411", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12700/" ]
I can't get any help on the buddypress forums so I'm going to ask it here. I'm trying to use conditional tags so I can have a different sidebar for the profile page than the activity page. For some reason the way I have it setup in my sidebar.php still returns the default. Any suggestions? ``` <?php if (is_single()){...
Your problem may be the choice of `bp_is_user_profile()`. This only returns true when you are literally looking at the xprofile component - the 'Profile' tab of a user's page. `bp_is_user()` is more general, returning true whenever you're viewing a user page (even if it's user activity, user groups, etc). [EDIT] Afte...
45,413
<p>I have a list of products, each with a price in a custom field stored as text such as "2.50" or "5.00" and I am displaying them on the page with a custom query that sorts by the price:</p> <pre><code> if(!$wp_query) { global $wp_query; } $args = array( 'meta_key' =&gt; 'price', '...
[ { "answer_id": 45422, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 6, "selected": true, "text": "<p>The <code>OrderBy</code> argument can take more then one parameter so the solution was to change :</p>\n\n<pre...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45413", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112/" ]
I have a list of products, each with a price in a custom field stored as text such as "2.50" or "5.00" and I am displaying them on the page with a custom query that sorts by the price: ``` if(!$wp_query) { global $wp_query; } $args = array( 'meta_key' => 'price', 'orderby' => 'meta...
The `OrderBy` argument can take more then one parameter so the solution was to change : ``` 'orderby' => 'meta_value_num', ``` to: ``` 'orderby' => 'meta_value meta_value_num', ```
45,418
<p>I would like to use toggle option in my sidebar widgets. But my sidebar widgets not generating unique id. This is my register sidebar code.</p> <pre><code>register_sidebar(array( 'name' =&gt; 'Main Sidebar', 'before_widget' =&gt; '&lt;div class="widget %2$s"&gt;', 'after_widget' =&gt; '&lt;/...
[ { "answer_id": 46318, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 0, "selected": false, "text": "<p>No, it is not possible, not cleanly anyway</p>\n\n<p>There are kludges that will get you half there but they ...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45418", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5074/" ]
I would like to use toggle option in my sidebar widgets. But my sidebar widgets not generating unique id. This is my register sidebar code. ``` register_sidebar(array( 'name' => 'Main Sidebar', 'before_widget' => '<div class="widget %2$s">', 'after_widget' => '</div></div></div>', 'befo...
if you can include the `wp-load.php` from WP install; after this you can use all WP Core functions and can also check the user and his rights with core function - `current_user_can()`. But maybe it's easier to create an bridge from CS Cart to WP, if CS Cart has an own user table; i dont know.
45,419
<p><strong>Calling Post ID:</strong> Lets go first with calling post id definition :) This name i actually find inside a core file <a href="http://core.trac.wordpress.org/browser/tags/3.3.1/wp-admin/includes/media.php#L1167" rel="nofollow noreferrer"><code>wp-admin/includes/media.php</code></a> which means for the post...
[ { "answer_id": 45420, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>It comes down to a simple one liner:</p>\n\n<pre><code>var p_id = jQuery(\"#content-add_media\").attr('href')...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45419", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3094/" ]
**Calling Post ID:** Lets go first with calling post id definition :) This name i actually find inside a core file [`wp-admin/includes/media.php`](http://core.trac.wordpress.org/browser/tags/3.3.1/wp-admin/includes/media.php#L1167) which means for the post you requested the media upload. Media gets attached to the that...
You are on the correct path on thinking about `post-edit.php`. <http://core.trac.wordpress.org/browser/tags/3.3.1/wp-admin/post-new.php#L45> See how `get_default_post_to_edit` is called to return a new post. The second argument tells it to create a post in the database. The function is defined here: <http://core.tra...
45,431
<p>Is it possible to limit a search for keywords to a specific post type (say 'news') but filter the results by selected custom taxonomies?</p> <ul> <li>I have a news section.</li> <li>This has the custom post type called 'news'.</li> <li>This then has the custom taxonomy 'news-category'.</li> <li>There are several cu...
[ { "answer_id": 45435, "author": "Boone Gorges", "author_id": 14052, "author_profile": "https://wordpress.stackexchange.com/users/14052", "pm_score": 1, "selected": false, "text": "<p>You should be able to do this by combining the 'tax_query' and 's' parameters of a WP_Query. I'm assuming...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45431", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
Is it possible to limit a search for keywords to a specific post type (say 'news') but filter the results by selected custom taxonomies? * I have a news section. * This has the custom post type called 'news'. * This then has the custom taxonomy 'news-category'. * There are several custom taxonomy terms that need to be...
It's fairly inefficient to use `query_posts` and I often find it's more trouble than it's worth. Instead, to set the post type you can just have a hidden input inside the form with name 'post\_type' and value (in this example) 'news'. WordPress handles the rest. Unfortunately it is not so easy with taxonomies (maybe ...
45,436
<p><a href="https://wordpress.stackexchange.com/questions/16637/how-to-filter-post-listing-in-wp-dashboard-posts-listing-using-a-custom-field/16641">This answer</a> is very close to what I am looking to do, but instead I would like to specify a specific custom field and display a select menu of its available values. Th...
[ { "answer_id": 45447, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 7, "selected": true, "text": "<p>Simple to do, first create the dropdown with just the meta values you want and then catch the submit of the fi...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45436", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11739/" ]
[This answer](https://wordpress.stackexchange.com/questions/16637/how-to-filter-post-listing-in-wp-dashboard-posts-listing-using-a-custom-field/16641) is very close to what I am looking to do, but instead I would like to specify a specific custom field and display a select menu of its available values. Thanks!
Simple to do, first create the dropdown with just the meta values you want and then catch the submit of the filter, just change `POST_TYPE` to the name of your post type and `META_KEY` to the name of your meta key: ``` <?php /* Plugin Name: Admin Filter BY Custom Fields Plugin URI: http://en.bainternet.info Descriptio...
45,437
<p>I'm doing it right now with the following code: </p> <pre><code>function uw_load_scripts() { // De-register the built in jQuery wp_deregister_script('jquery'); // Register the CDN version wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', array(), null, f...
[ { "answer_id": 45439, "author": "Boone Gorges", "author_id": 14052, "author_profile": "https://wordpress.stackexchange.com/users/14052", "pm_score": 2, "selected": false, "text": "<p>Fair warning: deregistering WP's packaged version of jQuery in favor of your own can cause problems, espe...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45437", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5079/" ]
I'm doing it right now with the following code: ``` function uw_load_scripts() { // De-register the built in jQuery wp_deregister_script('jquery'); // Register the CDN version wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', array(), null, false); //...
First rule of thumb: **do not deregister core-bundled scripts and replace with other versions**, unless you are absolutely certain that no Theme, Plugins, or core itself will break due to the version change. Really, unless you **absolutely need** an alternate version of a core-bundled script, just use what is bundled w...
45,452
<p>I used <a href="http://net.tutsplus.com/tutorials/wordpress/how-to-create-a-better-wordpress-options-panel/" rel="nofollow">this nettuts tutorial</a> to create an options panel. What I'm trying to figure out how to do and have been unsuccessful doing so far (I keep "breaking" the code/getting a server error) when I ...
[ { "answer_id": 45439, "author": "Boone Gorges", "author_id": 14052, "author_profile": "https://wordpress.stackexchange.com/users/14052", "pm_score": 2, "selected": false, "text": "<p>Fair warning: deregistering WP's packaged version of jQuery in favor of your own can cause problems, espe...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45452", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7662/" ]
I used [this nettuts tutorial](http://net.tutsplus.com/tutorials/wordpress/how-to-create-a-better-wordpress-options-panel/) to create an options panel. What I'm trying to figure out how to do and have been unsuccessful doing so far (I keep "breaking" the code/getting a server error) when I try to add current user info....
First rule of thumb: **do not deregister core-bundled scripts and replace with other versions**, unless you are absolutely certain that no Theme, Plugins, or core itself will break due to the version change. Really, unless you **absolutely need** an alternate version of a core-bundled script, just use what is bundled w...
45,465
<p>My pagination pages echo out the same content on every page. Page one is queried to show two posts, which it shows up correctly. Page two shows the exact same two posts as page one does. Here is my code: (functions.php) (this is a pre-made code I found on the web).</p> <pre><code>function wp_corenavi() { global $...
[ { "answer_id": 45467, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": true, "text": "<p>This is because <a href=\"http://codex.wordpress.org/Function_Reference/query_posts\" rel=\"nofollow\"><co...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45465", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13980/" ]
My pagination pages echo out the same content on every page. Page one is queried to show two posts, which it shows up correctly. Page two shows the exact same two posts as page one does. Here is my code: (functions.php) (this is a pre-made code I found on the web). ``` function wp_corenavi() { global $wp_query, $wp_...
This is because [`query_posts`](http://codex.wordpress.org/Function_Reference/query_posts) resets the query. See this warning on the Codex page: > > Pagination won't work correctly, unless you use query\_posts() in a > page template and you set the 'paged' query var appropriately: > <http://scribu.net/wordpress/wp-...
45,473
<p>The question title is pretty self-explanatory - I don't really like the new Admin's bar's colour but I find it useful and want to keep it so I would like to change the colour of it. However, I'm not the best at web scripting, let alone CSS so I wondered if anybody here would help me to make the Admin Bar the followi...
[ { "answer_id": 45467, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": true, "text": "<p>This is because <a href=\"http://codex.wordpress.org/Function_Reference/query_posts\" rel=\"nofollow\"><co...
2012/03/13
[ "https://wordpress.stackexchange.com/questions/45473", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14001/" ]
The question title is pretty self-explanatory - I don't really like the new Admin's bar's colour but I find it useful and want to keep it so I would like to change the colour of it. However, I'm not the best at web scripting, let alone CSS so I wondered if anybody here would help me to make the Admin Bar the following ...
This is because [`query_posts`](http://codex.wordpress.org/Function_Reference/query_posts) resets the query. See this warning on the Codex page: > > Pagination won't work correctly, unless you use query\_posts() in a > page template and you set the 'paged' query var appropriately: > <http://scribu.net/wordpress/wp-...
45,516
<p>I have created a custom post type and custom category for that post. There are some categories in that custom category. now I want to get the links for each category I have in that list.</p> <p>I just want to get the link form its tag id. how can I do that</p>
[ { "answer_id": 45982, "author": "maha_2012", "author_id": 14273, "author_profile": "https://wordpress.stackexchange.com/users/14273", "pm_score": 0, "selected": false, "text": "<p>wp_list_categories('taxonomy=custom_tax');\ncustom_tax is custom taxonomy name</p>\n" }, { "answer_i...
2012/03/14
[ "https://wordpress.stackexchange.com/questions/45516", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8912/" ]
I have created a custom post type and custom category for that post. There are some categories in that custom category. now I want to get the links for each category I have in that list. I just want to get the link form its tag id. how can I do that
As the other's mentioned, [`wp_list_categories`](http://codex.wordpress.org/Template_Tags/wp_list_categories) will work if you you want to do a list of things (just like `wp_list_pages` does for pages). If you specifically want the link (URL), you can use [`get_term_link`](http://codex.wordpress.org/Function_Reference...
45,526
<p>(updated)</p> <p>I´m using this query to loop divs in to my front page slider. I use counters to split 4 posts into a slider, then open a new slider etc. Also a counter to set a class to every fourth post (to fix margin). This worked great until I wanted to use the 'post_per_page' argument. If I put it to -1 or som...
[ { "answer_id": 45982, "author": "maha_2012", "author_id": 14273, "author_profile": "https://wordpress.stackexchange.com/users/14273", "pm_score": 0, "selected": false, "text": "<p>wp_list_categories('taxonomy=custom_tax');\ncustom_tax is custom taxonomy name</p>\n" }, { "answer_i...
2012/03/14
[ "https://wordpress.stackexchange.com/questions/45526", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5079/" ]
(updated) I´m using this query to loop divs in to my front page slider. I use counters to split 4 posts into a slider, then open a new slider etc. Also a counter to set a class to every fourth post (to fix margin). This worked great until I wanted to use the 'post\_per\_page' argument. If I put it to -1 or something d...
As the other's mentioned, [`wp_list_categories`](http://codex.wordpress.org/Template_Tags/wp_list_categories) will work if you you want to do a list of things (just like `wp_list_pages` does for pages). If you specifically want the link (URL), you can use [`get_term_link`](http://codex.wordpress.org/Function_Reference...
45,529
<p>I need to set a featured image for every post I publish. So, when a post is published/updated, the script would scan the post for the first image using a script like this:</p> <pre><code> // Get URL of first image in a post function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(...
[ { "answer_id": 45533, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": false, "text": "<p>Use your function with these two function read the comments in the code to understand</p>\n\n<pre><code>/**\n...
2012/03/14
[ "https://wordpress.stackexchange.com/questions/45529", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14128/" ]
I need to set a featured image for every post I publish. So, when a post is published/updated, the script would scan the post for the first image using a script like this: ``` // Get URL of first image in a post function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_c...
This might work for you as well. It scans the post, then pulls in the image set as 'featured'. If that doesn't exist, it returns the first image attached to the post. If there isn't one, it looks for any image in the post; if that's not there, it grabs a YouTube screenshot. Put this in your theme's functions.php file: ...
45,543
<p>Is it possible to include an image within the auto excerpt?</p> <p>So in the editor you have image then some text and once live it includes the image and not just the text?</p>
[ { "answer_id": 45560, "author": "Michelle", "author_id": 16, "author_profile": "https://wordpress.stackexchange.com/users/16", "pm_score": 3, "selected": true, "text": "<p>Yes, you can do that, but you'll need to tweak the <code>&lt;?php the_excerpt(); ?&gt;</code> function. This is a go...
2012/03/14
[ "https://wordpress.stackexchange.com/questions/45543", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7384/" ]
Is it possible to include an image within the auto excerpt? So in the editor you have image then some text and once live it includes the image and not just the text?
Yes, you can do that, but you'll need to tweak the `<?php the_excerpt(); ?>` function. This is a good article on how to do that: <http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/> To sum up the article in case it goes away, put this in your theme's functions.php file: ``` function improved_trim_exce...
45,554
<p>i'm writing this plugin and i need to deactivate it when NextGen is deactivated:</p> <pre><code>&lt;?php /* Plugin Name: Plugin Name Description: Description Version: 1.0 Author: Author Author URI: Author URI */ // ini_set( "display_errors", 0); global $nextgenUrl; $nextgenUrl = str_replace('/','\\',WP_PLUGIN_DIR...
[ { "answer_id": 45563, "author": "SickHippie", "author_id": 5434, "author_profile": "https://wordpress.stackexchange.com/users/5434", "pm_score": 1, "selected": false, "text": "<p>You've got to actually check <code>is_plugin_active</code>. I would use something more like this, shamelessl...
2012/03/14
[ "https://wordpress.stackexchange.com/questions/45554", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10096/" ]
i'm writing this plugin and i need to deactivate it when NextGen is deactivated: ``` <?php /* Plugin Name: Plugin Name Description: Description Version: 1.0 Author: Author Author URI: Author URI */ // ini_set( "display_errors", 0); global $nextgenUrl; $nextgenUrl = str_replace('/','\\',WP_PLUGIN_DIR.'nextgen-gallery...
You've got to actually check `is_plugin_active`. I would use something more like this, shamelessly stolen and modified from [here](http://www.cleancode.co.nz/blog/481/wordpress-plugin-dependency-programming): ``` register_activation_hook( __FILE__, 'dependentplugin_activate' ); function dependentplugin_activate() { ...
45,561
<p>How can I associate posts with pages?</p> <p>Trying to determine the best architecture / strategy to achieve the following...</p> <p>Using WordPress as a CMS<br> 8 Pages each with sub pages<br> Each page can also have posts</p> <p>I can set up 8 categories where each category matches a page and then list the pos...
[ { "answer_id": 45578, "author": "David", "author_id": 11218, "author_profile": "https://wordpress.stackexchange.com/users/11218", "pm_score": 0, "selected": false, "text": "<p>If I understand you correctly, you'd need something like WP_Query to iterate through your different categories, ...
2012/03/14
[ "https://wordpress.stackexchange.com/questions/45561", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2825/" ]
How can I associate posts with pages? Trying to determine the best architecture / strategy to achieve the following... Using WordPress as a CMS 8 Pages each with sub pages Each page can also have posts I can set up 8 categories where each category matches a page and then list the posts in that category under ...
There is an awesome plugin by @scribu called [Posts 2 Posts](http://wordpress.org/extend/plugins/posts-to-posts/). It allows you to manually associate different post types (or the same post type) with each other. I use it quite a bit for bigger CMS type projects and even [pluginized a common pattern](https://github.com...
45,562
<p>I've been searching high and low for an answer. </p> <p>I simply want to remove the Alternate Text, Caption, Description and Link URL-fields from the uploader and gallery view.</p> <p>I seem that every thing else than this Media-thingy can be removed.</p> <p>Thanx for helping out:)</p>
[ { "answer_id": 45581, "author": "sanchothefat", "author_id": 1733, "author_profile": "https://wordpress.stackexchange.com/users/1733", "pm_score": 3, "selected": true, "text": "<p>You can do this via a filter. Add the following to functions.php. You can also add your own fields this way....
2012/03/14
[ "https://wordpress.stackexchange.com/questions/45562", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14144/" ]
I've been searching high and low for an answer. I simply want to remove the Alternate Text, Caption, Description and Link URL-fields from the uploader and gallery view. I seem that every thing else than this Media-thingy can be removed. Thanx for helping out:)
You can do this via a filter. Add the following to functions.php. You can also add your own fields this way... ``` // edit fields in media upload area add_filter('attachment_fields_to_edit', 'remove_media_upload_fields', 10000, 2); function remove_media_upload_fields( $form_fields, $post ) { // remove unnecessary...
45,564
<p>Lets say I have this menu:</p> <pre><code>Top |___ Sub 1 |___ Sub Sub 1 |___ Sub Sub 2 |___ Sub Sub 3 |___ Sub Sub 4 |___ Sub 2 |___ Sub Sub 1 |___ Sub Sub 2 |___ Sub Sub 3 |___ Sub ...
[ { "answer_id": 45569, "author": "Nikolay Yordanov", "author_id": 8344, "author_profile": "https://wordpress.stackexchange.com/users/8344", "pm_score": 0, "selected": false, "text": "<p>You can consider using a mixture of get_children() for the children of the page and page siblings and g...
2012/03/14
[ "https://wordpress.stackexchange.com/questions/45564", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
Lets say I have this menu: ``` Top |___ Sub 1 |___ Sub Sub 1 |___ Sub Sub 2 |___ Sub Sub 3 |___ Sub Sub 4 |___ Sub 2 |___ Sub Sub 1 |___ Sub Sub 2 |___ Sub Sub 3 |___ Sub Sub 4 |___...
I have come up with my own solution but I'm not convinced it's the best. ``` $parents = array( $post->ID ); if( 0 != $post->post_parent ) { $parents = array_merge( $parents, get_post_ancestors( $post->ID ) ); } $child_of = end( $parents ); $args = array ( 'child_of' => $chi...
45,566
<p>I'm using this piece of code to generate Related Posts by looking at the tags of posts. The problem is I have use a tag named Featured in order for a post to show up in a slideshow. So posts are showing up as related because of that matching Featured tag, even though they are not alike at all. </p> <p>So is there a...
[ { "answer_id": 45569, "author": "Nikolay Yordanov", "author_id": 8344, "author_profile": "https://wordpress.stackexchange.com/users/8344", "pm_score": 0, "selected": false, "text": "<p>You can consider using a mixture of get_children() for the children of the page and page siblings and g...
2012/03/14
[ "https://wordpress.stackexchange.com/questions/45566", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13349/" ]
I'm using this piece of code to generate Related Posts by looking at the tags of posts. The problem is I have use a tag named Featured in order for a post to show up in a slideshow. So posts are showing up as related because of that matching Featured tag, even though they are not alike at all. So is there an easy to ...
I have come up with my own solution but I'm not convinced it's the best. ``` $parents = array( $post->ID ); if( 0 != $post->post_parent ) { $parents = array_merge( $parents, get_post_ancestors( $post->ID ) ); } $child_of = end( $parents ); $args = array ( 'child_of' => $chi...
45,576
<p>I am using wp alchemy to add a custom metabox to my site with multiple image uploader option. This part is working fine, but I have no Idea how to go about outputting the image links to my template. I am hoping to output as a unordered list.</p> <p>setup.php file</p> <pre><code>&lt;?php include_once WP_CONTENT_DI...
[ { "answer_id": 45583, "author": "David", "author_id": 11218, "author_profile": "https://wordpress.stackexchange.com/users/11218", "pm_score": 2, "selected": false, "text": "<p>Do you have any output code we can reference?</p>\n\n<p>Put this in your Theme file:</p>\n\n<pre><code> &lt;...
2012/03/14
[ "https://wordpress.stackexchange.com/questions/45576", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7653/" ]
I am using wp alchemy to add a custom metabox to my site with multiple image uploader option. This part is working fine, but I have no Idea how to go about outputting the image links to my template. I am hoping to output as a unordered list. setup.php file ``` <?php include_once WP_CONTENT_DIR . '/wpalchemy/MetaBox....
Do you have any output code we can reference? Put this in your Theme file: ``` <img src="<?php get_the_value('imgurl'); ?>” style=”width:100px;height:100px” /> ``` if you have multiple you'll have to go through a foreach loop: ``` <?php foreach ($meta['imgurl'] as $img ) { echo '<a href="#" /><img src="'...
45,589
<p>My titles, site wide, will follow this theme all within a h1 tag:</p> <p>Main title heading / Sub-title text</p> <p>I'm trying to wrap a span tag around all text after and including the '/' so my markup will look like this:</p> <pre><code>&lt;h1&gt;Main title heading &lt;span&gt;/ Sub-title text&lt;/span&gt;&lt;/...
[ { "answer_id": 45602, "author": "Sagive", "author_id": 7990, "author_profile": "https://wordpress.stackexchange.com/users/7990", "pm_score": 3, "selected": true, "text": "<p>its best if you just use <strong>custom field</strong> type to create a sub title...<br>\nThat way you leave the t...
2012/03/14
[ "https://wordpress.stackexchange.com/questions/45589", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14149/" ]
My titles, site wide, will follow this theme all within a h1 tag: Main title heading / Sub-title text I'm trying to wrap a span tag around all text after and including the '/' so my markup will look like this: ``` <h1>Main title heading <span>/ Sub-title text</span></h1> ``` How do I accomplish this? I'm not great...
its best if you just use **custom field** type to create a sub title... That way you leave the title un-touched and just add a field where you can insert a value like so (calling field sub title): ![enter image description here](https://i.stack.imgur.com/6RsdI.jpg) --- Then you can fetch your subtitle easily: ``...
45,590
<p>Could anyone help me finding which WP theme has been used in this site?</p> <p><a href="http://www.laquilacittaaperta.it/" rel="nofollow">http://www.laquilacittaaperta.it/</a></p> <p>I only have found concerning a DM theme but I really haven't been able to find it anywhere</p> <p>thank you Mari0</p>
[ { "answer_id": 45602, "author": "Sagive", "author_id": 7990, "author_profile": "https://wordpress.stackexchange.com/users/7990", "pm_score": 3, "selected": true, "text": "<p>its best if you just use <strong>custom field</strong> type to create a sub title...<br>\nThat way you leave the t...
2012/03/14
[ "https://wordpress.stackexchange.com/questions/45590", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14150/" ]
Could anyone help me finding which WP theme has been used in this site? <http://www.laquilacittaaperta.it/> I only have found concerning a DM theme but I really haven't been able to find it anywhere thank you Mari0
its best if you just use **custom field** type to create a sub title... That way you leave the title un-touched and just add a field where you can insert a value like so (calling field sub title): ![enter image description here](https://i.stack.imgur.com/6RsdI.jpg) --- Then you can fetch your subtitle easily: ``...
45,592
<p>I've been trying to get the caption to show under the thumbnail with css but to no avail. It keeps appearing on top.</p> <p>css:</p> <pre><code>.lcp_catlist { float:left; text-align:center; } .lcp_catlist li { display:block; float:left; width: 160px; height: 150px; margin-bottom: 10px;...
[ { "answer_id": 45608, "author": "SolaceBeforeDawn", "author_id": 12651, "author_profile": "https://wordpress.stackexchange.com/users/12651", "pm_score": 1, "selected": false, "text": "<p>please either post the URL or look at page source and post the actual html code so that we can see th...
2012/03/14
[ "https://wordpress.stackexchange.com/questions/45592", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14152/" ]
I've been trying to get the caption to show under the thumbnail with css but to no avail. It keeps appearing on top. css: ``` .lcp_catlist { float:left; text-align:center; } .lcp_catlist li { display:block; float:left; width: 160px; height: 150px; margin-bottom: 10px; } div.project-title...
after a whole night of googling and test runs, I've resolved the matter by using List Category Posts' template. all I did was create another template (from the one provided by plugin) in a folder inside my theme's directory. Then i go in and edit the code by placing the show thumnail codes on top of the title codes, an...
45,650
<p>I am currently using this little loop to display a list of posts using the "events" custom post type</p> <pre><code>&lt;?php global $post; // required $args = array('post_type' =&gt; 'events'); $custom_posts = get_posts($args); foreach($custom_posts as $post) : setup_postdata($post); ?&gt; &lt;ul&gt;&...
[ { "answer_id": 45657, "author": "Zsono", "author_id": 14048, "author_profile": "https://wordpress.stackexchange.com/users/14048", "pm_score": 0, "selected": false, "text": "<p>I know a CSS3 solution:</p>\n\n<pre><code>li {background: #000;}\nli:nth-child(odd) {background: #fff;}\n</code>...
2012/03/15
[ "https://wordpress.stackexchange.com/questions/45650", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7999/" ]
I am currently using this little loop to display a list of posts using the "events" custom post type ``` <?php global $post; // required $args = array('post_type' => 'events'); $custom_posts = get_posts($args); foreach($custom_posts as $post) : setup_postdata($post); ?> <ul><li class="post">Content goes h...
A simple solution would be to add an alternating class to every other post in the list. In particular, (in your style.css) style the list elements `<li>` in one particular way, and then over-ride that style for list elements of a particular class `<li class='my-alternate-class'>`. The class `my-alternate-cass` will app...
45,655
<p>I am using Isotope and I currently have each post rendering as a box on my homepage. I am currently trying to edit my (working) query that currently displays all posts with the category slug of 'static'. Within that query i'd like to target 4 specific post ID's and customise the appearance of each of those 4 posts. ...
[ { "answer_id": 45657, "author": "Zsono", "author_id": 14048, "author_profile": "https://wordpress.stackexchange.com/users/14048", "pm_score": 0, "selected": false, "text": "<p>I know a CSS3 solution:</p>\n\n<pre><code>li {background: #000;}\nli:nth-child(odd) {background: #fff;}\n</code>...
2012/03/15
[ "https://wordpress.stackexchange.com/questions/45655", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14149/" ]
I am using Isotope and I currently have each post rendering as a box on my homepage. I am currently trying to edit my (working) query that currently displays all posts with the category slug of 'static'. Within that query i'd like to target 4 specific post ID's and customise the appearance of each of those 4 posts. So ...
A simple solution would be to add an alternating class to every other post in the list. In particular, (in your style.css) style the list elements `<li>` in one particular way, and then over-ride that style for list elements of a particular class `<li class='my-alternate-class'>`. The class `my-alternate-cass` will app...
45,690
<p>My custom permalink with dynamic taxonomy is working for my custom post type. However, it breaks all my other permalinks. They display a 404 error in the content area (header and sidebar still display).</p> <p>I used the following code to create the dynamic permalinks for the custom post type:</p> <pre><code>/*Add...
[ { "answer_id": 45881, "author": "Rachel Carden", "author_id": 14003, "author_profile": "https://wordpress.stackexchange.com/users/14003", "pm_score": 2, "selected": false, "text": "<p>If you're running WordPress 3.0.1 or later, I believe your problem lies with the 'post_type_link' filter...
2012/03/15
[ "https://wordpress.stackexchange.com/questions/45690", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14190/" ]
My custom permalink with dynamic taxonomy is working for my custom post type. However, it breaks all my other permalinks. They display a 404 error in the content area (header and sidebar still display). I used the following code to create the dynamic permalinks for the custom post type: ``` /*Adds Custom Permalinks f...
If you're running WordPress 3.0.1 or later, I believe your problem lies with the 'post\_type\_link' filter declaration and function arguments. When the 'post\_type\_link' filter is applied, it passes the following 4 arguments: ``` apply_filters('post_type_link', $post_link, $post, $leavename, $sample); ``` But your...
45,692
<p>So i'm using this configuration for an AJAX call in the administrative area (<a href="http://codex.wordpress.org/AJAX_in_Plugins#Ajax_on_the_Administration_Side">like this</a>):</p> <pre><code>add_action( 'admin_head', 'ajaxPerNgg' ); function ajaxPerNgg(){ ?&gt; &lt;script type="text/javascript" &gt; jQuery(docum...
[ { "answer_id": 46523, "author": "Jeff", "author_id": 11711, "author_profile": "https://wordpress.stackexchange.com/users/11711", "pm_score": 2, "selected": false, "text": "<p>Not sure if this is your problem, but I was getting a response of just \"0\" and it took me the longest time to f...
2012/03/15
[ "https://wordpress.stackexchange.com/questions/45692", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10096/" ]
So i'm using this configuration for an AJAX call in the administrative area ([like this](http://codex.wordpress.org/AJAX_in_Plugins#Ajax_on_the_Administration_Side)): ``` add_action( 'admin_head', 'ajaxPerNgg' ); function ajaxPerNgg(){ ?> <script type="text/javascript" > jQuery(document).ready(function() { jQuery...
Add this as well: `add_action('wp_ajax_nopriv_my_action', 'my_action_callback');`. Notice the `nopriv`. It will solve your problem!
45,697
<p>I'm using <code>do_shortcode</code> function to add shortcode in my template. But i would like to check if that shortcode exists before display them. </p> <p>I mean like this</p> <pre><code>If (shortcode_gallery_exists) { echo do_shortcode('[gallery]'); } </code></pre> <p>Can anyone help me? Thanks</p>
[ { "answer_id": 45701, "author": "Ryan", "author_id": 10790, "author_profile": "https://wordpress.stackexchange.com/users/10790", "pm_score": 3, "selected": false, "text": "<p>I think you could use the following code to do this:</p>\n\n<pre><code>$content = get_the_content();\n//write the...
2012/03/15
[ "https://wordpress.stackexchange.com/questions/45697", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5074/" ]
I'm using `do_shortcode` function to add shortcode in my template. But i would like to check if that shortcode exists before display them. I mean like this ``` If (shortcode_gallery_exists) { echo do_shortcode('[gallery]'); } ``` Can anyone help me? Thanks
[#23572](http://core.trac.wordpress.org/ticket/23572) introduced [shortcode\_exists()](http://codex.wordpress.org/Function_Reference/shortcode_exists) into 3.6.
45,700
<p>I have a custom menu that I can call just fine using wp_nav_menu. Is there a way to have the menu name displayed inside an h3 tag before the menu?</p> <p>Ex.</p> <pre><code>&lt;h3&gt;My Menu Name&lt;/h3&gt; &lt;nav&gt; &lt;ul&gt; &lt;li&gt;Menu Item 1&lt;/li&gt; &lt;li&gt;Menu Item 2&lt;/li&gt; &lt;/ul&gt; &lt;/n...
[ { "answer_id": 45708, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 5, "selected": true, "text": "<p>If you know the menu's slug, then things are easier, otherwise you can use this function to get the menu a...
2012/03/15
[ "https://wordpress.stackexchange.com/questions/45700", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2825/" ]
I have a custom menu that I can call just fine using wp\_nav\_menu. Is there a way to have the menu name displayed inside an h3 tag before the menu? Ex. ``` <h3>My Menu Name</h3> <nav> <ul> <li>Menu Item 1</li> <li>Menu Item 2</li> </ul> </nav> ```
If you know the menu's slug, then things are easier, otherwise you can use this function to get the menu at a specified location. ``` <?php function wpse45700_get_menu_by_location( $location ) { if( empty($location) ) return false; $locations = get_nav_menu_locations(); if( ! isset( $locations[$location] ...
45,713
<p>I want to create custom post types with multiple views based on URL.</p> <p>E.g., suppose I have a "Product" post type. I would like to have something like the following:</p> <ul> <li><a href="http://example.com/products/product_name" rel="nofollow">http://example.com/products/product_name</a> &lt;-- Regular view ...
[ { "answer_id": 45760, "author": "moraleida", "author_id": 7890, "author_profile": "https://wordpress.stackexchange.com/users/7890", "pm_score": 0, "selected": false, "text": "<p>Probably not the best way to do it, but one way to get there is: set your CPT to hierarchical, so it will allo...
2012/03/15
[ "https://wordpress.stackexchange.com/questions/45713", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14183/" ]
I want to create custom post types with multiple views based on URL. E.g., suppose I have a "Product" post type. I would like to have something like the following: * <http://example.com/products/product_name> <-- Regular view of the product/regular template * <http://example.com/products/product_name/detailed> <-- Ex...
What you want is a [rewrite endpoint](http://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint). You're already familiar with these. WordPress' urls that end with `feed` are simple a rewrite endpoint, and you can add your own! `add_rewrite_endpoint` takes two arguments: the endpoint you want, and the "mask" of whe...
45,714
<p>Below is the code from my author.php file. The problem is that <code>next_posts_link</code> and <code>previous_posts_link</code> only generate links based on the number of posts in the blog authored by the author in question, not the number of posts in the query ( which includes pages and events). I have used WP_Que...
[ { "answer_id": 45718, "author": "Ryan", "author_id": 10790, "author_profile": "https://wordpress.stackexchange.com/users/10790", "pm_score": 2, "selected": false, "text": "<p>When using custom post types I got around this problem by using the following code. Of course you will need to pu...
2012/03/15
[ "https://wordpress.stackexchange.com/questions/45714", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6169/" ]
Below is the code from my author.php file. The problem is that `next_posts_link` and `previous_posts_link` only generate links based on the number of posts in the blog authored by the author in question, not the number of posts in the query ( which includes pages and events). I have used WP\_Query to add the custom pos...
I got it working, first by implementing [the solution](http://designrjc.com/fix-previous_posts_link-and-next_posts_link-for-custom-post-types/) I described in the edit above, and then by adding the code below ( from [this question](https://wordpress.stackexchange.com/questions/35380/pagination-in-author-php-template-re...
45,721
<p>I am trying to learn more on Theme Development so I've created my own and everything worked fine except when I added <code>functions.php</code> and tried to update it with something simple as:</p> <pre><code>&lt;?php add_theme_support('admin-bar', array('menus')); ?&gt; </code></pre> <p>I get <code>Server 500 ERR...
[ { "answer_id": 45716, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 4, "selected": true, "text": "<p>That's pretty advanced and it doesn't sound like you are all that comfortable with WP yet, no offense. Yo...
2012/03/15
[ "https://wordpress.stackexchange.com/questions/45721", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13434/" ]
I am trying to learn more on Theme Development so I've created my own and everything worked fine except when I added `functions.php` and tried to update it with something simple as: ``` <?php add_theme_support('admin-bar', array('menus')); ?> ``` I get `Server 500 ERROR` and I cannot access any part of Wordpress, n...
That's pretty advanced and it doesn't sound like you are all that comfortable with WP yet, no offense. You can definitely do this with WP Alchemy (I have and do), but you really have to get down and dirty with some Javascript to 1. launch the media uploader and 2. to hijack the send to editor function. some good read...
45,739
<p>Somewhere along the line I have messed up my js enqueue I am not sure how. I have the following in my functions.php file and I am including <code>&lt;?php wp_footer(); ?&gt;</code> in my footer.php before the js files were outputting in the footer no problem, but now it isn't working and I don't know why?</p> <pre...
[ { "answer_id": 45741, "author": "SickHippie", "author_id": 5434, "author_profile": "https://wordpress.stackexchange.com/users/5434", "pm_score": 1, "selected": false, "text": "<p><code>add_action</code> needs to be outside the original function. Right now, it's in the function outside t...
2012/03/15
[ "https://wordpress.stackexchange.com/questions/45739", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7653/" ]
Somewhere along the line I have messed up my js enqueue I am not sure how. I have the following in my functions.php file and I am including `<?php wp_footer(); ?>` in my footer.php before the js files were outputting in the footer no problem, but now it isn't working and I don't know why? ``` function foundationScript...
I am not sure if you posted code as-is or extracted part of it, but per this snippet - you are hooking function **inside itself**. Which doesn't seem like it will work nicely. :) Also `init` hook should **not** be used for enqueue, on front-end hook to use is `wp_enqueue_scripts`, see [where is the right place to regi...
45,747
<p>I am using the Advanced custom fields plugin to add a upload image option to a page, but I am wondering if there is a way so that, when I output it to a theme with <code>&lt;img src="&lt;?php the_field('add_image'); ?&gt;"/&gt;</code> it is not full size, it is cropped or set to one of the wordpress preset media siz...
[ { "answer_id": 45749, "author": "Dwayne Charrington", "author_id": 1687, "author_profile": "https://wordpress.stackexchange.com/users/1687", "pm_score": 3, "selected": true, "text": "<p>In Advanced Custom Fields the field editing screen where you add in the required fields and assign the...
2012/03/15
[ "https://wordpress.stackexchange.com/questions/45747", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7653/" ]
I am using the Advanced custom fields plugin to add a upload image option to a page, but I am wondering if there is a way so that, when I output it to a theme with `<img src="<?php the_field('add_image'); ?>"/>` it is not full size, it is cropped or set to one of the wordpress preset media sizes. Right now it outputs t...
In Advanced Custom Fields the field editing screen where you add in the required fields and assign them to post edit screens did you choose image URL or Attachment ID for the image field? It sounds like you've got it set as image URL which will just return the URL to the originally uploaded file as you've discovered. ...
45,752
<p>I need to duplicate a list of thumbnails elsewhere on a page and have set up a few different custom thumbnail sizes in my functions.php file.</p> <p>If I use:</p> <pre><code>the_post_thumbnail('photo-small'); </code></pre> <p>Then the thumbnail gets displayed correctly, if I use:</p> <pre><code>echo get_post_thu...
[ { "answer_id": 45754, "author": "JohnG", "author_id": 14194, "author_profile": "https://wordpress.stackexchange.com/users/14194", "pm_score": 1, "selected": false, "text": "<p>dumb question, but are you calling <code>the_post_thumbnail</code> from within a loop? If not, then you would wa...
2012/03/16
[ "https://wordpress.stackexchange.com/questions/45752", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14203/" ]
I need to duplicate a list of thumbnails elsewhere on a page and have set up a few different custom thumbnail sizes in my functions.php file. If I use: ``` the_post_thumbnail('photo-small'); ``` Then the thumbnail gets displayed correctly, if I use: ``` echo get_post_thumbnail('photo-small'); ``` Nothing gets ec...
You're using `get_the_post_thumbnail()` and not the nonexistent `get_post_thumbnail()` function, right? As JohnG said, you *have* to pass the ID of the current post to `get_the_post_thumbnail()` (the `the_post_thumbnail()` function already handles that for you). The [Function Reference](http://codex.wordpress.org/Func...
45,755
<h2>1. My shortcodes</h2> <p>I've developed multiple shortcodes for my own theme, I'm loading them in functions.php like this <code>require_once (MY_URL . '/bartag_shortcode.php')</code>.</p> <p>Here's an exemplary bartag shortcode from WordPress Codex:</p> <pre><code>function bartag_func( $atts ) { extract( sho...
[ { "answer_id": 45769, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>Inspect the global variable <code>$shortcode_tags</code>:</p>\n\n<pre><code>print '&lt;pre&gt;' . htmlspecialchars( pri...
2012/03/16
[ "https://wordpress.stackexchange.com/questions/45755", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
1. My shortcodes ---------------- I've developed multiple shortcodes for my own theme, I'm loading them in functions.php like this `require_once (MY_URL . '/bartag_shortcode.php')`. Here's an exemplary bartag shortcode from WordPress Codex: ``` function bartag_func( $atts ) { extract( shortcode_atts( array( ...
Inspect the global variable `$shortcode_tags`: ``` print '<pre>' . htmlspecialchars( print_r( $GLOBALS['shortcode_tags'], TRUE ) ) . '</pre>'; ``` Output: ``` Array ( [wp_caption] => img_caption_shortcode [caption] => img_caption_shortcode [gallery] => gallery_shortcode [embed] => __return_false ...
45,777
<p>I have the latest wordpress version installed. When I upload an image in the control panel for a post, I then go to edit it (crop an image for the thumbnail the way I want or rotate or do any kind of editing) and instead it shows a broken image. </p> <p>The actual images are uploaded, I just can't seem to use the...
[ { "answer_id": 45769, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>Inspect the global variable <code>$shortcode_tags</code>:</p>\n\n<pre><code>print '&lt;pre&gt;' . htmlspecialchars( pri...
2012/03/16
[ "https://wordpress.stackexchange.com/questions/45777", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8668/" ]
I have the latest wordpress version installed. When I upload an image in the control panel for a post, I then go to edit it (crop an image for the thumbnail the way I want or rotate or do any kind of editing) and instead it shows a broken image. The actual images are uploaded, I just can't seem to use the wordpress i...
Inspect the global variable `$shortcode_tags`: ``` print '<pre>' . htmlspecialchars( print_r( $GLOBALS['shortcode_tags'], TRUE ) ) . '</pre>'; ``` Output: ``` Array ( [wp_caption] => img_caption_shortcode [caption] => img_caption_shortcode [gallery] => gallery_shortcode [embed] => __return_false ...
45,782
<p>I am trying to make an AJAX call for a plugin.</p> <pre><code>&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; jQuery(document).ready(function($) { $.post( '&lt;?php admin_url('admin-ajax.php'); ?&gt;', ...
[ { "answer_id": 45785, "author": "Tareq", "author_id": 7156, "author_profile": "https://wordpress.stackexchange.com/users/7156", "pm_score": 2, "selected": false, "text": "<p>You didn't echo <code>admin_url('admin-ajax.php')</code></p>\n" }, { "answer_id": 45789, "author": "ka...
2012/03/16
[ "https://wordpress.stackexchange.com/questions/45782", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14211/" ]
I am trying to make an AJAX call for a plugin. ``` <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript"> jQuery(document).ready(function($) { $.post( '<?php admin_url('admin-ajax.php'); ?>', { action : 'AAA' }, ...
You didn't echo `admin_url('admin-ajax.php')`
45,796
<p>Tabs placed in a <code>&lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;</code> block are stripped and line breaks are removed leaving a single continuous line of text. This occurs when switching from html to visual editors. Is there a setting in TinyMCE to avoid this?</p> <p>BEFORE:</p> <p><img src="https://i.stac...
[ { "answer_id": 46256, "author": "Donna", "author_id": 13725, "author_profile": "https://wordpress.stackexchange.com/users/13725", "pm_score": 1, "selected": false, "text": "<p>I have also added custom shortcodes to functions.php to avoid things breaking when switching from html to visual...
2012/03/16
[ "https://wordpress.stackexchange.com/questions/45796", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7701/" ]
Tabs placed in a `<pre><code></code></pre>` block are stripped and line breaks are removed leaving a single continuous line of text. This occurs when switching from html to visual editors. Is there a setting in TinyMCE to avoid this? BEFORE: ![enter image description here](https://i.stack.imgur.com/VKwGV.png) AFTER:...
Add to function.php ``` add_filter('tiny_mce_before_init', 'tiny_mce_before_init'); ``` And function tiny\_mce\_before\_init: ``` function tiny_mce_before_init($init) { $init['setup'] = "function(ed) { ed.onBeforeSetContent.add(function(ed, o) { if ( o.content.indexOf('<pre') != -1) { o.content = o....
45,798
<p>I have create a custom post type in my WordPress attached with a custom taxonomy.</p> <p>The post collect date from the from end of the web site by using wp_insert_post().</p> <p>This is my Custom post registration code:</p> <pre><code>$labels = array( 'name' =&gt; 'Films', 'singular_name' =&gt; '...
[ { "answer_id": 45810, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": false, "text": "<p>You shouldn't need to use:</p>\n\n<pre><code>wp_set_object_terms($new_film_id, $_POST['category'], 'film_...
2012/03/16
[ "https://wordpress.stackexchange.com/questions/45798", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7850/" ]
I have create a custom post type in my WordPress attached with a custom taxonomy. The post collect date from the from end of the web site by using wp\_insert\_post(). This is my Custom post registration code: ``` $labels = array( 'name' => 'Films', 'singular_name' => 'Film', 'add_new' => 'Add...
Where is the code that catches an processes the `$_POST` data? Is it in a template file? Or is it in a function that is run on a hook? If it's the latter, and if `taxonomy_exists()` is returning `false` as you suggest here (http://wordpress.stackexchange.com/questions/45798/wp-insert-post-and-custom-taxonomy#comment584...
45,801
<p>I’m working on a small plugin - part of it needs to add several meta boxes to all custom post types. I’ve tried looping through my array of custom port types in various ways but I keep getting errors that I’ve already called functions such as add_meta_box. The script below is my latest effort, it’s not saving values...
[ { "answer_id": 45805, "author": "Geert", "author_id": 4936, "author_profile": "https://wordpress.stackexchange.com/users/4936", "pm_score": 2, "selected": false, "text": "<p>Here is a simple example that adds a meta box to all public post types:</p>\n\n<pre><code>// All public post types...
2012/03/16
[ "https://wordpress.stackexchange.com/questions/45801", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12350/" ]
I’m working on a small plugin - part of it needs to add several meta boxes to all custom post types. I’ve tried looping through my array of custom port types in various ways but I keep getting errors that I’ve already called functions such as add\_meta\_box. The script below is my latest effort, it’s not saving values ...
Here is a simple example that adds a meta box to all public post types: ``` // All public post types $post_types = array_merge( array('page' => 'page', 'post' => 'post'), get_post_types(array('_builtin' => FALSE)), ); // Add meta box for each post type foreach ($post_types as $post_type) { add_meta_box('i...
45,802
<p><strong>Original question</strong> <em>How do I get menu items using slug and not ID</em></p> <blockquote> <p>I need to get a specific menu, but I can't use ID, since the menu ID on my dev is not the same as on my staging and prod server.</p> <p>WP doc says that <code>wp_get_nav_menu_items</code>can be use...
[ { "answer_id": 45806, "author": "Mamaduka", "author_id": 888, "author_profile": "https://wordpress.stackexchange.com/users/888", "pm_score": 0, "selected": false, "text": "<p>You can get menus using <code>theme_location</code> parameter, see <a href=\"http://codex.wordpress.org/Function_...
2012/03/16
[ "https://wordpress.stackexchange.com/questions/45802", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1447/" ]
**Original question** *How do I get menu items using slug and not ID* > > I need to get a specific menu, but I can't use ID, since the menu ID > on my dev is not the same as on my staging and prod server. > > > WP doc says that `wp_get_nav_menu_items`can be used with menu slug. > But how do I know what slug is cr...
So, based on your comment: > > `wp_nav_menu` is what I'm using now. But now I have to add 'home' menu item depending on certain criteria > > > I'm going to propose a solution that will allow you to add a "Home" menu item to *any* menu, based on arbitrary conditions, using the `wp_nav_menu_items` filter ([see tuto...
45,815
<p>In the Wordpress control panel, when writing a new post, I would like to disable the Header 1 and Header 2 from the text formatting combobox, because I already use them on my theme (h1 for blog name and h2 for post titles), and would like to keep all headers inside a post with h3 or higher. Is that possible?</p> <p...
[ { "answer_id": 45823, "author": "molokom", "author_id": 14047, "author_profile": "https://wordpress.stackexchange.com/users/14047", "pm_score": 1, "selected": false, "text": "<p>This is a quick and dirty solution but it may work if your objective is to disable H1 and H2.</p>\n\n<p>Add th...
2012/03/16
[ "https://wordpress.stackexchange.com/questions/45815", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14218/" ]
In the Wordpress control panel, when writing a new post, I would like to disable the Header 1 and Header 2 from the text formatting combobox, because I already use them on my theme (h1 for blog name and h2 for post titles), and would like to keep all headers inside a post with h3 or higher. Is that possible? It doesn'...
you can change lots of things about the tinyMCE editor at the tiny\_mce\_before\_init filter. <http://codex.wordpress.org/TinyMCE_Custom_Buttons> the following will restrict your blockformats to p,h3,h4 and blockquote ``` function wpa_45815($arr){ $arr['theme_advanced_blockformats'] = 'p,h3,h4,blockquote'; r...
45,840
<p>I have <code>wp_nonce_field</code> in my code but it's creating two instances to the html code for some reason, one where I'd expect it and another at the start of the entry. Is this correct or am I doing somehthing wrong. It's creating a validator error. One thing I'm doing a bit different is that the form is bein...
[ { "answer_id": 45850, "author": "Boone Gorges", "author_id": 14052, "author_profile": "https://wordpress.stackexchange.com/users/14052", "pm_score": 4, "selected": true, "text": "<p>If you're going to add the nonce field to an HTML string, you have to specify that you don't want it echoe...
2012/03/16
[ "https://wordpress.stackexchange.com/questions/45840", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6169/" ]
I have `wp_nonce_field` in my code but it's creating two instances to the html code for some reason, one where I'd expect it and another at the start of the entry. Is this correct or am I doing somehthing wrong. It's creating a validator error. One thing I'm doing a bit different is that the form is being output via a ...
If you're going to add the nonce field to an HTML string, you have to specify that you don't want it echoed. That's the fourth parameter; see <https://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/functions.php#L1952> ``` $formDisplay .= wp_nonce_field( 'contact-form', '_wpnonce', true, false ); ```
45,855
<p>I'm curious if it is possible, in a plugin/custom code, to take an URL that has been generated by the currently running WordPress site &amp; parse it to retrieve the $blog_id and $post_id?</p> <p>ie. taking a string like "myblog.mysite.com/2012/03/16/whatever/" and determining that this is post #6 ("whatever") on b...
[ { "answer_id": 45860, "author": "weston deboer", "author_id": 8926, "author_profile": "https://wordpress.stackexchange.com/users/8926", "pm_score": 0, "selected": false, "text": "<p>Plain and simple, to get the post id you just use:</p>\n\n<pre><code>&lt;?php \necho get_the_ID(); \n?&gt;...
2012/03/16
[ "https://wordpress.stackexchange.com/questions/45855", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1446/" ]
I'm curious if it is possible, in a plugin/custom code, to take an URL that has been generated by the currently running WordPress site & parse it to retrieve the $blog\_id and $post\_id? ie. taking a string like "myblog.mysite.com/2012/03/16/whatever/" and determining that this is post #6 ("whatever") on blog #2 ("myb...
As Weston mentioned, if you're within WordPress and you know what blog the URL came from, then ask WordPress for the blog ID. But if you're really, really sure there's no better method in this case than parsing a URL, then here you go: ``` $url = 'http://myblog.mysite.com/2012/03/16/whatever/'; $domain = parse_url( ...
45,858
<p>I've got a this site <a href="http://casaraoamenoreseda.com.br/" rel="nofollow">Casarão Amneo Reseda</a>, that has 2 themes, the main one for any desktop browser and a second one, mobie friendly, based on the <a href="http://jquerymobile.com/" rel="nofollow">jQuery mobile framework</a>. </p> <p>I'm currently using ...
[ { "answer_id": 45867, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 1, "selected": false, "text": "<p>I've been using Chris Schuld's <a href=\"http://chrisschuld.com/projects/browser-php-detecting-a-users-brows...
2012/03/16
[ "https://wordpress.stackexchange.com/questions/45858", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1997/" ]
I've got a this site [Casarão Amneo Reseda](http://casaraoamenoreseda.com.br/), that has 2 themes, the main one for any desktop browser and a second one, mobie friendly, based on the [jQuery mobile framework](http://jquerymobile.com/). I'm currently using the [WPtap Mobile Detector](http://wordpress.org/extend/plugin...
I've been using Chris Schuld's [Browser Class](http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php/) with very good results detecting a variety of data from the browser agent. Example of use ``` require_once('lib/Browser.php'); $browser_check = new Browser(); $browser = $browser_check->getB...
45,898
<p>My <code>.htaccess</code> files are intercepting WordPress' <code>.htaccess</code> file.</p> <p>Which modules and which settings (specified by <code>.htaccess</code>) are required for WordPress to work? In other words, where can I find WordPress' default <code>.htaccess</code> file?</p>
[ { "answer_id": 45899, "author": "Manimaran", "author_id": 5515, "author_profile": "https://wordpress.stackexchange.com/users/5515", "pm_score": 5, "selected": false, "text": "<p>Here is the default code for that file.</p>\n\n<pre><code># BEGIN WordPress\n&lt;IfModule mod_rewrite.c&gt;\nR...
2012/03/17
[ "https://wordpress.stackexchange.com/questions/45898", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
My `.htaccess` files are intercepting WordPress' `.htaccess` file. Which modules and which settings (specified by `.htaccess`) are required for WordPress to work? In other words, where can I find WordPress' default `.htaccess` file?
Here is the default code for that file. ``` # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress ``` you can check it here for default h...
45,900
<p>I am going to enhance my WordPress authentication page. My idea is that simply adding an extra field into the login page. The extra field will require user to enter personal identification code (4 to 8 digit).</p> <p>I have changed the login page layout in <code>wp-login.php</code> and added extra column for storin...
[ { "answer_id": 45902, "author": "Manimaran", "author_id": 5515, "author_profile": "https://wordpress.stackexchange.com/users/5515", "pm_score": 2, "selected": false, "text": "<p>This answer for reference purpose only.</p>\n\n<p>You should not edit core files WordPress files or else you w...
2012/03/17
[ "https://wordpress.stackexchange.com/questions/45900", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14245/" ]
I am going to enhance my WordPress authentication page. My idea is that simply adding an extra field into the login page. The extra field will require user to enter personal identification code (4 to 8 digit). I have changed the login page layout in `wp-login.php` and added extra column for storing personal identifica...
First of all, I would **advise against editing the core files** as it will be overwritten when you next update WordPress. Also, you *should* update WordPress, because it will often include security updates. (It's recently [been reported](http://blog.sucuri.net/2012/03/rr-nu-malware-campain-more-details.html) that ther...
45,901
<p>Is a way to pass my own parameters to the function in <code>add_filter</code> or <code>add_action</code>. For example take a look in the following code:</p> <pre><code>function my_content($content, $my_param) { do something... using $my_param here ... return $content; } add_filter('the_content', 'my_content', 10, 1...
[ { "answer_id": 45920, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 8, "selected": true, "text": "<p>By default this is not possible. There are workarounds if you do it the OOP way.<br>\nYou could create a class to store...
2012/03/17
[ "https://wordpress.stackexchange.com/questions/45901", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3914/" ]
Is a way to pass my own parameters to the function in `add_filter` or `add_action`. For example take a look in the following code: ``` function my_content($content, $my_param) { do something... using $my_param here ... return $content; } add_filter('the_content', 'my_content', 10, 1); ``` Can I pass my own parameter...
By default this is not possible. There are workarounds if you do it the OOP way. You could create a class to store the values you want to use later. Example: ``` /** * Stores a value and calls any existing function with this value. */ class WPSE_Filter_Storage { /** * Filled by __construct(). Used by __...
45,921
<p>I'm looking to modify the output of the_excerpt when there isn't an excerpt specified and the post is password protected. I already can modify the password protected form to whatever I want, but the_excerpt is outputting "There is no excerpt because this is a protected post.".</p> <p>The code for this lies in wp-in...
[ { "answer_id": 45924, "author": "David", "author_id": 11218, "author_profile": "https://wordpress.stackexchange.com/users/11218", "pm_score": 1, "selected": false, "text": "<p>You'd want to look into add_filter(). </p>\n\n<p>Here's the codex link to it: <a href=\"http://codex.wordpress.o...
2012/03/17
[ "https://wordpress.stackexchange.com/questions/45921", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13252/" ]
I'm looking to modify the output of the\_excerpt when there isn't an excerpt specified and the post is password protected. I already can modify the password protected form to whatever I want, but the\_excerpt is outputting "There is no excerpt because this is a protected post.". The code for this lies in wp-includes/p...
Simple way would be to check output in template (or small wrapper): ``` $excerpt = get_the_excerpt(); if( 'There is no excerpt because this is a protected post.' == $excerpt ) { // stuff } else { echo $excerpt; } ``` Another way would be to use `gettext` filter (which is used inside `__()`) to catch and m...
45,936
<p>This is something that has always confused me and I could use some help.</p> <p>I want to do four things directly above the closing body tag:</p> <ol> <li>include jQuery (WordPress version is fine)</li> <li>include a jQuery plugin dependent on jQuery beneath this</li> <li>initialize the plugin directly underneath ...
[ { "answer_id": 45939, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 1, "selected": false, "text": "<p>I'm not sure it's still (or ever was) the \"best way\" since I haven't had time to browse the latest develo...
2012/03/17
[ "https://wordpress.stackexchange.com/questions/45936", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8678/" ]
This is something that has always confused me and I could use some help. I want to do four things directly above the closing body tag: 1. include jQuery (WordPress version is fine) 2. include a jQuery plugin dependent on jQuery beneath this 3. initialize the plugin directly underneath this plugin AND avoid conflict i...
The following (in your theme's `functions.php`) will register your script, and set jQuery as a dependency. So when you enqueue it, jQuery will also be enqueued. ``` function my_scripts_method() { // register your script location, dependencies and version wp_register_script('my_custom_script', get_template...
45,941
<p>I am working on a private site where the comments need to be hidden. I know how to remove the comments feed from the header, but can anyone give me some instructions on how to disable the comments feed altogether. Because all you need to do is add /feed/ to the single post and then you can see the comments feed. </p...
[ { "answer_id": 45943, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 3, "selected": true, "text": "<p>Something like this should work.</p>\n\n<pre><code>function wpse45941_disable_feed( $comments ) {\n if( $co...
2012/03/17
[ "https://wordpress.stackexchange.com/questions/45941", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8926/" ]
I am working on a private site where the comments need to be hidden. I know how to remove the comments feed from the header, but can anyone give me some instructions on how to disable the comments feed altogether. Because all you need to do is add /feed/ to the single post and then you can see the comments feed. I tr...
Something like this should work. ``` function wpse45941_disable_feed( $comments ) { if( $comments ) { wp_die( 'No feed available' ); } } add_action('do_feed', 'wpse45941_disable_feed',1 ); add_action('do_feed_rdf', 'wpse45941_disable_feed',1 ); add_action('do_feed_rss', 'wpse45941_disable_feed',1 ); ad...