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
28,060
<p>For Microkids <a href="http://www.microkid.net/wordpress/related-posts/" rel="nofollow">related post plugin</a> He said </p> <blockquote> <p>"Using the get_post() function you could get any data you need from the related posts."</p> </blockquote> <p>and he posted this snippet of code.</p> <pre><code>$related_...
[ { "answer_id": 28061, "author": "tollmanz", "author_id": 4850, "author_profile": "https://wordpress.stackexchange.com/users/4850", "pm_score": 0, "selected": false, "text": "<p>Try sending the post id to the function:</p>\n\n<p><code>$values = get_post_custom_values(\"issue-cover\", $pos...
2011/09/09
[ "https://wordpress.stackexchange.com/questions/28060", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3495/" ]
For Microkids [related post plugin](http://www.microkid.net/wordpress/related-posts/) He said > > "Using the get\_post() function you could get any data you need from > the related posts." > > > and he posted this snippet of code. ``` $related_posts = MRP_get_related_posts( $post_id ); ``` I'm not exactly su...
Just wondering why you are using $values = get\_post\_custom\_values("issue-cover"); so many times. You are missing the post->ID argument as the second parameter. You only need to define this variable once and then use it over and over. I'm also wondering why you don't use post-thumbnails to solve this. There are two...
28,070
<p>I have the following code in my sidebar.php file:</p> <pre><code>&lt;ul class="list-posts"&gt; &lt;?php $lastposts = get_posts('numberposts=5&amp;orderby=date&amp;cat=-52'); foreach($lastposts as $post) : setup_postdata($post); $page_name = $wp_query-&gt;post-&gt;post_name; ...
[ { "answer_id": 28061, "author": "tollmanz", "author_id": 4850, "author_profile": "https://wordpress.stackexchange.com/users/4850", "pm_score": 0, "selected": false, "text": "<p>Try sending the post id to the function:</p>\n\n<p><code>$values = get_post_custom_values(\"issue-cover\", $pos...
2011/09/09
[ "https://wordpress.stackexchange.com/questions/28070", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8497/" ]
I have the following code in my sidebar.php file: ``` <ul class="list-posts"> <?php $lastposts = get_posts('numberposts=5&orderby=date&cat=-52'); foreach($lastposts as $post) : setup_postdata($post); $page_name = $wp_query->post->post_name; if (is_page_template('news-page...
Just wondering why you are using $values = get\_post\_custom\_values("issue-cover"); so many times. You are missing the post->ID argument as the second parameter. You only need to define this variable once and then use it over and over. I'm also wondering why you don't use post-thumbnails to solve this. There are two...
28,081
<p>I have a multisite wordpress installation with 5 sites, and within each site there are the same 4 custom post type,</p> <p>I want to query the latest 5 posts across all sites where the <code>post_type</code> is <code>gallery</code></p> <p><strong>is it possible to get <code>wp_query()</code> to pull across all blo...
[ { "answer_id": 28085, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 4, "selected": true, "text": "<p>Yes but not in a single query, e.g.:</p>\n\n<pre><code>if(is_multisite()){\n global $wpdb;\n $blogs = $w...
2011/09/09
[ "https://wordpress.stackexchange.com/questions/28081", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4816/" ]
I have a multisite wordpress installation with 5 sites, and within each site there are the same 4 custom post type, I want to query the latest 5 posts across all sites where the `post_type` is `gallery` **is it possible to get `wp_query()` to pull across all blogs within the site instead of just the current blog?**
Yes but not in a single query, e.g.: ``` if(is_multisite()){ global $wpdb; $blogs = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE spam = '0' AND deleted = '0' and archived = '0' and public='1'")); if(!empty($blogs)){ ?><?php foreach($blogs as $blog){ switch...
28,143
<p>Every tutorial I've seen on this subject is out of date, so I'm hoping someone here can help me.</p> <p>I want to style my wp-login.php page with a CSS file. But I'd like to do it in a way that won't get overwritten when Wordpress is updated. From what I can tell, based on the tuts I've read, the best way it to add...
[ { "answer_id": 28120, "author": "Niraj Chauhan", "author_id": 1743, "author_profile": "https://wordpress.stackexchange.com/users/1743", "pm_score": 0, "selected": false, "text": "<p>I don't know about plugin\nbut you can edit your index.php file and set it to open default page as your fl...
2011/09/10
[ "https://wordpress.stackexchange.com/questions/28143", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7298/" ]
Every tutorial I've seen on this subject is out of date, so I'm hoping someone here can help me. I want to style my wp-login.php page with a CSS file. But I'd like to do it in a way that won't get overwritten when Wordpress is updated. From what I can tell, based on the tuts I've read, the best way it to add it using ...
rename your intro html file `front-page.php` and put it in your template directory, then create a dummy 'intro' page in WordPress and set that as your front page.
28,168
<p>Seriously, why <code>'with_front' =&gt; false</code> does not work as it should be? It is supposed to remove TAXONOMY BASE NAME and my question is why it does not work?</p> <p>I just dont want the taxonamy base slug appear in my URL and codex says <code>'with_front' =&gt;</code> false should help but it does not. L...
[ { "answer_id": 28206, "author": "Manny Fleurmond", "author_id": 2234, "author_profile": "https://wordpress.stackexchange.com/users/2234", "pm_score": 4, "selected": false, "text": "<p>All with_front does is toggle whether or not a taxonomy link can have something else in front of it ie e...
2011/09/10
[ "https://wordpress.stackexchange.com/questions/28168", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7954/" ]
Seriously, why `'with_front' => false` does not work as it should be? It is supposed to remove TAXONOMY BASE NAME and my question is why it does not work? I just dont want the taxonamy base slug appear in my URL and codex says `'with_front' =>` false should help but it does not. Leaving the slug empty like `'slug'=> '...
All with\_front does is toggle whether or not a taxonomy link can have something else in front of it ie extra permalink stuff from the permalinks options page. For example with\_front set to true makes this possible: ``` blah.com/2011/09/tax/term ``` with it set to false, all you can do is: ``` blah.com/tax/term `...
28,185
<p>Having recently installed a theme update on an inherited premium theme, I am facing a minor irritation that I do not have the coding knowledge to solve.</p> <p>The theme displays a link to RSS feeds for archive and category pages but for some reason the new php file breaks the link - it displays correctly on the pa...
[ { "answer_id": 28186, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 0, "selected": false, "text": "<p><code>get_category_rss_link</code> is a deprecated function, use <a href=\"http://codex.wordpress.org/Function_Refe...
2011/09/11
[ "https://wordpress.stackexchange.com/questions/28185", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8575/" ]
Having recently installed a theme update on an inherited premium theme, I am facing a minor irritation that I do not have the coding knowledge to solve. The theme displays a link to RSS feeds for archive and category pages but for some reason the new php file breaks the link - it displays correctly on the page but the...
This is not a PHP or HTML issue, but a CSS issue. Your top menu is overlapping with the top of the content, so when you place the mouse over the link you are in fact still hovering over the top menu. You can see this in the developer tools of your browser: ![Top part of content obscured by top menu](https://i.stack.im...
28,189
<p>When I try to insert a map into my WordPress page, I get only a gray-colored field with some controls as shown on the picture: <img src="https://i.stack.imgur.com/faHJ9.jpg" alt="enter image description here"></p> <p>No matter, how I put in into the page: by using a special plugin or with my own java-code. I use Wo...
[ { "answer_id": 28198, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>From quick test snippet you provided does embed map seemingly correctly. There is nothing on that map, because marke...
2011/09/11
[ "https://wordpress.stackexchange.com/questions/28189", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8577/" ]
When I try to insert a map into my WordPress page, I get only a gray-colored field with some controls as shown on the picture: ![enter image description here](https://i.stack.imgur.com/faHJ9.jpg) No matter, how I put in into the page: by using a special plugin or with my own java-code. I use WordPress 3.2.1 and I've t...
These errors come from CSS rules from your WordPress theme that are also applied to elements on the map. For example, on your page, I was able to fix the popup by disabling the `#content table` and `#content tr th` rules which add extra margins. In a test setup I even got gray gaps between the tiles because of `.entry-...
28,202
<p>I am having a weird problem. Every few days I go to my website and get an "Internal Server Error" - Or 500 error. I go into the .htaccess file of the site and notice it's been altered. One character is added at the end of the file.</p> <p>It's easy to fix and continue on, but it keeps happening. htaccess permission...
[ { "answer_id": 28219, "author": "farinspace", "author_id": 466, "author_profile": "https://wordpress.stackexchange.com/users/466", "pm_score": 0, "selected": false, "text": "<p>weird ... </p>\n\n<ol>\n<li><p>is the site auto updated somehow, via FTP, SVN, RSYNC, etc.?</p></li>\n<li><p>ev...
2011/09/11
[ "https://wordpress.stackexchange.com/questions/28202", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6155/" ]
I am having a weird problem. Every few days I go to my website and get an "Internal Server Error" - Or 500 error. I go into the .htaccess file of the site and notice it's been altered. One character is added at the end of the file. It's easy to fix and continue on, but it keeps happening. htaccess permissions are 644 ...
Assuming you're on Linux, if you go to your wp-content/plugins folder and run ``` grep -R 'htaccess' * ``` it should let you know if any plugins are addressing that file by name
28,267
<p>I have a custom post type running fine, but some of the text in the page is the same for every post, so I want to add it in using a function.</p> <p>I have this set up:</p> <pre><code>function new_default_content($content) { global $post; if ($post-&gt;post_type == 'custom-post-type') { $content = 'Test te...
[ { "answer_id": 28268, "author": "helenhousandi", "author_id": 2226, "author_profile": "https://wordpress.stackexchange.com/users/2226", "pm_score": 4, "selected": true, "text": "<p>You're completely overwriting the content instead of appending it. You need to do something like <code>$con...
2011/09/12
[ "https://wordpress.stackexchange.com/questions/28267", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7553/" ]
I have a custom post type running fine, but some of the text in the page is the same for every post, so I want to add it in using a function. I have this set up: ``` function new_default_content($content) { global $post; if ($post->post_type == 'custom-post-type') { $content = 'Test text here'; } retu...
You're completely overwriting the content instead of appending it. You need to do something like `$content .= 'Test text here';` instead.
28,288
<p>I'm trying to display the latest post revision if the page is "pending", by default the page displays a 404 if it is pending. But I want it to show the latest revision until the page is updated.</p> <p>The code below doesn't seem to display anything but the title, I have used a hook to the <code>wp_insert_post_data...
[ { "answer_id": 28584, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 2, "selected": false, "text": "<p>It took me a while but I got it! This works as follows:</p>\n\n<ol>\n<li>Since you have no reference to the...
2011/09/12
[ "https://wordpress.stackexchange.com/questions/28288", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6824/" ]
I'm trying to display the latest post revision if the page is "pending", by default the page displays a 404 if it is pending. But I want it to show the latest revision until the page is updated. The code below doesn't seem to display anything but the title, I have used a hook to the `wp_insert_post_data` function whic...
It took me a while but I got it! This works as follows: 1. Since you have no reference to the post other than the URI, we segment out the URI to check for a page with that page\_name 2. If there is a page, we get the latest revision child 3. Hack the query to force our revision slug to source the page This works swel...
28,292
<p>I used </p> <pre><code>// Delete Post Link function wp_delete_post_link($link = 'Delete This', $before = '', $after = '', $title="Move this item to the Trash", $cssClass="") { global $post; if ( $post-&gt;post_type == 'page' ) { if ( !current_user_can( 'edit_page' ) ) return; } else ...
[ { "answer_id": 28329, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>Attachments are not considered part of the post, because they can be easily used in multiple places. </p>\n\n<p>Dele...
2011/09/12
[ "https://wordpress.stackexchange.com/questions/28292", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7338/" ]
I used ``` // Delete Post Link function wp_delete_post_link($link = 'Delete This', $before = '', $after = '', $title="Move this item to the Trash", $cssClass="") { global $post; if ( $post->post_type == 'page' ) { if ( !current_user_can( 'edit_page' ) ) return; } else { if ( !c...
Try using these delete links instead. Yours don't seem to be formatted right. For delete: ``` $delLink = wp_nonce_url( admin_url() . "post.php", "post=" . $post->ID . "&action=delete"); ``` For trash: ``` $delLink = wp_nonce_url( admin_url() . "post.php", "post=" . $post->ID . "&action=trash"); ``` EDIT: No try...
28,306
<p>I have the following: </p> <pre><code>&lt;?php $num_cols = 2; // set the number of columns here $args = array( 'post_type' =&gt; 'testimonials', 'posts_per_page' =&gt; 4, 'orderby' =&gt; 'ID', 'include' =&gt; '883, 563, 5...
[ { "answer_id": 28309, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 5, "selected": true, "text": "<p>use <strong><code>post__in</code></strong> key instead of <strong><code>include</code></strong> to get posts from th...
2011/09/12
[ "https://wordpress.stackexchange.com/questions/28306", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5175/" ]
I have the following: ``` <?php $num_cols = 2; // set the number of columns here $args = array( 'post_type' => 'testimonials', 'posts_per_page' => 4, 'orderby' => 'ID', 'include' => '883, 563, 568, 106', ...
use **`post__in`** key instead of **`include`** to get posts from the specific post ids. ``` $args = array( 'post_type' => 'testimonials', 'posts_per_page' => 4, 'orderby' => 'ID', 'post__in' => array(883, 563, 568, 106), ); ``` And to **`order posts`** by the **`given posts ids`**, you can use th...
28,313
<p>How can I extract the width of an image as defined in <code>add_image_size</code> for use as a template variable?</p> <p>For example if my theme defines the size <em>small</em> as <code>add_image_size( 'small', 195, 146, true );</code> <em>195</em> would be the variable.</p> <p>I am trying to build a dynamic <em>...
[ { "answer_id": 28315, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 0, "selected": false, "text": "<p>This <code>&lt;?php wp_get_attachment_image_src( $attachment_id); ?&gt;</code> should return an array of</p>\n\n<p...
2011/09/12
[ "https://wordpress.stackexchange.com/questions/28313", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1057/" ]
How can I extract the width of an image as defined in `add_image_size` for use as a template variable? For example if my theme defines the size *small* as `add_image_size( 'small', 195, 146, true );` *195* would be the variable. I am trying to build a dynamic *mshots* url.
Generally speaking, there's no need to do this. However, if it's one added using `add_image_size`, it will be in the $\_wp\_additional\_image\_sizes global. ``` global $_wp_additional_image_sizes; echo $_wp_additional_image_sizes['small']['width']; ```
28,341
<p>I've recently created a custom post type, however each time an update is saved the contents of the meta field disappears after a few minutes.</p> <p>Is this a bug? </p> <pre><code>&lt;?php // CUSTOM POST TYPE 1 add_action('init', 'ootb_tenant_register'); function ootb_tenant_register() { $args = array( ...
[ { "answer_id": 28333, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>There is a lot of leftovers in script-related articles in Codex that are not entirely correct (putting it mildly).</p...
2011/09/12
[ "https://wordpress.stackexchange.com/questions/28341", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3782/" ]
I've recently created a custom post type, however each time an update is saved the contents of the meta field disappears after a few minutes. Is this a bug? ``` <?php // CUSTOM POST TYPE 1 add_action('init', 'ootb_tenant_register'); function ootb_tenant_register() { $args = array( 'label' => __('T...
There is a lot of leftovers in script-related articles in Codex that are not entirely correct (putting it mildly). The enqueue should not be done before `wp_head()`, it should be done on `wp_enqueue_scripts`. Which is technically early inside `wp_head()`. It doesn't harm performance, because registering/enqueueing sc...
28,342
<p>I have a Wordpress site and a web application that can be used only by the registered (Wordpress) users.</p> <p>Now I'm loading <code>wp-blog-header.php</code> to check if the user is logged in. Everything is working fine but because on every request (including AJAX) I have to load the Wordpress core also, it slows...
[ { "answer_id": 28343, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": -1, "selected": false, "text": "<p>If you just want to allow all Wordpress users to use the web app, you can use the Wordpress user management syste...
2011/09/12
[ "https://wordpress.stackexchange.com/questions/28342", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8615/" ]
I have a Wordpress site and a web application that can be used only by the registered (Wordpress) users. Now I'm loading `wp-blog-header.php` to check if the user is logged in. Everything is working fine but because on every request (including AJAX) I have to load the Wordpress core also, it slows down my application ...
If I had to do this, I'd use my own cookie to determine login and only load WordPress to check when necessary. The wordpress\_logged\_in\_{some-hash} cookie can be used to determine the user, and WordPress uses it to determine same. You can't easily reimplement that, but you can use it without loading WordPress on mul...
28,359
<p>I need a way to restrict authors from uploading images bellow specific dimensions. </p> <p>Say I only want to allow uploading images that are at least 400px x 400px. If the image size is smaller, the author should get an error notice that the image is too small. </p> <p>Is there a plugin or code that can accompli...
[ { "answer_id": 28404, "author": "Maor Barazany", "author_id": 2063, "author_profile": "https://wordpress.stackexchange.com/users/2063", "pm_score": 6, "selected": true, "text": "<p>Add this code to your theme's <strong>functions.php</strong> file, and it will limit minimum image dimentio...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28359", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6623/" ]
I need a way to restrict authors from uploading images bellow specific dimensions. Say I only want to allow uploading images that are at least 400px x 400px. If the image size is smaller, the author should get an error notice that the image is too small. Is there a plugin or code that can accomplish this?
Add this code to your theme's **functions.php** file, and it will limit minimum image dimentions ``` add_filter('wp_handle_upload_prefilter','tc_handle_upload_prefilter'); function tc_handle_upload_prefilter($file) { $img=getimagesize($file['tmp_name']); $minimum = array('width' => '640', 'height' => '480');...
28,363
<p>Everyone! I am new to WP and trying to build a plugin. I have the following codes working properly:</p> <pre><code>add_filter('the_content', 'say_hello'); function say_hello($content){ if(is_single() || is_page()){ print $content." Thank you for reading!"; } else { print $content; } } </...
[ { "answer_id": 28404, "author": "Maor Barazany", "author_id": 2063, "author_profile": "https://wordpress.stackexchange.com/users/2063", "pm_score": 6, "selected": true, "text": "<p>Add this code to your theme's <strong>functions.php</strong> file, and it will limit minimum image dimentio...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28363", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8607/" ]
Everyone! I am new to WP and trying to build a plugin. I have the following codes working properly: ``` add_filter('the_content', 'say_hello'); function say_hello($content){ if(is_single() || is_page()){ print $content." Thank you for reading!"; } else { print $content; } } ``` But the fo...
Add this code to your theme's **functions.php** file, and it will limit minimum image dimentions ``` add_filter('wp_handle_upload_prefilter','tc_handle_upload_prefilter'); function tc_handle_upload_prefilter($file) { $img=getimagesize($file['tmp_name']); $minimum = array('width' => '640', 'height' => '480');...
28,369
<p>bear with me here as I explain my problem.</p> <p>Generated menu via wp_nav_menu, so I have use of the .current_page_item class. The thing is, I've used jQuery to replace the generated link text with some custom images that I have made and I have to use jQuery now to swap out the image so that the button looks "und...
[ { "answer_id": 28370, "author": "helenhousandi", "author_id": 2226, "author_profile": "https://wordpress.stackexchange.com/users/2226", "pm_score": 2, "selected": true, "text": "<p>There's a site option for <code>page_for_posts</code>, so you might try <code>if ( is_page( get_option('pag...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28369", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
bear with me here as I explain my problem. Generated menu via wp\_nav\_menu, so I have use of the .current\_page\_item class. The thing is, I've used jQuery to replace the generated link text with some custom images that I have made and I have to use jQuery now to swap out the image so that the button looks "underline...
There's a site option for `page_for_posts`, so you might try `if ( is_page( get_option('page_for_posts') ) )`. **Edit:** According to the Codex, `is_home()` will tell you if you're on the blog page when you have a static front page: <http://codex.wordpress.org/Conditional_Tags#The_Main_Page>. I can't test it right at ...
28,376
<p>I'm using <code>next_post_link</code> and <code>previous_post_link</code> on my single post templates, to navigate from post to post, so far so good.</p> <p>But if I do a search and click on a result post, then the <code>next_post_link</code> doesn't bring me to the next result post, but to the next post in the def...
[ { "answer_id": 28594, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>That is not the way WordPress Works, meaning that once you enter s single post from the search results you lo...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28376", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1381/" ]
I'm using `next_post_link` and `previous_post_link` on my single post templates, to navigate from post to post, so far so good. But if I do a search and click on a result post, then the `next_post_link` doesn't bring me to the next result post, but to the next post in the default post order. Is there a way to make `n...
Building on Bainternet's answer above, but making it more generic, I wrote this quick plugin. You can probably modify the link building function at the bottom to do what you want more exactly. ``` <?php /* Plugin Name: Search Context Description: Use search context on single post pages when they're reached from a se...
28,381
<p>am Having Custom Field named as thumb.i want to show the images using these custom fields.i want to be fix the image size.</p> <p>My code is </p> <pre><code> &lt;img class="thumb" src="&lt;?php echo get_post_meta($post-&gt;ID, 'thumb', true) ?&gt;" alt="&lt;?php the_title(); ?&gt;" /&gt; </code></pre> <p>i tried ...
[ { "answer_id": 28594, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>That is not the way WordPress Works, meaning that once you enter s single post from the search results you lo...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28381", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5669/" ]
am Having Custom Field named as thumb.i want to show the images using these custom fields.i want to be fix the image size. My code is ``` <img class="thumb" src="<?php echo get_post_meta($post->ID, 'thumb', true) ?>" alt="<?php the_title(); ?>" /> ``` i tried timthumb also like this ``` <img class="thumb" timth...
Building on Bainternet's answer above, but making it more generic, I wrote this quick plugin. You can probably modify the link building function at the bottom to do what you want more exactly. ``` <?php /* Plugin Name: Search Context Description: Use search context on single post pages when they're reached from a se...
28,382
<p>I have a login safe application and it has hundreds of users. WordPress is a separate module of it and only used for blogging purpose [no other usage]. Both using the common database. The blogs are not for public but only for our users.</p> <p>Recently I am getting spam comments to our blogs and I am worried about...
[ { "answer_id": 28594, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>That is not the way WordPress Works, meaning that once you enter s single post from the search results you lo...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28382", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7576/" ]
I have a login safe application and it has hundreds of users. WordPress is a separate module of it and only used for blogging purpose [no other usage]. Both using the common database. The blogs are not for public but only for our users. Recently I am getting spam comments to our blogs and I am worried about the blogs...
Building on Bainternet's answer above, but making it more generic, I wrote this quick plugin. You can probably modify the link building function at the bottom to do what you want more exactly. ``` <?php /* Plugin Name: Search Context Description: Use search context on single post pages when they're reached from a se...
28,391
<p>I got quite confused with Custom Post Type (CPT) 'capability_type' parameter and adding generated capabilities to a role.</p> <p>So I've got a CPT called 'external_role' registered as following:</p> <pre><code>add_action('init', 'external_roles_post_type_init'); function external_roles_post_type_init() { $labels...
[ { "answer_id": 29304, "author": "bluantinoo", "author_id": 4155, "author_profile": "https://wordpress.stackexchange.com/users/4155", "pm_score": 2, "selected": false, "text": "<p>Have you tried defining the capabilities inside the external_roles_post_type_init() function?</p>\n\n<p>After...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28391", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1343/" ]
I got quite confused with Custom Post Type (CPT) 'capability\_type' parameter and adding generated capabilities to a role. So I've got a CPT called 'external\_role' registered as following: ``` add_action('init', 'external_roles_post_type_init'); function external_roles_post_type_init() { $labels = array( 'name...
Have you tried defining the capabilities inside the external\_roles\_post\_type\_init() function? After the ``` 'capability_type' => array('external_role', 'external_roles'), ``` try add this ``` 'capabilities' => array( 'publish_posts' => 'publish_external_roles', 'edit_posts' => 'edit_external_roles', ...
28,397
<p>My WordPress site uses a theme that is a child of a parent theme. As required, both themes have style.css files. However, as far as I can tell WordPress only provides the mechanism to load the child theme style.css file. How do the parent theme styles get loaded? Is it necessary to manually import the parent the...
[ { "answer_id": 28400, "author": "Alex Older", "author_id": 3365, "author_profile": "https://wordpress.stackexchange.com/users/3365", "pm_score": 2, "selected": true, "text": "<p>At the top of your child themes style.css add:</p>\n\n<pre><code>@import url(\"../twentyeleven/style.css\");\n...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28397", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4197/" ]
My WordPress site uses a theme that is a child of a parent theme. As required, both themes have style.css files. However, as far as I can tell WordPress only provides the mechanism to load the child theme style.css file. How do the parent theme styles get loaded? Is it necessary to manually import the parent theme's st...
At the top of your child themes style.css add: ``` @import url("../twentyeleven/style.css"); ``` Obviously replace `twentyeleven` with your parent themes folder. 2016 - This practice has now been replaced by declaring the 'Template' in your theme stylesheet header: ``` Template: twentyfifteen ``` <https://co...
28,399
<p>hey i got a slightly weird problem.. </p> <p>i got a form enabling login in certain single's according to the cateory and user level.. it works great but the server which is windows (where the website is hosted on returns the wrong "current page" value</p> <p>Meaning.. this:</p> <pre><code>'redirect' =&gt; site_u...
[ { "answer_id": 28401, "author": "Alex Older", "author_id": 3365, "author_profile": "https://wordpress.stackexchange.com/users/3365", "pm_score": 0, "selected": false, "text": "<p>change your redirect to:</p>\n\n<pre><code>'redirect' =&gt; '/' . $_SERVER['REQUEST_URI'],\n</code></pre>\n\n...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28399", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7990/" ]
hey i got a slightly weird problem.. i got a form enabling login in certain single's according to the cateory and user level.. it works great but the server which is windows (where the website is hosted on returns the wrong "current page" value Meaning.. this: ``` 'redirect' => site_url( $_SERVER['REQUEST_URI'] ), ...
based on the changes seen in the diff on this trac ticket: <http://core.trac.wordpress.org/ticket/17243> i've adjusted my redirect to the following ``` 'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ``` and this seems to work for WP when it is in a subfolder. t...
28,409
<p><strong>EDIT 2</strong>: <strong>Rather than figuring out the real solution I've decided to use a workaround, and am simply setting the default value for book_in_series to '0'.</strong> Thanks to <a href="https://wordpress.stackexchange.com/users/51/eddiemoya">@eddiemoya</a> for all his the time he spent looking at ...
[ { "answer_id": 28418, "author": "eddiemoya", "author_id": 51, "author_profile": "https://wordpress.stackexchange.com/users/51", "pm_score": 3, "selected": false, "text": "<p>To be clear, you mean to say that any items that don't have book_in_series key will just be at the bottom and unor...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28409", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16/" ]
**EDIT 2**: **Rather than figuring out the real solution I've decided to use a workaround, and am simply setting the default value for book\_in\_series to '0'.** Thanks to [@eddiemoya](https://wordpress.stackexchange.com/users/51/eddiemoya) for all his the time he spent looking at this with me! **EDIT**: I had a diffe...
Rather than figuring out the real solution I decided to use a workaround, and am simply setting the default value for book\_in\_series to '0'.
28,413
<p>I've created the following custom post type (lugares means places) with a custom taxonomy of tacos and it works fine form the backend:</p> <pre><code>/** * Custom post-type lugares **/ add_action('init', 'lugares_register'); function lugares_register() { $labels = array( 'name' =&gt; _x('Lugares', ...
[ { "answer_id": 28435, "author": "Flo Mincucci", "author_id": 8636, "author_profile": "https://wordpress.stackexchange.com/users/8636", "pm_score": 1, "selected": false, "text": "<p>Have you tried <a href=\"http://wordpress.org/extend/plugins/tdo-mini-forms/\" rel=\"nofollow\">TDO Mini Fo...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28413", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1806/" ]
I've created the following custom post type (lugares means places) with a custom taxonomy of tacos and it works fine form the backend: ``` /** * Custom post-type lugares **/ add_action('init', 'lugares_register'); function lugares_register() { $labels = array( 'name' => _x('Lugares', 'post type genera...
It turned out that there was a difference between the custom post type's name and the type I added in the form. One was "lugares" and the other one was "Lugares". From this, I asume capabilities were broken. Rebuilt the register post type like so: ``` add_action('init', 'lugar_register'); ``` function lugar\_regist...
28,416
<p>I want to give the Editor Role access to editing the sidebar and it's contents. I have a text widget in there and in order to edit this text widget the user needs to be an admin - this sucks. How do I grant permission to the Editor Role that will give him access to edit the sidebar?</p>
[ { "answer_id": 28420, "author": "Elliott", "author_id": 6824, "author_profile": "https://wordpress.stackexchange.com/users/6824", "pm_score": 6, "selected": true, "text": "<p>The <code>edit_theme_options</code> capability should allow the user to edit the sidebar as described on this pag...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28416", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7355/" ]
I want to give the Editor Role access to editing the sidebar and it's contents. I have a text widget in there and in order to edit this text widget the user needs to be an admin - this sucks. How do I grant permission to the Editor Role that will give him access to edit the sidebar?
The `edit_theme_options` capability should allow the user to edit the sidebar as described on this page : <http://codex.wordpress.org/Appearance_Widgets_SubPanel> Code to add to `functions.php` ``` $role = get_role('editor'); $role->add_cap('edit_theme_options'); ``` **Edit:** This should work to prevent ed...
28,424
<p>I have the following ALMOST working perfectly, but have run into a couple of issues. </p> <p>Right now this displays a Books archive page, ordered like this:</p> <p>Genre Name</p> <p>-- Series Name</p> <p>--- Books within series, sorted by book-in-series (aka reading order)</p> <p>Which is fantastic - I can...
[ { "answer_id": 28437, "author": "eddiemoya", "author_id": 51, "author_profile": "https://wordpress.stackexchange.com/users/51", "pm_score": 1, "selected": false, "text": "<p>This is almost exactly the same as what I am helping someone workout on another question.</p>\n\n<p><a href=\"http...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28424", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16/" ]
I have the following ALMOST working perfectly, but have run into a couple of issues. Right now this displays a Books archive page, ordered like this: Genre Name -- Series Name --- Books within series, sorted by book-in-series (aka reading order) Which is fantastic - I can't tell you how long it's taken me to get ...
I've solved this with a custom select query; here's the full code for posterity. :) ``` <?php // QUERY THAT PULLS ALL SERIES SORTED BY GENRE, THEN MENU ORDER $querystr = " SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb...
28,427
<p>I have a wp_query that gets all custom post types in ascending order from today, to list some events on a site of mine. While this works fine:</p> <pre><code> $args = array( 'post_type' =&gt; 'events', 'posts_per_page' =&gt; 5, 'orderby' ...
[ { "answer_id": 28430, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 2, "selected": false, "text": "<p>Firstly, there's no point in converting to 'meta_query' if you're dealing with a single custom field.</p>\n\n<p>Sec...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28427", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7967/" ]
I have a wp\_query that gets all custom post types in ascending order from today, to list some events on a site of mine. While this works fine: ``` $args = array( 'post_type' => 'events', 'posts_per_page' => 5, 'orderby' => 'meta_...
Simple solution: orderby => meta\_key still needs to be set as meta\_query does not handle ordering. Also, I was comparing char data as numeric.
28,431
<p>I am trying to link my thumbnail image that is displayed by the list-category-post plugin on this page... <a href="http://elizabeth.vernetti.com/featured-properties/" rel="nofollow">http://elizabeth.vernetti.com/featured-properties/</a></p> <p>I am using a custom template and have managed to get it linked to "#" us...
[ { "answer_id": 28433, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 2, "selected": false, "text": "<p>Have you tried replacing get_thumbnail with:</p>\n\n<pre><code>&lt;a href=\"&lt;?php the_permalink(); ?&gt;...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28431", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8634/" ]
I am trying to link my thumbnail image that is displayed by the list-category-post plugin on this page... <http://elizabeth.vernetti.com/featured-properties/> I am using a custom template and have managed to get it linked to "#" using this code. ``` //Post Thumbnail $lcp_display_output .= '<a href="#">'; $lcp_displa...
Have you tried replacing get\_thumbnail with: ``` <a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><?php the_post_thumbnail(); ?></a> ```
28,439
<p>I have a widget that works with my theme that expects images named in a certain way, slide1.png, slide2.png, etc...</p> <p>However, when the user uploads their own images, named slide1.png, slide2.png, etc to the media library, rather than updating the images with the new ones, WordPress changes the names of the re...
[ { "answer_id": 28444, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>Here is something i cooked up which was taken mainly from the plugin <a href=\"http://wordpress.org/extend/plu...
2011/09/13
[ "https://wordpress.stackexchange.com/questions/28439", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6620/" ]
I have a widget that works with my theme that expects images named in a certain way, slide1.png, slide2.png, etc... However, when the user uploads their own images, named slide1.png, slide2.png, etc to the media library, rather than updating the images with the new ones, WordPress changes the names of the replacement ...
Here is something i cooked up which was taken mainly from the plugin [**`Overwrite Uploads`**](http://wordpress.org/extend/plugins/overwrite-uploads/) but without the extra stuff ``` add_filter('wp_handle_upload_overrides','noneUniqueFilename'); function noneUniqueFilename($overrides){ $overrides['test_form'] = fa...
28,449
<p>I admin a Wordpress blog with a few dozens of users. Since we upgraded to version 3.1+ my users can't insert the YouTube embed tags into a post ( wordpress or TinyMCE removes them ). </p> <p>When I'm logged in as administrator, I can insert the , and tags. But my users cannot.</p> <p>What about the auto-embed...
[ { "answer_id": 28444, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>Here is something i cooked up which was taken mainly from the plugin <a href=\"http://wordpress.org/extend/plu...
2011/09/14
[ "https://wordpress.stackexchange.com/questions/28449", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3058/" ]
I admin a Wordpress blog with a few dozens of users. Since we upgraded to version 3.1+ my users can't insert the YouTube embed tags into a post ( wordpress or TinyMCE removes them ). When I'm logged in as administrator, I can insert the , and tags. But my users cannot. What about the auto-embed ( oEmbed )? Well, my ...
Here is something i cooked up which was taken mainly from the plugin [**`Overwrite Uploads`**](http://wordpress.org/extend/plugins/overwrite-uploads/) but without the extra stuff ``` add_filter('wp_handle_upload_overrides','noneUniqueFilename'); function noneUniqueFilename($overrides){ $overrides['test_form'] = fa...
28,467
<p>I am trying to add custom columns to edit-tags.php for a custom taxonomy that I have created. This custom taxonomy is called equipment-types and it only applies to one custom post type called equipment. I am trying to use the same filters and actions that I would use to add custom columns on the edit.php page. I wa...
[ { "answer_id": 28468, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 4, "selected": true, "text": "<p>You can do this by hooking into the 'taxonomy'_edit_form and edited_'taxonomy' actions.</p>\n\n<pre><code>ad...
2011/09/14
[ "https://wordpress.stackexchange.com/questions/28467", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7814/" ]
I am trying to add custom columns to edit-tags.php for a custom taxonomy that I have created. This custom taxonomy is called equipment-types and it only applies to one custom post type called equipment. I am trying to use the same filters and actions that I would use to add custom columns on the edit.php page. I was ab...
You can do this by hooking into the 'taxonomy'\_edit\_form and edited\_'taxonomy' actions. ``` add_action('taxonomy_edit_form', 'foo_render_extra_fields'); function foo_render_extra_fields(){ $term_id = $_GET['tag_ID']; $term = get_term_by('id', $term_id, 'taxonomy'); $meta = get_option("taxonomy_{$term_id...
28,469
<p>I've found tons of code and plugins to do various things; from show posts for specific cats, subcats of a cat, etc.. BUT, I cannot for the life of me find, nor do I know the WP API well enough to do what I need with it..</p> <p>Here is what I'm trying to accomplish:</p> <p>Display a UL of all subcats within Cat31,...
[ { "answer_id": 28646, "author": "revive", "author_id": 8645, "author_profile": "https://wordpress.stackexchange.com/users/8645", "pm_score": 3, "selected": true, "text": "<p>Question was answered on another site.. thank you!\nBTW, the code that accomplished what I needed was:</p>\n\n<pre...
2011/09/14
[ "https://wordpress.stackexchange.com/questions/28469", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8645/" ]
I've found tons of code and plugins to do various things; from show posts for specific cats, subcats of a cat, etc.. BUT, I cannot for the life of me find, nor do I know the WP API well enough to do what I need with it.. Here is what I'm trying to accomplish: Display a UL of all subcats within Cat31, and the posts fo...
Question was answered on another site.. thank you! BTW, the code that accomplished what I needed was: ``` $categories = get_categories('child_of=31'); foreach ($categories as $category) { //Display the sub category information using $category values like $category->cat_name echo '<h2>'.$category->name.'</h...
28,491
<p>The wp_posts table seems to retain all revisions of the same, ok very similar but presumably different, posts/pages/whatever.</p> <p>I'm somewhat conversant with SQL but not WordPress. I need to extract just those records which would appear on the public facing site; so just the most recent revision, and not all th...
[ { "answer_id": 28498, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>Rather than constructing query from scratch, it is easier to see what exactly is WordPress querying when API function...
2011/09/14
[ "https://wordpress.stackexchange.com/questions/28491", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8651/" ]
The wp\_posts table seems to retain all revisions of the same, ok very similar but presumably different, posts/pages/whatever. I'm somewhat conversant with SQL but not WordPress. I need to extract just those records which would appear on the public facing site; so just the most recent revision, and not all the superce...
Rather than constructing query from scratch, it is easier to see what exactly is WordPress querying when API function is used: ``` get_posts(array( 'numberposts' => -1, )); var_dump( $wpdb->last_query ); ``` Gives following SQL: ``` SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.pos...
28,506
<p>How can i redirect all posts permalinks from .html to / ,in Wordpress ? now all my posts url are ending in / ,but before it was with .html</p> <p>to be more clear ,for example a post url like this <a href="http://sitename.com/%category%/%postname%.html" rel="nofollow">http://sitename.com/%category%/%postname%.html<...
[ { "answer_id": 28512, "author": "Jamie", "author_id": 8657, "author_profile": "https://wordpress.stackexchange.com/users/8657", "pm_score": 0, "selected": false, "text": "<p>That's strange. I thought WordPress did that automatically. Here's the default one that WordPress generated for me...
2011/09/14
[ "https://wordpress.stackexchange.com/questions/28506", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8455/" ]
How can i redirect all posts permalinks from .html to / ,in Wordpress ? now all my posts url are ending in / ,but before it was with .html to be more clear ,for example a post url like this <http://sitename.com/%category%/%postname%.html> to be redirected to <http://sitename.com/%year%/%monthnum%/%postname%/> . It's s...
it's curious that `redirect_canonical` doesn't work in this case, but this will redirect everything with .html via .htaccess: ``` RewriteRule (.+)\.html?$ http://example.com/$1/ [R=301,L] ``` but keep in mind this will redirect *everything* with .html, you may need to explicitly exclude things.
28,507
<p>I need to modify the default gallery code, I need the alt of the image to be the path to the big image. I've modified media.php like this:</p> <pre><code>function wp_get_attachment_image(........... 'alt' =&gt; $src, 'title' =&gt; trim(strip_tags( $attachment-&gt;post_title )), .......... </code></pre> <p>But no...
[ { "answer_id": 28525, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 0, "selected": false, "text": "<p>Do you mean \n<code>[gallery link=\"file\"]</code><br>\n This should work if I understand your question.</p...
2011/09/14
[ "https://wordpress.stackexchange.com/questions/28507", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8617/" ]
I need to modify the default gallery code, I need the alt of the image to be the path to the big image. I've modified media.php like this: ``` function wp_get_attachment_image(........... 'alt' => $src, 'title' => trim(strip_tags( $attachment->post_title )), .......... ``` But now my alt is the path to the thumbna...
This should do the trick ``` add_filter('wp_get_attachment_image_attributes', 'change_alt_image', 10, 2); function change_alt_image($attr, $attachment) { $data_img = wp_get_attachment_image_src($attachment->ID, 'original', false); $attr['alt'] = esc_url($data_img[0]); return $attr; } ```
28,515
<p>I just can't find a way to make it possible to show only current parent items down to current page item in a vertical menu the "wordpress way".</p> <p>What I want to achieve is the following dynamic structure, if I visit Page 3.2.2.2:</p> <p>Page 1 Page 2 <strong>Page 3</strong> Page 4</p> <ul> <li>Page 3.1</li> ...
[ { "answer_id": 28517, "author": "mines", "author_id": 8241, "author_profile": "https://wordpress.stackexchange.com/users/8241", "pm_score": 0, "selected": false, "text": "<p>Try using this snippet from WordPress Codex:</p>\n\n<p><a href=\"http://codex.wordpress.org/Template_Tags/wp_list_...
2011/09/14
[ "https://wordpress.stackexchange.com/questions/28515", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3216/" ]
I just can't find a way to make it possible to show only current parent items down to current page item in a vertical menu the "wordpress way". What I want to achieve is the following dynamic structure, if I visit Page 3.2.2.2: Page 1 Page 2 **Page 3** Page 4 * Page 3.1 * **Page 3.2** + Page 3.2.1 + **Page 3.2.2**...
Finally, I solved it myself. Here is the solution: In **functions.php**: ``` function show_all_children($parent_id, $post_id, $current_level) { $top_parents = array(); $top_parents = get_post_ancestors($post_id); $top_parents[] = $post_id; $children = get_posts( array( 'post_type' => 'page'...
28,522
<p>I am writing a plugin that fetches some extended user info from a remote service and I need it to execute its function each time a user logs in.</p> <p>Is there a hook that gets fired after login that I can add an action to?</p>
[ { "answer_id": 28524, "author": "Drew Gourley", "author_id": 4282, "author_profile": "https://wordpress.stackexchange.com/users/4282", "pm_score": 7, "selected": true, "text": "<p>The action hook wp_login runs when the user logs in - it can run a simple function.</p>\n\n<pre><code>functi...
2011/09/14
[ "https://wordpress.stackexchange.com/questions/28522", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8660/" ]
I am writing a plugin that fetches some extended user info from a remote service and I need it to execute its function each time a user logs in. Is there a hook that gets fired after login that I can add an action to?
The action hook wp\_login runs when the user logs in - it can run a simple function. ``` function do_anything() { //do stuff } add_action('wp_login', 'do_anything'); ``` documentation : <https://codex.wordpress.org/Plugin_API/Action_Reference/wp_login> The real breadwinner here is `wp_authenticate` which has a ...
28,523
<p>I'm having some trouble feeding a custom post-type I created (events) on my homepage. I am trying to allow this particular post-type to display under the query which looks for category 8 (Featured).</p> <p>I have managed to enable to ability to add categories to my custom post type, but for some reason none of the ...
[ { "answer_id": 28524, "author": "Drew Gourley", "author_id": 4282, "author_profile": "https://wordpress.stackexchange.com/users/4282", "pm_score": 7, "selected": true, "text": "<p>The action hook wp_login runs when the user logs in - it can run a simple function.</p>\n\n<pre><code>functi...
2011/09/14
[ "https://wordpress.stackexchange.com/questions/28523", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5883/" ]
I'm having some trouble feeding a custom post-type I created (events) on my homepage. I am trying to allow this particular post-type to display under the query which looks for category 8 (Featured). I have managed to enable to ability to add categories to my custom post type, but for some reason none of the posts from...
The action hook wp\_login runs when the user logs in - it can run a simple function. ``` function do_anything() { //do stuff } add_action('wp_login', 'do_anything'); ``` documentation : <https://codex.wordpress.org/Plugin_API/Action_Reference/wp_login> The real breadwinner here is `wp_authenticate` which has a ...
28,526
<p>I believe this is completely different than the question asked <a href="https://wordpress.stackexchange.com/questions/26540/getting-two-wp-link-pages-output">here</a>.</p> <p>I'm adding pagination to my theme using a filter hook. The output appears at the beginning and end of my content, rather than just the end.</...
[ { "answer_id": 28536, "author": "Niraj Chauhan", "author_id": 1743, "author_profile": "https://wordpress.stackexchange.com/users/1743", "pm_score": 0, "selected": false, "text": "<p>You need to do something like this</p>\n\n<pre><code>add_filter ('the_content', 'pagination_after_post',1)...
2011/09/14
[ "https://wordpress.stackexchange.com/questions/28526", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7229/" ]
I believe this is completely different than the question asked [here](https://wordpress.stackexchange.com/questions/26540/getting-two-wp-link-pages-output). I'm adding pagination to my theme using a filter hook. The output appears at the beginning and end of my content, rather than just the end. My function, in the t...
you need to set the 'echo' parameter of [`wp_link_pages()`](http://codex.wordpress.org/Function_Reference/wp_link_pages) to 'echo=0'; example: ``` $content .= '<div class="pagination">' . wp_link_pages('before=&after=&next_or_number=next&nextpagelink=Next&previouspagelink=Previous&echo=0') . '</div>'; ```
28,552
<p>I have a multisite setup and I am adding some additional information fields in the profile edit screen in my theme's dashboard. I am primarily using text fields however I have a drop down selection menu for the author's country</p> <pre><code>&lt;select name="country" class="mid2" id="country" value="&lt;?php echo...
[ { "answer_id": 28559, "author": "Cole", "author_id": 2130, "author_profile": "https://wordpress.stackexchange.com/users/2130", "pm_score": 0, "selected": false, "text": "<p>So you say it registers the change, so it doesn't really sound like its a Wordpress problem but here is how you wou...
2011/09/14
[ "https://wordpress.stackexchange.com/questions/28552", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7999/" ]
I have a multisite setup and I am adding some additional information fields in the profile edit screen in my theme's dashboard. I am primarily using text fields however I have a drop down selection menu for the author's country ``` <select name="country" class="mid2" id="country" value="<?php echo $userdata->country ...
Wordpress has a great little function built in for handling selections. ``` <option <?php selected('value1', 'value2');?> value='foo'>Bar</option> ``` You can also check out these form handling functions: * checked() <http://codex.wordpress.org/Function_Reference/checked> * disabled() <http://codex.wordpress.org/Fu...
28,562
<p>I have a specific category who's page I'd like to look like the home page of my site, with all the nice sliding featured stories, etc. If I create a file <code>category-slug.php</code>, can I do some sort of include of the index template?</p> <p>If it helps, I'm using wootheme's FlashNews theme.</p>
[ { "answer_id": 28564, "author": "Michelle", "author_id": 16, "author_profile": "https://wordpress.stackexchange.com/users/16", "pm_score": 0, "selected": false, "text": "<p>Yes, that should work. I'm not familiar with the theme you reference, but in most if you copy over index.php and re...
2011/09/14
[ "https://wordpress.stackexchange.com/questions/28562", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7229/" ]
I have a specific category who's page I'd like to look like the home page of my site, with all the nice sliding featured stories, etc. If I create a file `category-slug.php`, can I do some sort of include of the index template? If it helps, I'm using wootheme's FlashNews theme.
A somewhat ghetto but fast way to do this is to just use `get_template_part`, for example, ``` get_template_part('index'); ``` A better use for it is to grab "parts" of your template and not a whole index, but it still works. <http://codex.wordpress.org/Function_Reference/get_template_part>
28,563
<p>I'm learning how to build a google maps plugin. (I know that there are plugins that add Google Maps, but I'd like to be able to adapt the code to my needs. And it's fun to learn). </p> <p>Unfortunately, I'm not getting a map after inserting my short code. This is the main php file of the plugin: </p> <pre><code>&l...
[ { "answer_id": 28571, "author": "patnz", "author_id": 4093, "author_profile": "https://wordpress.stackexchange.com/users/4093", "pm_score": 0, "selected": false, "text": "<p>It all looks fine. Are both the scripts showing up and have correct src references when you view the page's source...
2011/09/14
[ "https://wordpress.stackexchange.com/questions/28563", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4509/" ]
I'm learning how to build a google maps plugin. (I know that there are plugins that add Google Maps, but I'd like to be able to adapt the code to my needs. And it's fun to learn). Unfortunately, I'm not getting a map after inserting my short code. This is the main php file of the plugin: ``` <?php /* Plugin Name: L...
Wierd, just re-read your comment and looks like your shortcode is working when you call it that early - if the map-canvas div is showing up. here's the code I tested, also added jquery as a dependency for your custom script & changed some css on you div... ``` function lax_google_map_init() { wp_enqueue_script('g...
28,617
<p>Is there a hook available that lets you append or prepend text to the <code>&lt;title&gt;</code> tag in the head?</p> <p>I've seen lots of posts about customizing the <code>&lt;title&gt;</code> tag, but they all involve manually adding a function inside the <code>&lt;title&gt;</code> tag. I'm looking to modify it w...
[ { "answer_id": 28618, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 0, "selected": false, "text": "<p>yes, it's <a href=\"http://core.trac.wordpress.org/browser/branches/3.2/wp-includes/general-template.php#L6...
2011/09/15
[ "https://wordpress.stackexchange.com/questions/28617", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8677/" ]
Is there a hook available that lets you append or prepend text to the `<title>` tag in the head? I've seen lots of posts about customizing the `<title>` tag, but they all involve manually adding a function inside the `<title>` tag. I'm looking to modify it with a hook if possible so it can be easily turned on/off in a...
The content is modified with filters, not hooks. To modify the <title>, use [wp\_title](http://codex.wordpress.org/Plugin_API/Filter_Reference) filter Example: ``` add_filter('wp_title', 'set_page_title'); function set_page_title($orig_title) { return 'Modified ' . $orig_title; } ```
28,623
<p>I need to pass a plugin's $atts variable to a javascript function, but I'm not sure how to do it. The javascript function needs the shortcode's php latitude variable in order to build the map.</p> <p>My plugin looks like this: </p> <pre><code>&lt;?php /* Plugin Name: Lax Google Map Plugin Plugin URI: http://www.my...
[ { "answer_id": 28626, "author": "Maciej Kuś", "author_id": 8682, "author_profile": "https://wordpress.stackexchange.com/users/8682", "pm_score": 0, "selected": false, "text": "<p>I would do this that way:</p>\n\n<p>in plugin code add data-latitude attr to div#map_canvas:</p>\n\n<pre><cod...
2011/09/15
[ "https://wordpress.stackexchange.com/questions/28623", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4509/" ]
I need to pass a plugin's $atts variable to a javascript function, but I'm not sure how to do it. The javascript function needs the shortcode's php latitude variable in order to build the map. My plugin looks like this: ``` <?php /* Plugin Name: Lax Google Map Plugin Plugin URI: http://www.mysite.com Description: Ma...
You could use [wp\_localize\_script](http://codex.wordpress.org/Function_Reference/wp_localize_script) to take your PHP variables and put them into JavaScript.
28,632
<p>I want to create a page labeled "Today's News" which displays a simple bulleted list of all posts published on the current day and grab the current date based on the server's date/time. Is this feasible?</p> <p>Thank you for any help.</p>
[ { "answer_id": 28635, "author": "Maxim Krizhanovsky", "author_id": 8294, "author_profile": "https://wordpress.stackexchange.com/users/8294", "pm_score": 1, "selected": false, "text": "<p>Use <a href=\"http://codex.wordpress.org/Template_Tags/query_posts\" rel=\"nofollow\">query_posts</a>...
2011/09/15
[ "https://wordpress.stackexchange.com/questions/28632", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8684/" ]
I want to create a page labeled "Today's News" which displays a simple bulleted list of all posts published on the current day and grab the current date based on the server's date/time. Is this feasible? Thank you for any help.
Use [query\_posts](http://codex.wordpress.org/Template_Tags/query_posts) ``` $day = date('j'); query_posts( "day=$day&order=ASC" ); ```
28,637
<p>I previously created a new user role called "Owner" which worked fine, however I decided to delete it afterwards from my functions.php since I found it to not be as useful for my project after all...Odd thing is though, the new custom user role is still showing up in wordpress' dropdown menu where you assign a role ...
[ { "answer_id": 28645, "author": "Elliott", "author_id": 6824, "author_profile": "https://wordpress.stackexchange.com/users/6824", "pm_score": 2, "selected": true, "text": "<p>You could try running this once in your <code>functions.php</code></p>\n\n<pre><code> $wp_roles = new WP_Roles(...
2011/09/15
[ "https://wordpress.stackexchange.com/questions/28637", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3567/" ]
I previously created a new user role called "Owner" which worked fine, however I decided to delete it afterwards from my functions.php since I found it to not be as useful for my project after all...Odd thing is though, the new custom user role is still showing up in wordpress' dropdown menu where you assign a role to ...
You could try running this once in your `functions.php` ``` $wp_roles = new WP_Roles(); $wp_roles->remove_role("your_role"); ```
28,650
<p>In functions.php I have: </p> <pre><code>function testajax() { echo "test"; exit; } add_action('wp_ajax_testthisajax', 'testajax'); add_action('wp_ajax_nopriv_testthisajax', 'testajax'); </code></pre> <p>In scripts.js I have:</p> <pre><code>$("#thisformsid").submit( function() { $.ajax({ url:...
[ { "answer_id": 28651, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>First try to perform this without JS altogether. Just visit link <code>yoursite.com/wp-admin/admin-ajax.php?action=t...
2011/09/15
[ "https://wordpress.stackexchange.com/questions/28650", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4176/" ]
In functions.php I have: ``` function testajax() { echo "test"; exit; } add_action('wp_ajax_testthisajax', 'testajax'); add_action('wp_ajax_nopriv_testthisajax', 'testajax'); ``` In scripts.js I have: ``` $("#thisformsid").submit( function() { $.ajax({ url: CustomAjax.ajaxurl, type...
First try to perform this without JS altogether. Just visit link `yoursite.com/wp-admin/admin-ajax.php?action=testthisajax`. `0` seems like something kinda works, but not quite. If I remember right failed requests should be `-1`.
28,653
<p>I've created a custom post type which now has around 100 posts in it. I simply want to display these in alphabetical order by the post title rather than the default which seems to be most recent first. I've tried various plugins and other solutions, but most only allow manual sorting (too many posts for that to work...
[ { "answer_id": 28651, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>First try to perform this without JS altogether. Just visit link <code>yoursite.com/wp-admin/admin-ajax.php?action=t...
2011/09/15
[ "https://wordpress.stackexchange.com/questions/28653", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3782/" ]
I've created a custom post type which now has around 100 posts in it. I simply want to display these in alphabetical order by the post title rather than the default which seems to be most recent first. I've tried various plugins and other solutions, but most only allow manual sorting (too many posts for that to work), ...
First try to perform this without JS altogether. Just visit link `yoursite.com/wp-admin/admin-ajax.php?action=testthisajax`. `0` seems like something kinda works, but not quite. If I remember right failed requests should be `-1`.
28,657
<p>Okay, I've been working on this all day and can't find the solution anywhere. I've created a custom field within the image upload screen (info first found <a href="http://devilsworkshop.org/adding-custom-fields-to-wordpress-media-gallery-upload/" rel="nofollow">here</a>). The field stores the name of a photographer ...
[ { "answer_id": 28671, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 2, "selected": true, "text": "<p>You can create a filter using the \"wp_get_attachment_image_attributes\" hook. Place this in your functions....
2011/09/15
[ "https://wordpress.stackexchange.com/questions/28657", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7324/" ]
Okay, I've been working on this all day and can't find the solution anywhere. I've created a custom field within the image upload screen (info first found [here](http://devilsworkshop.org/adding-custom-fields-to-wordpress-media-gallery-upload/)). The field stores the name of a photographer to give him/her credit. Every...
You can create a filter using the "wp\_get\_attachment\_image\_attributes" hook. Place this in your functions.php file. ``` function filter_image_title($attr, $attachment = null){ //Find your $photographer with $attachment->ID $attr['title'] .= ' (' . __('Photographed by', 'foobar') . ' ' . $photograph...
28,670
<p>How can I change arguments for the main query only, and not affect other queries?</p> <pre><code>add_filter('pre_get_posts', 'custom_post_count'); function custom_post_count($query){ $query-&gt;set('posts_per_page', 5); return $query; }; </code></pre> <p>Because this action is called inside the get_posts metho...
[ { "answer_id": 28672, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 3, "selected": false, "text": "<p>Firstly, 'pre_get_posts' is an action and not a filter. That's the main problem to start. Secondly, you nee...
2011/09/16
[ "https://wordpress.stackexchange.com/questions/28670", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1986/" ]
How can I change arguments for the main query only, and not affect other queries? ``` add_filter('pre_get_posts', 'custom_post_count'); function custom_post_count($query){ $query->set('posts_per_page', 5); return $query; }; ``` Because this action is called inside the get\_posts method of WP\_Query, this code wi...
Basically what you are looking for is the **`global $wp_the_query`** variable which is set to the value of the main query. It may not be a perfect fit for 100% of cases but will probably work fine in 99% of cases: ``` add_action( 'pre_get_posts', 'custom_post_count' ); function custom_post_count( $query ){ global $w...
28,673
<p>What I'm trying to do is edit the output of <code>image_send_to_editor</code> so that i can make the anchor that wraps around the image have a specific <strong>class</strong> &amp; <strong>rel</strong>.</p> <p>I plan to basically make each image that gets inserted into a post become fancybox capable without having ...
[ { "answer_id": 28674, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 3, "selected": true, "text": "<p>Your best bet here would be to use jQuery to grab any link that links to an image and tell it to use fanceyb...
2011/09/16
[ "https://wordpress.stackexchange.com/questions/28673", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3567/" ]
What I'm trying to do is edit the output of `image_send_to_editor` so that i can make the anchor that wraps around the image have a specific **class** & **rel**. I plan to basically make each image that gets inserted into a post become fancybox capable without having to be in a gallery or using a plugin. Heres what ...
Your best bet here would be to use jQuery to grab any link that links to an image and tell it to use fanceybox. ``` jQuery(document).ready(function($){ $('a[href$="jpg"], a[href$="png"], a[href$="jpeg"]').fancybox(); }); ``` If you want this to work just for your post content areas use this: ``` $('.post-conten...
28,677
<p>I have had a wordpress site handed off to me halfway through completion. It's been at least a year since I last used wordpress and there are a lot of things I'm finding different. The way I am used to displaying different content on different pages is to create page templates for each page that needs unique content....
[ { "answer_id": 28680, "author": "MikeSchinkel", "author_id": 89, "author_profile": "https://wordpress.stackexchange.com/users/89", "pm_score": 3, "selected": true, "text": "<p>I think what you might need is simply to run <code>register_sidebar()</code> in an <code>'widgets_init'</code> h...
2011/09/16
[ "https://wordpress.stackexchange.com/questions/28677", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8693/" ]
I have had a wordpress site handed off to me halfway through completion. It's been at least a year since I last used wordpress and there are a lot of things I'm finding different. The way I am used to displaying different content on different pages is to create page templates for each page that needs unique content. I...
I think what you might need is simply to run `register_sidebar()` in an `'widgets_init'` hook. The TwentyTen theme has examples for `register_sidebar()` in its `functions.php` file, but here's what it might look like: ``` add_action( 'widgets_init', 'twentyten_widgets_init' ); function twentyten_widgets_init() { reg...
28,690
<p>I'm pretty sure that this can be solved quite easy, but for some reason I just can't get it to work.</p> <p>My current code looks like this:</p> <pre><code>&lt;?php $comments = get_comments('status=approve&amp;number=5'); ?&gt; &lt;ul id="recent_comments"&gt; &lt;?php foreach ($comments as $comment) { ?&gt; &lt;...
[ { "answer_id": 28697, "author": "Hameedullah Khan", "author_id": 5337, "author_profile": "https://wordpress.stackexchange.com/users/5337", "pm_score": 3, "selected": true, "text": "<p>Instead of <code>$comment-&gt;post_ID</code> use <code>$comment-&gt;comment_post_ID</code>. Your code wi...
2011/09/16
[ "https://wordpress.stackexchange.com/questions/28690", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6903/" ]
I'm pretty sure that this can be solved quite easy, but for some reason I just can't get it to work. My current code looks like this: ``` <?php $comments = get_comments('status=approve&number=5'); ?> <ul id="recent_comments"> <?php foreach ($comments as $comment) { ?> <li><p><strong><?php $title = get_the_t...
Instead of `$comment->post_ID` use `$comment->comment_post_ID`. Your code will look like following: ``` <?php $comments = get_comments('status=approve&number=5'); ?> <ul id="recent_comments"> <?php foreach ($comments as $comment) { ?> <li><p><strong><?php $title = get_the_title($comment->comment_post_ID); ...
28,714
<p>I was working on this site this morning and I ran into a bit of an issue with my static page.</p> <p>I have a "featured" post section and I use:</p> <pre><code>&lt;div id="featured"&gt; &lt;img src="&lt;?php echo get_bloginfo('template_directory'); ?&gt;/images/house.jpg" alt"Buy Me" /&gt; &lt;div class="...
[ { "answer_id": 28715, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": true, "text": "<p>You're using <code>query_posts()</code> for your featured-post <a href=\"http://codex.wordpress.org/Displayi...
2011/09/16
[ "https://wordpress.stackexchange.com/questions/28714", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/807/" ]
I was working on this site this morning and I ran into a bit of an issue with my static page. I have a "featured" post section and I use: ``` <div id="featured"> <img src="<?php echo get_bloginfo('template_directory'); ?>/images/house.jpg" alt"Buy Me" /> <div class="info"> <?php query_posts(array ('tag'...
You're using `query_posts()` for your featured-post [custom loop](http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query). As the Codex says: [**don't do that**](http://codex.wordpress.org/Function_Reference/query_posts#Not_for_Secondary_Loops). The `query_posts()` function is intended to modify the *...
28,724
<p>I have created the file <strong>latest.php</strong> in the public_html so that when I go to <strong>www.domain.com/latest.php</strong> it will show me the latest articles. Sadly, nothing of the posts came up. Later, I will sort them with other ways (mostly based on custom fields).</p> <p>This is my <strong>latest.p...
[ { "answer_id": 29656, "author": "Joseph Leedy", "author_id": 8554, "author_profile": "https://wordpress.stackexchange.com/users/8554", "pm_score": 3, "selected": true, "text": "<p>After trudging through the BP source code today, I believe that I have finally figured this out. The hook us...
2011/09/16
[ "https://wordpress.stackexchange.com/questions/28724", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4448/" ]
I have created the file **latest.php** in the public\_html so that when I go to **www.domain.com/latest.php** it will show me the latest articles. Sadly, nothing of the posts came up. Later, I will sort them with other ways (mostly based on custom fields). This is my **latest.php** file (I removed any styling for bett...
After trudging through the BP source code today, I believe that I have finally figured this out. The hook used to update Profile Fields in BuddyPress is "xprofile\_data\_before\_save". If anyone know of something better, please let me know!
28,737
<p>Sometimes when I upload a picture (either with flash or browser uploader), I get a message like (this was with a 1.46MB jpg):</p> <pre><code>Fatal error: Out of memory (allocated 69206016) (tried to allocate 4000 bytes) in /home/ab64489/public_html/wp-includes/media.php on line 254 </code></pre> <p>I am on a share...
[ { "answer_id": 28741, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 3, "selected": true, "text": "<p>This isn't a Wordpress problem. There's no telling on a shared environment what the culprit might be. You pr...
2011/09/16
[ "https://wordpress.stackexchange.com/questions/28737", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8425/" ]
Sometimes when I upload a picture (either with flash or browser uploader), I get a message like (this was with a 1.46MB jpg): ``` Fatal error: Out of memory (allocated 69206016) (tried to allocate 4000 bytes) in /home/ab64489/public_html/wp-includes/media.php on line 254 ``` I am on a shared host, but the max upload...
This isn't a Wordpress problem. There's no telling on a shared environment what the culprit might be. You probably don't have access to your php.ini config, nor do we know how many websites your hosting company has jammed on your server. The very nature of a shared server is that each client shares the resources of th...
28,754
<p>I've been using custom fields for my wordpress theme, but i'd like to use shortcodes now for easier posting.</p> <p>so before, in my index.php i have this:</p> <pre><code>&lt;?php echo get_post_meta($post-&gt;ID, "Thumbnail", true);?&gt; </code></pre> <p>how do i replace it with custom fields? SUch that i can jus...
[ { "answer_id": 28756, "author": "Niraj Chauhan", "author_id": 1743, "author_profile": "https://wordpress.stackexchange.com/users/1743", "pm_score": 0, "selected": false, "text": "<p>I don't know whether this will work or not, but just try this code</p>\n\n<pre><code>function customfield_...
2011/09/17
[ "https://wordpress.stackexchange.com/questions/28754", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8711/" ]
I've been using custom fields for my wordpress theme, but i'd like to use shortcodes now for easier posting. so before, in my index.php i have this: ``` <?php echo get_post_meta($post->ID, "Thumbnail", true);?> ``` how do i replace it with custom fields? SUch that i can just insert: ``` [thumbnail]http://domain.co...
A shortcode like this ``` [thumbnail height=100 width=100]http://urltoimage.com/image.jpg[/thumbnail] ``` Would need this type of setup ``` function content_insert_thumbnail($atts, $content = null){ global $post; extract($atts); $thumbnail = get_the_post_thumbnail($post->ID, array($height, $width)); ...
28,782
<p>What I'm looking to do is completely hide the UI for a custom post type from specific user roles...Ive previously found many resources on how to disable access to using those CPTs but nothing that really allows you to completely hide the CPT UI all together based on what user is logged into the dashboard. </p> <p>T...
[ { "answer_id": 28784, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 7, "selected": true, "text": "<h2>To hide a post type menu item from non-admin users:</h2>\n\n<pre><code>function wpse28782_remove_menu_items() {\n ...
2011/09/17
[ "https://wordpress.stackexchange.com/questions/28782", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3567/" ]
What I'm looking to do is completely hide the UI for a custom post type from specific user roles...Ive previously found many resources on how to disable access to using those CPTs but nothing that really allows you to completely hide the CPT UI all together based on what user is logged into the dashboard. This is imp...
To hide a post type menu item from non-admin users: --------------------------------------------------- ``` function wpse28782_remove_menu_items() { if( !current_user_can( 'administrator' ) ): remove_menu_page( 'edit.php?post_type=your_post_type' ); endif; } add_action( 'admin_menu', 'wpse28782_remove_...
28,785
<p>I want to make selecting a featured post is just by checking a checkbox in edit screen AND be able to retrieve these featured articles from only specific category ?</p> <p>in short what I'm looking for :</p> <ul> <li><p>set featured post</p></li> <li><p>loop throw featured posts in a specific category (not all pos...
[ { "answer_id": 28804, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 3, "selected": false, "text": "<p>You can do this by following these steps:</p>\n\n<ol>\n<li>Add a custom meta box to your posts</li>\n<li>Cr...
2011/09/17
[ "https://wordpress.stackexchange.com/questions/28785", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8697/" ]
I want to make selecting a featured post is just by checking a checkbox in edit screen AND be able to retrieve these featured articles from only specific category ? in short what I'm looking for : * set featured post * loop throw featured posts in a specific category (not all posts) Any help? and thanks in advance :...
You can do this by following these steps: 1. Add a custom meta box to your posts 2. Create a function to save the meta data using the save\_post action 3. Add the 'meta\_key' query argument to whatever query you are using. Place this in your themes functions.php file: ``` function register_post_assets(){ add_met...
28,786
<p>I created a login form in the frontend with <code>wp_login_form()</code>. In my <strong>functions.php</strong> file I added an action to prevent the redirect to <strong>/wp-login.php</strong> if the login failed with </p> <blockquote> <p>add_action('wp_login_failed', ….</p> </blockquote> <p>As it turns out the a...
[ { "answer_id": 59502, "author": "user18485", "author_id": 18485, "author_profile": "https://wordpress.stackexchange.com/users/18485", "pm_score": 1, "selected": false, "text": "<p>The problem lies with the function <code>wp_authenticate()</code> (found in the file <code>pluggable.php</co...
2011/09/17
[ "https://wordpress.stackexchange.com/questions/28786", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8722/" ]
I created a login form in the frontend with `wp_login_form()`. In my **functions.php** file I added an action to prevent the redirect to **/wp-login.php** if the login failed with > > add\_action('wp\_login\_failed', …. > > > As it turns out the action only hooks if the **username** and **password** fields are f...
Add this filter to change how blank username/password is treated: ``` add_filter( 'authenticate', 'custom_authenticate_username_password', 30, 3); function custom_authenticate_username_password( $user, $username, $password ) { if ( is_a($user, 'WP_User') ) { return $user; } if ( empty($username) || empty($pas...
28,789
<p>I want to create "city" taxonomy in all sites of MultiSite. But i want to show same listing in every blog and i want to edit it from only master site and not letting other blog owners edit it. I think only solution for this is setting a master site for specific taxonomy in MultiSite. So when someone try to use "city...
[ { "answer_id": 59502, "author": "user18485", "author_id": 18485, "author_profile": "https://wordpress.stackexchange.com/users/18485", "pm_score": 1, "selected": false, "text": "<p>The problem lies with the function <code>wp_authenticate()</code> (found in the file <code>pluggable.php</co...
2011/09/17
[ "https://wordpress.stackexchange.com/questions/28789", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1372/" ]
I want to create "city" taxonomy in all sites of MultiSite. But i want to show same listing in every blog and i want to edit it from only master site and not letting other blog owners edit it. I think only solution for this is setting a master site for specific taxonomy in MultiSite. So when someone try to use "city" t...
Add this filter to change how blank username/password is treated: ``` add_filter( 'authenticate', 'custom_authenticate_username_password', 30, 3); function custom_authenticate_username_password( $user, $username, $password ) { if ( is_a($user, 'WP_User') ) { return $user; } if ( empty($username) || empty($pas...
28,792
<p>what would be the best way to exclude the current post I am viewing from this recent posts query. Thank You!</p> <pre><code>&lt;?php global $post; if (in_category('top-lists')) { $myposts2 = get_posts('numberposts=5&amp;offset=0&amp;category=7'); } els...
[ { "answer_id": 28801, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 6, "selected": true, "text": "<p>This the <code>post__not_in</code> arg should work dandy for you: </p>\n\n<pre><code>$args = array(\n 'nu...
2011/09/17
[ "https://wordpress.stackexchange.com/questions/28792", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3495/" ]
what would be the best way to exclude the current post I am viewing from this recent posts query. Thank You! ``` <?php global $post; if (in_category('top-lists')) { $myposts2 = get_posts('numberposts=5&offset=0&category=7'); } else if (in_category('playli...
This the `post__not_in` arg should work dandy for you: ``` $args = array( 'numberposts' => 5, 'offset' => 0, 'category' => 7, 'post__not_in' => array( $post->ID ) ); $myposts2 = get_posts($args); ```
28,817
<p>Some of you might know that I've been really struggling with trying to enqueue Javascript to my Wordpress theme and I just can't get it to work. I need to get this done somehow. I will keep this question updated, I will edit and I hope you will work together with me through this step by step! It's been a few months ...
[ { "answer_id": 28823, "author": "Sisir", "author_id": 3094, "author_profile": "https://wordpress.stackexchange.com/users/3094", "pm_score": 2, "selected": false, "text": "<p>You can try these. </p>\n\n<ol>\n<li>Make a <code>functions.php</code> file for your child theme and paste your co...
2011/09/18
[ "https://wordpress.stackexchange.com/questions/28817", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6903/" ]
Some of you might know that I've been really struggling with trying to enqueue Javascript to my Wordpress theme and I just can't get it to work. I need to get this done somehow. I will keep this question updated, I will edit and I hope you will work together with me through this step by step! It's been a few months now...
**First Hint:** Copy your parent theme (without modifications) and start a new child theme that only contains the style.css file with the comment and a plain functions.php file. You can move stuff later, but this way you can make sure that nothing interrupts. Solve one task after each other in this plain vanilla setup....
28,833
<p>I have a Wooframework specified question. I'm using <a href="http://www.woothemes.com/2009/11/bueno/" rel="nofollow">Bueno</a> theme with WooFramework 4.5.4 . I'm trying to get url of image which resized with <strong>Dynamic Image resizer</strong> of WooFramework on single.php. I'm using woo_get_image('image', 490, ...
[ { "answer_id": 28823, "author": "Sisir", "author_id": 3094, "author_profile": "https://wordpress.stackexchange.com/users/3094", "pm_score": 2, "selected": false, "text": "<p>You can try these. </p>\n\n<ol>\n<li>Make a <code>functions.php</code> file for your child theme and paste your co...
2011/09/18
[ "https://wordpress.stackexchange.com/questions/28833", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3552/" ]
I have a Wooframework specified question. I'm using [Bueno](http://www.woothemes.com/2009/11/bueno/) theme with WooFramework 4.5.4 . I'm trying to get url of image which resized with **Dynamic Image resizer** of WooFramework on single.php. I'm using woo\_get\_image('image', 490, 200); for this but this isn't returning ...
**First Hint:** Copy your parent theme (without modifications) and start a new child theme that only contains the style.css file with the comment and a plain functions.php file. You can move stuff later, but this way you can make sure that nothing interrupts. Solve one task after each other in this plain vanilla setup....
28,842
<p>I am looking for a plugin or a way to list first five posts as new. It should be just a small picture added in the index.php. Any ideas of how I could achieve this? Thanks!</p>
[ { "answer_id": 28823, "author": "Sisir", "author_id": 3094, "author_profile": "https://wordpress.stackexchange.com/users/3094", "pm_score": 2, "selected": false, "text": "<p>You can try these. </p>\n\n<ol>\n<li>Make a <code>functions.php</code> file for your child theme and paste your co...
2011/09/18
[ "https://wordpress.stackexchange.com/questions/28842", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7552/" ]
I am looking for a plugin or a way to list first five posts as new. It should be just a small picture added in the index.php. Any ideas of how I could achieve this? Thanks!
**First Hint:** Copy your parent theme (without modifications) and start a new child theme that only contains the style.css file with the comment and a plain functions.php file. You can move stuff later, but this way you can make sure that nothing interrupts. Solve one task after each other in this plain vanilla setup....
28,851
<p>Just wondering how to fetch a page by using 'title contains'. I can retrieve a page by using the following</p> <pre><code>&lt;?php $page = get_page_by_title('Restaurants and Pubs'); ?&gt; </code></pre> <p>but how could I do 'page title contains "Pubs"'?</p> <p>Thanks</p>
[ { "answer_id": 28853, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 2, "selected": true, "text": "<p>You should build a query using the Wordpress database class. Place this in your functions.php file</p>\n\n<...
2011/09/18
[ "https://wordpress.stackexchange.com/questions/28851", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6374/" ]
Just wondering how to fetch a page by using 'title contains'. I can retrieve a page by using the following ``` <?php $page = get_page_by_title('Restaurants and Pubs'); ?> ``` but how could I do 'page title contains "Pubs"'? Thanks
You should build a query using the Wordpress database class. Place this in your functions.php file ``` function get_page_by_title_search($string){ global $wpdb; $title = esc_sql($string); if(!$title) return; $page = $wpdb->get_results(" SELECT * FROM $wpdb->posts WHERE post_tit...
28,861
<p>I am adding items to a CPT Admin menu using <code>add_submenu_page</code> which works great, but they are added to the bottom of the sub-menu after the CPT options. I want to be able to have them on top , but I suppose this question can also apply to ordering all Admin based sub-menu items.</p> <p>What I tried ( n...
[ { "answer_id": 28865, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 3, "selected": true, "text": "<p>The filter 'custom_menu_order' will not work on the menu order because apply_filters in wp-admin/includes/me...
2011/09/19
[ "https://wordpress.stackexchange.com/questions/28861", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1509/" ]
I am adding items to a CPT Admin menu using `add_submenu_page` which works great, but they are added to the bottom of the sub-menu after the CPT options. I want to be able to have them on top , but I suppose this question can also apply to ordering all Admin based sub-menu items. What I tried ( not working, I tried se...
The filter 'custom\_menu\_order' will not work on the menu order because apply\_filters in wp-admin/includes/menu.php supplies false as the filtered content. You can try changing false to $menu and the filter works grand. Since we obviously can't touch the core, here's how I got it to work: ``` function custom_menu_o...
28,862
<p>Is there anyway to show in a template for a post, how many times that post has been viewed, like hits without some sort of plugin? It seems wordpress would have this built in, but I am unable to find any template tags for such a think in the documentation?</p>
[ { "answer_id": 28867, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 2, "selected": false, "text": "<p>No, WP doesn't have such functionality built-in. Probably because updating the post table on each page hit ...
2011/09/19
[ "https://wordpress.stackexchange.com/questions/28862", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8668/" ]
Is there anyway to show in a template for a post, how many times that post has been viewed, like hits without some sort of plugin? It seems wordpress would have this built in, but I am unable to find any template tags for such a think in the documentation?
Not in core. You can use post meta to store this information on page loads. If you have caching plugins enabled, you might want to increment the hit counter with an AJAX call, otherwise you can just add this directly in your single.php and page.php templates: ``` //Add to functions.php function get_hits(){ global ...
28,864
<p>I've just successfully enabled networks in WP 3.2.1.</p> <p>However, at top right, I have <strong>no Network Admin</strong> under my (admin) username.</p> <p>If I go to /wp-admin/network, I receive "<strong>You do not have sufficient permissions to access this page</strong>."</p> <ul> <li>In my WP_Sitemeta table,...
[ { "answer_id": 29389, "author": "Steve", "author_id": 3206, "author_profile": "https://wordpress.stackexchange.com/users/3206", "pm_score": 3, "selected": true, "text": "<p>I installed Wordpress 3.2.1 fresh on a new domain, and then enabled Multi-Site, which functioned as documented. I ...
2011/09/19
[ "https://wordpress.stackexchange.com/questions/28864", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
I've just successfully enabled networks in WP 3.2.1. However, at top right, I have **no Network Admin** under my (admin) username. If I go to /wp-admin/network, I receive "**You do not have sufficient permissions to access this page**." * In my WP\_Sitemeta table, **site\_admins** is set to `a:2:{i:0;N;i:1;s:3:"My_U...
I installed Wordpress 3.2.1 fresh on a new domain, and then enabled Multi-Site, which functioned as documented. I could reach /wp-admin/network without problems. Comparing the database of this WP with the problem installation, in the **wp\_sitemeta** table, **admin\_email was not set** for the problem site. Also, **w...
28,871
<p>I just did a clean install of Wordpress. But I have a problem when I install or use the WordPress API. So send me a sign</p> <blockquote> <p>An Unexpected HTTP Error occurred during the API request.</p> </blockquote> <p>The strange thing is that I have looked everywhere. And the solutions do not work for me porp...
[ { "answer_id": 28874, "author": "Hameedullah Khan", "author_id": 5337, "author_profile": "https://wordpress.stackexchange.com/users/5337", "pm_score": 2, "selected": false, "text": "<p>Use the following function to debug the HTTP API request, you will get to know the actual reason why th...
2011/09/19
[ "https://wordpress.stackexchange.com/questions/28871", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8742/" ]
I just did a clean install of Wordpress. But I have a problem when I install or use the WordPress API. So send me a sign > > An Unexpected HTTP Error occurred during the API request. > > > The strange thing is that I have looked everywhere. And the solutions do not work for me porponen Wordpress 3.2.1 and do not ...
Use the following function to debug the HTTP API request, you will get to know the actual reason why the HTTP API request is failing. Paste the following code in your theme's function.php. ``` function dump_http_response( $response, $type, $transport, $args, $url ) { if ( is_admin() && $type == "response" ) { ...
28,873
<p>I am looking for a solution to reuse the header and footer navigation links (with style, of course) in one of my WordPress website for several other WordPress sites.</p> <p>Please note that I'm trying to share header and footer among WordPress sites, not from WordPress site to a PHP page. The sites I'm referring to...
[ { "answer_id": 28874, "author": "Hameedullah Khan", "author_id": 5337, "author_profile": "https://wordpress.stackexchange.com/users/5337", "pm_score": 2, "selected": false, "text": "<p>Use the following function to debug the HTTP API request, you will get to know the actual reason why th...
2011/09/19
[ "https://wordpress.stackexchange.com/questions/28873", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6986/" ]
I am looking for a solution to reuse the header and footer navigation links (with style, of course) in one of my WordPress website for several other WordPress sites. Please note that I'm trying to share header and footer among WordPress sites, not from WordPress site to a PHP page. The sites I'm referring to are on th...
Use the following function to debug the HTTP API request, you will get to know the actual reason why the HTTP API request is failing. Paste the following code in your theme's function.php. ``` function dump_http_response( $response, $type, $transport, $args, $url ) { if ( is_admin() && $type == "response" ) { ...
28,885
<p>For some reason Total Cache does seem to be caching my pages.</p> <p>Each time I got to a page, when I view source, the Total Cache comment shows that it regenerated the page for this request. </p> <p>What worse, it seems to be regenerating the combined/minified css and js files for each request as well! This alon...
[ { "answer_id": 28874, "author": "Hameedullah Khan", "author_id": 5337, "author_profile": "https://wordpress.stackexchange.com/users/5337", "pm_score": 2, "selected": false, "text": "<p>Use the following function to debug the HTTP API request, you will get to know the actual reason why th...
2011/09/19
[ "https://wordpress.stackexchange.com/questions/28885", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8749/" ]
For some reason Total Cache does seem to be caching my pages. Each time I got to a page, when I view source, the Total Cache comment shows that it regenerated the page for this request. What worse, it seems to be regenerating the combined/minified css and js files for each request as well! This alone adds another 5s...
Use the following function to debug the HTTP API request, you will get to know the actual reason why the HTTP API request is failing. Paste the following code in your theme's function.php. ``` function dump_http_response( $response, $type, $transport, $args, $url ) { if ( is_admin() && $type == "response" ) { ...
28,896
<p>As with anything in Wordpress it seems there are 20 way to do something, but after several weeks of extensive searching I really haven't found more then a couple tutorials floating around that really mirror each other in writing conventions which always makes me a little uneasy when this is the way I learn so I want...
[ { "answer_id": 28899, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 3, "selected": true, "text": "<p>I have a sort of \"plugin library\" that contains a <a href=\"https://github.com/chrisguitarguy/mrg-wordpr...
2011/09/19
[ "https://wordpress.stackexchange.com/questions/28896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3567/" ]
As with anything in Wordpress it seems there are 20 way to do something, but after several weeks of extensive searching I really haven't found more then a couple tutorials floating around that really mirror each other in writing conventions which always makes me a little uneasy when this is the way I learn so I wanted ...
I have a sort of "plugin library" that contains a [base class for meta boxes](https://github.com/chrisguitarguy/mrg-wordpress-store/blob/master/store-plugin/library/includes/meta-box-tools.php). Basically all it contains are a bunch of methods that generate form fields and some tabbed navigation stuff that I do for met...
28,905
<p>This code is from my page <code>single-publication.php</code>. </p> <p>It outputs the relevant custom fields etc (here wrapped in template tags), but <code>the_content()</code> won't output the post content. I've resorted to using <code>$post-&gt;post_content</code> (which works), but the mystery remains:</p> <pre...
[ { "answer_id": 28909, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 3, "selected": false, "text": "<p>There's a good chance your HTML is not included in the loop. Make sure your code looks like this:</p>\n\n<p...
2011/09/19
[ "https://wordpress.stackexchange.com/questions/28905", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7905/" ]
This code is from my page `single-publication.php`. It outputs the relevant custom fields etc (here wrapped in template tags), but `the_content()` won't output the post content. I've resorted to using `$post->post_content` (which works), but the mystery remains: ``` <div class="publication-info"> <?php printf("<...
**Some post-related data is not available to get\_posts by default**, such as post content through `the_content()`, or the numeric ID. This is resolved by calling an internal function **`setup_postdata()`**, with the **$post** array as its argument: ``` <?php $args = array( 'posts_per_page' => 3 ); $lastposts = get_po...
28,954
<pre><code>$shortname = "nuod"; array( "name" =&gt; "Custom Logo URL", "desc" =&gt; "Enter the link to your site's custom logo.", "id" =&gt; $shortname."_logo", "type" =&gt; "text", "std" =&gt; "newlogo.png") </code></pre> <p>How do i make the std be automatically set as the value for <code>&lt;?php e...
[ { "answer_id": 51208, "author": "Ashfame", "author_id": 1521, "author_profile": "https://wordpress.stackexchange.com/users/1521", "pm_score": 2, "selected": false, "text": "<p>This is important which most of the people don't get right. Don't save the defaults in the database. You should ...
2011/09/20
[ "https://wordpress.stackexchange.com/questions/28954", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8711/" ]
``` $shortname = "nuod"; array( "name" => "Custom Logo URL", "desc" => "Enter the link to your site's custom logo.", "id" => $shortname."_logo", "type" => "text", "std" => "newlogo.png") ``` How do i make the std be automatically set as the value for `<?php echo get_option('nuod_logo'); ?>`
This is important which most of the people don't get right. Don't save the defaults in the database. You should be using `wp_parse_args()` for this purpose. ``` $defaults = array ( 'logo' => 'http://domain.com/logo.png', 'do_extra_thing' => false ); // Parse incomming $args into an array and merge it with $de...
28,973
<p>If I create a post and set the visibility to "password protected", it still shows up on the front page and in the feeds. Is it possible to hide posts from general view altogether, but still allow quick access to some people without creating an account for them?</p> <p>(This is in WP 3.0.4)</p>
[ { "answer_id": 28992, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": false, "text": "<p>Both the <code>the_content()</code> and the <code>the_excerpt()</code> template tags already account for pa...
2011/09/20
[ "https://wordpress.stackexchange.com/questions/28973", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1976/" ]
If I create a post and set the visibility to "password protected", it still shows up on the front page and in the feeds. Is it possible to hide posts from general view altogether, but still allow quick access to some people without creating an account for them? (This is in WP 3.0.4)
Both the `the_content()` and the `the_excerpt()` template tags already account for password-protected posts, via the [`post_password_required()`](http://codex.wordpress.org/Function_Reference/post_password_required) conditional. If you need to output content, or comments, etc. outside of `the_content()`/`the_excerpt()`...
28,979
<p><em>This is a repost of an earlier question I had, but I like to go into more details now to be able to fully solve this.</em></p> <p>So again, with (normal) posts changing the permalink is as easy as going to Settings > Permalink and by changing it to anything you like such as the broadly used <code>%category%/%po...
[ { "answer_id": 28997, "author": "Mark", "author_id": 8757, "author_profile": "https://wordpress.stackexchange.com/users/8757", "pm_score": 3, "selected": false, "text": "<p>Ok I think I might have a solution. I have no idea if this is the right way to accomplish this, but as for now it's...
2011/09/20
[ "https://wordpress.stackexchange.com/questions/28979", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8757/" ]
*This is a repost of an earlier question I had, but I like to go into more details now to be able to fully solve this.* So again, with (normal) posts changing the permalink is as easy as going to Settings > Permalink and by changing it to anything you like such as the broadly used `%category%/%postname%.html`. This al...
Ok I think I might have a solution. I have no idea if this is the right way to accomplish this, but as for now it's the only thing that seems to work. ``` add_filter('rewrite_rules_array', 'mmp_rewrite_rules'); function mmp_rewrite_rules($rules) { $newRules = array(); $newRules['...
28,985
<p>I want to display the latest post from a "featured" category <code>(id=1)</code> that may also be in either <code>X</code> category, <code>Y</code> category, or <code>Z</code> category <code>(id=2,3,4 respectively)</code>. Note, there are other posts in categories <code>(A,B)</code> that may also be listed under "fe...
[ { "answer_id": 28986, "author": "Marty", "author_id": 1325, "author_profile": "https://wordpress.stackexchange.com/users/1325", "pm_score": 0, "selected": false, "text": "<p>how about?</p>\n\n<pre><code>&lt;?php \n$temp = $wp_query;\n$wp_query= null;\n$wp_query = new WP_Query();\n$wp_que...
2011/09/20
[ "https://wordpress.stackexchange.com/questions/28985", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8802/" ]
I want to display the latest post from a "featured" category `(id=1)` that may also be in either `X` category, `Y` category, or `Z` category `(id=2,3,4 respectively)`. Note, there are other posts in categories `(A,B)` that may also be listed under "featured" but I want to limit my results to the `XYZ set`. Is there an...
Maybe this could help and should return any post either in 2, 3 or 4 category AND in categoery 1 : ``` query_posts( array( 'cat' => array(2,3,4), 'category__and' => 1, 'posts_per_page' => 1, 'orderby' => 'title', 'order' => 'DESC' ) ); ``` (from codex <http://codex.wordpress.org/Function_Reference/query_posts>) No...
29,000
<p>I'm currently developing an intranet and I am using Justin Tadlock's Members plugin to control roles and capabilities.</p> <p>I have created a <code>HR</code> role to allow Human Resources staff to create and edit user accounts. All staff created in WP are given the <code>contributor</code> role with a select few ...
[ { "answer_id": 29087, "author": "Scott", "author_id": 4610, "author_profile": "https://wordpress.stackexchange.com/users/4610", "pm_score": 4, "selected": true, "text": "<p>Worked it out with a bit of time. Here is the code I am using:</p>\n\n<pre><code>&lt;?php\n/*\nPlugin Name: Restric...
2011/09/20
[ "https://wordpress.stackexchange.com/questions/29000", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
I'm currently developing an intranet and I am using Justin Tadlock's Members plugin to control roles and capabilities. I have created a `HR` role to allow Human Resources staff to create and edit user accounts. All staff created in WP are given the `contributor` role with a select few members of staff given `editor` a...
Worked it out with a bit of time. Here is the code I am using: ``` <?php /* Plugin Name: Restrict User Editing Own Profile Plugin URI: http://www.philosophydesign.com Description: Restricts users from editing their own profile information. Author: Scott Cariss Version: 0.1 Author URI: http://www.philosophydesign.com/s...
29,001
<p>I'm using these filters to clean the head of my theme:</p> <pre><code>remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'feed_links', 2); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'feed_li...
[ { "answer_id": 29010, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 3, "selected": false, "text": "<p>Add these to your list:</p>\n\n<pre><code>&lt;?php\nremove_action('wp_head', 'wp_shortlink_wp_head');\nre...
2011/09/20
[ "https://wordpress.stackexchange.com/questions/29001", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6620/" ]
I'm using these filters to clean the head of my theme: ``` remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'feed_links', 2); remove_action('wp_head', 'index_rel_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'feed_links_extra', 3)...
One shouldn't remove them. They are important for search engines like Google. One can remove them like this: ``` remove_action('wp_head', 'wp_shortlink_wp_head'); remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); ``` --- Here are some additional explanations *why* they should not be removed and how this...
29,020
<p>The wp_title-generated <code>&lt;title&gt;</code> in my custom taxonomy archive pages contains the singular taxonomy name with a colon. I can't figure out where this is coming from (or if it's default Wordpress behavior), and I'd like to remove it. For example, in the archive page for the term 'Vanilla' in a taxono...
[ { "answer_id": 29030, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 0, "selected": false, "text": "<p>I'd recommend you use a SEO plugin to take control of all of your titles. <a href=\"http://wordpress.org...
2011/09/20
[ "https://wordpress.stackexchange.com/questions/29020", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3564/" ]
The wp\_title-generated `<title>` in my custom taxonomy archive pages contains the singular taxonomy name with a colon. I can't figure out where this is coming from (or if it's default Wordpress behavior), and I'd like to remove it. For example, in the archive page for the term 'Vanilla' in a taxonomy called 'Flavors',...
Use `wp_title` filter to control output ``` function mamaduka_remove_tax_name( $title, $sep, $seplocation ) { if ( is_tax() ) { $term_title = single_term_title( '', false ); // Determines position of separator if ( 'right' == $seplocation ) { $title = $term_title . " $sep "; ...
29,065
<p>I'm creating a simple slideshow on the side where i want to show 4 images from a post, i searched around i found this code that simply uses the build in gallery function </p> <pre><code>&lt;li&gt;&lt;?php echo do_shortcode('[gallery id="'.$post-&gt;ID.'"]'); ?&gt;&lt;/li&gt; </code></pre> <p>the problem is that it...
[ { "answer_id": 29071, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 0, "selected": false, "text": "<p>To exclude an image from the WordPress Gallery you would use something like this:</p>\n\n<pre><code>[galler...
2011/09/20
[ "https://wordpress.stackexchange.com/questions/29065", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8818/" ]
I'm creating a simple slideshow on the side where i want to show 4 images from a post, i searched around i found this code that simply uses the build in gallery function ``` <li><?php echo do_shortcode('[gallery id="'.$post->ID.'"]'); ?></li> ``` the problem is that it spits out the entire gallery... is there noway...
There is no way to limit the gallery query in the shortcode\_gallery function. However, you can get the child attachments of a post using the following. ``` $attachments = get_children( array('post_parent' => $post->id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $o...
29,066
<p>I'm trying to add tinyMCE instead of textarea for one of my options in my plugin with no luck so far. I tried this :</p> <p><a href="http://www.dbuggr.com/smallwei/add-wysiwyg-editor-tinymce-wordpress-plugin/" rel="noreferrer">http://www.dbuggr.com/smallwei/add-wysiwyg-editor-tinymce-wordpress-plugin/</a></p> <p>a...
[ { "answer_id": 29067, "author": "redconservatory", "author_id": 2417, "author_profile": "https://wordpress.stackexchange.com/users/2417", "pm_score": 1, "selected": false, "text": "<p>If I am reading your question correctly: </p>\n\n<p>wordpress.org/extend/plugins/tinymce-advanced/</p>\n...
2011/01/03
[ "https://wordpress.stackexchange.com/questions/29066", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1822/" ]
I'm trying to add tinyMCE instead of textarea for one of my options in my plugin with no luck so far. I tried this : <http://www.dbuggr.com/smallwei/add-wysiwyg-editor-tinymce-wordpress-plugin/> and this: <http://blog.imwd8solutions.com/wordpress/wordpress-plugin-development-add-editor-to-plugin-admin-page/> There ...
Pre WP 3.3: <http://www.dev4press.com/2010/tutorials/wordpress/tips/add-rich-text-editor-to-your-plugin/> If you are using WP 3.3 or later you might look up wp\_editor: <http://codex.wordpress.org/Function_Reference/wp_editor> ``` $settings = array( 'teeny' => true, 'textarea_rows' => 15, 'tabindex' => 1 ...
29,072
<p>I'm having a bit of a problem with my custom post types... My post type is called 'videos'. I have all of the posts showing on their single page using the 'single.php' template. But when I take the post name out of the url and keep /videos/, I get a 404 - but I want to list all of the 'videos' here. I tried using ar...
[ { "answer_id": 29073, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 3, "selected": true, "text": "<p>You need to add the arg 'has_archive' => true. Hope this helps!</p>\n" }, { "answer_id": 35692, ...
2011/09/21
[ "https://wordpress.stackexchange.com/questions/29072", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8819/" ]
I'm having a bit of a problem with my custom post types... My post type is called 'videos'. I have all of the posts showing on their single page using the 'single.php' template. But when I take the post name out of the url and keep /videos/, I get a 404 - but I want to list all of the 'videos' here. I tried using archi...
You need to add the arg 'has\_archive' => true. Hope this helps!
29,095
<p>I have a post that shows the titles and excerpts from a specific category underneath the content. Currently this is coded into a specific template like this:</p> <pre><code>&lt;?php query_posts('category_name=dogs&amp;showposts=5'); if (have_posts()) : ?&gt; </code></pre> <p>This is fine but I need the client to b...
[ { "answer_id": 29096, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 0, "selected": false, "text": "<p>Try to <a href=\"https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-p...
2011/09/21
[ "https://wordpress.stackexchange.com/questions/29095", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8824/" ]
I have a post that shows the titles and excerpts from a specific category underneath the content. Currently this is coded into a specific template like this: ``` <?php query_posts('category_name=dogs&showposts=5'); if (have_posts()) : ?> ``` This is fine but I need the client to be able to handle this themselves fro...
Finally solved it! I needed to add this at the end of each loop :) ``` <?php $my_query = new WP_Query(array( 'category_name' => get_post_meta($post->ID, 'featured', true), 'posts_per_page' => 5, )); if ($my_query->have_posts()): ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> content etc goes here...
29,103
<p>I'm creating a custom Google map that plots multiple markers.</p> <h2><em><strong>View the link as it will make it easier to explain what is happening and what I want</em></strong></h2> <p>If you click on each marker it shows company names that are grabbed from the child pages. At the moment it's showing ALL the c...
[ { "answer_id": 29105, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 3, "selected": true, "text": "<p>Use the <code>offset</code> argument, and only get 1 result:</p>\n\n<pre><code>global $my_page_offset;\n\nif...
2011/09/21
[ "https://wordpress.stackexchange.com/questions/29103", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
I'm creating a custom Google map that plots multiple markers. ***View the link as it will make it easier to explain what is happening and what I want*** ------------------------------------------------------------------------------------------ If you click on each marker it shows company names that are grabbed from t...
Use the `offset` argument, and only get 1 result: ``` global $my_page_offset; if(!isset($my_page_offset)) $my_page_offset = 0; $pages = get_pages(array( 'child_of' => $post->ID, 'sort_column' => 'menu_order', 'offset' => $my_page_offset, 'number' => 1, )); $my_page_offset++; ... ``` I'm...
29,113
<p>I have a Contact Us page which is showing 9 locations on the sidebar by querying the custom post type "Distributors." I want the user to be able to use a drop down that is populated by the taxonomy "Location." For example, if the user selects "California" from the drop down, it will automatically update the list wit...
[ { "answer_id": 29165, "author": "Assad Nazar", "author_id": 7338, "author_profile": "https://wordpress.stackexchange.com/users/7338", "pm_score": 3, "selected": true, "text": "<p>First use this code for populating parent dropdown.</p>\n\n<pre><code>&lt;select id=\"parent\"&gt;\n &lt;o...
2011/09/21
[ "https://wordpress.stackexchange.com/questions/29113", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1753/" ]
I have a Contact Us page which is showing 9 locations on the sidebar by querying the custom post type "Distributors." I want the user to be able to use a drop down that is populated by the taxonomy "Location." For example, if the user selects "California" from the drop down, it will automatically update the list with j...
First use this code for populating parent dropdown. ``` <select id="parent"> <option>-</option> <?php if(taxonomy_exists('parent_taxonomy_name')): $results = get_terms('parent_taxonomy_name',array('fields'=>'all','parent'=>0)); if ($results): foreach ($results as...
29,116
<p>Looking to create a customized single.php for my posts. In one column I'd like to display all images added through the add media function (inserted into post). In the next column all other content associated with the post (except images). </p> <p>What I need is the proper / best practice method of doing so. I am ju...
[ { "answer_id": 29165, "author": "Assad Nazar", "author_id": 7338, "author_profile": "https://wordpress.stackexchange.com/users/7338", "pm_score": 3, "selected": true, "text": "<p>First use this code for populating parent dropdown.</p>\n\n<pre><code>&lt;select id=\"parent\"&gt;\n &lt;o...
2011/09/21
[ "https://wordpress.stackexchange.com/questions/29116", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3899/" ]
Looking to create a customized single.php for my posts. In one column I'd like to display all images added through the add media function (inserted into post). In the next column all other content associated with the post (except images). What I need is the proper / best practice method of doing so. I am just beginni...
First use this code for populating parent dropdown. ``` <select id="parent"> <option>-</option> <?php if(taxonomy_exists('parent_taxonomy_name')): $results = get_terms('parent_taxonomy_name',array('fields'=>'all','parent'=>0)); if ($results): foreach ($results as...
29,119
<p>Was wondering if anyone knows here if the API at api.wordpress.org is free to use without keys. I haven't really found any information about key registration.</p> <p>I'd like to use it to make a few requests a day, really not many &lt; 50 requests.</p> <p>What's the official way to go about consuming that API?</p>...
[ { "answer_id": 29165, "author": "Assad Nazar", "author_id": 7338, "author_profile": "https://wordpress.stackexchange.com/users/7338", "pm_score": 3, "selected": true, "text": "<p>First use this code for populating parent dropdown.</p>\n\n<pre><code>&lt;select id=\"parent\"&gt;\n &lt;o...
2011/09/21
[ "https://wordpress.stackexchange.com/questions/29119", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/890/" ]
Was wondering if anyone knows here if the API at api.wordpress.org is free to use without keys. I haven't really found any information about key registration. I'd like to use it to make a few requests a day, really not many < 50 requests. What's the official way to go about consuming that API? Thanks!
First use this code for populating parent dropdown. ``` <select id="parent"> <option>-</option> <?php if(taxonomy_exists('parent_taxonomy_name')): $results = get_terms('parent_taxonomy_name',array('fields'=>'all','parent'=>0)); if ($results): foreach ($results as...
29,142
<p>I just wasted 1 day trying to make wp threaded comments works... and I think I'm finally done!!!! except that it doesn't work properly - well it doesn't work the way I want ! :)</p> <p>Child comments get displayed inside the comment li - I don't like this behavior, I'd prefer wp to display it right below the parent...
[ { "answer_id": 29143, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 0, "selected": false, "text": "<p>Go to Settings->Discussion and disable threaded comments.</p>\n" }, { "answer_id": 29171, "auth...
2011/09/21
[ "https://wordpress.stackexchange.com/questions/29142", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I just wasted 1 day trying to make wp threaded comments works... and I think I'm finally done!!!! except that it doesn't work properly - well it doesn't work the way I want ! :) Child comments get displayed inside the comment li - I don't like this behavior, I'd prefer wp to display it right below the parent comment l...
What you need is a custom `Walker`. You will probably use `wp_list_comments()` somewhere in your `comments.php` template file. There you can pass a `walker` parameter in the argument array to tell WordPress you want to style the list on your own. This requires you to extend the `Walker` class. The following resources ...
29,144
<p>I'd like to export my blog posts to plain text files so I can version control and update them using emacs org-mode via the <a href="https://github.com/punchagan/org2blog" rel="nofollow">org2blog</a> package. However, I'm unfamiliar with SQL and the wordpress database structure. I'm hoping to get ideas for a SQL sc...
[ { "answer_id": 29143, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 0, "selected": false, "text": "<p>Go to Settings->Discussion and disable threaded comments.</p>\n" }, { "answer_id": 29171, "auth...
2011/09/22
[ "https://wordpress.stackexchange.com/questions/29144", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8843/" ]
I'd like to export my blog posts to plain text files so I can version control and update them using emacs org-mode via the [org2blog](https://github.com/punchagan/org2blog) package. However, I'm unfamiliar with SQL and the wordpress database structure. I'm hoping to get ideas for a SQL script to export my posts where e...
What you need is a custom `Walker`. You will probably use `wp_list_comments()` somewhere in your `comments.php` template file. There you can pass a `walker` parameter in the argument array to tell WordPress you want to style the list on your own. This requires you to extend the `Walker` class. The following resources ...
29,147
<p>I understand little about regular expressions, but I need to figure one out to use with the Redirection plugin which supports redirects with regular expressions. <a href="http://urbangiraffe.com/plugins/redirection/" rel="noreferrer">http://urbangiraffe.com/plugins/redirection/</a></p> <p>What I need to do is redir...
[ { "answer_id": 29323, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 4, "selected": true, "text": "<p>Got it to work with this:</p>\n\n<pre><code>Source: /oldsite/(.*)\nTarget: http://mydomain.com\n</code></pre>...
2011/09/22
[ "https://wordpress.stackexchange.com/questions/29147", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/268/" ]
I understand little about regular expressions, but I need to figure one out to use with the Redirection plugin which supports redirects with regular expressions. <http://urbangiraffe.com/plugins/redirection/> What I need to do is redirect all urls in /oldsite/ to the domain root. That means any page in /oldsite/ like ...
Got it to work with this: ``` Source: /oldsite/(.*) Target: http://mydomain.com ```
29,150
<p>I've created a custom taxonomy. It's working just as expected, aside from it is not showing in the <code>get_taxonomies</code> array. <code>get_terms</code> function returns an <code>invalid taxonomy</code> error. </p> <p>I want to use <code>get_terms</code> to loop through the Double India Pale Ales and print each...
[ { "answer_id": 29164, "author": "Roman", "author_id": 3817, "author_profile": "https://wordpress.stackexchange.com/users/3817", "pm_score": 5, "selected": true, "text": "<p>The <code>Invalid Taxonomy</code> error will be raised by the function <code>get_terms()</code>. You're registring ...
2011/09/22
[ "https://wordpress.stackexchange.com/questions/29150", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7183/" ]
I've created a custom taxonomy. It's working just as expected, aside from it is not showing in the `get_taxonomies` array. `get_terms` function returns an `invalid taxonomy` error. I want to use `get_terms` to loop through the Double India Pale Ales and print each name for a select box. Here is the code used to regi...
The `Invalid Taxonomy` error will be raised by the function `get_terms()`. You're registring your taxonomy on the `init` action hook. Therefore you have to call your `get_terms()` function on the same or a later hook. Try this snippet. It should display all term names of your taxonomy, regardless if the term is empty....
29,155
<p>Please give me details on how to remove the custom header image in the Twenty Eleven theme.</p>
[ { "answer_id": 29164, "author": "Roman", "author_id": 3817, "author_profile": "https://wordpress.stackexchange.com/users/3817", "pm_score": 5, "selected": true, "text": "<p>The <code>Invalid Taxonomy</code> error will be raised by the function <code>get_terms()</code>. You're registring ...
2011/09/22
[ "https://wordpress.stackexchange.com/questions/29155", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8845/" ]
Please give me details on how to remove the custom header image in the Twenty Eleven theme.
The `Invalid Taxonomy` error will be raised by the function `get_terms()`. You're registring your taxonomy on the `init` action hook. Therefore you have to call your `get_terms()` function on the same or a later hook. Try this snippet. It should display all term names of your taxonomy, regardless if the term is empty....
29,179
<p>I'm trying to order the member list by <strike>display_name</strike> or first name ASC. <a href="http://sim.is/sim/felagatal-sim/" rel="nofollow">http://sim.is/sim/felagatal-sim/</a></p> <p>This doesn't seem to work. Any pointers out there? :/</p> <pre><code>$users = get_users(array( 'role' =&gt; 'sm_flagar',...
[ { "answer_id": 29181, "author": "Assad Nazar", "author_id": 7338, "author_profile": "https://wordpress.stackexchange.com/users/7338", "pm_score": 0, "selected": false, "text": "<p>remove ',' (without quotes) after 'ASC'. It will do the trick.</p>\n\n<pre><code>$users = get_users(array(\n...
2011/09/22
[ "https://wordpress.stackexchange.com/questions/29179", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8848/" ]
I'm trying to order the member list by display\_name or first name ASC. <http://sim.is/sim/felagatal-sim/> This doesn't seem to work. Any pointers out there? :/ ``` $users = get_users(array( 'role' => 'sm_flagar', 'orderby' => 'display_name', 'order' => 'ASC', )); foreach ($users as $user) { ...
Here is my solution ``` function split_names( $name ) { $names = explode( " ", trim( join( " ", $name ) ) ); $first_name = array_shift( $names ); $last_name = array_pop( $names ); $middle_name = join( " ", $names ); return array( "first_name" => $first_name, "middle_name" => $middle_name, "last_n...
29,191
<p>What is best practice for WP with regard to using loop.php (loop-single.php, etc) versus looping inside the template file? Does it matter with regard to efficiency or ?</p>
[ { "answer_id": 29181, "author": "Assad Nazar", "author_id": 7338, "author_profile": "https://wordpress.stackexchange.com/users/7338", "pm_score": 0, "selected": false, "text": "<p>remove ',' (without quotes) after 'ASC'. It will do the trick.</p>\n\n<pre><code>$users = get_users(array(\n...
2011/09/22
[ "https://wordpress.stackexchange.com/questions/29191", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3899/" ]
What is best practice for WP with regard to using loop.php (loop-single.php, etc) versus looping inside the template file? Does it matter with regard to efficiency or ?
Here is my solution ``` function split_names( $name ) { $names = explode( " ", trim( join( " ", $name ) ) ); $first_name = array_shift( $names ); $last_name = array_pop( $names ); $middle_name = join( " ", $names ); return array( "first_name" => $first_name, "middle_name" => $middle_name, "last_n...
29,210
<p>While I quite like the admin bar I actually want it to be OFF by default instead of ON ( I don't want to disable it altogether because I want users to be able to turn it on if they want - but but I don't want to have to manually turn it off for every user ) Is there a way to implement this.</p>
[ { "answer_id": 29212, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<pre><code>function wpse29210_admin_bar_toogle()\n{\n add_filter( 'show_admin_bar', '__return_false' );\n\n $use...
2011/09/22
[ "https://wordpress.stackexchange.com/questions/29210", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6169/" ]
While I quite like the admin bar I actually want it to be OFF by default instead of ON ( I don't want to disable it altogether because I want users to be able to turn it on if they want - but but I don't want to have to manually turn it off for every user ) Is there a way to implement this.
``` add_action("user_register", "set_user_admin_bar_false_by_default", 10, 1); function set_user_admin_bar_false_by_default($user_id) { update_user_meta( $user_id, 'show_admin_bar_front', 'false' ); update_user_meta( $user_id, 'show_admin_bar_admin', 'false' ); } ``` Place in theme functions file or you can m...
29,236
<h2>Let me first explain what I am wanting to do...</h2> <p>I am wanting to add all my hundreds of website bookmarks that I have now in my browser, into wordpress for the following reasons.</p> <ul> <li>Can search my bookmarks by category</li> <li>Can search my bookmarks by tags</li> <li>Can search my bookmarks by desc...
[ { "answer_id": 29410, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 0, "selected": false, "text": "<p>I get the feeling that people are afraid of custom taxonomies which is a shame,</p>\n\n<p>from the codex: </p...
2011/09/22
[ "https://wordpress.stackexchange.com/questions/29236", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8668/" ]
Let me first explain what I am wanting to do... ----------------------------------------------- I am wanting to add all my hundreds of website bookmarks that I have now in my browser, into wordpress for the following reasons. * Can search my bookmarks by category * Can search my bookmarks by tags * Can search my book...
Here's a clean way to accomplish what you need. * Register custom post types (sans post\_tags and categories) * Register taxonomies specific to your bookmarks * Create a post meta box for the bookmark options (sample included). You could add a nofollow checkbox option to the meta box. * Save post meta Here's the whol...