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
43,789
<p>I have enabled the excerpt feature for pages in my wordpress theme -</p> <pre><code>add_action( 'init', 'my_add_excerpts_to_pages' ); function my_add_excerpts_to_pages() { add_post_type_support( 'page', 'excerpt' ); } </code></pre> <p>This has enabled the excerpt box when adding or updating pages ...
[ { "answer_id": 44036, "author": "TGuimond", "author_id": 13161, "author_profile": "https://wordpress.stackexchange.com/users/13161", "pm_score": 0, "selected": false, "text": "<p>Fixed :)</p>\n\n<p>I updated <code>&lt;p&gt;&lt;?php the_excerpt(); ?&gt;&lt;/p&gt;</code> to be <code>&lt;p&...
2012/02/28
[ "https://wordpress.stackexchange.com/questions/43789", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13161/" ]
I have enabled the excerpt feature for pages in my wordpress theme - ``` add_action( 'init', 'my_add_excerpts_to_pages' ); function my_add_excerpts_to_pages() { add_post_type_support( 'page', 'excerpt' ); } ``` This has enabled the excerpt box when adding or updating pages through the admin area, wh...
Because I am very particular about how to do things in Wordpress when it comes to looping, I couldn't help but want to post a better way to do the above loop in your question as seeing the way you've done it looks like a lot of unnecessary work for yourself. You already answered your own question but for the sake of ...
43,798
<p>I am working on a plugin that needs to run many different queries. I created a class that has many functions and all these functions runs different queries. A DAL basically.</p> <p>Now when I call these functions in my program, all of them work fine but only one of them runs its query. All other queries in all othe...
[ { "answer_id": 43815, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<h1>Why you really should take care & stick 100% to the core when doing funny DB stuff</h1>\n\n<ol>\n<li><p><strong>Po...
2012/02/28
[ "https://wordpress.stackexchange.com/questions/43798", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13622/" ]
I am working on a plugin that needs to run many different queries. I created a class that has many functions and all these functions runs different queries. A DAL basically. Now when I call these functions in my program, all of them work fine but only one of them runs its query. All other queries in all other function...
**Don't bother using wpdb to update post content, use wp\_update\_post instead!** <http://codex.wordpress.org/Function_Reference/wp_update_post> Instead of ``` $wpdb->update($seo_tblPosts, array('post_content'=>$seo_pageContents), array('ID'=>$row_id)); ``` Do: ``` // Update post 37 $my_post = array(); $my_post['...
43,804
<p>I've set up this query in Wordpress to find all associated news for a company:</p> <pre><code> &lt;h2 class="heading"&gt;Related News&lt;/h2&gt; &lt;?php $link = get_the_title(); ?&gt; &lt;?php $portfolioloop = new WP_Query( array( 'post_type' =&gt; 'news' ) ); ?&gt; &lt;?php while ( $portfolioloop-&g...
[ { "answer_id": 43815, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<h1>Why you really should take care & stick 100% to the core when doing funny DB stuff</h1>\n\n<ol>\n<li><p><strong>Po...
2012/02/28
[ "https://wordpress.stackexchange.com/questions/43804", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
I've set up this query in Wordpress to find all associated news for a company: ``` <h2 class="heading">Related News</h2> <?php $link = get_the_title(); ?> <?php $portfolioloop = new WP_Query( array( 'post_type' => 'news' ) ); ?> <?php while ( $portfolioloop->have_posts() ) : $portfolioloop->the_post(); ...
**Don't bother using wpdb to update post content, use wp\_update\_post instead!** <http://codex.wordpress.org/Function_Reference/wp_update_post> Instead of ``` $wpdb->update($seo_tblPosts, array('post_content'=>$seo_pageContents), array('ID'=>$row_id)); ``` Do: ``` // Update post 37 $my_post = array(); $my_post['...
43,805
<p>I have a few custom fields for a taxonomy "Author". The term title is the Author's last name, and one of the custom fields is his first_name. Now I need, in a post loop, to list all "Authors" of that post by their full name. How can I do this? I'm using Ultimate CMS plugin to manage taxonomy custom fields.<br> Just ...
[ { "answer_id": 44041, "author": "AnaRita", "author_id": 2816, "author_profile": "https://wordpress.stackexchange.com/users/2816", "pm_score": 2, "selected": true, "text": "<p>So I decided to go another way. I now have the Author's Full Name as terms in the taxonomy. For the index, for wh...
2012/02/28
[ "https://wordpress.stackexchange.com/questions/43805", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2816/" ]
I have a few custom fields for a taxonomy "Author". The term title is the Author's last name, and one of the custom fields is his first\_name. Now I need, in a post loop, to list all "Authors" of that post by their full name. How can I do this? I'm using Ultimate CMS plugin to manage taxonomy custom fields. Just to ...
So I decided to go another way. I now have the Author's Full Name as terms in the taxonomy. For the index, for which I need to separate Last Name and First Name, I used PHP string functions. ``` <?php $taxonomy = 'autores'; $queried_term = get_query_var($taxonomy); $terms = get_terms($taxonomy, 'slug='.$q...
43,808
<p>I'm trying to set user meta based on queries. Basically, things like IF the query returns true, set this or if not, set this (or don't set it, if it is true). This works great but the problem is I currently make the call EVERTYIME to check true or false which I know is bad and unnecessary especially for the types of...
[ { "answer_id": 43818, "author": "Manny Fleurmond", "author_id": 2234, "author_profile": "https://wordpress.stackexchange.com/users/2234", "pm_score": 1, "selected": false, "text": "<p>There were some good answers from when I asked a similar question a few months back <a href=\"https://wo...
2012/02/28
[ "https://wordpress.stackexchange.com/questions/43808", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12042/" ]
I'm trying to set user meta based on queries. Basically, things like IF the query returns true, set this or if not, set this (or don't set it, if it is true). This works great but the problem is I currently make the call EVERTYIME to check true or false which I know is bad and unnecessary especially for the types of qu...
Although both of your options (that is, using transients or using a cron job) are viable, I'm a fan of using transients unless the dataset is exceptionally large or if there is some need to automate the process. Without seeing much of your current code, it's difficult to give a working example. Nonetheless, if you end...
43,824
<p>I've got a CPT called <code>Service</code> registered as following:</p> <pre><code>$args = array( 'public' =&gt; true, 'publicly_queryable' =&gt; true, 'show_ui' =&gt; true, 'has_archive' =&gt; false, 'rewrite' =&gt; array('slug' =&gt; 'services', 'with_front' =&gt; false), 'query_var' =&gt;...
[ { "answer_id": 44266, "author": "dashaluna", "author_id": 1343, "author_profile": "https://wordpress.stackexchange.com/users/1343", "pm_score": 1, "selected": false, "text": "<p>Ok, so I got it working more or less correctly, although there is still a <strong>small problem</strong> left,...
2012/02/28
[ "https://wordpress.stackexchange.com/questions/43824", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1343/" ]
I've got a CPT called `Service` registered as following: ``` $args = array( 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'has_archive' => false, 'rewrite' => array('slug' => 'services', 'with_front' => false), 'query_var' => true, 'capability_type' => 'post', 'hier...
Ok, so I got it working more or less correctly, although there is still a **small problem** left, please read on.. Here is what I've got: in `fucntions.php`: **Rewrite rules** ``` add_action('init', 'my_rewrite_add_rewrites'); function my_rewrite_add_rewrites(){ add_rewrite_rule( '^services/([^/]+)/?$',...
43,834
<p>As I'm often involved with people who don't know anything about WordPress, a CMS or even the internet :) I try to hide things irrelevant (for them) as much as possible.</p> <p>Normally this would involve removing a meta box here and there, but I have to admit, I'm sort of stuck on the WP menu system.</p> <p>Would ...
[ { "answer_id": 44266, "author": "dashaluna", "author_id": 1343, "author_profile": "https://wordpress.stackexchange.com/users/1343", "pm_score": 1, "selected": false, "text": "<p>Ok, so I got it working more or less correctly, although there is still a <strong>small problem</strong> left,...
2012/02/28
[ "https://wordpress.stackexchange.com/questions/43834", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
As I'm often involved with people who don't know anything about WordPress, a CMS or even the internet :) I try to hide things irrelevant (for them) as much as possible. Normally this would involve removing a meta box here and there, but I have to admit, I'm sort of stuck on the WP menu system. Would anyone know perha...
Ok, so I got it working more or less correctly, although there is still a **small problem** left, please read on.. Here is what I've got: in `fucntions.php`: **Rewrite rules** ``` add_action('init', 'my_rewrite_add_rewrites'); function my_rewrite_add_rewrites(){ add_rewrite_rule( '^services/([^/]+)/?$',...
43,839
<p>I'm developing a very media-centered site with WordPress and am using the default categories and tags on uploaded media using, in part this plugin <a href="http://eddiemoya.com/plugins/media-categories-wordpress-plugin/" rel="nofollow" title="Media Categories">Media Categories</a>.</p> <p>I am displaying a sub-menu...
[ { "answer_id": 43888, "author": "Ibrahim", "author_id": 13653, "author_profile": "https://wordpress.stackexchange.com/users/13653", "pm_score": 0, "selected": false, "text": "<p>The sub_menu_page that you are trying to open is currently linked to the Tags sub_menu_page. Hopefully, someon...
2012/02/28
[ "https://wordpress.stackexchange.com/questions/43839", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8187/" ]
I'm developing a very media-centered site with WordPress and am using the default categories and tags on uploaded media using, in part this plugin [Media Categories](http://eddiemoya.com/plugins/media-categories-wordpress-plugin/ "Media Categories"). I am displaying a sub-menu item under 'Media' for each 'Categories' ...
To add to what @brasofilo answered 3 years ago, this is what is necessary in the current menu system (WP v4.5.1). ``` add_action( 'admin_head-edit-tags.php', 'modify_menu_highlight_wpse_43839' ); function modify_menu_highlight_wpse_43839() { if( 'post_tag' == $_GET['taxonomy'] ) { ?> <s...
43,848
<p>I am currently designing a musician's wordpress theme, and am looking to create a user-controlled dynamic gig list. I've done this before using PHP, but am wondering what the best way to do it in WordPress would be. </p> <p>I've tested a method using custom post types, but I feel like some users would be confused a...
[ { "answer_id": 43850, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 1, "selected": false, "text": "<p>I've used GigPress before and it works really well.</p>\n\n<p><a href=\"http://gigpress.com/\" rel=\"nofoll...
2012/02/28
[ "https://wordpress.stackexchange.com/questions/43848", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13545/" ]
I am currently designing a musician's wordpress theme, and am looking to create a user-controlled dynamic gig list. I've done this before using PHP, but am wondering what the best way to do it in WordPress would be. I've tested a method using custom post types, but I feel like some users would be confused about creat...
Create a Custom Post Type named "Gig" and WordPress will take care of the UI creation, then all that is left for you is to add a Metabox with the fields you want (date, venue, about). Here is a simple step by step guide: **First: Register Your Gig Post Type** ``` //register your custom post type gig add_action( 'ini...
43,852
<p>I am building a custom (child) theme and I want to style the first post of my loop in a different way than the others (bigger image, different position of some stuff). </p> <p>Which is the best way of doing it? My "problem" is that my theme has support for different post types and the style would vary depending on ...
[ { "answer_id": 43850, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 1, "selected": false, "text": "<p>I've used GigPress before and it works really well.</p>\n\n<p><a href=\"http://gigpress.com/\" rel=\"nofoll...
2012/02/28
[ "https://wordpress.stackexchange.com/questions/43852", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13644/" ]
I am building a custom (child) theme and I want to style the first post of my loop in a different way than the others (bigger image, different position of some stuff). Which is the best way of doing it? My "problem" is that my theme has support for different post types and the style would vary depending on the type o...
Create a Custom Post Type named "Gig" and WordPress will take care of the UI creation, then all that is left for you is to add a Metabox with the fields you want (date, venue, about). Here is a simple step by step guide: **First: Register Your Gig Post Type** ``` //register your custom post type gig add_action( 'ini...
43,862
<p>How can I get rid of the attachment URLs completely?</p> <p>I don't want users to have the ability to link an image to the Attachment URL when inserting an image, ever.</p> <p>I've done things in the past like redirect back to the attachment's parent ID and could even alter it to redirect to the full size file URL...
[ { "answer_id": 43863, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": false, "text": "<p>The form for the 'From Url' tab seems to be pretty much hard-coded, so I don't think there is away of rem...
2012/02/29
[ "https://wordpress.stackexchange.com/questions/43862", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11340/" ]
How can I get rid of the attachment URLs completely? I don't want users to have the ability to link an image to the Attachment URL when inserting an image, ever. I've done things in the past like redirect back to the attachment's parent ID and could even alter it to redirect to the full size file URL but I'd rather g...
The form for the 'From Url' tab seems to be pretty much hard-coded, so I don't think there is away of removing the 'Link Image To' field. However, for the Media Library tab you can remove the link field, with the following: ``` add_filter('attachment_fields_to_edit', 'my_attachment_fields_edit', 10, 2); function my_a...
43,884
<p>I am working on a project, which requires a page visit count to be shown on the single post.</p> <p>How can I do this in wordpress, I am guessing, that I have to store them in the same wordpress db?</p>
[ { "answer_id": 43886, "author": "krembo99", "author_id": 13256, "author_profile": "https://wordpress.stackexchange.com/users/13256", "pm_score": 0, "selected": false, "text": "<pre><code>function k99_post_hits( $id, $action ) {\n $k99_HitMetaField = '_k99_post_hits'; // Your Cus...
2012/02/29
[ "https://wordpress.stackexchange.com/questions/43884", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8912/" ]
I am working on a project, which requires a page visit count to be shown on the single post. How can I do this in wordpress, I am guessing, that I have to store them in the same wordpress db?
You can use custom fields for this. What I would suggest is setting up a shortcode you can put on any page you want to show the counter. For an extremely basic example with no HTML formatting, you can do this: ``` add_shortcode( 'examplecounter', 'counter_shortcode' ); function counter_shortcode( $atts, $content = nul...
43,896
<p>I am sorry if this is not clear, but I am using translated wordpress so I am translating some names back.</p> <p>I have pages in menu and when I click on some item it goes to that page. But I need f. e. page Item which has subpages SubItem1 and SubItem2. So in menu there would be shown Item, then I click on Item it...
[ { "answer_id": 48819, "author": "developdaly", "author_id": 3293, "author_profile": "https://wordpress.stackexchange.com/users/3293", "pm_score": 3, "selected": true, "text": "<p>I think you're asking how to make a menu with drop downs clickable rather than hoverable, so here's a very si...
2012/02/29
[ "https://wordpress.stackexchange.com/questions/43896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13656/" ]
I am sorry if this is not clear, but I am using translated wordpress so I am translating some names back. I have pages in menu and when I click on some item it goes to that page. But I need f. e. page Item which has subpages SubItem1 and SubItem2. So in menu there would be shown Item, then I click on Item it does not ...
I think you're asking how to make a menu with drop downs clickable rather than hoverable, so here's a very simple example of what I think you want: <http://jsfiddle.net/pk5Bx/> **HTML** ``` <div id="navigation"> <ul> <li class="current_page_parent"><a href="#">Top level 1</a> <ul> ...
43,907
<p>I have added a custom taxonomy to my posts, that will get a value by iteself on post_update action. What will be the SQL query to update all my posts at once so that the taxonomy value is added to each of them. Also will updating from SQL call the update_post action of wordpress?</p>
[ { "answer_id": 43962, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 0, "selected": false, "text": "<p>I would not do this with SQL. I would do this with <code>WP_Query</code>. You can use <a href=\"http://codex....
2012/02/29
[ "https://wordpress.stackexchange.com/questions/43907", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13661/" ]
I have added a custom taxonomy to my posts, that will get a value by iteself on post\_update action. What will be the SQL query to update all my posts at once so that the taxonomy value is added to each of them. Also will updating from SQL call the update\_post action of wordpress?
I got the same need, personally I used `wp_set_object_terms` after a WP\_Query resquest on all of my custom post type. I suppose you could replace `my_custom_type` with `post` in the following quote of my code: ``` $my_query = array( 'post_type' => array( 'post', 'my_custom_type' ) ); $the_query = new WP_Query( $m...
43,909
<p>I got the following question:</p> <p>When I go to a WooCommerce category, the link displays like this:</p> <pre><b>http://www.example.com/product-category/</b>category/</pre> <p>Where the bold text is the link like it is and the rest is the product category that needs to be shown.</p> <p>When i go into WooCommer...
[ { "answer_id": 43962, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 0, "selected": false, "text": "<p>I would not do this with SQL. I would do this with <code>WP_Query</code>. You can use <a href=\"http://codex....
2012/02/29
[ "https://wordpress.stackexchange.com/questions/43909", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13662/" ]
I got the following question: When I go to a WooCommerce category, the link displays like this: ``` **http://www.example.com/product-category/**category/ ``` Where the bold text is the link like it is and the rest is the product category that needs to be shown. When i go into WooCommerce settings and I go to the pa...
I got the same need, personally I used `wp_set_object_terms` after a WP\_Query resquest on all of my custom post type. I suppose you could replace `my_custom_type` with `post` in the following quote of my code: ``` $my_query = array( 'post_type' => array( 'post', 'my_custom_type' ) ); $the_query = new WP_Query( $m...
43,913
<p>I need some help! I'm trying to rewrite this...</p> <pre><code>localhost/blog/?c=var to-&gt; localhost/blog/var </code></pre> <p>But seems there is some problem... <strong>I get a 500</strong> :( I also believe there is some conflict with the default rules of wordpress too. This is my entire htaccess:</p> <pre...
[ { "answer_id": 43962, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 0, "selected": false, "text": "<p>I would not do this with SQL. I would do this with <code>WP_Query</code>. You can use <a href=\"http://codex....
2012/02/29
[ "https://wordpress.stackexchange.com/questions/43913", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13665/" ]
I need some help! I'm trying to rewrite this... ``` localhost/blog/?c=var to-> localhost/blog/var ``` But seems there is some problem... **I get a 500** :( I also believe there is some conflict with the default rules of wordpress too. This is my entire htaccess: ``` <IfModule mod_rewrite.c> RewriteEngine On Rewr...
I got the same need, personally I used `wp_set_object_terms` after a WP\_Query resquest on all of my custom post type. I suppose you could replace `my_custom_type` with `post` in the following quote of my code: ``` $my_query = array( 'post_type' => array( 'post', 'my_custom_type' ) ); $the_query = new WP_Query( $m...
43,928
<p>What's the proper way to add a favicon in Wordpress <strong>without a plugin</strong>?</p> <p>Do I just place a file called <code>favicon.ico</code> with my icon into the root of my site?</p> <p>Do I also need this code?</p> <pre><code>&lt;link rel="shortcut icon" href="http://example.com/favicon.ico" type="image...
[ { "answer_id": 43932, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 4, "selected": false, "text": "<p>I usually put the icons in an images folder inside my theme so I'd use</p>\n\n<pre><code>function kia_add...
2012/02/29
[ "https://wordpress.stackexchange.com/questions/43928", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13196/" ]
What's the proper way to add a favicon in Wordpress **without a plugin**? Do I just place a file called `favicon.ico` with my icon into the root of my site? Do I also need this code? ``` <link rel="shortcut icon" href="http://example.com/favicon.ico" type="image/x-icon" /> ``` Some say it's this code: ``` <link r...
I usually put the icons in an images folder inside my theme so I'd use ``` function kia_add_favicon(){ ?> <!-- Custom Favicons --> <link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri();?>/images/favicon.ico"/> <link rel="apple-touch-icon" href="<?php echo get_stylesheet_directory_uri();...
43,957
<p>I am using this php code to display a list of gigs, which is a custom post type. I want to order it by the 'when' value of the post, and omit the gigs that have already happened. How can I modify the following code to get that happening?</p> <pre><code> &lt;?php $args2 = array( 'post_type' =&gt; 'gig', ...
[ { "answer_id": 43964, "author": "GhostToast", "author_id": 13676, "author_profile": "https://wordpress.stackexchange.com/users/13676", "pm_score": 0, "selected": false, "text": "<p>After a little research, I'm thinking the ability to \"unpublish\" or expire a post might be more up your a...
2012/02/29
[ "https://wordpress.stackexchange.com/questions/43957", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13545/" ]
I am using this php code to display a list of gigs, which is a custom post type. I want to order it by the 'when' value of the post, and omit the gigs that have already happened. How can I modify the following code to get that happening? ``` <?php $args2 = array( 'post_type' => 'gig', 'numberposts' => -1...
the best way ============ If you input the gig time as a unix timestamp (using `strtotime()`), then you can use `WP_Query`'s `meta_value_num` in the `orderby` element to set the order. You can also use `WP_Query`'s `meta_query` to only get posts that have a date that occur in the future. the other way ============= ...
43,970
<p>I want to use the <code>menu order</code> attribute to control ordering for a custom post type that's going to be used for a specific purpose.</p> <p>It's easy enough to add this to the CPT via <code>supports =&gt; array('page-attributes')</code> but how do I expose the menu order value on the admin listing screen ...
[ { "answer_id": 43972, "author": "ungestaltbar", "author_id": 12449, "author_profile": "https://wordpress.stackexchange.com/users/12449", "pm_score": -1, "selected": false, "text": "<p>You have to register your CPT with:</p>\n\n<pre><code>'hierachical' =&gt; true\n</code></pre>\n" }, ...
2012/02/29
[ "https://wordpress.stackexchange.com/questions/43970", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/490/" ]
I want to use the `menu order` attribute to control ordering for a custom post type that's going to be used for a specific purpose. It's easy enough to add this to the CPT via `supports => array('page-attributes')` but how do I expose the menu order value on the admin listing screen for this CPT?
OK - in the end turned out to be fairly simple - as I'd had some kind of mental block - `menu_order` is a variable in the `$post` object (thanks to @brady for reminding me of that). @scribu's [post on creating sortable column values](http://scribu.net/wordpress/custom-sortable-columns.html) then gives the rest. So, a...
43,977
<p>To improve site/page performance, I added the following code to accept headers:</p> <pre><code>&lt;php flush(); ?&gt; </code></pre> <p>It works, but perhaps not as well as it could. Any advice?</p> <p>I also tried to leverage browser caching, using the following code:</p> <pre><code># Begin Expires Caching &lt;I...
[ { "answer_id": 43981, "author": "Dougal Campbell", "author_id": 65, "author_profile": "https://wordpress.stackexchange.com/users/65", "pm_score": 3, "selected": false, "text": "<p>The most common thing to try is a content caching plugin like <a href=\"http://wordpress.org/extend/plugins/...
2012/02/29
[ "https://wordpress.stackexchange.com/questions/43977", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13719/" ]
To improve site/page performance, I added the following code to accept headers: ``` <php flush(); ?> ``` It works, but perhaps not as well as it could. Any advice? I also tried to leverage browser caching, using the following code: ``` # Begin Expires Caching <IfModule mod_expires.c> ExpiresActive On ExpiresByType...
The most common thing to try is a content caching plugin like [W3 Total Cache](http://wordpress.org/extend/plugins/w3-total-cache/) or [WP Super Cache](http://wordpress.org/extend/plugins/wp-super-cache/). Both will cache entire pages to disk, and will allow the Apache web server to completely bypass PHP processing for...
43,986
<p>I have set some custom field 'artist' and 'song-name' displaying like:</p> <pre><code>Artist: &lt;user input&gt; Song Name: &lt;user input&gt; </code></pre> <p>My question, how do you make the on artist and song name into a clickable link? Such that when the artist name is clicked for example, it will bring up th...
[ { "answer_id": 43991, "author": "Matthew Muro", "author_id": 1511, "author_profile": "https://wordpress.stackexchange.com/users/1511", "pm_score": 3, "selected": true, "text": "<p>This is better accomplished by registering a new taxonomy. You get all of the advantages of categories and ...
2012/02/29
[ "https://wordpress.stackexchange.com/questions/43986", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3305/" ]
I have set some custom field 'artist' and 'song-name' displaying like: ``` Artist: <user input> Song Name: <user input> ``` My question, how do you make the on artist and song name into a clickable link? Such that when the artist name is clicked for example, it will bring up the page with all posts of that artist na...
This is better accomplished by registering a new taxonomy. You get all of the advantages of categories and tags without the hassle of custom fields. Codex: [register\_taxonomy](http://codex.wordpress.org/Function_Reference/register_taxonomy) Tutorial: [How to Create Custom Taxonomies in WordPress 3](http://wp.smashin...
44,009
<p>Hello I have a query that gets a post with id=x and it works but it leaves out the comment box.</p> <p>Is there a way to add "get comment box" to the query?</p> <pre><code>&lt;?php $post_id = 104; $queried_post = get_post($post_id); $content = $queried_post-&gt;post_content; $content = apply_filters('the_conte...
[ { "answer_id": 44011, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 1, "selected": true, "text": "<p>First of all, welcome to WPSE!</p>\n\n<p>By default, the comment box does not come with the post object, what you a...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44009", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13698/" ]
Hello I have a query that gets a post with id=x and it works but it leaves out the comment box. Is there a way to add "get comment box" to the query? ``` <?php $post_id = 104; $queried_post = get_post($post_id); $content = $queried_post->post_content; $content = apply_filters('the_content', $content); $content =...
First of all, welcome to WPSE! By default, the comment box does not come with the post object, what you are looking for is the [`comments_template`](http://codex.wordpress.org/Function_Reference/comments_template) function. It should be as simple as changing your code to this: ``` <?php $post_id = 104; $queried_po...
44,016
<p>I have been experiencing too many following errors in my apache logs.</p> <p><strong>PHP Fatal error: Cannot call overloaded function for non-object in wp-includes/capabilities.php on line 1187</strong></p> <p>This is inside function current_user_can( $capability ) and line 1187 is as follows:</p> <pre><code>$cu...
[ { "answer_id": 44682, "author": "anmari", "author_id": 3569, "author_profile": "https://wordpress.stackexchange.com/users/3569", "pm_score": 0, "selected": false, "text": "<p>I have found that usually these capability problems end up being in a plugin somewhere (hard to find since the er...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44016", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13700/" ]
I have been experiencing too many following errors in my apache logs. **PHP Fatal error: Cannot call overloaded function for non-object in wp-includes/capabilities.php on line 1187** This is inside function current\_user\_can( $capability ) and line 1187 is as follows: ``` $current_user = wp_get_current_user(); ```...
This issue usually stems from PHP configuration issues, APC caching, and/or a call to an incompatible XML library. From what I've seen, it is usually a combination of php 5.2.X and caching. If you're using caching on your site, try switching from APC/memcached cache to disk caching and see if it clears up. 9/10 times...
44,020
<p>I'm looking for a function that can redirect users when they logout to the current page. I'm looking for a code I can use in <code>functions.php</code>?</p>
[ { "answer_id": 44021, "author": "Vince P", "author_id": 1859, "author_profile": "https://wordpress.stackexchange.com/users/1859", "pm_score": 2, "selected": false, "text": "<p>Have a look here - <a href=\"http://codex.wordpress.org/Function_Reference/wp_logout_url\" rel=\"nofollow\">http...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44020", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12727/" ]
I'm looking for a function that can redirect users when they logout to the current page. I'm looking for a code I can use in `functions.php`?
Using this code in the `functions.php` does the trick: ``` function wpse_44020_logout_redirect( $logouturl, $redir ) { return $logouturl . '&amp;redirect_to=' . get_permalink(); } add_filter( 'logout_url', 'wpse_44020_logout_redirect', 10, 2 ); ``` Note - The above code works only on non-admin pages. To make thi...
44,022
<p>my website www.saoyuying.com (the site is in Chinese :)) is included in Google's malware blacklist yesterday. But I didn't find any unusual files on the server. Google's report mentioned that </p> <p>"Some of the URLs on this site redirect browsers to web pages that install malware. This indicates that the server(s...
[ { "answer_id": 44025, "author": "Vince P", "author_id": 1859, "author_profile": "https://wordpress.stackexchange.com/users/1859", "pm_score": 0, "selected": false, "text": "<p>There is nothing out of the ordinary there, standard WP .htaccess file</p>\n" }, { "answer_id": 44027, ...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44022", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13703/" ]
my website www.saoyuying.com (the site is in Chinese :)) is included in Google's malware blacklist yesterday. But I didn't find any unusual files on the server. Google's report mentioned that "Some of the URLs on this site redirect browsers to web pages that install malware. This indicates that the server(s) that hos...
Redirection can happen in many different shapes or forms. Sometimes it is due to an injection into a page or sometimes pages. Usually a snippet of JavaScript or an iFrame is injected into a page which redirects a user when they load a page. The most common form of redirection hack is usually some kind of SQL injection....
44,026
<p>I've actually found a solution to my problem here: <a href="https://wordpress.stackexchange.com/questions/7456/altering-the-appearance-of-custom-taxonomy-inputs">Altering the appearance of custom taxonomy inputs</a> but I wanted to ask a followup question, and it seems I couldn't ask in that thread.</p> <p>Here's t...
[ { "answer_id": 44034, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": false, "text": "<p>The most straightforward way would be to to de-register the taxonomy's metabox and replace it with your o...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44026", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3305/" ]
I've actually found a solution to my problem here: [Altering the appearance of custom taxonomy inputs](https://wordpress.stackexchange.com/questions/7456/altering-the-appearance-of-custom-taxonomy-inputs) but I wanted to ask a followup question, and it seems I couldn't ask in that thread. Here's the code provided on t...
The most straightforward way would be to to de-register the taxonomy's metabox and replace it with your own custom metabox. Below is my attempt. There are some drawbacks though, without adding in some javascript, I was unable to replicate WordPress 'add new term' feature, consequently you can only select pre-existing c...
44,046
<p>I am in the process of writing my first plugin and my call to the <code>plugin_basename(__FILE__)</code> function results in a:</p> <p>PHP Fatal error: Call to undefined function plugin_basename()</p> <p>My plugin resides in a directory of its own under the standard wp-content/plugins/. I am also using wordpress ...
[ { "answer_id": 44034, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": false, "text": "<p>The most straightforward way would be to to de-register the taxonomy's metabox and replace it with your o...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44046", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11465/" ]
I am in the process of writing my first plugin and my call to the `plugin_basename(__FILE__)` function results in a: PHP Fatal error: Call to undefined function plugin\_basename() My plugin resides in a directory of its own under the standard wp-content/plugins/. I am also using wordpress 3.3.1 and have looked at the...
The most straightforward way would be to to de-register the taxonomy's metabox and replace it with your own custom metabox. Below is my attempt. There are some drawbacks though, without adding in some javascript, I was unable to replicate WordPress 'add new term' feature, consequently you can only select pre-existing c...
44,047
<p>I'm registering my CPT like so:</p> <pre><code>$args = array( 'labels' =&gt; $labels, 'public' =&gt; true, 'hierarchical' =&gt; false, 'rewrite' =&gt; array( 'with_front' =&gt; false, 'slug' =&gt; 'news/events' ), 'supports' =&gt; array( 'title', 'editor', 'thumbnail' ) ); re...
[ { "answer_id": 44054, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": false, "text": "<p>Try this First add to <code>%event_id%</code> to your slug:</p>\n\n<pre><code>$args = array(\n 'labels' =&...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44047", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
I'm registering my CPT like so: ``` $args = array( 'labels' => $labels, 'public' => true, 'hierarchical' => false, 'rewrite' => array( 'with_front' => false, 'slug' => 'news/events' ), 'supports' => array( 'title', 'editor', 'thumbnail' ) ); register_post_type('events',$args); ...
@Bainternet - your answer didn't fully work but I did some more searching and was able to piece this filter together that did work: ``` add_filter('post_type_link', 'custom_event_permalink', 1, 3); function custom_event_permalink($post_link, $id = 0, $leavename) { if ( strpos('%event_id%', $post_link) === 'FALSE' ...
44,067
<p>I have a list of attachment IDs which are built using this array:</p> <pre><code>$all_images = get_posts( array( 'post_type' =&gt; 'attachment', 'numberposts' =&gt; -1, ) ); </code></pre> <p>Is it possible to take the image ID from this list and find the Title and permalink of the POST the image is attached to? </...
[ { "answer_id": 44069, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 4, "selected": true, "text": "<p>So, if you start with this:</p>\n\n<pre><code>$all_images = get_posts( array(\n'post_type' =&gt; 'attachment...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44067", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12920/" ]
I have a list of attachment IDs which are built using this array: ``` $all_images = get_posts( array( 'post_type' => 'attachment', 'numberposts' => -1, ) ); ``` Is it possible to take the image ID from this list and find the Title and permalink of the POST the image is attached to? I know it's feasible because the...
So, if you start with this: ``` $all_images = get_posts( array( 'post_type' => 'attachment', 'numberposts' => -1, ) ); ``` Then `$all_images` is an array of *objects*. Step through each one: ``` foreach ( $all_images as $image ) {} ``` Inside that foreach, you can use the normal parameters available to the `$post...
44,068
<p>If you want a custom admin page for a taxonomy, you can set <code>'show_ui' =&gt; false</code> when you register it to suppress the default admin page and then create a new admin page to replace it.</p> <p>However <code>edit-tags.php?taxonomy=taxonomy-slug</code> still takes you to the 'hidden' default admin page. ...
[ { "answer_id": 44924, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>Do a simple redirect:</p>\n\n<pre><code>if ( CONDITION_SEE_BELOW )\n{\n wp_redirect( admin_url( 'edit.php?post_t...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44068", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9364/" ]
If you want a custom admin page for a taxonomy, you can set `'show_ui' => false` when you register it to suppress the default admin page and then create a new admin page to replace it. However `edit-tags.php?taxonomy=taxonomy-slug` still takes you to the 'hidden' default admin page. Is there way of directing it instea...
Not sure why I didn't think of this earlier. I suppose I was hoping for a way to 'hijack' the default page to display something else... Anyway following my original method: > > If you want a custom admin page for a taxonomy, you can set 'show\_ui' => false when you register it to suppress the default admin page and t...
44,072
<p>Having some issues on the tag.php page. </p> <p>Right now it just give me a "nothing to show" If I have no query it shows posts, but I want to change the number of posts per page.</p> <p>Changing the reading settings in the admin is not an option in this case, so I'm looking for template tag ideas only. </p> <p>A...
[ { "answer_id": 44206, "author": "ifdion", "author_id": 6383, "author_profile": "https://wordpress.stackexchange.com/users/6383", "pm_score": 0, "selected": false, "text": "<p>Hope this help</p>\n\n<pre><code>$story_type = $_GET['type'];\nif ( get_query_var('paged') ) {\n $paged = get_...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44072", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8574/" ]
Having some issues on the tag.php page. Right now it just give me a "nothing to show" If I have no query it shows posts, but I want to change the number of posts per page. Changing the reading settings in the admin is not an option in this case, so I'm looking for template tag ideas only. Any suggestions on ways t...
After some other attempts I Found the syntax solution I was looking for. Just sharing. ``` <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts($query_string .'&posts_per_page=10&paged=' . $paged); if (have_posts()) : while (have_posts()) : the_post(); ?> ```
44,078
<p>The theme I am using does most all the SEO stuff that I want it to with the exception of tweaking the titles on a post by post basis, and the ability for me to write my own meta descriptions for each post. I just looked at my source code and I noticed lots of duplicate code. I'm wondering what the best practice is t...
[ { "answer_id": 44081, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 0, "selected": false, "text": "<p>If you want to use that plugin, just remove duplicate functionality from the theme. Or disable the plugin i...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44078", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13390/" ]
The theme I am using does most all the SEO stuff that I want it to with the exception of tweaking the titles on a post by post basis, and the ability for me to write my own meta descriptions for each post. I just looked at my source code and I noticed lots of duplicate code. I'm wondering what the best practice is to c...
As far as my usage with Yoast's WordPress SEO plugin goes, I thought always assumed the plugin simply replaced any existing code with what it generates for that same purpose. If you are using the plugin and don't want to disable it, then simply go into your header.php file and delete/comment-out any meta tags that are...
44,089
<p>Edit: Thanks for your replies, guys. This is exactly what I was after. You each brought up some good points. I think I'll stick with using constants.</p> <p>This is really a best practices/performance question.</p> <p>I'm mainly concerned with the following functions:</p> <pre><code>get_template_directory_uri() g...
[ { "answer_id": 44098, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>I don't think there is a right or best way to do that (there are wrong ways), if you use constants you save f...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44089", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2807/" ]
Edit: Thanks for your replies, guys. This is exactly what I was after. You each brought up some good points. I think I'll stick with using constants. This is really a best practices/performance question. I'm mainly concerned with the following functions: ``` get_template_directory_uri() get_template_directory() get_...
I think there is **zero** performance issue regarding multiple uses of `get_template_directory()` (or any of its siblings). The return values of these functions are part of the cache. Multiple calls to these functions do not incur multiple database hits.
44,092
<p>How would I modify my WP_Query in order to get a custom meta box value instead of a custom field one like I currently do?</p> <p>This is how my query looks like:</p> <pre><code>&lt;?php $today = date("Y-m-d",mktime(0,0,0,date("m"),date("d"),date("Y"))); $the_query = new WP_Query( array ('showposts' =&gt; 10, ...
[ { "answer_id": 44100, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 3, "selected": true, "text": "<p>Custom meta boxes store values in the same way as custom fields, they just have a prettier UI.</p>\n\n<p>Y...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44092", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9718/" ]
How would I modify my WP\_Query in order to get a custom meta box value instead of a custom field one like I currently do? This is how my query looks like: ``` <?php $today = date("Y-m-d",mktime(0,0,0,date("m"),date("d"),date("Y"))); $the_query = new WP_Query( array ('showposts' => 10, 'post_type' =...
Custom meta boxes store values in the same way as custom fields, they just have a prettier UI. You shouldn't need to modify your query in anyway other than knowing the `key` under which the custom meta box stores it's values. If you're using a plugin to generate the custom meta box, you'll have to dig into its interna...
44,131
<p>I have several custom media sizes we always use. </p> <p>vertical: 95x117, 130x160 horizontal: 440x304, 220x152 home: 260x160</p> <p>Is there anyway to set the thumbnail, medium and large to vertical parameters and horizontal ones? Or is it better to leave the defaults (150x150, 300, 1024) so that I can set the si...
[ { "answer_id": 44132, "author": "Dr Deo", "author_id": 9335, "author_profile": "https://wordpress.stackexchange.com/users/9335", "pm_score": 0, "selected": false, "text": "<p>Some media size names are <a href=\"http://codex.wordpress.org/Function_Reference/add_image_size#Reserved_Image_S...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44131", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13725/" ]
I have several custom media sizes we always use. vertical: 95x117, 130x160 horizontal: 440x304, 220x152 home: 260x160 Is there anyway to set the thumbnail, medium and large to vertical parameters and horizontal ones? Or is it better to leave the defaults (150x150, 300, 1024) so that I can set the sizes using width a...
I would **not** alter the core intermediate image sizes. If you have custom image sizes, register them using `add_image_size()`. e.g. ``` function mytheme_add_custom_image_sizes() { // Add "vertical" image add_image_size( 'vertical-a', 95, 117, true ); add_image_size( 'vertical-b', 130, 160, true ); /...
44,135
<p>I'm trying to load a CSS file for my WordPress post area, but having no luck. I have read over the wp_enqueue_style function and came up with the code below, but it doesn't load up. Is there a tag or character missing from my code. I have a custom write panel when a user post that I want to style with the CSS file. ...
[ { "answer_id": 44138, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 4, "selected": true, "text": "<p>Just hook your callback into <code>admin_print_styles</code>, i.e.:</p>\n\n<pre><code>add_action( 'admin_pri...
2012/03/01
[ "https://wordpress.stackexchange.com/questions/44135", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13735/" ]
I'm trying to load a CSS file for my WordPress post area, but having no luck. I have read over the wp\_enqueue\_style function and came up with the code below, but it doesn't load up. Is there a tag or character missing from my code. I have a custom write panel when a user post that I want to style with the CSS file. A...
Just hook your callback into `admin_print_styles`, i.e.: ``` add_action( 'admin_print_styles', 'mytheme_add_init' ); ``` Alternately, you could add an `is_admin()` conditional wrapper inside your callback, and hook into `wp_enqueue_scripts`: ``` function mytheme_add_init() { if ( is_admin() ) { $file_di...
44,184
<p>I did these tree tutorials to create custom metaboxes.</p> <ul> <li>wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-1-intro-and-basic-fields/</li> <li>wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-2-advanced-fields/</li> <li>wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-3-extra-fie...
[ { "answer_id": 44714, "author": "Cristian", "author_id": 2264, "author_profile": "https://wordpress.stackexchange.com/users/2264", "pm_score": 2, "selected": false, "text": "<p>After reviewing your code there are a couple of things you need to change depending on where the meta content i...
2012/03/02
[ "https://wordpress.stackexchange.com/questions/44184", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13746/" ]
I did these tree tutorials to create custom metaboxes. * wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-1-intro-and-basic-fields/ * wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-2-advanced-fields/ * wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-3-extra-fields/ but i don't know how t...
After reviewing your code there are a couple of things you need to change depending on where the meta content is being held. If you try ``` $meta = get_post_meta( get_the_ID(), 'custom_text', TRUE ); echo 'The meta content is: ' . $meta;` ``` That should give you the appropriate meta. You are calling this functi...
44,192
<p>I am making a website about world countries and cities.Every Post will be a city name and will have a category of a country.</p> <p>In the beggining of the post I want to have a brief description of the country instead of writing the same description to 20 or more cities.</p> <p>Is it possible that wordpress would...
[ { "answer_id": 44196, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": true, "text": "<p>Yup, inside the loop (in single.php for example) you can use <a href=\"http://codex.wordpress.org/Function...
2012/03/02
[ "https://wordpress.stackexchange.com/questions/44192", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13578/" ]
I am making a website about world countries and cities.Every Post will be a city name and will have a category of a country. In the beggining of the post I want to have a brief description of the country instead of writing the same description to 20 or more cities. Is it possible that wordpress would see the category...
Yup, inside the loop (in single.php for example) you can use [`get_the_terms`](http://codex.wordpress.org/Function_Reference/get_the_terms) to retrieve an array of terms (countries in this case) associated with that post. This will always be an array (or false /error if something has gone wrong) even if there is only o...
44,202
<p>I've setup a CPT to act the same ways as posts but used to post event details.</p> <p>Thing is that some of the posts are in the future and such have a future date set on them. Problem is that normal users cannot see these posts.</p> <p>So:</p> <ul> <li>How do I alter archive-events.php to list future posts too? ...
[ { "answer_id": 44213, "author": "Scott", "author_id": 4610, "author_profile": "https://wordpress.stackexchange.com/users/4610", "pm_score": 4, "selected": true, "text": "<p>I've been able to solve this myself. My entire code for registering the CPT:</p>\n\n<pre><code>&lt;?php\nadd_action...
2012/03/02
[ "https://wordpress.stackexchange.com/questions/44202", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
I've setup a CPT to act the same ways as posts but used to post event details. Thing is that some of the posts are in the future and such have a future date set on them. Problem is that normal users cannot see these posts. So: * How do I alter archive-events.php to list future posts too? Showing far future posts fir...
I've been able to solve this myself. My entire code for registering the CPT: ``` <?php add_action( 'init', 'events_post_type_register' ); function events_post_type_register() { $post_type = "events"; $labels = array( 'name' => _x('Events', 'post type general name', 'project_X'), 'singular_nam...
44,208
<p>I need to modify the following code to show a placeholder if there is no featured image available.</p> <p>I understand that I need to add a <code>if</code> statement in the following code but wasn't sure of the exact coding I needed. Obviously in plain english it's going to be along the lines of if there is a thumb...
[ { "answer_id": 44212, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 4, "selected": true, "text": "<p>Misspelling of <strong>thumbnail</strong> (thumnail) in the if statement. </p>\n\n<p>Also <a href=\"http:/...
2012/03/02
[ "https://wordpress.stackexchange.com/questions/44208", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1859/" ]
I need to modify the following code to show a placeholder if there is no featured image available. I understand that I need to add a `if` statement in the following code but wasn't sure of the exact coding I needed. Obviously in plain english it's going to be along the lines of if there is a thumbnail show it, if not ...
Misspelling of **thumbnail** (thumnail) in the if statement. Also [`get_the_post_thumbnail`](http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail) does echo the thumbnail, but just returns the html. You need to echo it. Also, for checking if a post has a thumbnail, you can use [`has_post_thumbnail`](...
44,227
<p>I have on frontend search box, I have implement autocomplete for it, and when I'm logged in, it works great for me.</p> <p>But when I'm not logged in, I get 302 as result of ajax call, response headers have location in it, so it is trying to redirect, I do not know why. I notice a lot of posts around this issue, but...
[ { "answer_id": 44234, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 3, "selected": true, "text": "<p>Sounds like you have an issue with another plugin or function that is trying to prevent non logged in or non admin ...
2012/03/02
[ "https://wordpress.stackexchange.com/questions/44227", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1147/" ]
I have on frontend search box, I have implement autocomplete for it, and when I'm logged in, it works great for me. But when I'm not logged in, I get 302 as result of ajax call, response headers have location in it, so it is trying to redirect, I do not know why. I notice a lot of posts around this issue, but none of ...
Sounds like you have an issue with another plugin or function that is trying to prevent non logged in or non admin users access to the wp-admin area so it is redirecting from wp-admin/admin-ajax.php and giving you your 302 response. You need to find the code that is doing this and add a conditional not to redirect if ...
44,249
<p>In a multisite setup, you can associate an existing user in the network to a site. The standard wp_insert_user function doesn't seem to have the proper logic to handle. How would I do this for multisite?</p> <p>Also, is there a way to see if a given user is already associated with a particular site?</p>
[ { "answer_id": 44261, "author": "ltfishie", "author_id": 12388, "author_profile": "https://wordpress.stackexchange.com/users/12388", "pm_score": 3, "selected": true, "text": "<p>After looking the code the create user, i found that that I can do:</p>\n\n<pre><code>$userdata = get_user_by(...
2012/03/02
[ "https://wordpress.stackexchange.com/questions/44249", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12388/" ]
In a multisite setup, you can associate an existing user in the network to a site. The standard wp\_insert\_user function doesn't seem to have the proper logic to handle. How would I do this for multisite? Also, is there a way to see if a given user is already associated with a particular site?
After looking the code the create user, i found that that I can do: ``` $userdata = get_user_by('login', 'user1'); add_existing_user_to_blog( array( 'user_id' => $userdata->ID, 'role' => 'author')); ``` Fix: was missing closing )
44,268
<p>I am developing a child theme based on the twentyten theme and now i notice the featured image in the WP backend (wp-admin) shows the wrong scaled image. </p> <p>It shows the "twenty ten" size, meaning an image scaled to x198.</p> <p>How do i show the featured image of my chosen size???</p> <p>regards,</p>
[ { "answer_id": 44278, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": true, "text": "<p>First: why do you care the size of the thumbnail displayed in the \"Featured Image\" meta box on the Edit Po...
2012/03/02
[ "https://wordpress.stackexchange.com/questions/44268", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9936/" ]
I am developing a child theme based on the twentyten theme and now i notice the featured image in the WP backend (wp-admin) shows the wrong scaled image. It shows the "twenty ten" size, meaning an image scaled to x198. How do i show the featured image of my chosen size??? regards,
First: why do you care the size of the thumbnail displayed in the "Featured Image" meta box on the Edit Post screen? Second: that image size isn't defined by Twenty Ten (or any other Theme). It's defined by core, and is actually simply calling the original image size, and scaling it. ### Edit Whoops; that was wrong....
44,270
<p>I have a custom post type, Jobs, with 3 taxonomies under it in the Admin menu. </p> <p>One of the taxonomies is Status, which is either Active or Closed. I want a menu item under Jobs for Active Jobs. I created it with this code</p> <pre><code>add_submenu_page( 'edit.php?post_type=jobs', 'Active Jobs', ...
[ { "answer_id": 75411, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 3, "selected": false, "text": "<p>I made this work using the Posts menus and the Draft status. It relies on jQuery to modify the list item cla...
2012/03/02
[ "https://wordpress.stackexchange.com/questions/44270", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3175/" ]
I have a custom post type, Jobs, with 3 taxonomies under it in the Admin menu. One of the taxonomies is Status, which is either Active or Closed. I want a menu item under Jobs for Active Jobs. I created it with this code ``` add_submenu_page( 'edit.php?post_type=jobs', 'Active Jobs', 'Active Jobs', '...
I made this work using the Posts menus and the Draft status. It relies on jQuery to modify the list item classes. Adapt to work with your post type and URLs. This is the result: ![extra drafts submenu item](https://i.stack.imgur.com/oL9Ax.png) ``` add_action( 'admin_menu', 'wpse_44270_menu_admin' ); add_action( 'a...
44,280
<p>Hey i installed buddypress and wanted to know if there is a theme function o can add so that on my theme it says </p> <blockquote> <p>Login • Sign Up</p> </blockquote> <p>and when they login it says</p> <blockquote> <p>My Profile • Sign Out</p> </blockquote>
[ { "answer_id": 75411, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 3, "selected": false, "text": "<p>I made this work using the Posts menus and the Draft status. It relies on jQuery to modify the list item cla...
2012/03/03
[ "https://wordpress.stackexchange.com/questions/44280", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13556/" ]
Hey i installed buddypress and wanted to know if there is a theme function o can add so that on my theme it says > > Login • Sign Up > > > and when they login it says > > My Profile • Sign Out > > >
I made this work using the Posts menus and the Draft status. It relies on jQuery to modify the list item classes. Adapt to work with your post type and URLs. This is the result: ![extra drafts submenu item](https://i.stack.imgur.com/oL9Ax.png) ``` add_action( 'admin_menu', 'wpse_44270_menu_admin' ); add_action( 'a...
44,282
<p>I've got an <code>event</code> custom post type, and using filters, I've configured the archive page to show only event in the future, and in chronological order based on a meta value (start date).</p> <p>I want to make a second archive page to show events in the past, complete with pagination, ordered reverse chro...
[ { "answer_id": 44343, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 1, "selected": false, "text": "<p>I would use a query parameter, something like <code>?time=future</code> maybe, to shift your query. The diffe...
2012/03/03
[ "https://wordpress.stackexchange.com/questions/44282", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6843/" ]
I've got an `event` custom post type, and using filters, I've configured the archive page to show only event in the future, and in chronological order based on a meta value (start date). I want to make a second archive page to show events in the past, complete with pagination, ordered reverse chronologically on the sa...
This is what I went with. It creates a second archive for *past events*. It shows upcoming events in the main event archive, and old events in the *past events* page. Sorting is ascending for the main archive (so you see the next upcoming event first), and descending for the *past events* page, so you see the most rece...
44,286
<p>I am trying to create my first plugin. So far it actually works fine but for one error:</p> <p>I get a 'Headers Already Sent' PHP message when I try to login to wp-admin.</p> <p>If I remove the plugin file from the wpcontent/plugins directory, login as usual, then replace the plugin file it works fine - this just ...
[ { "answer_id": 44343, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 1, "selected": false, "text": "<p>I would use a query parameter, something like <code>?time=future</code> maybe, to shift your query. The diffe...
2012/03/03
[ "https://wordpress.stackexchange.com/questions/44286", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13767/" ]
I am trying to create my first plugin. So far it actually works fine but for one error: I get a 'Headers Already Sent' PHP message when I try to login to wp-admin. If I remove the plugin file from the wpcontent/plugins directory, login as usual, then replace the plugin file it works fine - this just seems to occur wi...
This is what I went with. It creates a second archive for *past events*. It shows upcoming events in the main event archive, and old events in the *past events* page. Sorting is ascending for the main archive (so you see the next upcoming event first), and descending for the *past events* page, so you see the most rece...
44,290
<p>I'm working on a WordPress site we have for some software my lab is developing. What I'd like to do is add a page that would allow collaborating groups to upload their data to us for testing, but that would be hidden from anyone else visiting the site (i.e. the collaborators would have to be logged in to see the pag...
[ { "answer_id": 44343, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 1, "selected": false, "text": "<p>I would use a query parameter, something like <code>?time=future</code> maybe, to shift your query. The diffe...
2012/03/03
[ "https://wordpress.stackexchange.com/questions/44290", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13768/" ]
I'm working on a WordPress site we have for some software my lab is developing. What I'd like to do is add a page that would allow collaborating groups to upload their data to us for testing, but that would be hidden from anyone else visiting the site (i.e. the collaborators would have to be logged in to see the page)....
This is what I went with. It creates a second archive for *past events*. It shows upcoming events in the main event archive, and old events in the *past events* page. Sorting is ascending for the main archive (so you see the next upcoming event first), and descending for the *past events* page, so you see the most rece...
44,293
<p>I've got a custom post type of files I'm trying to list using a new WP_Query.</p> <p>It works fine when I add the shortcode within the main post content. However, when I add the shortcode to a custom field (which I have set to display on the page along with the main content as a secondary "column"), the main conten...
[ { "answer_id": 44294, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 3, "selected": true, "text": "<p>You're using <code>get_posts</code> which returns an array of posts, which you can loop through using <c...
2012/03/03
[ "https://wordpress.stackexchange.com/questions/44293", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12660/" ]
I've got a custom post type of files I'm trying to list using a new WP\_Query. It works fine when I add the shortcode within the main post content. However, when I add the shortcode to a custom field (which I have set to display on the page along with the main content as a secondary "column"), the main content disappe...
You're using `get_posts` which returns an array of posts, which you can loop through using `foreach`, but not `the_loop`. Try this version of the code: ``` function ia_news_display_test($atts){ // [ia_news cat='category' num='numbertodisplay'] extract(shortcode_atts(array( 'cat' => 'any', 'num' => '2'...
44,314
<p>I have added a custom button to the media actions in a custom theme, </p> <pre><code>function wp_myplugin_media_button($context) { $wp_myplugin_media_button_image = '../wp-content/themes/datamine/images/icon_create_table.gif'; $wp_myplugin_media_button = ' %s' . '&lt;a id="fluffyRabbit" href="javascript:;" ...
[ { "answer_id": 44294, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 3, "selected": true, "text": "<p>You're using <code>get_posts</code> which returns an array of posts, which you can loop through using <c...
2012/03/03
[ "https://wordpress.stackexchange.com/questions/44314", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13780/" ]
I have added a custom button to the media actions in a custom theme, ``` function wp_myplugin_media_button($context) { $wp_myplugin_media_button_image = '../wp-content/themes/datamine/images/icon_create_table.gif'; $wp_myplugin_media_button = ' %s' . '<a id="fluffyRabbit" href="javascript:;" title="Add a Tabl...
You're using `get_posts` which returns an array of posts, which you can loop through using `foreach`, but not `the_loop`. Try this version of the code: ``` function ia_news_display_test($atts){ // [ia_news cat='category' num='numbertodisplay'] extract(shortcode_atts(array( 'cat' => 'any', 'num' => '2'...
44,354
<p>I am using a page template with code to display all blog posts:</p> <pre><code>&lt;?php /* Template Name: Blog */ ?&gt; &lt;?php get_header(); ?&gt; &lt;div id="main"&gt; &lt;?php // ACF Page number variable $numposts = get_field('number_of_posts_per_page'); $args = array( 'numberposts' =&gt; $numposts ); $lastp...
[ { "answer_id": 44375, "author": "hannit cohen", "author_id": 395, "author_profile": "https://wordpress.stackexchange.com/users/395", "pm_score": 2, "selected": false, "text": "<p>probably coz you override the default query and forgot to take care of pagination :-)\nchange the code this w...
2012/03/04
[ "https://wordpress.stackexchange.com/questions/44354", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13798/" ]
I am using a page template with code to display all blog posts: ``` <?php /* Template Name: Blog */ ?> <?php get_header(); ?> <div id="main"> <?php // ACF Page number variable $numposts = get_field('number_of_posts_per_page'); $args = array( 'numberposts' => $numposts ); $lastposts = get_posts( $args ); foreach($la...
probably coz you override the default query and forgot to take care of pagination :-) change the code this way: ``` $page = isset(get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'numberposts' => $numposts, 'paged' => $paged ); ``` This should do the work
44,359
<p>I can get the image to appear fine in this bit of gallery code. However the flex slider gets its caption from a <code>&lt;p&gt;</code> tag (<code>class="flex-caption"</code>) and I just need to <code>echo</code> out the image title inside that paragraph.</p> <pre><code>&lt;?php if (!empty($flex_gallery)) {?&gt; ...
[ { "answer_id": 44366, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 2, "selected": true, "text": "<p>You should be able to get the image title with <a href=\"http://codex.wordpress.org/Function_Reference/wp_get_...
2012/03/04
[ "https://wordpress.stackexchange.com/questions/44359", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13392/" ]
I can get the image to appear fine in this bit of gallery code. However the flex slider gets its caption from a `<p>` tag (`class="flex-caption"`) and I just need to `echo` out the image title inside that paragraph. ``` <?php if (!empty($flex_gallery)) {?> <div class="flex-container resize-620"...
You should be able to get the image title with [`wp_get_attachment_metadata()`](http://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata). It will return an array that contains useful stuff like the width and height, as well as the title.
44,372
<p>I record my problem here.</p> <p><a href="http://www.screenr.com/pg88" rel="nofollow">http://www.screenr.com/pg88</a></p> <p>Does someone know what I am doing wrong?</p>
[ { "answer_id": 44389, "author": "Jen", "author_id": 13810, "author_profile": "https://wordpress.stackexchange.com/users/13810", "pm_score": 0, "selected": false, "text": "<p>Try moving your <code>$metabox-&gt;the_value('title')</code> inside your custom loop.</p>\n\n<p>The WPAlchemy obje...
2012/03/04
[ "https://wordpress.stackexchange.com/questions/44372", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13746/" ]
I record my problem here. <http://www.screenr.com/pg88> Does someone know what I am doing wrong?
usually you need to ``` global $custom_metabox; $custom_metabox->the_meta(); ``` as described in the alchemy docs. however i can't tell more unless you post your code.
44,380
<p>I am including a .css which i parse with php like so</p> <pre><code>&lt;link rel="stylesheet" type="text/css" media="all" href="&lt;?php echo get_childTheme_url(); ?&gt;/css/productgallery.php" /&gt; </code></pre> <p>Now in productgallery i can not use a global variable (an array) which i have set in functions.php...
[ { "answer_id": 44383, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 2, "selected": false, "text": "<p>You should be adding stylesheets using the <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue...
2012/03/04
[ "https://wordpress.stackexchange.com/questions/44380", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9936/" ]
I am including a .css which i parse with php like so ``` <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_childTheme_url(); ?>/css/productgallery.php" /> ``` Now in productgallery i can not use a global variable (an array) which i have set in functions.php How do i fix this?
Short answer, no. Long Answer =========== In your comment, you explain that you're including `wp-blog-header.php` in the PHP file that generates your CSS file. This is a ***very bad idea.*** When your page references your stylesheet, your browser sees the reference and makes a *separate* HTTP request to your server ...
44,420
<p>So I am using the <a href="http://woothemes.com/woocommerce/" rel="nofollow">http://woothemes.com/woocommerce/</a> plugin for eCommerce and it's registering jQuery local and conflicting with my default jQuery call from Google CDN.</p> <p>It took a long time but I isolated the issue to the following lines of code wi...
[ { "answer_id": 44421, "author": "Mike Jolley", "author_id": 13683, "author_profile": "https://wordpress.stackexchange.com/users/13683", "pm_score": 3, "selected": true, "text": "<p>Actually it looks like your calling jquery wrong. You should <em>always</em> use wp_enqueue_script, otherwi...
2012/03/05
[ "https://wordpress.stackexchange.com/questions/44420", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2527/" ]
So I am using the <http://woothemes.com/woocommerce/> plugin for eCommerce and it's registering jQuery local and conflicting with my default jQuery call from Google CDN. It took a long time but I isolated the issue to the following lines of code within `woocommerce.php`: ``` $suffix = defined('SCRIPT_DEBUG') && S...
Actually it looks like your calling jquery wrong. You should *always* use wp\_enqueue\_script, otherwise your asking for conflicts. Don't call it manually. The lines you pasted in from WooCommerce don't load jquery directly - they load it by setting the dependencies for the other scripts. WordPress handles the rest. ...
44,429
<p>This plugin works just fine in a post/page, but I need it to appear in a Text widget. Anyway to make it work in this location?</p>
[ { "answer_id": 44459, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 1, "selected": false, "text": "<p>to enable shortcode in textwidgets, add this to functions.php of your theme:</p>\n\n<pre><code>add_filter('widge...
2012/03/05
[ "https://wordpress.stackexchange.com/questions/44429", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13827/" ]
This plugin works just fine in a post/page, but I need it to appear in a Text widget. Anyway to make it work in this location?
to enable shortcode in textwidgets, add this to functions.php of your theme: ``` add_filter('widget_text', 'do_shortcode'); ```
44,441
<p>I use front end posting on my site so I don't get a chance to set a featured image for alot of my posts. So I use catch_the_image to get thumbs but it gets the original size and then scales it which is hurting page speed. Basically what I want to do is add "-150x150" into the string in the function so it pulls the s...
[ { "answer_id": 44451, "author": "alex", "author_id": 9936, "author_profile": "https://wordpress.stackexchange.com/users/9936", "pm_score": 2, "selected": true, "text": "<p>You can add your own named image size by adding code to your functions.php.</p>\n\n<p>Something in the line of\n ...
2012/03/05
[ "https://wordpress.stackexchange.com/questions/44441", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12700/" ]
I use front end posting on my site so I don't get a chance to set a featured image for alot of my posts. So I use catch\_the\_image to get thumbs but it gets the original size and then scales it which is hurting page speed. Basically what I want to do is add "-150x150" into the string in the function so it pulls the sm...
You can add your own named image size by adding code to your functions.php. Something in the line of add\_theme\_support('post-thumbnails');//might not be necessary add\_image\_size('front-end-150', 300, 300); Now you should be able to use in your catch\_that\_image() ``` wp_get_attachment_image($post->ID, 'front-...
44,443
<p>i need to add [attach thumbnail] to this form </p> <p>functions.php Code:</p> <pre><code>if( 'POST' == $_SERVER['REQUEST_METHOD'] &amp;&amp; !empty( $_POST['action'] ) &amp;&amp; $_POST['action'] == "new_post") { // Do some minor form validation to make sure there is content $title = $_POST['title']; ...
[ { "answer_id": 44446, "author": "ifdion", "author_id": 6383, "author_profile": "https://wordpress.stackexchange.com/users/6383", "pm_score": 1, "selected": false, "text": "<p>Its pretty simple actually. Here is the link for the set_thumbnail function reference <a href=\"http://codex.word...
2012/03/05
[ "https://wordpress.stackexchange.com/questions/44443", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12233/" ]
i need to add [attach thumbnail] to this form functions.php Code: ``` if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == "new_post") { // Do some minor form validation to make sure there is content $title = $_POST['title']; $ordertype = $_POST['ordertype']; ...
Its pretty simple actually. Here is the link for the set\_thumbnail function reference [codex](http://codex.wordpress.org/Function_Reference/set_post_thumbnail). And here is the answer for the [file upload](https://wordpress.stackexchange.com/questions/42068/handling-front-end-file-uploads-considering-safety-and-ease-o...
44,444
<p>The body_class hook seem only to work with non-admin pages. When I do </p> <pre><code>add_filter('body_class', 'add_body_classes'); function add_body_classes($classes) { $classes[] = 'myclass'; return $classes; } </code></pre> <p>Is there another hook i should be using if i want to add a class to ...
[ { "answer_id": 44447, "author": "Mamaduka", "author_id": 888, "author_profile": "https://wordpress.stackexchange.com/users/888", "pm_score": 6, "selected": true, "text": "<p>Admin pages don't use the <code>body_class</code> filter, use the <code>admin_body_class</code> filter to add clas...
2012/03/05
[ "https://wordpress.stackexchange.com/questions/44444", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12388/" ]
The body\_class hook seem only to work with non-admin pages. When I do ``` add_filter('body_class', 'add_body_classes'); function add_body_classes($classes) { $classes[] = 'myclass'; return $classes; } ``` Is there another hook i should be using if i want to add a class to the body of an admin page?
Admin pages don't use the `body_class` filter, use the `admin_body_class` filter to add classes to admin body tag instead. Note that `$classes` in that case is a string, not an array.
44,475
<p>I'm trying to make a simple widget that displays a list of posts, and is followed by some metadata from each post.</p> <p>Here is my code: <code>$eventdate</code> contains the metadata i need to retrieve.</p> <pre><code>query_posts(''); if (have_posts()) : echo "&lt;ul&gt;"; while (have_posts()) : the_po...
[ { "answer_id": 44560, "author": "Northernlights", "author_id": 13443, "author_profile": "https://wordpress.stackexchange.com/users/13443", "pm_score": 1, "selected": false, "text": "<p>Debugged and realised that $post in $post->ID needed to be declared a global variable. Sorted.</p>\n" ...
2012/03/05
[ "https://wordpress.stackexchange.com/questions/44475", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13443/" ]
I'm trying to make a simple widget that displays a list of posts, and is followed by some metadata from each post. Here is my code: `$eventdate` contains the metadata i need to retrieve. ``` query_posts(''); if (have_posts()) : echo "<ul>"; while (have_posts()) : the_post(); $eventdate = get_post_m...
`query_posts()` is for main query, it would be more wise to use `get_posts()` function to get you events. ``` // Modify get_posts args for your needs $events = get_posts( array ( 'post_type' => 'events' ) ); if ( $events ) { echo '<ul>'; foreach ( $events as $event ) { $event_date = get_post_meta( $e...
44,485
<p>I don't think I can make the excerpt required, but if anyone knows a workaround please share. At least I want to print a message if excerpt is empty after posts have been publish/update, maybe a red notification to be more visible!</p> <p>I use <a href="https://wordpress.stackexchange.com/a/14088/9023">this script<...
[ { "answer_id": 44493, "author": "The Z Man", "author_id": 13677, "author_profile": "https://wordpress.stackexchange.com/users/13677", "pm_score": 1, "selected": false, "text": "<p>You could always use the <a href=\"http://codex.wordpress.org/Function_Reference/has_excerpt\" rel=\"nofollo...
2012/03/05
[ "https://wordpress.stackexchange.com/questions/44485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9023/" ]
I don't think I can make the excerpt required, but if anyone knows a workaround please share. At least I want to print a message if excerpt is empty after posts have been publish/update, maybe a red notification to be more visible! I use [this script](https://wordpress.stackexchange.com/a/14088/9023) to show excerpt b...
You could always use the [has\_excerpt()](http://codex.wordpress.org/Function_Reference/has_excerpt) function to test for excerpt content and if it is not filled in you could display a message. **Example:** ``` if( has_excerpt() ) { the_excerpt(); } else { echo '<p>Please enter the excerpt.</p>'; } ```
44,489
<p>I'm looking to display a list of posts in the header section on my template on all pages with the exception of the front page where I would like to show an image in place of the list of posts.</p> <p>Is there a function within wordpress to detect the front page that I can use in my template code? or should I just b...
[ { "answer_id": 44491, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 4, "selected": true, "text": "<p>You can use the <a href=\"http://codex.wordpress.org/Template_Hierarchy\" rel=\"nofollow\">wordpress template ...
2012/03/05
[ "https://wordpress.stackexchange.com/questions/44489", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1859/" ]
I'm looking to display a list of posts in the header section on my template on all pages with the exception of the front page where I would like to show an image in place of the list of posts. Is there a function within wordpress to detect the front page that I can use in my template code? or should I just be looking ...
You can use the [wordpress template hierarchy](http://codex.wordpress.org/Template_Hierarchy) to do just that. Specifically, you can put the code you want in `front-page.php` and then use `index.php` for the rest of them, though that's a rather bland way of doing design with what you have on your hands. Alternately, t...
44,506
<p>I have a contact form with "Accept Privacy Policy" check box. I need to add a link, that will create a modal box displaying the privacy policy. Just like fancy box but for text. </p> <p>I was looking for a plugin that would help me. I looked at OrangeBox and Modal Dialog but it seems they don't do what I'm looking ...
[ { "answer_id": 49815, "author": "colllin", "author_id": 13047, "author_profile": "https://wordpress.stackexchange.com/users/13047", "pm_score": 1, "selected": false, "text": "<p>Fancybox works great for displaying content as well as images or videos. To display content, use something li...
2012/03/05
[ "https://wordpress.stackexchange.com/questions/44506", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13335/" ]
I have a contact form with "Accept Privacy Policy" check box. I need to add a link, that will create a modal box displaying the privacy policy. Just like fancy box but for text. I was looking for a plugin that would help me. I looked at OrangeBox and Modal Dialog but it seems they don't do what I'm looking for. Is t...
Fancybox works great for displaying content as well as images or videos. To display content, use something like: ``` $.fancybox('<h1>My html content here</h1>', { fancyOption: 'fancyValue' }); ``` This functionality is documented on fancybox's [How To](http://fancybox.net/howto) page. You can also use fancybox t...
44,522
<p>I want to display a random page in the index page of my site and it's all good with that.The problem is that before the post I want to display a page depending in which category the post is posted.Website is about world countries so before the post I want to display a description of the country, some pictures and st...
[ { "answer_id": 44524, "author": "Chris_", "author_id": 13854, "author_profile": "https://wordpress.stackexchange.com/users/13854", "pm_score": 1, "selected": false, "text": "<p>Looking at your code the issue you're experiencing relates to the point in code where you call: </p>\n\n<pre><c...
2012/03/05
[ "https://wordpress.stackexchange.com/questions/44522", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13578/" ]
I want to display a random page in the index page of my site and it's all good with that.The problem is that before the post I want to display a page depending in which category the post is posted.Website is about world countries so before the post I want to display a description of the country, some pictures and stuff...
Assuming you have an original query that is wrapping the code you pasted, it looks like `<?php wp_reset_query(); ?>` is your issue, but I'm pretty sure you should be able to replace it with `<?php wp_reset_postdata() ?>` to get back to your original $post variable within the main query.
44,527
<p>I am facing issue in debug mode with wordpress. In my featured slider getting error <code>Notice: Object of class WP_Query could not be converted to int in on line</code></p> <p>I am using below code for my slider</p> <pre><code>&lt;div id="&lt;?php slider_class() //Theme function ?&gt;" class="clearfix"&gt; ...
[ { "answer_id": 44524, "author": "Chris_", "author_id": 13854, "author_profile": "https://wordpress.stackexchange.com/users/13854", "pm_score": 1, "selected": false, "text": "<p>Looking at your code the issue you're experiencing relates to the point in code where you call: </p>\n\n<pre><c...
2012/03/05
[ "https://wordpress.stackexchange.com/questions/44527", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9821/" ]
I am facing issue in debug mode with wordpress. In my featured slider getting error `Notice: Object of class WP_Query could not be converted to int in on line` I am using below code for my slider ``` <div id="<?php slider_class() //Theme function ?>" class="clearfix"> <!--[BEGIN: Slider wrapper]--> <div id="...
Assuming you have an original query that is wrapping the code you pasted, it looks like `<?php wp_reset_query(); ?>` is your issue, but I'm pretty sure you should be able to replace it with `<?php wp_reset_postdata() ?>` to get back to your original $post variable within the main query.
44,537
<p>Finally got pagination to work with the below code, but now the pagination links to /videos/page/2/, which doesn't exist. How do I get page 2 to work?</p> <pre><code>&lt;?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query-&gt;query('post_type=videos&amp;showposts=1'.'&amp;paged='.$paged);...
[ { "answer_id": 44538, "author": "Dave", "author_id": 11059, "author_profile": "https://wordpress.stackexchange.com/users/11059", "pm_score": 5, "selected": true, "text": "<p>Found the answer:</p>\n\n<blockquote>\n <p>After a looong day debugging thru wordpress core, I managed to solve\n...
2012/03/05
[ "https://wordpress.stackexchange.com/questions/44537", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11059/" ]
Finally got pagination to work with the below code, but now the pagination links to /videos/page/2/, which doesn't exist. How do I get page 2 to work? ``` <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('post_type=videos&showposts=1'.'&paged='.$paged); while ($wp_query->have_pos...
Found the answer: > > After a looong day debugging thru wordpress core, I managed to solve > this issue. > > > Basicly, you CANT have a PAGE and a CUSTOM POST TYPE with the same > name. If you do, the permalink rewrite rules will get confused and > trigger a 404. > > > A very simple solution I'm using is: The ...
44,540
<p>Working on a real estate website and setting Open House dates and times using drop downs in a Custom Meta Box. Example drop down below:</p> <pre><code>&lt;select name="sale_listing_open_house1_start_day" id="sale_listing_open_house1_start_day"&gt; &lt;option value="monday" &lt;?php selected( $selected, 'M...
[ { "answer_id": 44554, "author": "nembleton", "author_id": 13348, "author_profile": "https://wordpress.stackexchange.com/users/13348", "pm_score": -1, "selected": false, "text": "<p>I am not sure to clearly understand what you want but why won't you use a Javascript timer to \"lock\" it a...
2012/03/06
[ "https://wordpress.stackexchange.com/questions/44540", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13859/" ]
Working on a real estate website and setting Open House dates and times using drop downs in a Custom Meta Box. Example drop down below: ``` <select name="sale_listing_open_house1_start_day" id="sale_listing_open_house1_start_day"> <option value="monday" <?php selected( $selected, 'Monday' ); ?>>Monday</optio...
Have a look at the [Post Expirator plugin](http://wordpress.org/extend/plugins/post-expirator/). > > The Post Expirator plugin allows the user to set expiration dates for both posts and pages. There is a configuration option page in the plugins area that will allow you to seperataly control whether or not posts/pages...
44,561
<p>I am currently loading a single post using ajax. While the post loading works ok, I cannot get the comments to load. Here is my code:</p> <p>My javascript to load the post:</p> <pre><code>&lt;script&gt; $(".view_post").click(function(e) { e.preventDefault(); postid = $(this).attr("rel"); $.ajax({ ...
[ { "answer_id": 61407, "author": "ifdion", "author_id": 6383, "author_profile": "https://wordpress.stackexchange.com/users/6383", "pm_score": 0, "selected": false, "text": "<p>On my opinion, it would be better to go with a JQuery <code>.load($[this].attr('href') '.div-with-content-and-com...
2012/03/06
[ "https://wordpress.stackexchange.com/questions/44561", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13340/" ]
I am currently loading a single post using ajax. While the post loading works ok, I cannot get the comments to load. Here is my code: My javascript to load the post: ``` <script> $(".view_post").click(function(e) { e.preventDefault(); postid = $(this).attr("rel"); $.ajax({ url:"/wp-admin/admin-aja...
To quote the Codex on the `have_comments` function: > > This function relies upon the global $wp\_query object to be set - this is usually the case from within The Loop > > > The problem is that your ajax handler creates its own WP\_Query object. Note that you are not calling `the_post()`, instead you are calling...
44,571
<p>I want to exclude posts from one category. These posts should not show in the sidebar on the homepage only when I explicitly don't want that particular posts to show. In all other cases these posts will be displayed.</p> <p>I have tried with plugin "WP Hide Post", but that seems not to work with sidebars, only for ...
[ { "answer_id": 44603, "author": "Chris_", "author_id": 13854, "author_profile": "https://wordpress.stackexchange.com/users/13854", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if this is what you're looking for, but you could just wrap everything INSIDE the while/endwhile w...
2012/03/06
[ "https://wordpress.stackexchange.com/questions/44571", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4490/" ]
I want to exclude posts from one category. These posts should not show in the sidebar on the homepage only when I explicitly don't want that particular posts to show. In all other cases these posts will be displayed. I have tried with plugin "WP Hide Post", but that seems not to work with sidebars, only for regular lo...
You can add this code to a new file named wpsites.php and then use the template tag directly in any file or hook it in using a custom function with theme specific or WordPress hooks. **Note:** All code can be used in a child theme. ``` <?php // Your Custom Query Arguments $args = array( 'category__not_in' => array...
44,575
<p>I have a custom function which looks if an attachement has a certain caption value, if so the attachement is selected, like so</p> <pre><code> foreach ($attachments as $attachment) { if ($attachment-&gt;post_excerpt == 'single-gallery') { </code></pre> <p>But how can i give a attachement two or more va...
[ { "answer_id": 44603, "author": "Chris_", "author_id": 13854, "author_profile": "https://wordpress.stackexchange.com/users/13854", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if this is what you're looking for, but you could just wrap everything INSIDE the while/endwhile w...
2012/03/06
[ "https://wordpress.stackexchange.com/questions/44575", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9936/" ]
I have a custom function which looks if an attachement has a certain caption value, if so the attachement is selected, like so ``` foreach ($attachments as $attachment) { if ($attachment->post_excerpt == 'single-gallery') { ``` But how can i give a attachement two or more values and select one? So if i ...
You can add this code to a new file named wpsites.php and then use the template tag directly in any file or hook it in using a custom function with theme specific or WordPress hooks. **Note:** All code can be used in a child theme. ``` <?php // Your Custom Query Arguments $args = array( 'category__not_in' => array...
44,597
<p>I just installed bbPress 2.0.2 forum plugin for WordPress, and would like to change the text of link <code>Home</code> to <code>iGeek</code> (or anything else, for that matter).</p> <p>So the breadcrumb <code>Home › Community</code> becomes <code>iGeek › Community</code> (or something like that). How do I do that?<...
[ { "answer_id": 50814, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 0, "selected": false, "text": "<p>jQuery alternative if no plugin hook exists:</p>\n\n<pre><code>&lt;script type=\"text/javascript\"&gt;\n ...
2012/03/06
[ "https://wordpress.stackexchange.com/questions/44597", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10691/" ]
I just installed bbPress 2.0.2 forum plugin for WordPress, and would like to change the text of link `Home` to `iGeek` (or anything else, for that matter). So the breadcrumb `Home › Community` becomes `iGeek › Community` (or something like that). How do I do that? In case it helps, this is the code in [`\wp-content\p...
The string is now in `bbpress/includes/common/template-tags.php`. Hook into `bbp_no_breadcrumb`, register a filter for `gettext` and change the text: ``` add_filter( 'bbp_no_breadcrumb', 'wpse_44597_change_home_text' ); function wpse_44597_change_home_text( $translated, $original = '', $domain = '' ) { if ( 'bbp...
44,598
<p>Hi I have a WordPress site where all the content is in English, however I need just one page to be in Arabic with left to right text, plus some bullets which obviously appear on the right instead of on the left, how do I go about creating such a page? </p>
[ { "answer_id": 50814, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 0, "selected": false, "text": "<p>jQuery alternative if no plugin hook exists:</p>\n\n<pre><code>&lt;script type=\"text/javascript\"&gt;\n ...
2012/03/06
[ "https://wordpress.stackexchange.com/questions/44598", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
Hi I have a WordPress site where all the content is in English, however I need just one page to be in Arabic with left to right text, plus some bullets which obviously appear on the right instead of on the left, how do I go about creating such a page?
The string is now in `bbpress/includes/common/template-tags.php`. Hook into `bbp_no_breadcrumb`, register a filter for `gettext` and change the text: ``` add_filter( 'bbp_no_breadcrumb', 'wpse_44597_change_home_text' ); function wpse_44597_change_home_text( $translated, $original = '', $domain = '' ) { if ( 'bbp...
44,623
<p>I want to use a form from the <code>Contact Form 7</code> plugin to allow the users to upload a document to my website. The problem is that I'd like to manage those uploads from WordPress instead of receiving them in my E-Mail. </p> <p>Is there a way of redirecting the output of those forms to a PHP script, or some...
[ { "answer_id": 44624, "author": "Scott", "author_id": 4610, "author_profile": "https://wordpress.stackexchange.com/users/4610", "pm_score": 4, "selected": true, "text": "<p>Take a look at the <code>wpcf7_before_send_mail</code> hook CF7 provides.</p>\n\n<pre><code>add_action(\"wpcf7_befo...
2012/03/06
[ "https://wordpress.stackexchange.com/questions/44623", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2169/" ]
I want to use a form from the `Contact Form 7` plugin to allow the users to upload a document to my website. The problem is that I'd like to manage those uploads from WordPress instead of receiving them in my E-Mail. Is there a way of redirecting the output of those forms to a PHP script, or something similar?
Take a look at the `wpcf7_before_send_mail` hook CF7 provides. ``` add_action("wpcf7_before_send_mail", "wpcf7_do_something_else_with_the_data"); function wpcf7_do_something_else_with_the_data(&$wpcf7_data) { // Everything you should need is in this variable var_dump($wpcf7_data); // I can skip sending t...
44,638
<p>I created a navigation bar like tab system for my header and I can get all but my news button to highlight on that page. The news is a static page for all of my blog/news post.</p> <p>Not sure if it's my code but if anyone has any ideas, much thanks to you.</p> <pre><code>&lt;?php $parent_title = get_the_title($p...
[ { "answer_id": 44635, "author": "SickHippie", "author_id": 5434, "author_profile": "https://wordpress.stackexchange.com/users/5434", "pm_score": 5, "selected": true, "text": "<p>Check the slugs of the other pages - chances are /company/ is being used for one of those. You could also go ...
2012/03/06
[ "https://wordpress.stackexchange.com/questions/44638", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9707/" ]
I created a navigation bar like tab system for my header and I can get all but my news button to highlight on that page. The news is a static page for all of my blog/news post. Not sure if it's my code but if anyone has any ideas, much thanks to you. ``` <?php $parent_title = get_the_title($post->post_parent); ?> ...
Check the slugs of the other pages - chances are /company/ is being used for one of those. You could also go to /company/ on your site and see if anything pulls up. [As mentioned in a comment](https://wordpress.stackexchange.com/questions/44634/strange-permalink-issue-cant-rename-company-2-to-company#comment56742_4463...
44,655
<p>I am using woocommerce and have some 'product attributes' which are just a taxonomies.</p> <p>I have the following taxonomies:</p> <ul> <li>pa_color </li> <li>pa_material</li> <li>pa_style</li> </ul> <p>the pa_ stands for product attribute and it is built-in to WooCommerce handles these taxonomies, so I can't cha...
[ { "answer_id": 44635, "author": "SickHippie", "author_id": 5434, "author_profile": "https://wordpress.stackexchange.com/users/5434", "pm_score": 5, "selected": true, "text": "<p>Check the slugs of the other pages - chances are /company/ is being used for one of those. You could also go ...
2012/03/06
[ "https://wordpress.stackexchange.com/questions/44655", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6477/" ]
I am using woocommerce and have some 'product attributes' which are just a taxonomies. I have the following taxonomies: * pa\_color * pa\_material * pa\_style the pa\_ stands for product attribute and it is built-in to WooCommerce handles these taxonomies, so I can't change that. WooCommerce also comes with produc...
Check the slugs of the other pages - chances are /company/ is being used for one of those. You could also go to /company/ on your site and see if anything pulls up. [As mentioned in a comment](https://wordpress.stackexchange.com/questions/44634/strange-permalink-issue-cant-rename-company-2-to-company#comment56742_4463...
44,664
<p>The setup:</p> <ul> <li>custom post type of 'attorney' </li> <li>custom taxonomy of 'specialty', which is registered against the 'attorney' post type</li> <li>custom post type of 'practice-area'</li> </ul> <p>For every specialty, there is a matching practice area. However, there are many more practice areas than...
[ { "answer_id": 44667, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 0, "selected": false, "text": "<p>if i understand you correctly then when you are on the Bankruptcy 'practice-area'... 'Bankruptcy' will be...
2012/03/06
[ "https://wordpress.stackexchange.com/questions/44664", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49/" ]
The setup: * custom post type of 'attorney' * custom taxonomy of 'specialty', which is registered against the 'attorney' post type * custom post type of 'practice-area' For every specialty, there is a matching practice area. However, there are many more practice areas than there are specialties. Ideally, when viewin...
I've dealt a similar requirement and so far the best way to do that is by using a custom field to save the related term id. That means for each 'practice-area' post type, there will be a 'specialty-term-id' custom field with the 'specialty' term id as value. Here the action hook to create the term for each post ``` ...
44,672
<p>I have this code for the loop, and I need to exclude a category <code>4</code> from this loop. Any suggestions on how to achieve this?</p> <p>Code that starts the loop</p> <pre><code> &lt;?php if(have_posts()): ?&gt; &lt;ol class="item_lists"&gt; &lt;?php $end = array(3,6,9,12,15,18,21,24,27,...
[ { "answer_id": 44675, "author": "Adam Rice", "author_id": 13603, "author_profile": "https://wordpress.stackexchange.com/users/13603", "pm_score": 1, "selected": false, "text": "<p>Before the line </p>\n\n<pre><code>&lt;?php if(have_posts()): ?&gt;\n</code></pre>\n\n<p>Insert something li...
2012/03/06
[ "https://wordpress.stackexchange.com/questions/44672", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5499/" ]
I have this code for the loop, and I need to exclude a category `4` from this loop. Any suggestions on how to achieve this? Code that starts the loop ``` <?php if(have_posts()): ?> <ol class="item_lists"> <?php $end = array(3,6,9,12,15,18,21,24,27,30,33,36,39,42,45); $i = 0; wh...
you could use wp\_parse\_args() to merge your arguments into the default query ``` // Define the default query args global $wp_query; $defaults = $wp_query->query_vars; // Your custom args $args = array('cat'=>-4); // merge the default with your custom args $args = wp_parse_args( $args, $defaults ); // query posts...
44,694
<p>Simple shortcode turning overcomplicated</p> <pre><code>&lt;?php function recent_posts() { $q = new WP_Query( array( 'orderby' =&gt; 'date', 'posts_per_page' =&gt; '1') ); $list = '&lt;ul&gt;'; while($q-&gt;have_posts()) : $q-&gt;the_post(); //$location = bloginfo('template_directory'); $imgsrc = get_post_me...
[ { "answer_id": 44678, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>I recommend using the search replace on ALL wordpress tables. You will have missed the entries in the options...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44694", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10268/" ]
Simple shortcode turning overcomplicated ``` <?php function recent_posts() { $q = new WP_Query( array( 'orderby' => 'date', 'posts_per_page' => '1') ); $list = '<ul>'; while($q->have_posts()) : $q->the_post(); //$location = bloginfo('template_directory'); $imgsrc = get_post_meta($q->ID, 'blog-left-image', true)...
I recommend using the search replace on ALL wordpress tables. You will have missed the entries in the options table as well as many other locations such as post meta, etc
44,711
<p>I´m trying to make a slider which takes thumbnails from a certain custom post type and displays for of them for each "slide". I get the slider and thumbnails to work like they should, but I´m unsure of how I should modify the loop to get it to display 4 posts in a container, then repeat with the next 4 posts and so ...
[ { "answer_id": 44712, "author": "Sisir", "author_id": 3094, "author_profile": "https://wordpress.stackexchange.com/users/3094", "pm_score": 3, "selected": true, "text": "<p>Tried very simple math. <code>&lt;div class=\"slide\"&gt;</code> will print after every 4 post. So, if statement wi...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44711", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5079/" ]
I´m trying to make a slider which takes thumbnails from a certain custom post type and displays for of them for each "slide". I get the slider and thumbnails to work like they should, but I´m unsure of how I should modify the loop to get it to display 4 posts in a container, then repeat with the next 4 posts and so on....
Tried very simple math. `<div class="slide">` will print after every 4 post. So, if statement with old school logic `$i%4 == 0` ``` <div class="slides_container"> <?php $args = array( 'post_type' => 'fastighet...
44,717
<p>I'm trying to query the database for posts based on multiple custom fields. This is easy enough with the code below if values are simple:</p> <pre><code> $querydetails = " SELECT wposts.* FROM $wpdb-&gt;posts wposts, $wpdb-&gt;postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wp...
[ { "answer_id": 44712, "author": "Sisir", "author_id": 3094, "author_profile": "https://wordpress.stackexchange.com/users/3094", "pm_score": 3, "selected": true, "text": "<p>Tried very simple math. <code>&lt;div class=\"slide\"&gt;</code> will print after every 4 post. So, if statement wi...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44717", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13905/" ]
I'm trying to query the database for posts based on multiple custom fields. This is easy enough with the code below if values are simple: ``` $querydetails = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '...
Tried very simple math. `<div class="slide">` will print after every 4 post. So, if statement with old school logic `$i%4 == 0` ``` <div class="slides_container"> <?php $args = array( 'post_type' => 'fastighet...
44,731
<p>I have a form and date fields in it: "date from" and "date to" (to make a specify a period of availability. There may be several available periods, so I made a button by which you can add more "date from" and "date to" fields.</p> <p>I use custom meta fields to store the values of the entered days and here is the ...
[ { "answer_id": 44735, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 1, "selected": false, "text": "<p>This completely untested, but something like this should work. It assumes that the dates come in before (...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44731", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13909/" ]
I have a form and date fields in it: "date from" and "date to" (to make a specify a period of availability. There may be several available periods, so I made a button by which you can add more "date from" and "date to" fields. I use custom meta fields to store the values of the entered days and here is the code: ``` ...
This completely untested, but something like this should work. It assumes that the dates come in before (start and end) - this should have been verified when the data was processed. ``` $i=1; $key_start = 'available_dates_from_'; $key_end = 'available_dates_to_'; echo '<ul>'; while($start = get_post_meta($post_id, $k...
44,736
<p>Through API functions, I want to define a new <a href="http://codex.wordpress.org/Navigation_Menus">Navigation menu</a>, select it in the current theme, and then insert a few Pages as menu items. This is to be done for instance on a theme activation.</p> <p>Through a (moderately painful) process of reverse engineer...
[ { "answer_id": 44739, "author": "ZaMoose", "author_id": 61, "author_profile": "https://wordpress.stackexchange.com/users/61", "pm_score": 7, "selected": true, "text": "<p>I might be misunderstanding you, but why not use <code>wp_create_nav_menu()</code>?</p>\n\n<p>E.g., this is what I do...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44736", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4826/" ]
Through API functions, I want to define a new [Navigation menu](http://codex.wordpress.org/Navigation_Menus), select it in the current theme, and then insert a few Pages as menu items. This is to be done for instance on a theme activation. Through a (moderately painful) process of reverse engineering the database inse...
I might be misunderstanding you, but why not use `wp_create_nav_menu()`? E.g., this is what I do to create a custom BuddyPress menu when I detect BP as active: ``` $menuname = $lblg_themename . ' BuddyPress Menu'; $bpmenulocation = 'lblgbpmenu'; // Does the menu exist already? $menu_exists = wp_get_nav_menu_objec...
44,740
<p>I noticed a strange behavior in WordPress where it automatically 301 redirects certain URL structures for posts.</p> <p>For example, I have a post entry for: mysite.com/999/about-us</p> <p>Then, you would think the following link would produce a 404: mysite.com/567891/about-us-1</p> <p>However, WordPress automati...
[ { "answer_id": 45081, "author": "William", "author_id": 9942, "author_profile": "https://wordpress.stackexchange.com/users/9942", "pm_score": 2, "selected": false, "text": "<p>This appears to have to do with <code>redirect_guess_404_permalink()</code> called on line 96 of <code>wp-includ...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44740", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2333/" ]
I noticed a strange behavior in WordPress where it automatically 301 redirects certain URL structures for posts. For example, I have a post entry for: mysite.com/999/about-us Then, you would think the following link would produce a 404: mysite.com/567891/about-us-1 However, WordPress automatically redirects to /999/...
This appears to have to do with `redirect_guess_404_permalink()` called on line 96 of `wp-includes/canonical.php`. Just to test, I added a `return false;` to the first line of the `redirect_guess_404_permalink()` function, and that seemed to stop this odd behavior. I'm poking around a bit, but so far I don't see a **go...
44,748
<p>I am using TinyMCE Advanced plugin according to qTranslate in a wordpress 3.3 installation. <strong>My question is:</strong> why does tinymce translate visual editor new line ("enter" key) in a <code>&lt;p&gt;&amp;nbsp;&lt;/p&gt;</code> instead of <code>&lt;br/&gt;</code>?</p> <p>Is it possible to change this behav...
[ { "answer_id": 44780, "author": "SickHippie", "author_id": 5434, "author_profile": "https://wordpress.stackexchange.com/users/5434", "pm_score": 4, "selected": true, "text": "<p>Go into Settings -> TinyMCE Advanced, and check the option <code>Stop removing the &lt;p&gt; and &lt;br /&gt; ...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44748", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3990/" ]
I am using TinyMCE Advanced plugin according to qTranslate in a wordpress 3.3 installation. **My question is:** why does tinymce translate visual editor new line ("enter" key) in a `<p>&nbsp;</p>` instead of `<br/>`? Is it possible to change this behavior?
Go into Settings -> TinyMCE Advanced, and check the option `Stop removing the <p> and <br /> tags when saving and show them in the HTML editor`. This will allow you full control over those tags inside the HTML view. For a single line break without overriding the editor, use `Shift+Enter`. To override the editor and m...
44,753
<p>Is there a way to override the styles in the admin in my theme?</p> <p>I don't want to touch the admin style sheet if I don't have to.</p> <p>I just want to make a column bigger in my admin, but also, to do it in a way that doesn't get overridden in a future wordpress update.</p>
[ { "answer_id": 44754, "author": "The Z Man", "author_id": 13677, "author_profile": "https://wordpress.stackexchange.com/users/13677", "pm_score": 4, "selected": false, "text": "<p>Take a look here at the <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scrip...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44753", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2417/" ]
Is there a way to override the styles in the admin in my theme? I don't want to touch the admin style sheet if I don't have to. I just want to make a column bigger in my admin, but also, to do it in a way that doesn't get overridden in a future wordpress update.
Take a look here at the [CODEX](http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts) for an example on how to do this very thing. **Example: Load CSS File on All Admin Pages** ``` function load_custom_wp_admin_style(){ wp_register_style( 'custom_wp_admin_css', get_bloginfo('stylesheet_di...
44,764
<p>I have a custom post textbox that I want to sanitize using <code>wp_kses</code> before I update my post meta.</p> <p>I was looking for examples of common <code>$allowed</code> settings, but I have only seen this example:</p> <pre><code>$allowed = array( 'a' =&gt; array( // on allow a tags '...
[ { "answer_id": 44773, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 2, "selected": false, "text": "<p>I've only used <code>wp_kses</code> when I've specifically needed to allow / filter <strong>attributes</stron...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44764", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2417/" ]
I have a custom post textbox that I want to sanitize using `wp_kses` before I update my post meta. I was looking for examples of common `$allowed` settings, but I have only seen this example: ``` $allowed = array( 'a' => array( // on allow a tags 'href' => array() // and those anchors can only...
I would disagree with the solution posted by @JaredCobb, `wp_kses()` is much more flexible than the method he presented. It can strip out unwanted attributes from tags without destroying the tags themselves. For example, if the user put in `<strong class='foo'>`, `wp_kses()` would return `<strong>` if you did not allow...
44,777
<p>I wanted to add support for .wif files (text/plain) to my site (WP3.3.1). So I added the below function to my theme's <code>functions.php</code>. My theme is a child theme of <a href="http://aquoid.com/news/themes/suffusion/" rel="noreferrer">Suffusion</a>.</p> <pre><code>add_filter('upload_mimes', 'custom_upload_m...
[ { "answer_id": 47866, "author": "Gabriel S Merovingi", "author_id": 14851, "author_profile": "https://wordpress.stackexchange.com/users/14851", "pm_score": 1, "selected": false, "text": "<p>I would use:</p>\n\n<pre><code>add_filter( 'upload_mimes', 'theme_restrict_mime_types' );\nfunctio...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44777", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3644/" ]
I wanted to add support for .wif files (text/plain) to my site (WP3.3.1). So I added the below function to my theme's `functions.php`. My theme is a child theme of [Suffusion](http://aquoid.com/news/themes/suffusion/). ``` add_filter('upload_mimes', 'custom_upload_mimes'); function custom_upload_mimes ( $existing_mim...
The problem is with the filter. Deregister the old key, to avoid conflicts. Then simply add your new one. ``` add_filter( 'upload_mimes', 'wpse44777_upload_mimes' ); function wpse44777_upload_mimes( $mime_types ) { // First we unregister the old key unset( $mime_types['txt|asc|c|cc|h'] ); // Then we add a...
44,783
<p>How can I show a list of Users with alphabetical headings? For example:</p> <p><strong>A</strong><br>Adam<br>Alan</p> <p><strong>B</strong><br>Bill<br>Bob</p> <p>I've found examples that do it with Posts, but I can't figure out how to make it work with <code>WP_User_query()</code> :(</p>
[ { "answer_id": 44896, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 1, "selected": true, "text": "<p>After a good bit of tinkering I've come up with something. It's certainly not the BEST method, but since there...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44783", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10530/" ]
How can I show a list of Users with alphabetical headings? For example: **A** Adam Alan **B** Bill Bob I've found examples that do it with Posts, but I can't figure out how to make it work with `WP_User_query()` :(
After a good bit of tinkering I've come up with something. It's certainly not the BEST method, but since there's not a good way to do it through the core directly without having to do a bunch of array-reordering, I think SQL is a better solution here. Anyways, the SQL is as follows: ``` SELECT users.*, meta.meta_value...
44,785
<p>I know that I can get my translations into JavaScript doing:</p> <pre><code> $MyTranslations = array( 'translation1' =&gt; __("Some String 1", "MyTranslations"), 'translation2' =&gt; __("Some String 2", "MyTranslations") ); wp_localize_script( 'jquery', 'my_translations', $MyTranslations ...
[ { "answer_id": 44792, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>Use the filter <code>'mce_external_languages'</code>. From <code>wp-includes/class-wp-editor.php</code>:</p>\n\n<blockq...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44785", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
I know that I can get my translations into JavaScript doing: ``` $MyTranslations = array( 'translation1' => __("Some String 1", "MyTranslations"), 'translation2' => __("Some String 2", "MyTranslations") ); wp_localize_script( 'jquery', 'my_translations', $MyTranslations ); ``` But looking...
Use the filter `'mce_external_languages'`. From `wp-includes/class-wp-editor.php`: > > The following filter loads external language files for TinyMCE plugins. > It takes an associative array 'plugin\_name' => 'path', where path is the > include path to the file. The language file should follow the same format as > ...
44,790
<p>I need to register a metabox in my WordPress custom post, but only in case the post is permanent saved in database.</p> <p>What I mean, when the user click on "Add new" I don't want to display the metabox. When the user click on "Publish" after the page refresh display the metabox.</p> <p>The post status doesn't m...
[ { "answer_id": 44793, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 1, "selected": false, "text": "<p>You should be able to filter the call to <code>add_meta_box()</code> conditionally using the <code>$current_s...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44790", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7850/" ]
I need to register a metabox in my WordPress custom post, but only in case the post is permanent saved in database. What I mean, when the user click on "Add new" I don't want to display the metabox. When the user click on "Publish" after the page refresh display the metabox. The post status doesn't matter (published,...
As an alternative to @m0r7if3r's solution, the `add_meta_boxes` hook optionally passes two variables, the post type and post object. You can use this to conditionally add your metabox. New posts have the post status of 'auto-draft'. ``` add_action( 'add_meta_boxes', 'myplugin_add_custom_box',10,2); function myplugin_a...
44,807
<p>I have a custom meta box with a textarea where users can drop in vimeo embed code.</p> <p>Should I sanitize this code before I update_post_meta, and, if so, how should I go about it? I don't want to strip out important information (like the iframe)...I just want to make sure nothing malicious is getting entered.</p...
[ { "answer_id": 44809, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 0, "selected": false, "text": "<p><code>update_post_meta()</code> will sanitize it for database insertion for you. What you really need to be w...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44807", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2417/" ]
I have a custom meta box with a textarea where users can drop in vimeo embed code. Should I sanitize this code before I update\_post\_meta, and, if so, how should I go about it? I don't want to strip out important information (like the iframe)...I just want to make sure nothing malicious is getting entered.
You need to add a custom validation/sanitization callback, and hook it into `publish_post` (and/or `draft_post` and/or `future_post`, as applicable). For example: ``` <?php function wpse_44807_update_custom_post_meta() { // Globalize the $post object global $post; // If our custom post meta key is set, san...
44,832
<p>I am using this excellent piece of code to insert a line break in single image captions by way of inserting a pipe character...</p> <p>Now I would like your help to try to incorporate this into the gallery image captions too.</p> <p>Here's the original code that works for single image captions. My attempt at the ...
[ { "answer_id": 44894, "author": "Sagive", "author_id": 7990, "author_profile": "https://wordpress.stackexchange.com/users/7990", "pm_score": 0, "selected": false, "text": "<p>You can css it using width no?</p>\n\n<p>just do a css condition for that p tag (wp-caption-text)\nsay the defaul...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44832", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12651/" ]
I am using this excellent piece of code to insert a line break in single image captions by way of inserting a pipe character... Now I would like your help to try to incorporate this into the gallery image captions too. Here's the original code that works for single image captions. My attempt at the gallery code is be...
For what it's worth, this has been fixed in 3.4: <http://core.trac.wordpress.org/ticket/18311>
44,834
<p>For built-in Wordpress functions such as the "forgot password" option, where is the SMTP server configured? Does it just default to the local daemon? What e-mail does it send messages as?</p>
[ { "answer_id": 44837, "author": "SickHippie", "author_id": 5434, "author_profile": "https://wordpress.stackexchange.com/users/5434", "pm_score": 1, "selected": false, "text": "<p>WordPress uses php mail by default. To use SMTP you'll need to use a separate plugin, of which there's sever...
2012/03/07
[ "https://wordpress.stackexchange.com/questions/44834", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13928/" ]
For built-in Wordpress functions such as the "forgot password" option, where is the SMTP server configured? Does it just default to the local daemon? What e-mail does it send messages as?
The default `wp_mail()` function is pluggable - meaning it can be entirely overridden by plugins. In the absence of any external influence, though, the "from" settings for the email address are hard-coded. Here's a snippet from `/wp-includes/pluggable.php`: ``` // From email and name // If we don't have a name from t...
44,845
<p>I'm working on a WordPress site for my band and I'd like to mark every 3rd post on our blog page to have a special class applied to it, anybody have any pointers on how to achieve this? Any help is very very appreciated, thanks! rock n roll.</p>
[ { "answer_id": 44848, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<pre><code>$i = 0;\nif ( have_posts ) :\nwhile( have_posts ) :\n the_post();\n\n $class = 'class=\"BASIC-CLASS';...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44845", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13931/" ]
I'm working on a WordPress site for my band and I'd like to mark every 3rd post on our blog page to have a special class applied to it, anybody have any pointers on how to achieve this? Any help is very very appreciated, thanks! rock n roll.
My approach. No extra function, no filter. :) ``` <?php $GLOBALS['wpdb']->current_post = 0; ?> <div <?php post_class( 0 === ++$GLOBALS['wpdb']->current_post % 3 ? 'third' : '' ); ?>> ``` Alternative: ``` <div <?php post_class( 0 === ++$GLOBALS['wpdb']->wpse_post_counter % 3 ? 'third' : '' ); ?>> ```
44,862
<p>This is one of those problems that I've spent way too much time on, and there is probably a VERY simple solution that I am missing. Any help would be greatly appreciated. </p> <p>I am trying to populate a select box with names from custom data (<code>meta_key</code> "<code>pyd_pub_author</code>"). But, I cant jus...
[ { "answer_id": 44867, "author": "Dwayne Charrington", "author_id": 1687, "author_profile": "https://wordpress.stackexchange.com/users/1687", "pm_score": 0, "selected": false, "text": "<p>I seriously doubt there is a plugin out there that can do this for you. I did have a quick Google sea...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44862", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10765/" ]
This is one of those problems that I've spent way too much time on, and there is probably a VERY simple solution that I am missing. Any help would be greatly appreciated. I am trying to populate a select box with names from custom data (`meta_key` "`pyd_pub_author`"). But, I cant just call the data directly, because ...
First, you need a list of all available URIs. You may use my [plugin T5 All URIs](https://gist.github.com/1999696) for that. Just activate and go to your blog on `/alluris/`. There is also a link to the file in your plugin list after activation. ![enter image description here](https://i.stack.imgur.com/YPOT3.png) The...
44,865
<p>Ok i have a custom post type on my blog called videos, where i only post a video. There's a sceen cap below </p> <p><img src="https://i.stack.imgur.com/WqOSN.jpg" alt="enter image description here"></p> <p><strong>On the right are the latest post from the custom post type, on the left is the video, and under the v...
[ { "answer_id": 44887, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": true, "text": "<p>The problem lies in how you are displaying the videos on the side. Somewhere you are looping through some ...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44865", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13556/" ]
Ok i have a custom post type on my blog called videos, where i only post a video. There's a sceen cap below ![enter image description here](https://i.stack.imgur.com/WqOSN.jpg) **On the right are the latest post from the custom post type, on the left is the video, and under the video is the date and time, category a...
The problem lies in how you are displaying the videos on the side. Somewhere you are looping through some posts to produce that list. Notice the last post on that list in the screenshot is an *interview* with once *upon a time* - and thats what the categories and tags are related to. Why is this happening? ===========...
44,889
<p>I want to link to attachments but through its parent page.</p> <p>/directors/piranha-bar/ shows all of that post's attachments on single.php</p> <p>and i want /directors/piranha-bar/video/name-or-ID/ to still use single.php but have the variable $video captured.</p> <p>How can i firstly make the links on the atta...
[ { "answer_id": 44940, "author": "sanchothefat", "author_id": 1733, "author_profile": "https://wordpress.stackexchange.com/users/1733", "pm_score": 1, "selected": false, "text": "<h1>Showing links to attachments in the desired format</h1>\n\n<p>Loop through the attachments and generate th...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44889", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3978/" ]
I want to link to attachments but through its parent page. /directors/piranha-bar/ shows all of that post's attachments on single.php and i want /directors/piranha-bar/video/name-or-ID/ to still use single.php but have the variable $video captured. How can i firstly make the links on the attachments into this format...
Showing links to attachments in the desired format ================================================== Loop through the attachments and generate the link you want: ``` $args = array( 'post_type' => 'attachment', 'numberposts' => null, 'post_status' => null, 'post_parent' => $post->ID ); $attachments = ...
44,893
<p>I have a custom post type that includes many custom fields. I would like to add them as a search target to admin search.</p> <p>Currently the admin search searches only the content and the title, I would like it to search these custom fields as well.</p> <p>Is there a way to do that ?</p>
[ { "answer_id": 44930, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 4, "selected": true, "text": "<p>It <em>is</em> possible, but you'll have to play a little bit with the actual query. As always, the furious <code>po...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44893", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/395/" ]
I have a custom post type that includes many custom fields. I would like to add them as a search target to admin search. Currently the admin search searches only the content and the title, I would like it to search these custom fields as well. Is there a way to do that ?
It *is* possible, but you'll have to play a little bit with the actual query. As always, the furious `posts_clauses` filter comes to action: ``` function wpse_alter_posts_search( $pieces ) { global $wpdb; // Make the input save $search_string = like_escape( $_GET['s'] ); // Your new WHERE clause ...
44,898
<p>I have a custom post type that is created using a form on the site. I want to disable new post creation from wordpress admin. Is there a way to do that ?</p>
[ { "answer_id": 44901, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": true, "text": "<p>There are several ways (depending on what you're trying to do):</p>\n\n<h3>If it's about the \"publish\" button</h3>...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44898", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/395/" ]
I have a custom post type that is created using a form on the site. I want to disable new post creation from wordpress admin. Is there a way to do that ?
There are several ways (depending on what you're trying to do): ### If it's about the "publish" button You could… 1. …remove the capability from the targeted role with [`remove_cap()`](http://codex.wordpress.org/Function_Reference/remove_cap) 2. …remove the [publish button 1)](https://wordpress.stackexchange.com/a/3...
44,903
<p>We develop a new WordPress site with a new theme developed exclusively for this site.</p> <p>Some widgets of the same type (such as two "Bookmarks" widgets) should be styled differently (that is have different CSS).</p> <p>My question: In this case, should I use two Bookmarks widgets or hard-code it into the theme...
[ { "answer_id": 44906, "author": "Geert", "author_id": 4936, "author_profile": "https://wordpress.stackexchange.com/users/4936", "pm_score": 0, "selected": false, "text": "<p>Taking the widget route definitely seems like to clean way to me. Note that you can also <a href=\"https://wordpre...
2012/03/08
[ "https://wordpress.stackexchange.com/questions/44903", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13880/" ]
We develop a new WordPress site with a new theme developed exclusively for this site. Some widgets of the same type (such as two "Bookmarks" widgets) should be styled differently (that is have different CSS). My question: In this case, should I use two Bookmarks widgets or hard-code it into the theme? I can write CS...
The general concept on dynamic sidebars ======================================= Basically WP loops through the global `$wp_registered_widgets` and builds the widget depending on it's arguments. You can intercept them easily: ### Use a filter You can use the `dynamic_sidebar_params` to add a class to target specific ...