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
61,784
<p>I want to change the url of the Wordpress 'Back to XXXX' on the wordpress url. </p> <p>I've used this function to change the logo url, but there doesnt seem to be a footerurl reference. </p> <pre><code>add_filter( 'login_headerurl', 'custom_login_header_url' ); function custom_login_header_url($url) { return 'ht...
[ { "answer_id": 61802, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": 3, "selected": true, "text": "<p>Since this is not a standard feature you could achieve this \nwith your own css and js you could add to the page ...
2012/08/14
[ "https://wordpress.stackexchange.com/questions/61784", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19231/" ]
I want to change the url of the Wordpress 'Back to XXXX' on the wordpress url. I've used this function to change the logo url, but there doesnt seem to be a footerurl reference. ``` add_filter( 'login_headerurl', 'custom_login_header_url' ); function custom_login_header_url($url) { return 'http://www.myurl.com/';...
Since this is not a standard feature you could achieve this with your own css and js you could add to the page like this ``` <?php function custom_login() { echo '<link rel="stylesheet" type="text/css" href="'.get_bloginfo('template_directory').'/custom-login/custom-login.css" />'; echo '<script src...
61,820
<p>I've got posts that I want to echo after the post content the categories only if they're a child of a given parent category.</p> <h3>Example:</h3> <p>Parent category: Goal<br /> Child categories of &quot;Goal&quot;: brand awareness, brand engagement</p> <p>If a post is categorized, I want it to echo out those catego...
[ { "answer_id": 61825, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 0, "selected": false, "text": "<p>What about using a conditional check?</p>\n<p>here's example which checks for parent category with ID <em>(4)</em...
2012/08/14
[ "https://wordpress.stackexchange.com/questions/61820", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10692/" ]
I've got posts that I want to echo after the post content the categories only if they're a child of a given parent category. ### Example: Parent category: Goal Child categories of "Goal": brand awareness, brand engagement If a post is categorized, I want it to echo out those category or categories: ``` <?php ...
Change: ``` $goal = get_category_by_slug('goal'); foreach($categories as $category) { $output .= '<a href="'.get_category_link($category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$seperator; } ``` Into: ``` foreach( $categori...
61,822
<p>I have the following JSON array:</p> <pre><code>[{"occurences":"1","post_title":"Test 1","ID":"16"}, {"occurences":"1","post_title":"Test 2","ID":"19"}, {"occurences":"1","post_title":"\u543b\u60a8\u7684\u5c41\u80a1","ID":"21"}] </code></pre> <p>And I use this js to parse and print it:</p> <pre><code>succe...
[ { "answer_id": 61829, "author": "Jasper Denkers", "author_id": 19129, "author_profile": "https://wordpress.stackexchange.com/users/19129", "pm_score": -1, "selected": false, "text": "<ol>\n<li>Add <code>var json = jQuery.parseJSON(data);</code></li>\n<li>Define <code>content</code> by ad...
2012/08/14
[ "https://wordpress.stackexchange.com/questions/61822", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18258/" ]
I have the following JSON array: ``` [{"occurences":"1","post_title":"Test 1","ID":"16"}, {"occurences":"1","post_title":"Test 2","ID":"19"}, {"occurences":"1","post_title":"\u543b\u60a8\u7684\u5c41\u80a1","ID":"21"}] ``` And I use this js to parse and print it: ``` success:function(data){ $.each(data, ...
``` $.ajax({ url: 'http://mypath/wp-admin/admin-ajax.php', data:{ 'action':'go_ajax', 'fn':'spw_autosuggest', 'queryString': $.trim(inputString.val()) }, dataType: 'JS...
61,831
<p>I developed a site locally with <code>/%postname%/</code> permalink structure. I did some sample posts locally and wanted to move this entire local setup to a temporary subdomain like <a href="http://review.clientsite.com" rel="nofollow">http://review.clientsite.com</a>. </p> <p>1.) I exported the local sql table a...
[ { "answer_id": 61837, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 1, "selected": false, "text": "<p>You have to change other URLs in the database, not just in the wp_options tables. Use these queries in phpmya...
2012/08/14
[ "https://wordpress.stackexchange.com/questions/61831", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
I developed a site locally with `/%postname%/` permalink structure. I did some sample posts locally and wanted to move this entire local setup to a temporary subdomain like <http://review.clientsite.com>. 1.) I exported the local sql table and imported it on the real database 2.) I changed the two fields inside the ...
You have to change other URLs in the database, not just in the wp\_options tables. Use these queries in phpmyadmin to change post links and metadata within post and page content: ``` UPDATE wp_posts SET guid = replace(guid, 'http://www.olddomain.com/','http://www.newdomain.com/'); UPDATE wp_posts SET post_content = r...
61,872
<p>I have been working with WordPress for the past 3-4 years, but I am new to BuddyPress.</p> <p>I would like to hide the admin account completely from BuddyPress for security reasons. For example with a regular WordPress blog I would have two separate accounts (one with admin privileges that remains hidden, and anoth...
[ { "answer_id": 61875, "author": "Diana", "author_id": 17048, "author_profile": "https://wordpress.stackexchange.com/users/17048", "pm_score": 2, "selected": false, "text": "<p>I found this:</p>\n<blockquote>\n<p><strong>Exclude Users from Members directory on a BuddyPress based social ne...
2012/08/15
[ "https://wordpress.stackexchange.com/questions/61872", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17869/" ]
I have been working with WordPress for the past 3-4 years, but I am new to BuddyPress. I would like to hide the admin account completely from BuddyPress for security reasons. For example with a regular WordPress blog I would have two separate accounts (one with admin privileges that remains hidden, and another one wit...
I found this: > > **Exclude Users from Members directory on a BuddyPress based social network** > > > We will need to hook to `'bp_ajax_querystring'` filter. > > > The following code will allow to exclude the users from the members directory. They will be still listed in the friends list of other users with whom ...
61,877
<p>Id like to have wordpress automatically wrap a div around any <code>iframe</code> or <code>embed</code> when they are used in <code>the_content</code>...how might this be achieved?</p>
[ { "answer_id": 61882, "author": "alexndm", "author_id": 4678, "author_profile": "https://wordpress.stackexchange.com/users/4678", "pm_score": 3, "selected": true, "text": "<p>try jQuery</p>\n\n<pre><code>$('iframe').wrap('&lt;div class=\"wrapper\" /&gt;');\n</code></pre>\n" }, { ...
2012/08/15
[ "https://wordpress.stackexchange.com/questions/61877", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3567/" ]
Id like to have wordpress automatically wrap a div around any `iframe` or `embed` when they are used in `the_content`...how might this be achieved?
try jQuery ``` $('iframe').wrap('<div class="wrapper" />'); ```
61,888
<p>I making my first Wordpress template. I used this code to add only the h1 to the page.</p> <pre><code>&lt;?php $title = get_the_title($post-&gt;ID); echo $title; ?&gt; </code></pre> <p>But is there a code. That only add the post to the page?</p>
[ { "answer_id": 61882, "author": "alexndm", "author_id": 4678, "author_profile": "https://wordpress.stackexchange.com/users/4678", "pm_score": 3, "selected": true, "text": "<p>try jQuery</p>\n\n<pre><code>$('iframe').wrap('&lt;div class=\"wrapper\" /&gt;');\n</code></pre>\n" }, { ...
2012/08/15
[ "https://wordpress.stackexchange.com/questions/61888", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17868/" ]
I making my first Wordpress template. I used this code to add only the h1 to the page. ``` <?php $title = get_the_title($post->ID); echo $title; ?> ``` But is there a code. That only add the post to the page?
try jQuery ``` $('iframe').wrap('<div class="wrapper" />'); ```
61,896
<p>I have the following below which I have used to create a custom post type and a custom taxonomy.</p> <p>Within the products section I've created the categories "monitors" &amp; "consumables".</p> <p>I have then created the template taxonomy-monitors.php, is that correctly named for the monitors category? Also what...
[ { "answer_id": 61898, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 4, "selected": false, "text": "<h2>Templates</h2>\n\n<p>See the <a href=\"http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_d...
2012/08/15
[ "https://wordpress.stackexchange.com/questions/61896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
I have the following below which I have used to create a custom post type and a custom taxonomy. Within the products section I've created the categories "monitors" & "consumables". I have then created the template taxonomy-monitors.php, is that correctly named for the monitors category? Also what is the url I need to...
Templates --------- See the [Template Hiearchy](http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display) for a more detailed break down of how WordPress chooses the template. For a *taxonomy term* `slug` ('monitors' your example) in the taxonomy `taxonomy` (e.g. 'products') WordPress will *try* to use...
61,909
<p>I used the Custom Category Post Order plugin in my Wordpress site. But this plugin load 4 times jquery ui code in. This jQuery ui code generate errors in my own javascript code. Is it posible to load only the jquery ui script in the admin page in wordpress. Of is that not possible.?</p>
[ { "answer_id": 61910, "author": "FlashingCursor", "author_id": 9276, "author_profile": "https://wordpress.stackexchange.com/users/9276", "pm_score": 0, "selected": false, "text": "<p>It's very possible, and a good plugin writer should know better. The solution is not a simple one, and u...
2012/08/15
[ "https://wordpress.stackexchange.com/questions/61909", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17868/" ]
I used the Custom Category Post Order plugin in my Wordpress site. But this plugin load 4 times jquery ui code in. This jQuery ui code generate errors in my own javascript code. Is it posible to load only the jquery ui script in the admin page in wordpress. Of is that not possible.?
This is a very poorly coded plugin, and a good writer should know better. I've grepped through the code and found the `process_post` method which is hooked into *init* (why?!) and enqueues *jquery-ui-sortable* which is probably the code which breaks your code: ``` function process_post(){ global $wp_query; wp...
61,915
<p>I'm trying to get up to speed with the terminology of the ins and outs of WordPress, so apologies.</p> <p>I'm setting up a full site utilizing WordPress and a custom template, basing it on TwentyTen underpinnings.</p> <p>I'm trying to have as much as possible under the "post" Post Type, and the top level "list" pa...
[ { "answer_id": 61921, "author": "artparks", "author_id": 7343, "author_profile": "https://wordpress.stackexchange.com/users/7343", "pm_score": 5, "selected": true, "text": "<p>Make your single.php the following: </p>\n\n<pre><code>&lt;?php\n$post = $wp_query-&gt;post;\n\nif ( in_categ...
2012/08/15
[ "https://wordpress.stackexchange.com/questions/61915", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10692/" ]
I'm trying to get up to speed with the terminology of the ins and outs of WordPress, so apologies. I'm setting up a full site utilizing WordPress and a custom template, basing it on TwentyTen underpinnings. I'm trying to have as much as possible under the "post" Post Type, and the top level "list" pages just be the c...
Make your single.php the following: ``` <?php $post = $wp_query->post; if ( in_category( 'work' ) ) { include( TEMPLATEPATH.'/single-work-cat.php' ); } else { include( TEMPLATEPATH.'/single-generic.php' ); } ?> ``` and make single-work-cat.php the template you wish to show for single work category posts, and ...
61,922
<p>So on the add post screen in wordpress there is the category checkbox div. Before you select a category for your post it shows the correct hierarchical structure as defined in the category admin screen. After selecting a category and saving the post it will put your selected category at the top of the list instead o...
[ { "answer_id": 61925, "author": "Tom Auger", "author_id": 3687, "author_profile": "https://wordpress.stackexchange.com/users/3687", "pm_score": 1, "selected": true, "text": "<p>Yup.</p>\n\n<p>Use the <code>add_meta_boxes_post</code> to add a new category metabox that preserves the struct...
2012/08/15
[ "https://wordpress.stackexchange.com/questions/61922", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19261/" ]
So on the add post screen in wordpress there is the category checkbox div. Before you select a category for your post it shows the correct hierarchical structure as defined in the category admin screen. After selecting a category and saving the post it will put your selected category at the top of the list instead of k...
Yup. Use the `add_meta_boxes_post` to add a new category metabox that preserves the structure and while you're at it, remove the default one, like this: ``` add_action( 'add_meta_boxes_post', 'fix_hierarchical_post_categories_metaboxes', 10, 1 ); ``` And here's the callback: ``` /* * This include provides an alte...
61,927
<p>I have been able to register a new post type. 'code' and now I would like to display it. I added </p> <pre><code>add_filter( 'pre_get_posts', 'my_get_posts' ); function my_get_posts( $query ) { if ( is_home() ) $query-&gt;set( 'post_type', array( 'post', 'page', 'album', 'movie', 'quote', 'code', 'attachment' ...
[ { "answer_id": 61931, "author": "westondeboer", "author_id": 2691, "author_profile": "https://wordpress.stackexchange.com/users/2691", "pm_score": 1, "selected": false, "text": "<p>You should be able to just create the template archive-code.php, and that will loop through your 'code' onl...
2012/08/15
[ "https://wordpress.stackexchange.com/questions/61927", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19271/" ]
I have been able to register a new post type. 'code' and now I would like to display it. I added ``` add_filter( 'pre_get_posts', 'my_get_posts' ); function my_get_posts( $query ) { if ( is_home() ) $query->set( 'post_type', array( 'post', 'page', 'album', 'movie', 'quote', 'code', 'attachment' ) ); return $...
The simplest way is to create Page (maybe call it "All Codes"). Then, you "hijack" that page's PHP template by creating a PHP file in your theme's directory called `page-all-codes.php` (note how the "all-codes" part corresponds to the slug of the Page you created). You can then use [WP\_Query](http://codex.wordpress.o...
61,966
<p>I recently converted a site from Moveable Type to WordPress and noticed that the permalinks for each post are short, cut off and have underscores in them.</p> <p>What I am looking to do is if there is a script or SQL command I can run to mass change each posts permalink to the default permalink it would have normal...
[ { "answer_id": 61978, "author": "Clorith", "author_id": 19307, "author_profile": "https://wordpress.stackexchange.com/users/19307", "pm_score": 1, "selected": false, "text": "<p>It would seem the importer did not fully import slug names, or had a slug limit, which caused this effect.</p>...
2012/08/16
[ "https://wordpress.stackexchange.com/questions/61966", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19302/" ]
I recently converted a site from Moveable Type to WordPress and noticed that the permalinks for each post are short, cut off and have underscores in them. What I am looking to do is if there is a script or SQL command I can run to mass change each posts permalink to the default permalink it would have normally generat...
Maybe this doesn't answer your question... but maybe you can adapt it to suit by changing what you put into $slug. Try this, which should loop over posts and reset the slug to match the post name. For pages, add `'post_type' => 'page'` to the array passed to get\_posts(). ``` $posts = get_posts(array('posts_per_page'...
61,971
<p>I have the following page which contains a single post and a number of comments:<br> <br>http://mysite.com/tips</p> <p>When a user posts a comment, I add meta-data to it so I can filter comments by using these URL's: <br>http://mysite/tips?id=cat&amp;filter_id=1 <br>http://mysite/tips?id=dog&amp;filter...
[ { "answer_id": 61972, "author": "Seeker", "author_id": 18837, "author_profile": "https://wordpress.stackexchange.com/users/18837", "pm_score": -1, "selected": false, "text": "<p>I Think you want to change the Permalink Style You can change the Permalink of your website through admin pane...
2012/08/16
[ "https://wordpress.stackexchange.com/questions/61971", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19306/" ]
I have the following page which contains a single post and a number of comments: http://mysite.com/tips When a user posts a comment, I add meta-data to it so I can filter comments by using these URL's: http://mysite/tips?id=cat&filter\_id=1 http://mysite/tips?id=dog&filter\_id=2 I want to use the following url'...
You can add a rewrite rule such as the following. Make sure to register your public query vars with WordPress so it recognizes your rewrite rule vars. ``` add_rewrite_rule('^(tips)/([^/]*)/([^/]*)/?', 'index.php?name=$matches[1]&id=$matches[2]&filter_id=$matches[3]','top'); add_filter('query_vars', 'foo_my_query_vars...
61,995
<p>I have two sidebar widgets, I need to display 1 widget on the archive pages for the standard post categories and the other widget needs to show on just the archive pages for a specific custom post type.</p> <p>If I use the conditional tag is_archive() then both widgets will show up on both archive pages. </p> <p>H...
[ { "answer_id": 62010, "author": "Zach", "author_id": 9605, "author_profile": "https://wordpress.stackexchange.com/users/9605", "pm_score": 2, "selected": false, "text": "<p>You could use the <a href=\"http://codex.wordpress.org/Function_Reference/is_tax\" rel=\"nofollow\">is_tax()</a> fu...
2012/08/16
[ "https://wordpress.stackexchange.com/questions/61995", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19312/" ]
I have two sidebar widgets, I need to display 1 widget on the archive pages for the standard post categories and the other widget needs to show on just the archive pages for a specific custom post type. If I use the conditional tag is\_archive() then both widgets will show up on both archive pages. How can I determi...
You could use the [is\_tax()](http://codex.wordpress.org/Function_Reference/is_tax) function to accomplish this. The first parameter, the taxonomy slug is optional, but you do want to specify it. This would be something like `product-categories`. The second, a specific term, is also optional. It'd be perfectly accepta...
62,014
<p>I have added a menu page to my plugin. In the <a href="http://codex.wordpress.org/Function_Reference/add_menu_page" rel="nofollow noreferrer">wp codex</a> is described that I can use a seperate .php file for the content of the menu.</p> <pre><code>function register_custom_menu_page() { add_menu_page('custom menu ...
[ { "answer_id": 62002, "author": "nvwd", "author_id": 18496, "author_profile": "https://wordpress.stackexchange.com/users/18496", "pm_score": 2, "selected": false, "text": "<p>Looks like someone has the documentation to assist with this:</p>\n\n<p><a href=\"https://github.com/h5bp/ant-bui...
2012/08/16
[ "https://wordpress.stackexchange.com/questions/62014", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12614/" ]
I have added a menu page to my plugin. In the [wp codex](http://codex.wordpress.org/Function_Reference/add_menu_page) is described that I can use a seperate .php file for the content of the menu. ``` function register_custom_menu_page() { add_menu_page('custom menu title', 'custom menu', 'add_users', 'myplugin/mypl...
There are several starter themes out there based on HTML5 Boilerplate, so you may find that forking one of them is a better option that rolling your own. * [Eulerplate](https://github.com/bytefair/eulerplate) * [Essence](https://github.com/kevva/essence) * [Roots](http://www.rootstheme.com/) * [Bones](https://github.c...
62,045
<p>I believe what I am trying to achieve is quite easy but I am failing to grasp what is needed here.</p> <p>I want a section in the admin panel... lets say "page sections"</p> <p>under that, I want to be able to add multiple post types. i.e. lets say </p> <p>"add member", "add foo", "add bar" ...</p> <p>I currentl...
[ { "answer_id": 62049, "author": "jepser", "author_id": 6519, "author_profile": "https://wordpress.stackexchange.com/users/6519", "pm_score": 0, "selected": false, "text": "<p>I think you might check the labels docs for post types like this:</p>\n\n<pre><code>function codex_custom_init() ...
2012/08/16
[ "https://wordpress.stackexchange.com/questions/62045", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7016/" ]
I believe what I am trying to achieve is quite easy but I am failing to grasp what is needed here. I want a section in the admin panel... lets say "page sections" under that, I want to be able to add multiple post types. i.e. lets say "add member", "add foo", "add bar" ... I currently have ``` add_action( 'init'...
Sorry, try this: ``` 'show_ui' => false, 'menu_position' => 'edit.php?post_type=main_posttype or registered section' ``` For example if you want it under Themes it would be: ``` 'menu_position' => 'themes.php' ``` This on your post type registering.
62,047
<p>I'm using wp all import to load in datafeeds but when i set a custom field (thats needed for the theme) it keeps modding it before it stores it</p> <p>when I put this in the field : a:7:{test}</p> <p>it saves it as s:10"a:7:{test}"</p> <p>Even when I update thru update_post_meta and set it there manually it adds ...
[ { "answer_id": 62049, "author": "jepser", "author_id": 6519, "author_profile": "https://wordpress.stackexchange.com/users/6519", "pm_score": 0, "selected": false, "text": "<p>I think you might check the labels docs for post types like this:</p>\n\n<pre><code>function codex_custom_init() ...
2012/08/16
[ "https://wordpress.stackexchange.com/questions/62047", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17478/" ]
I'm using wp all import to load in datafeeds but when i set a custom field (thats needed for the theme) it keeps modding it before it stores it when I put this in the field : a:7:{test} it saves it as s:10"a:7:{test}" Even when I update thru update\_post\_meta and set it there manually it adds the s:10... How can I...
Sorry, try this: ``` 'show_ui' => false, 'menu_position' => 'edit.php?post_type=main_posttype or registered section' ``` For example if you want it under Themes it would be: ``` 'menu_position' => 'themes.php' ``` This on your post type registering.
62,054
<p>I am making my first custom walker to build an accordion menu. To start with I used this example: <a href="http://bitacre.com/2025/custom-nav-menu-walker-for-wordpress-themes">http://bitacre.com/2025/custom-nav-menu-walker-for-wordpress-themes</a></p> <p>There are two functions. First start_lvl and then start_el.</...
[ { "answer_id": 62059, "author": "AlxVallejo", "author_id": 10099, "author_profile": "https://wordpress.stackexchange.com/users/10099", "pm_score": -1, "selected": false, "text": "<p>You can simply add $page to the argument of the custom walker:</p>\n\n<pre><code>class My_Custom_Walker ex...
2012/08/16
[ "https://wordpress.stackexchange.com/questions/62054", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19334/" ]
I am making my first custom walker to build an accordion menu. To start with I used this example: <http://bitacre.com/2025/custom-nav-menu-walker-for-wordpress-themes> There are two functions. First start\_lvl and then start\_el. In start\_el the ID get's implemented by $item->ID. Does anybody know how I can do this ...
I just had to do this in one of my themes... Since you don't have access to the $item variable at that stage of the Walker, you would want to store your current item in a more global scope at the moment you do have access to it. The following code will make more sense... note: I've stripped everything but the relevant ...
62,063
<p>I'm writing a basic plugin. Here's my code:</p> <pre><code>$new_user = get_userdata($user_id); $first_name1 = $new_user-&gt;user_firstname; $last_name1 = $new_user-&gt;user_lastname; echo "&lt;" . $first_name1 . $last_name1 . "&gt;"; //returns: &lt;&gt; $first_name2 = $new_user-first_name; $last_name2 = $...
[ { "answer_id": 62064, "author": "HungryCoder", "author_id": 17129, "author_profile": "https://wordpress.stackexchange.com/users/17129", "pm_score": 1, "selected": false, "text": "<p>According to the same page you referred, those two lines should be like:</p>\n\n<pre><code>$first_name = $...
2012/08/16
[ "https://wordpress.stackexchange.com/questions/62063", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11363/" ]
I'm writing a basic plugin. Here's my code: ``` $new_user = get_userdata($user_id); $first_name1 = $new_user->user_firstname; $last_name1 = $new_user->user_lastname; echo "<" . $first_name1 . $last_name1 . ">"; //returns: <> $first_name2 = $new_user-first_name; $last_name2 = $new_user->last_name; echo "<...
You have to use the function [`get_user_meta`](http://codex.wordpress.org/Function_Reference/get_user_meta) ``` $new_user = get_userdata($user_id); // get all the meta data of the user $new_user_data = get_user_meta( $user_id ); // get the first name of the user as a string $new_user_firstname = get_user_meta( $user...
62,065
<p>I would like to control who can see a page in BuddyPress and restrict anyone else from accessing it.</p> <p>Something along the lines of the following pseudocode:</p> <pre><code>&lt;?php if ( loggedin_user_ids==1,4,5,7 ) { ?&gt; // Show page &lt;?php } else { ?&gt; // "You are not allowed to view this page" messag...
[ { "answer_id": 62105, "author": "Robert Bouten", "author_id": 19334, "author_profile": "https://wordpress.stackexchange.com/users/19334", "pm_score": 2, "selected": false, "text": "<p>I did something like this a while ago. I think I've put a template file 'bbpress.php' in my theme folder...
2012/08/16
[ "https://wordpress.stackexchange.com/questions/62065", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17869/" ]
I would like to control who can see a page in BuddyPress and restrict anyone else from accessing it. Something along the lines of the following pseudocode: ``` <?php if ( loggedin_user_ids==1,4,5,7 ) { ?> // Show page <?php } else { ?> // "You are not allowed to view this page" message <?php } ?> ``` So basically, ...
> > I am new to BuddyPress so I don't know which functions and variables to use here. > > > Read the codex - for example: <http://codex.buddypress.org/developer-docs/the-bp-global/> You could create a function in your theme- functions.php or in bp-custom.php and call it from template files and pass it parameters...
62,069
<p>I have a site that features tables comparing products over hundreds of pages. Many of these products appear multiple times and I originally made these tables static, and now need a more efficient way to manage them.</p> <p>For example, if 'Product 1' has a change in price, I'd like to just have it so I can edit the...
[ { "answer_id": 62105, "author": "Robert Bouten", "author_id": 19334, "author_profile": "https://wordpress.stackexchange.com/users/19334", "pm_score": 2, "selected": false, "text": "<p>I did something like this a while ago. I think I've put a template file 'bbpress.php' in my theme folder...
2012/08/16
[ "https://wordpress.stackexchange.com/questions/62069", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19344/" ]
I have a site that features tables comparing products over hundreds of pages. Many of these products appear multiple times and I originally made these tables static, and now need a more efficient way to manage them. For example, if 'Product 1' has a change in price, I'd like to just have it so I can edit the price and...
> > I am new to BuddyPress so I don't know which functions and variables to use here. > > > Read the codex - for example: <http://codex.buddypress.org/developer-docs/the-bp-global/> You could create a function in your theme- functions.php or in bp-custom.php and call it from template files and pass it parameters...
62,077
<p>I just did a manual install and tried to login, but was unable to do so using domain.com/login. I got a 404 error. When I used domain.com/wp-admin, no issues. Did I do something wrong or forget to do something?</p>
[ { "answer_id": 62078, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p><code>/wp-admin/</code> is an existing directory, your server just adds the missing <code>/</code>.<br>\n<code>/login<...
2012/08/17
[ "https://wordpress.stackexchange.com/questions/62077", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2709/" ]
I just did a manual install and tried to login, but was unable to do so using domain.com/login. I got a 404 error. When I used domain.com/wp-admin, no issues. Did I do something wrong or forget to do something?
`/wp-admin/` is an existing directory, your server just adds the missing `/`. `/login` is … nothing. The correct name is `/wp-login.php`. If you have enabled permalinks [it should work](http://core.trac.wordpress.org/changeset/19880) though. To make `/login` *always* work add the following line to your `.htaccess`...
62,083
<p>I'm trying to access the $user->first_name property from a function triggered by the <code>register_user</code> action hook but it's not there:</p> <pre><code>function do_stuff($user_id) { $new_user = get_userdata($user_id); $first_name1 = $new_user-&gt;user_firstname; $last_name1 = $new_user-&gt;user_lastname; ...
[ { "answer_id": 62078, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p><code>/wp-admin/</code> is an existing directory, your server just adds the missing <code>/</code>.<br>\n<code>/login<...
2012/08/17
[ "https://wordpress.stackexchange.com/questions/62083", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11363/" ]
I'm trying to access the $user->first\_name property from a function triggered by the `register_user` action hook but it's not there: ``` function do_stuff($user_id) { $new_user = get_userdata($user_id); $first_name1 = $new_user->user_firstname; $last_name1 = $new_user->user_lastname; echo "<" . $first_name1 . $...
`/wp-admin/` is an existing directory, your server just adds the missing `/`. `/login` is … nothing. The correct name is `/wp-login.php`. If you have enabled permalinks [it should work](http://core.trac.wordpress.org/changeset/19880) though. To make `/login` *always* work add the following line to your `.htaccess`...
62,084
<p>I hope I can explain this properly:</p> <p>I'm working on a project involving multiple post types and custom permalinks. I have a post type for TV/movie series/franchise and a separate post type for content (episodes, movies, Direct to video). For the content type, I currently have a permalink that is as so:</p> ...
[ { "answer_id": 62096, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 2, "selected": true, "text": "<p>I've shared this exact frustration before. The following should help return any lost sanity.</p>\n\n<p>Your ...
2012/08/17
[ "https://wordpress.stackexchange.com/questions/62084", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2234/" ]
I hope I can explain this properly: I'm working on a project involving multiple post types and custom permalinks. I have a post type for TV/movie series/franchise and a separate post type for content (episodes, movies, Direct to video). For the content type, I currently have a permalink that is as so: ``` abc.com/wat...
I've shared this exact frustration before. The following should help return any lost sanity. Your first rewrite is pretty loose and is not seeing your second rewrite because 'page' matches your second segment of ([^/]+). The way to fix this is reverse the order of registration within the code. If the paged rewrite is ...
62,107
<h2>Issue</h2> <p>I am about to embark on some WordPress development in a multi person team environment. (3 or more people working on the same codebase at a time, each developing locally)</p> <p>With other CMSes we have worked with, everyone has pointed their installs at the same database and because of how that CMS/...
[ { "answer_id": 62589, "author": "davemac", "author_id": 131, "author_profile": "https://wordpress.stackexchange.com/users/131", "pm_score": 2, "selected": false, "text": "<p>I will answer question 2, be aware that some values in the database are stored in serialised arrays. For example, ...
2012/08/17
[ "https://wordpress.stackexchange.com/questions/62107", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2272/" ]
Issue ----- I am about to embark on some WordPress development in a multi person team environment. (3 or more people working on the same codebase at a time, each developing locally) With other CMSes we have worked with, everyone has pointed their installs at the same database and because of how that CMS/database has ...
I will answer question 2, be aware that some values in the database are stored in serialised arrays. For example, if the length of your URL string changes and it's in a serialised array, then you need to update the index for it. You can use [this PHP script](https://github.com/interconnectit/Search-Replace-DB) to upd...
62,142
<p>I have read a <a href="https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts"><strong>number</strong></a> <a href="https://wordpress.stackexchange.com/questions/9630/am-i-using-get-posts-wrong?lq=1">of</a> <a href="https://wordpress.stackexchange.com/questions/50...
[ { "answer_id": 62148, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 5, "selected": true, "text": "<h3>The difference between get_posts &amp; WP_Query</h3>\n\n<p>You can view <code>get_posts()</code> as a sli...
2012/08/17
[ "https://wordpress.stackexchange.com/questions/62142", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6169/" ]
I have read a [**number**](https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts) [of](https://wordpress.stackexchange.com/questions/9630/am-i-using-get-posts-wrong?lq=1) [**questions**](https://wordpress.stackexchange.com/questions/50761/when-to-use-wp-query-query-...
### The difference between get\_posts & WP\_Query You can view `get_posts()` as a slimmed down `WP_Query`. In fact looking at the [source](https://github.com/WordPress/WordPress/blob/3.4.1/wp-includes/post.php#L1433): ``` //... prepares query array $r $get_posts = new WP_Query; return $get_posts->query($r); ``` `ge...
62,156
<p>I've built an HTML table that is posted on a page in my site, and I'd like to use that same content inside a blog post (something of an announcement of the table's publication). The table is likely to get updated from time to time, so I'd like to have a single source for maintenance purposes.</p> <p>Is there a way ...
[ { "answer_id": 62161, "author": "Jeff Shinn", "author_id": 19369, "author_profile": "https://wordpress.stackexchange.com/users/19369", "pm_score": 1, "selected": false, "text": "<p>I would look at using the WordPress SHortcode API:</p>\n\n<p><a href=\"http://codex.wordpress.org/Shortcode...
2012/08/17
[ "https://wordpress.stackexchange.com/questions/62156", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19368/" ]
I've built an HTML table that is posted on a page in my site, and I'd like to use that same content inside a blog post (something of an announcement of the table's publication). The table is likely to get updated from time to time, so I'd like to have a single source for maintenance purposes. Is there a way I can do a...
Create a shortcode to embed the content. This will always be synchronized. Sample code from an older project. Just updated. :) GitHub: <https://gist.github.com/3380118> · This post in German (*auf Deutsch*) [on my blog](http://toscho.de/2012/wordpress-seite-einbetten/ "Eine Seite in eine andere einbetten"). ``` <?ph...
62,172
<p>I'm attempting to automatically add a class to all links created when clicking the "link" button in tinyMCE. I've found this snippet in the tinyMCE docs:</p> <pre><code>// Adds a class to all paragraphs in the active editor tinyMCE.activeEditor.dom.addClass( tinyMCE.activeEditor.dom.select('p'), 'myclass' )...
[ { "answer_id": 62429, "author": "reK1NDLE", "author_id": 19374, "author_profile": "https://wordpress.stackexchange.com/users/19374", "pm_score": 1, "selected": false, "text": "<p>So I ended up doing a jQuery fix rather than going through tinyMCE. Code as follows:</p>\n\n<pre><code>jQuery...
2012/08/17
[ "https://wordpress.stackexchange.com/questions/62172", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19374/" ]
I'm attempting to automatically add a class to all links created when clicking the "link" button in tinyMCE. I've found this snippet in the tinyMCE docs: ``` // Adds a class to all paragraphs in the active editor tinyMCE.activeEditor.dom.addClass( tinyMCE.activeEditor.dom.select('p'), 'myclass' ); ``` I thin...
So I ended up doing a jQuery fix rather than going through tinyMCE. Code as follows: ``` jQuery(document).ready(function(){ $("#content a").addClass("link_color"); }); ```
62,193
<p>I have created a search box with a drop down box of 4 options to customize the search: </p> <ul> <li>A general default search, no filter</li> <li>A custom search according to the post title for a custom post type only.</li> <li>A custom search according to the post content for a custom post type only.</li> <li>A cu...
[ { "answer_id": 62196, "author": "xiarnousx", "author_id": 19323, "author_profile": "https://wordpress.stackexchange.com/users/19323", "pm_score": 0, "selected": false, "text": "<p>you use action hook to format the wp_query before execution take a look at \n<a href=\"http://codex.wordpres...
2012/08/17
[ "https://wordpress.stackexchange.com/questions/62193", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10972/" ]
I have created a search box with a drop down box of 4 options to customize the search: * A general default search, no filter * A custom search according to the post title for a custom post type only. * A custom search according to the post content for a custom post type only. * A custom search according to the meta v...
Well, perhaps the answer could not be found in the `WP_Query` class for what I was trying to accomplish. Below is the final code that I plugged in to my functions.php file. I ultimately ended up search the `WP_Query` Class found in the `wp_includes/query.php` file. What I discovered is that there are a number of filter...
62,201
<p>Help, this is probably the best way to have control over the styling of the wp_tag_cloud ...</p> <p>I was looking for a way to add <a href="http://digwp.com/2010/01/rounded-font-sizes-tag-clouds/" rel="nofollow noreferrer">size based classes</a> to my tags within the tag cloud widget. The problem here is that this ...
[ { "answer_id": 62238, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 3, "selected": true, "text": "<p>try this code:</p>\n\n<pre><code>add_filter ( 'wp_tag_cloud', 'tag_cloud_font_size_class' ); \nfunction tag_clou...
2012/08/18
[ "https://wordpress.stackexchange.com/questions/62201", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14008/" ]
Help, this is probably the best way to have control over the styling of the wp\_tag\_cloud ... I was looking for a way to add [size based classes](http://digwp.com/2010/01/rounded-font-sizes-tag-clouds/) to my tags within the tag cloud widget. The problem here is that this solution only works when hard coded into for ...
try this code: ``` add_filter ( 'wp_tag_cloud', 'tag_cloud_font_size_class' ); function tag_cloud_font_size_class( $taglinks ) { $tags = explode('</a>', $taglinks); $regex1 = "#(.*style='font-size:)(.*)((pt|px|em|pc|%);'.*)#e"; $regex2 = "#(style='font-size:)(.*)((pt|px|em|pc|%);')#e"; $re...
62,207
<p>Apologies if this is not a <em>question</em> and belongs more in discussion, but In dealing with image attachments for a portfolio site, what is the benefit to having images be "attached" to a post versus saving the image IDs as an array in a post_meta field? </p>
[ { "answer_id": 62238, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 3, "selected": true, "text": "<p>try this code:</p>\n\n<pre><code>add_filter ( 'wp_tag_cloud', 'tag_cloud_font_size_class' ); \nfunction tag_clou...
2012/08/18
[ "https://wordpress.stackexchange.com/questions/62207", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6477/" ]
Apologies if this is not a *question* and belongs more in discussion, but In dealing with image attachments for a portfolio site, what is the benefit to having images be "attached" to a post versus saving the image IDs as an array in a post\_meta field?
try this code: ``` add_filter ( 'wp_tag_cloud', 'tag_cloud_font_size_class' ); function tag_cloud_font_size_class( $taglinks ) { $tags = explode('</a>', $taglinks); $regex1 = "#(.*style='font-size:)(.*)((pt|px|em|pc|%);'.*)#e"; $regex2 = "#(style='font-size:)(.*)((pt|px|em|pc|%);')#e"; $re...
62,210
<p>I'm trying to move my WordPress blog from Windows to Linux, but I'm seeing a weird character encoding problem in the Linux version that I'm not seeing on Windows. (I had thought it was an issue with the way I used <code>mysqldump</code> to export the data, but after upgrading mysql, dumping, checking, etc., I'm pret...
[ { "answer_id": 62238, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 3, "selected": true, "text": "<p>try this code:</p>\n\n<pre><code>add_filter ( 'wp_tag_cloud', 'tag_cloud_font_size_class' ); \nfunction tag_clou...
2012/08/18
[ "https://wordpress.stackexchange.com/questions/62210", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/927/" ]
I'm trying to move my WordPress blog from Windows to Linux, but I'm seeing a weird character encoding problem in the Linux version that I'm not seeing on Windows. (I had thought it was an issue with the way I used `mysqldump` to export the data, but after upgrading mysql, dumping, checking, etc., I'm pretty sure I did ...
try this code: ``` add_filter ( 'wp_tag_cloud', 'tag_cloud_font_size_class' ); function tag_cloud_font_size_class( $taglinks ) { $tags = explode('</a>', $taglinks); $regex1 = "#(.*style='font-size:)(.*)((pt|px|em|pc|%);'.*)#e"; $regex2 = "#(style='font-size:)(.*)((pt|px|em|pc|%);')#e"; $re...
62,221
<p>I have tried many solutions to no avail and really need some help.</p> <p>I have a Custom Post Type named "Portfolio" that is setup to display it's contents on a page called Portfolio.php. Wp PageNavi is hardcoded into the template and works fine under the Default permalink structure. When I try to switch permalink...
[ { "answer_id": 62223, "author": "Breezer", "author_id": 8818, "author_profile": "https://wordpress.stackexchange.com/users/8818", "pm_score": 0, "selected": false, "text": "<p>As far as i can its your query that is wrong...\nChant</p>\n\n<pre><code>&lt;?php //query_posts('paged='.$paged)...
2012/08/18
[ "https://wordpress.stackexchange.com/questions/62221", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19397/" ]
I have tried many solutions to no avail and really need some help. I have a Custom Post Type named "Portfolio" that is setup to display it's contents on a page called Portfolio.php. Wp PageNavi is hardcoded into the template and works fine under the Default permalink structure. When I try to switch permalinks to /%pos...
Problem solved. It was because I had the Custom Post Type and the Page name the same, "Portfolio" for both. Once I changed this, I went to Settings > Permalinks and flushed. Re-Saved Links. Then checked all the posts links that was using the CPT, and everything went fine after that. I did use the edit from Breezer as w...
62,232
<p>One you have called a template with <code>get_template_part()</code> (or <code>locate_template()</code>) is there a way to know what template you are in.</p> <p>For example if you call <code>get_template_part('loop','archive');</code> from <code>archive.php</code></p> <p>and then are working in your loop-archive.p...
[ { "answer_id": 62241, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 2, "selected": false, "text": "<p>bit of a facepalm, because the answer is in pure PHP</p>\n\n<pre><code>$path_parts = pathinfo(__FILE__);\...
2012/08/18
[ "https://wordpress.stackexchange.com/questions/62232", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6477/" ]
One you have called a template with `get_template_part()` (or `locate_template()`) is there a way to know what template you are in. For example if you call `get_template_part('loop','archive');` from `archive.php` and then are working in your loop-archive.php file. is there a way to define a variable that has the nam...
There isn't a core global variable that returns the current context. However, you can construct your own, using contextual [template conditional tags](http://codex.wordpress.org/Conditional_Tags). You can step through the conditional tags in the same order as WordPress core, by following [`wp-includes/template-loader.p...
62,247
<p>Well, am having a very hard time understanding the difference between Actions and Filters. I do use actions in my code, but am a rookie and I don't know even a slightest bit of Filters.</p> <p>I have been to codex, and various sites by NickTheGeek, BillErickson, Gary Jones etc, but no vein.</p> <p>If you can tell ...
[ { "answer_id": 62252, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>A filter <em>filters</em> content. An action <em>executes</em> an action.</p>\n\n<p>For instance, post cont...
2012/08/18
[ "https://wordpress.stackexchange.com/questions/62247", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19409/" ]
Well, am having a very hard time understanding the difference between Actions and Filters. I do use actions in my code, but am a rookie and I don't know even a slightest bit of Filters. I have been to codex, and various sites by NickTheGeek, BillErickson, Gary Jones etc, but no vein. If you can tell me in simple word...
Seeing that you've referenced 3 Genesis Developers, i'd like to answer this question using 2 Genesis code snippets as well as 2 WordPress examples of action hooks and filters. **Hooks** Different template files in Genesis include hooks which simply enable you to execute PHP code in that position of the template. Her...
62,260
<p>I have a custom post type called <code>portfolio</code> and I'm trying to add the tags taxonomy to it, how do I do this?</p>
[ { "answer_id": 62263, "author": "chifliiiii", "author_id": 4130, "author_profile": "https://wordpress.stackexchange.com/users/4130", "pm_score": 6, "selected": true, "text": "<p>Like this: (Where it says \"portfolio\" is where you register the taxonomy to a post type</p>\n\n<pre><code>ad...
2012/08/18
[ "https://wordpress.stackexchange.com/questions/62260", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15330/" ]
I have a custom post type called `portfolio` and I'm trying to add the tags taxonomy to it, how do I do this?
Like this: (Where it says "portfolio" is where you register the taxonomy to a post type ``` add_action( 'init', 'create_tag_taxonomies', 0 ); //create two taxonomies, genres and tags for the post type "tag" function create_tag_taxonomies() { // Add new taxonomy, NOT hierarchical (like tags) $labels = array( ...
62,271
<p>Using <code>&lt;?php wp_tag_cloud(''); ?&gt;</code> to display tags on my website, how do I separate each tag with a comma but also remove the comma from the last tag?</p>
[ { "answer_id": 62272, "author": "fdsa", "author_id": 8288, "author_profile": "https://wordpress.stackexchange.com/users/8288", "pm_score": 2, "selected": true, "text": "<p>According to the <a href=\"http://codex.wordpress.org/Function_Reference/wp_tag_cloud\" rel=\"nofollow\">Wordpress C...
2012/08/19
[ "https://wordpress.stackexchange.com/questions/62271", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15330/" ]
Using `<?php wp_tag_cloud(''); ?>` to display tags on my website, how do I separate each tag with a comma but also remove the comma from the last tag?
According to the [Wordpress Codex on tag clouds](http://codex.wordpress.org/Function_Reference/wp_tag_cloud), you need to specify a comma as the "separator" argument. ``` $args = "separator"=>","; wp_tag_cloud($args); ```
62,281
<p>I have been using a free web host while I set up my WP site. Now that it's all done I went and bought hosting from Namecheap.</p> <p>I uploaded the site and WordPress and everything seems to look fine, but I think I may have problems with my WP database. I couldn't figure out a way to import my old sql database whi...
[ { "answer_id": 62272, "author": "fdsa", "author_id": 8288, "author_profile": "https://wordpress.stackexchange.com/users/8288", "pm_score": 2, "selected": true, "text": "<p>According to the <a href=\"http://codex.wordpress.org/Function_Reference/wp_tag_cloud\" rel=\"nofollow\">Wordpress C...
2012/08/19
[ "https://wordpress.stackexchange.com/questions/62281", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10181/" ]
I have been using a free web host while I set up my WP site. Now that it's all done I went and bought hosting from Namecheap. I uploaded the site and WordPress and everything seems to look fine, but I think I may have problems with my WP database. I couldn't figure out a way to import my old sql database which I have ...
According to the [Wordpress Codex on tag clouds](http://codex.wordpress.org/Function_Reference/wp_tag_cloud), you need to specify a comma as the "separator" argument. ``` $args = "separator"=>","; wp_tag_cloud($args); ```
62,297
<p>I'm wondering what can I or should I NOT hook to <code>after_setup_theme</code>? I'm wondering because I have been told that I shouldn't hook <code>wp_enqueue_style</code> to it, but I have seen other places using it to hook <code>wp_enqueue_script</code> here: <a href="http://justintadlock.com/archives/2010/12/30/w...
[ { "answer_id": 62301, "author": "Mamaduka", "author_id": 888, "author_profile": "https://wordpress.stackexchange.com/users/888", "pm_score": 2, "selected": false, "text": "<p>I would recommend to check how other themes use <code>after_setup_theme</code> hook to get general idea, check <a...
2012/08/19
[ "https://wordpress.stackexchange.com/questions/62297", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1839/" ]
I'm wondering what can I or should I NOT hook to `after_setup_theme`? I'm wondering because I have been told that I shouldn't hook `wp_enqueue_style` to it, but I have seen other places using it to hook `wp_enqueue_script` here: <http://justintadlock.com/archives/2010/12/30/wordpress-theme-function-files> From what I ...
Think of WordPress execution as a series of rungs on a ladder: WordPress climbs one rung, then the next, then the next, and so on. Think of action hooks as the rungs themselves. [Here is a (slightly abbreviated, I think) list of those actions, or "rungs" executed during a typical WordPress request.](http://codex.wordp...
62,311
<p>Is there a way to have a form submit data to a admin control panel where the data is stored and can be rectified there? Could it also be able to export the data as excel for example?</p>
[ { "answer_id": 62301, "author": "Mamaduka", "author_id": 888, "author_profile": "https://wordpress.stackexchange.com/users/888", "pm_score": 2, "selected": false, "text": "<p>I would recommend to check how other themes use <code>after_setup_theme</code> hook to get general idea, check <a...
2012/08/19
[ "https://wordpress.stackexchange.com/questions/62311", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26173/" ]
Is there a way to have a form submit data to a admin control panel where the data is stored and can be rectified there? Could it also be able to export the data as excel for example?
Think of WordPress execution as a series of rungs on a ladder: WordPress climbs one rung, then the next, then the next, and so on. Think of action hooks as the rungs themselves. [Here is a (slightly abbreviated, I think) list of those actions, or "rungs" executed during a typical WordPress request.](http://codex.wordp...
62,314
<p>If I am not mistaken, the settings api only storing one single data array in wp_options table. You can only change the field data in the array. </p> <p>What if I want to add multiple array in the same table with same array structure but different value. </p> <p>What I mean is :</p> <pre><code>$data = array( '...
[ { "answer_id": 62316, "author": "danbrown", "author_id": 16885, "author_profile": "https://wordpress.stackexchange.com/users/16885", "pm_score": 1, "selected": false, "text": "<p>I just found a way of doing what I think you're after... otto just helped me out with it <a href=\"https://wo...
2012/08/19
[ "https://wordpress.stackexchange.com/questions/62314", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14728/" ]
If I am not mistaken, the settings api only storing one single data array in wp\_options table. You can only change the field data in the array. What if I want to add multiple array in the same table with same array structure but different value. What I mean is : ``` $data = array( '1' = array( 'cpt'=>...
I put this in the form so it knows its editting: ``` <form method="post" action="options.php"> <?php settings_fields('venues_section'); ?> <input type="hidden" name="editmode" value="<?php echo $editmode; ?>" /> <input type="hidden" name="venue_id" value="<?php echo $venue_id; ?>" /> <?php submit_...
62,321
<p>Is there a better way of retrieving the path of admin.php and the url of wp-admin.css?</p> <p>What I can think of is:</p> <pre><code>$adminphppath = ABSPATH . '\wp-admin\admin.php'; $admincssurl = get_bloginfo('wpurl') . '/wp-admin/css/wp-admin.css"; </code></pre> <p>But, some may be changing the admin path for s...
[ { "answer_id": 62322, "author": "Mamaduka", "author_id": 888, "author_profile": "https://wordpress.stackexchange.com/users/888", "pm_score": 4, "selected": true, "text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/admin_url\"><code>admin_url()</code></a> funct...
2012/08/19
[ "https://wordpress.stackexchange.com/questions/62321", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19360/" ]
Is there a better way of retrieving the path of admin.php and the url of wp-admin.css? What I can think of is: ``` $adminphppath = ABSPATH . '\wp-admin\admin.php'; $admincssurl = get_bloginfo('wpurl') . '/wp-admin/css/wp-admin.css"; ``` But, some may be changing the admin path for security. So I need a more reliabl...
You can use [`admin_url()`](http://codex.wordpress.org/Function_Reference/admin_url) function for wp-admin.css file and ABSPATH for admin.php. ``` $admin_php_path = ABSPATH . '/wp-admin/admin.php'; $admin_css_url = admin_url( 'css/wp-admin.css' ); ```
62,326
<p>There's this page <a href="http://voitair.com/scent-system/scent-system" rel="nofollow">http://voitair.com/scent-system/scent-system</a> I need to make editable via admin panel. It has to be understandable for a non-programmer. What system or plugin or anything can I use to make it still function as now but be edita...
[ { "answer_id": 62329, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 0, "selected": false, "text": "<p>I think you will need a custom theme settings page which can be used to get content or other settings from users....
2012/08/19
[ "https://wordpress.stackexchange.com/questions/62326", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18750/" ]
There's this page <http://voitair.com/scent-system/scent-system> I need to make editable via admin panel. It has to be understandable for a non-programmer. What system or plugin or anything can I use to make it still function as now but be editable?
I think a combination of two techniques will get you all the way there. 1. Shortcodes ------------- It's really easy to use shortcodes to wrap various content in a `<div>`/`<span>`/`<section>`. Take a look at the [Shortcode API](http://codex.wordpress.org/Shortcode_API). Then you could take something like this: ``` ...
62,337
<p>I apologize if this questions has already been answered, I have a feeling I'm just not using the right terminology for my search.</p> <p>I'm in the process of building a base theme for my employer. One of the things we want to do with this new theme is have the option to switch from a standard template to one that...
[ { "answer_id": 62343, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 0, "selected": false, "text": "<p>If I understand you correctly, you want to have one theme and just have some conditionals to load different templat...
2012/08/19
[ "https://wordpress.stackexchange.com/questions/62337", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19379/" ]
I apologize if this questions has already been answered, I have a feeling I'm just not using the right terminology for my search. I'm in the process of building a base theme for my employer. One of the things we want to do with this new theme is have the option to switch from a standard template to one that's been Zur...
When I want to change a specific part of template, such as header OR footer then I use conditions like this - ``` if(is_404()) { get_header(`error`); //loads header-error.php } else { get_header(); //loads header.php } ``` In your case, you want to load a completely different template, Now the ...
62,340
<p>Download a copy of <a href="http://modernizr.com/" rel="nofollow noreferrer">Modernizr</a>, put it in your plugin’s directory and simply enqueue the script whenever needed. Done.</p> <p>The problem is that Modernizr <strong>may already be loaded by another plugin</strong>. You wouldn’t want to load it more than onc...
[ { "answer_id": 62345, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 1, "selected": false, "text": "<p>If the plugin is well written is should be using <code>wp_enqueue_script()</code> and thus solves your issue.</p>\n...
2012/08/19
[ "https://wordpress.stackexchange.com/questions/62340", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4936/" ]
Download a copy of [Modernizr](http://modernizr.com/), put it in your plugin’s directory and simply enqueue the script whenever needed. Done. The problem is that Modernizr **may already be loaded by another plugin**. You wouldn’t want to load it more than once. How can you find out if Modernizr is already available be...
`wp_enqueue_script()` utilizes the `WP_Scripts` class, which extends the `WP_Dependencies` class. If you checkout that class, you will see a bunch of arrays at the top. So you could actually loop through list of queued scripts like so: ``` global $wp_scripts; // If inside a function foreach($wp_scripts->queue as $scr...
62,373
<p>Hi I have just learned how to add jQuery to wordpress themes and it works but an error keeps appearing in the wordpress development tool.Here is the code that I posted:</p> <pre><code> function register_js(){ if(!is_admin()){ wp_deregister_script('jquery'); wp_register_script('jquery' , 'http...
[ { "answer_id": 62375, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": 0, "selected": false, "text": "<p>I think your <code>$deps</code> need to be an array.</p>\n\n<p>Example:</p>\n\n<pre><code>&lt;?php \nwp_enqueu...
2012/08/20
[ "https://wordpress.stackexchange.com/questions/62373", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14752/" ]
Hi I have just learned how to add jQuery to wordpress themes and it works but an error keeps appearing in the wordpress development tool.Here is the code that I posted: ``` function register_js(){ if(!is_admin()){ wp_deregister_script('jquery'); wp_register_script('jquery' , 'http://ajax.google...
Your primary problem is that you are **de-registering core jQuery**. Don't do that. Ever. Period. If you get rid of that, your other scripts will work properly. Just do this: ``` function wpse62373_register_js() { if ( ! is_admin() ) { wp_enqueue_script('quicksand', get_template_directory_uri() . '/js/quic...
62,387
<p>I'm trying to build an advanced search form by post type.</p> <p>For example... </p> <p>I have custom Post Type : Locatie Taxonomy : locatii</p> <p>I have categories in PostType :</p> <p>Categories:</p> <p>-Orase - Arad - Alba....</p> <p>-Tip - Puncte de livrare - Gaze Medicale </p> <p>I want to ...
[ { "answer_id": 62408, "author": "Zach", "author_id": 9605, "author_profile": "https://wordpress.stackexchange.com/users/9605", "pm_score": 0, "selected": false, "text": "<p>You'll need to look into <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\" rel=\"nof...
2012/08/20
[ "https://wordpress.stackexchange.com/questions/62387", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17885/" ]
I'm trying to build an advanced search form by post type. For example... I have custom Post Type : Locatie Taxonomy : locatii I have categories in PostType : Categories: -Orase - Arad - Alba.... -Tip - Puncte de livrare - Gaze Medicale I want to get all post in that categories.. For example i select Arad an...
In your search form, add an input with `name="post_type"` and `value="customposttypehere"`. You can either have this as a hidden input or a text entry or a combobox or radio buttons etc, so long as it's inside the search form. The same is true for any other query vars like post\_type etc that you would normally put i...
62,389
<p>I am trying to make two plugins work together where one of them puts a tag around every title with a filter function. I want it to exclude posts of another plugin that have custom post_type (ai1ec_event). But I can't get the post type if the id is wrong. </p> <pre><code>add_filter('the_title', 'mealingua_title_fil...
[ { "answer_id": 62408, "author": "Zach", "author_id": 9605, "author_profile": "https://wordpress.stackexchange.com/users/9605", "pm_score": 0, "selected": false, "text": "<p>You'll need to look into <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\" rel=\"nof...
2012/08/20
[ "https://wordpress.stackexchange.com/questions/62389", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19454/" ]
I am trying to make two plugins work together where one of them puts a tag around every title with a filter function. I want it to exclude posts of another plugin that have custom post\_type (ai1ec\_event). But I can't get the post type if the id is wrong. ``` add_filter('the_title', 'mealingua_title_filter', 10); fu...
In your search form, add an input with `name="post_type"` and `value="customposttypehere"`. You can either have this as a hidden input or a text entry or a combobox or radio buttons etc, so long as it's inside the search form. The same is true for any other query vars like post\_type etc that you would normally put i...
62,396
<p>I'm collecting data via a form plugin and saving that data in form of a post with several custom fields. I then display the content of the post and the custom fields on my post template using...</p> <pre><code>if( get_post_meta( $post-&gt;ID, '_aboutus', true ) ) : echo '&lt;div class="c...
[ { "answer_id": 62423, "author": "2ndkauboy", "author_id": 462, "author_profile": "https://wordpress.stackexchange.com/users/462", "pm_score": 1, "selected": false, "text": "<p>I dont't know which form plugin you use and how it saves data to the database. But I would asume that the linebr...
2012/08/20
[ "https://wordpress.stackexchange.com/questions/62396", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19458/" ]
I'm collecting data via a form plugin and saving that data in form of a post with several custom fields. I then display the content of the post and the custom fields on my post template using... ``` if( get_post_meta( $post->ID, '_aboutus', true ) ) : echo '<div class="companyaboutus">' . g...
This could probably help, <http://codex.wordpress.org/Function_Reference/wpautop> This converts the new lines into html `<br/>` tags
62,415
<p>Hi can anyone help with the below, please?</p> <p>I want to be able to change the contents of my HTML <code>&lt;title&gt;</code> tag only, so need to write an if / else statement.</p> <p>I'm getting myself a bit muddled as my PHP isn't great... but basically something along the lines of the below but combined...</...
[ { "answer_id": 62417, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 4, "selected": true, "text": "<p>I think you will want to use the <code>wp_title</code> filter. Add the following to <code>functions.php</cod...
2012/08/20
[ "https://wordpress.stackexchange.com/questions/62415", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13998/" ]
Hi can anyone help with the below, please? I want to be able to change the contents of my HTML `<title>` tag only, so need to write an if / else statement. I'm getting myself a bit muddled as my PHP isn't great... but basically something along the lines of the below but combined... ``` <?php if ( ! is_page_template(...
I think you will want to use the `wp_title` filter. Add the following to `functions.php`: ``` function wpse62415_filter_wp_title( $title ) { // Return a custom document title for // the boat details custom page template if ( is_page_template( 'boatDetails.php' ) ) { return 'I\'m the boat details pa...
62,418
<p>I'm making a plugin administration page with the settings API. I'd like to know a way to display a warning message when the user submits an invalid value.</p> <p>For example, with the below code, if the user sends an empty value for Option A, the first input field, I'd like to show a message that says it's invalid ...
[ { "answer_id": 62421, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 0, "selected": false, "text": "<p>Once the validation callback is invoked, you're too late in the process to do form validation, because the ...
2012/08/20
[ "https://wordpress.stackexchange.com/questions/62418", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19360/" ]
I'm making a plugin administration page with the settings API. I'd like to know a way to display a warning message when the user submits an invalid value. For example, with the below code, if the user sends an empty value for Option A, the first input field, I'd like to show a message that says it's invalid and please...
First add a validation callback to your `register_settings`: ``` register_setting( 'settingsapi_optiongroupname', 'settingsapi_optionname','validation_callback'); ``` then define validation\_callback: ``` function validation_callback($input){ //check if all is good //If so then return the wanted value to be...
62,420
<p>I have my standard category page. On this page, I'd like to put a button which, when clicked, randomises the results shown on the category page.</p> <p>I know I could make a rand-category.php page and send the user on to that page. Ideally though, I'd like a more elegant solution, possibly something that refreshes ...
[ { "answer_id": 89501, "author": "Warwick", "author_id": 19554, "author_profile": "https://wordpress.stackexchange.com/users/19554", "pm_score": 1, "selected": false, "text": "<p>You can actually change any of the query parameters (like the order) by adding them to the url.</p>\n\n<p>For...
2012/08/20
[ "https://wordpress.stackexchange.com/questions/62420", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15695/" ]
I have my standard category page. On this page, I'd like to put a button which, when clicked, randomises the results shown on the category page. I know I could make a rand-category.php page and send the user on to that page. Ideally though, I'd like a more elegant solution, possibly something that refreshes the result...
You can actually change any of the query parameters (like the order) by adding them to the url. For instance, the sample url below would randomize the posts on the category archive every time you refreshed, randomizing the results. ``` http://sample.com/category/uncategorized/?orderby=rand ``` Below is a basic form...
62,424
<p>I've been looking for days, yet can't find a good answer. Perhaps the SE crowd can be of assistance. Any help is much appreciated.</p> <p>I am using a custom-coded pinterest button included on posts that pulls the first image of the post OR the featured image (if exists).</p> <pre><code>&lt;span data-icon="&amp;#x...
[ { "answer_id": 89501, "author": "Warwick", "author_id": 19554, "author_profile": "https://wordpress.stackexchange.com/users/19554", "pm_score": 1, "selected": false, "text": "<p>You can actually change any of the query parameters (like the order) by adding them to the url.</p>\n\n<p>For...
2012/08/20
[ "https://wordpress.stackexchange.com/questions/62424", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19471/" ]
I've been looking for days, yet can't find a good answer. Perhaps the SE crowd can be of assistance. Any help is much appreciated. I am using a custom-coded pinterest button included on posts that pulls the first image of the post OR the featured image (if exists). ``` <span data-icon="&#x30;" aria-hidden="true"></sp...
You can actually change any of the query parameters (like the order) by adding them to the url. For instance, the sample url below would randomize the posts on the category archive every time you refreshed, randomizing the results. ``` http://sample.com/category/uncategorized/?orderby=rand ``` Below is a basic form...
62,452
<p>Hi i have this code below in my header file</p> <pre><code>&lt;?php if ( ! is_home() ) { if ( get_post_type() == 'pretty-little-liars' ) { echo '&lt;div id="headerimg"&gt;&lt;img src="http://tv-cafe.com/wp-content/uploads/2012/08/liars.png"&gt;&lt;/div&gt;'; } if ( get_post_type() == 'revenge' ) { echo '&...
[ { "answer_id": 62457, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://queryposts.com/function/is_tax/\" rel=\"nofollow\">is_tax()</a> is a check for taxonomy archive pag...
2012/08/20
[ "https://wordpress.stackexchange.com/questions/62452", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13556/" ]
Hi i have this code below in my header file ``` <?php if ( ! is_home() ) { if ( get_post_type() == 'pretty-little-liars' ) { echo '<div id="headerimg"><img src="http://tv-cafe.com/wp-content/uploads/2012/08/liars.png"></div>'; } if ( get_post_type() == 'revenge' ) { echo '<div id="headerimg"><img src="http:...
[is\_tax()](http://queryposts.com/function/is_tax/) is a check for taxonomy archive page and as I understand you want this for individual posts. The function to use would be [has\_term()](http://queryposts.com/function/has_term/): ``` if ( has_term( 'pretty-little-liars', 'series' ) ) ``` Also it's good practice to ...
62,468
<p>Here is the setup.</p> <p>The site in question is a website that displays listings. Each listing has a rank (1-3). Basically it's a listing type... small, medium &amp; large to determine how much the customer pays.</p> <p>When I do a WP_QUERY of all of the listings I want to display them in order DESC from 3-1 (la...
[ { "answer_id": 62489, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": -1, "selected": false, "text": "<p>just add, <code>'order' =&gt; 'DESC'</code></p>\n\n<pre><code>$query = new WP_Query( array( 'post_type' =&gt; '...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62468", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4775/" ]
Here is the setup. The site in question is a website that displays listings. Each listing has a rank (1-3). Basically it's a listing type... small, medium & large to determine how much the customer pays. When I do a WP\_QUERY of all of the listings I want to display them in order DESC from 3-1 (larget - small)... bas...
I ran your query and got ... ``` ORDER BY wp_postmeta.meta_value+0,RAND() DESC ``` ... which is what I expected. If I am reading your question correctly, what you want is ... ``` ORDER BY wp_postmeta.meta_value+0 DESC,RAND() ``` ... as in [this question at SO](https://stackoverflow.com/questions/3990439/sorting...
62,479
<p>EDITED MY QUESTION TO MAKE IT WAY MORE CONCISE</p> <p>Using Wordpress plugin Events Manager, my goal is to alter the search form so it searches for events on single dates. I don't want a date range search which is built in. </p> <p>Most of my events are nightclub events, which carry on to the next day. Therefore, ...
[ { "answer_id": 62489, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": -1, "selected": false, "text": "<p>just add, <code>'order' =&gt; 'DESC'</code></p>\n\n<pre><code>$query = new WP_Query( array( 'post_type' =&gt; '...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62479", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13824/" ]
EDITED MY QUESTION TO MAKE IT WAY MORE CONCISE Using Wordpress plugin Events Manager, my goal is to alter the search form so it searches for events on single dates. I don't want a date range search which is built in. Most of my events are nightclub events, which carry on to the next day. Therefore, I also want to al...
I ran your query and got ... ``` ORDER BY wp_postmeta.meta_value+0,RAND() DESC ``` ... which is what I expected. If I am reading your question correctly, what you want is ... ``` ORDER BY wp_postmeta.meta_value+0 DESC,RAND() ``` ... as in [this question at SO](https://stackoverflow.com/questions/3990439/sorting...
62,481
<p>I have setup a custom meta_key for attachments. Since it is a radio button with Yes/No options, and the default value is always Yes, I need that this default value is saved into the db when the attachment is created.</p> <p>Right now the problem is that when I upload an image, the Edit Media page shows me that the ...
[ { "answer_id": 62489, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": -1, "selected": false, "text": "<p>just add, <code>'order' =&gt; 'DESC'</code></p>\n\n<pre><code>$query = new WP_Query( array( 'post_type' =&gt; '...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62481", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12495/" ]
I have setup a custom meta\_key for attachments. Since it is a radio button with Yes/No options, and the default value is always Yes, I need that this default value is saved into the db when the attachment is created. Right now the problem is that when I upload an image, the Edit Media page shows me that the value for...
I ran your query and got ... ``` ORDER BY wp_postmeta.meta_value+0,RAND() DESC ``` ... which is what I expected. If I am reading your question correctly, what you want is ... ``` ORDER BY wp_postmeta.meta_value+0 DESC,RAND() ``` ... as in [this question at SO](https://stackoverflow.com/questions/3990439/sorting...
62,499
<p>I'm using the enter_title_here filter to modify the 'Enter title here' text in a custom post type, question is what hook should I use to trigger this function?</p> <p>I have used admin_enqueue_script as a test and it worked, but I think there is a better hook since this is not really a script.</p> <pre><code> f...
[ { "answer_id": 62489, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": -1, "selected": false, "text": "<p>just add, <code>'order' =&gt; 'DESC'</code></p>\n\n<pre><code>$query = new WP_Query( array( 'post_type' =&gt; '...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62499", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
I'm using the enter\_title\_here filter to modify the 'Enter title here' text in a custom post type, question is what hook should I use to trigger this function? I have used admin\_enqueue\_script as a test and it worked, but I think there is a better hook since this is not really a script. ``` function print_scr...
I ran your query and got ... ``` ORDER BY wp_postmeta.meta_value+0,RAND() DESC ``` ... which is what I expected. If I am reading your question correctly, what you want is ... ``` ORDER BY wp_postmeta.meta_value+0 DESC,RAND() ``` ... as in [this question at SO](https://stackoverflow.com/questions/3990439/sorting...
62,506
<p>I have interactive pdf documents that I need to put on a wordpress site. Visitors need to be able to fill these in and print them out to sign and post. They do not need to be emailed or saved to the site. I have tries embedding them with all kinds of plugins but all they do is embed a non fillable pdf.</p> <p>What ...
[ { "answer_id": 62489, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": -1, "selected": false, "text": "<p>just add, <code>'order' =&gt; 'DESC'</code></p>\n\n<pre><code>$query = new WP_Query( array( 'post_type' =&gt; '...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62506", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3497/" ]
I have interactive pdf documents that I need to put on a wordpress site. Visitors need to be able to fill these in and print them out to sign and post. They do not need to be emailed or saved to the site. I have tries embedding them with all kinds of plugins but all they do is embed a non fillable pdf. What I need is ...
I ran your query and got ... ``` ORDER BY wp_postmeta.meta_value+0,RAND() DESC ``` ... which is what I expected. If I am reading your question correctly, what you want is ... ``` ORDER BY wp_postmeta.meta_value+0 DESC,RAND() ``` ... as in [this question at SO](https://stackoverflow.com/questions/3990439/sorting...
62,509
<p>I'm looking for how to get a class in the wp_get_archives functions to get the current month (when we are in a month archive) just like when we call wp_list_categories, the current category has a ".current-cat" selector for CSS or when we call wp_list_pages we have a '.current_page_item' selector.</p>
[ { "answer_id": 62607, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 2, "selected": false, "text": "<p>Put the following function in your <code>functions.php</code></p>\n\n<pre><code>function wpse_62509_cu...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62509", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8895/" ]
I'm looking for how to get a class in the wp\_get\_archives functions to get the current month (when we are in a month archive) just like when we call wp\_list\_categories, the current category has a ".current-cat" selector for CSS or when we call wp\_list\_pages we have a '.current\_page\_item' selector.
This function was created with the great help of Joshua Abenazer. Thanks! Basically, if is a monthly archive, go and get the current month watched, and add a class on the li. Worked great. ``` function wpse_62509_current_month_selector( $link_html ) { if (is_month()){ $current_month = get_the_date("F Y"); ...
62,511
<p>Hi I am trying to learn to add theme options to WordPress themes by reading The Complete guide to WordPress Settings Api on wptuts I have gotten as far as the 4th part and have stoped to create an example for myself because I have gotten confused with how can I add the sections I create in a page.Here is my code:</p...
[ { "answer_id": 62607, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 2, "selected": false, "text": "<p>Put the following function in your <code>functions.php</code></p>\n\n<pre><code>function wpse_62509_cu...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62511", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14752/" ]
Hi I am trying to learn to add theme options to WordPress themes by reading The Complete guide to WordPress Settings Api on wptuts I have gotten as far as the 4th part and have stoped to create an example for myself because I have gotten confused with how can I add the sections I create in a page.Here is my code: ``` ...
This function was created with the great help of Joshua Abenazer. Thanks! Basically, if is a monthly archive, go and get the current month watched, and add a class on the li. Worked great. ``` function wpse_62509_current_month_selector( $link_html ) { if (is_month()){ $current_month = get_the_date("F Y"); ...
62,526
<p>Hi I am trying to creating some custom options for a template I am developing but I seem to be getting an error:</p> <pre><code>Warning: Illegal string offset 'show_header' in C:\xampp\htdocs\wordpress\wp-content\themes\01MyWork\includes\theme-options.php on line 62 </code></pre> <p>This is the line that seems to ...
[ { "answer_id": 62528, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 4, "selected": true, "text": "<p>I believe the underlying problem is that <em>the option array keys don't exist yet</em>. Let's start here, i...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62526", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14752/" ]
Hi I am trying to creating some custom options for a template I am developing but I seem to be getting an error: ``` Warning: Illegal string offset 'show_header' in C:\xampp\htdocs\wordpress\wp-content\themes\01MyWork\includes\theme-options.php on line 62 ``` This is the line that seems to be throwing the error: ``...
I believe the underlying problem is that *the option array keys don't exist yet*. Let's start here, in your initialization function: ``` if( false == get_option( 'thanathos_theme_display_options' ) ) { add_option( 'thanathos_theme_display_options' ); } ``` First, this: ``` false == get_option( 'thanathos...
62,536
<p>I'm creating a plugin that will need to add a new WP page upon activation and then I want it to remove that same page upon uninstallation. Do I have to manually store that page id in the DB somewhere or is there a native WP option to remember that automatically?</p> <p>My code so far:</p> <pre><code>register_activ...
[ { "answer_id": 62572, "author": "Barry Carlyon", "author_id": 14034, "author_profile": "https://wordpress.stackexchange.com/users/14034", "pm_score": 2, "selected": true, "text": "<p>Why do you need to create a page?</p>\n\n<p>Its possible that before plugin deactivation, the page no lon...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62536", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19513/" ]
I'm creating a plugin that will need to add a new WP page upon activation and then I want it to remove that same page upon uninstallation. Do I have to manually store that page id in the DB somewhere or is there a native WP option to remember that automatically? My code so far: ``` register_activation_hook(__FILE__, ...
Why do you need to create a page? Its possible that before plugin deactivation, the page no longer exists, so your deletion function will need to check for if it exists But yes you will need to store the ID somewhere. Best option is to just update\_option('icreatedapage', $pageid); ``` if ($pageid == 0) { echo "...
62,546
<p>I'm trying to set 'orderby = none' to my loop but it is not working. Here's my code:</p> <pre><code>$query = new WP_Query(array('showposts'=&gt;2, 'post__in' =&gt; array(99,4,5,2,8,55), 'orderby'=&gt;'none')); </code></pre> <p>Could anyone help me?</p> <p>Thanks.</p>
[ { "answer_id": 62547, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 0, "selected": false, "text": "<p>See <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters\" rel=\"nofollow\"...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62546", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17736/" ]
I'm trying to set 'orderby = none' to my loop but it is not working. Here's my code: ``` $query = new WP_Query(array('showposts'=>2, 'post__in' => array(99,4,5,2,8,55), 'orderby'=>'none')); ``` Could anyone help me? Thanks.
Order by none doesn't do what you think it does. If you don't specify an order, then MySQL doesn't guarantee any particular order and will simply get the posts in whatever order it has them. Since they were inserted in a particular order, then you'll probably get them in that order. Since you need the posts in a speci...
62,548
<p>I've been trying to figure out for days how <a href="http://quotelicious.com" rel="nofollow">http://quotelicious.com</a> was able to place thumbnails and category links in a separate box alongside the actual post.</p> <p>Any ideas?</p>
[ { "answer_id": 62550, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 1, "selected": false, "text": "<p>They are actually doing this is one loop, here's an example to show similar structure.</p>\n\n<pre><code>&lt;?php...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62548", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19519/" ]
I've been trying to figure out for days how <http://quotelicious.com> was able to place thumbnails and category links in a separate box alongside the actual post. Any ideas?
They are actually doing this is one loop, here's an example to show similar structure. ``` <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="article"> <div class="left"> <?php the_post_thumbnail( $size, $attr ); ?> <?php get_the_category(); ?> ...
62,558
<p>Ok I know browser detection is considered bad practice but I can't find a way around it because I really do need whole different themes for a complex site. So I snatched this function from <a href="http://detectmobilebrowsers.com/" rel="nofollow">http://detectmobilebrowsers.com/</a></p> <pre><code>$useragent=$_SERV...
[ { "answer_id": 62570, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 4, "selected": true, "text": "<p>You can use the built in function <a href=\"http://codex.wordpress.org/Function_Reference/wp_is_mobile\" rel...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62558", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12700/" ]
Ok I know browser detection is considered bad practice but I can't find a way around it because I really do need whole different themes for a complex site. So I snatched this function from <http://detectmobilebrowsers.com/> ``` $useragent=$_SERVER['HTTP_USER_AGENT']; if(preg_match('/android.+mobile|avantgo|bada\/|bla...
You can use the built in function [`wp_is_mobile()`](http://codex.wordpress.org/Function_Reference/wp_is_mobile) Override a style with wp\_enqueue\_style ======================================== ``` add_action('wp_enqueue_scripts', 'my_mobile_styles'); function my_mobile_styles(){ if(wp_is_mobile()){ wp_r...
62,565
<p>This is first time that I tried the OOP method of writing an application. I don't quite understand it yet. Currently I have this cron hook:</p> <pre><code>if( !wp_next_scheduled( 'my_cron_hook' ) ) { //schedule the event to run daily wp_schedule_event( current_time( 'timestamp' ), 'daily', 'my_cron_hook' )...
[ { "answer_id": 63287, "author": "djb", "author_id": 7905, "author_profile": "https://wordpress.stackexchange.com/users/7905", "pm_score": 0, "selected": false, "text": "<ul>\n<li><p>PHP will throw a syntax error if you try to put an if-statement directly inside a class - the only things ...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62565", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14728/" ]
This is first time that I tried the OOP method of writing an application. I don't quite understand it yet. Currently I have this cron hook: ``` if( !wp_next_scheduled( 'my_cron_hook' ) ) { //schedule the event to run daily wp_schedule_event( current_time( 'timestamp' ), 'daily', 'my_cron_hook' ); } add_action(...
Add an action outside your class definition: ``` add_action('my_unique_plugin_event_hook', array($this,'hook')); ``` And then use this in your event: ``` wp_schedule_event(time(), 'daily', 'my_unique_plugin_event_hook'); ```
62,573
<p>Yoasts SEO plugin adds a metabox to the post edit screen. I'm trying to remove this for users who aren't editors or above.</p> <p>I've tried putting a <code>remove_meta_box</code> call in on admin_init, trying to remove the action on $wpseo_metabox but to no avail.</p> <p>How do I remove this metabox without requi...
[ { "answer_id": 62579, "author": "Mamaduka", "author_id": 888, "author_profile": "https://wordpress.stackexchange.com/users/888", "pm_score": 5, "selected": true, "text": "<p>On <a href=\"http://codex.wordpress.org/Function_Reference/remove_meta_box\"><code>remove_meta_box</code></a> is a...
2012/08/21
[ "https://wordpress.stackexchange.com/questions/62573", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/736/" ]
Yoasts SEO plugin adds a metabox to the post edit screen. I'm trying to remove this for users who aren't editors or above. I've tried putting a `remove_meta_box` call in on admin\_init, trying to remove the action on $wpseo\_metabox but to no avail. How do I remove this metabox without requiring user intervention (th...
On [`remove_meta_box`](http://codex.wordpress.org/Function_Reference/remove_meta_box) is a note: > > Because you can't remove a meta box until it's been added, it's > important to make sure your call to remove\_meta\_box() happens in the > right sequence. > > > WordPress SEO adds meta boxes on `add_meta_boxes` ...
62,594
<p>A while back I found that there was a reason to name a template like so</p> <p>template-name.php</p> <p>For the life of me, I can't remember what it was for. I thought it was so that WordPress would automatically pick up that template so that you would not have to set the page template when creating the post. I ha...
[ { "answer_id": 62605, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 1, "selected": false, "text": "<p>Ok, I found it on codex - <a href=\"http://codex.wordpress.org/Template_Hierarchy#Page_display\" rel=\"nofollow\"...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62594", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14761/" ]
A while back I found that there was a reason to name a template like so template-name.php For the life of me, I can't remember what it was for. I thought it was so that WordPress would automatically pick up that template so that you would not have to set the page template when creating the post. I have been looking i...
I always name them like so: page-name.php; This keeps my page templates nicely together + in some cases this can make your code easier, for example... ``` <?php // Get the file called loop-page.php get_template_part( 'loop', 'page' ); ?> ``` A quick Google revealed also this <http://wp.tutsplus.com/tutorials/organiz...
62,595
<p>With <code>&lt;?php _e('Save Changes') ?&gt;</code>, I know the phrase, "Save Changes" can be translated automatically if the user's locale is set to a different language. I'd like to know if there is a list of those already translated WordPress default messages. </p> <p>What else can I use? </p>
[ { "answer_id": 62601, "author": "GabLeRoux", "author_id": 19537, "author_profile": "https://wordpress.stackexchange.com/users/19537", "pm_score": 2, "selected": false, "text": "<p>Default wordpress translation files are available here:<br>\n<a href=\"http://i18n.svn.wordpress.org/\" rel=...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62595", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19360/" ]
With `<?php _e('Save Changes') ?>`, I know the phrase, "Save Changes" can be translated automatically if the user's locale is set to a different language. I'd like to know if there is a list of those already translated WordPress default messages. What else can I use?
The list is available in `$GLOBALS['l10n'][ $text_domain ]`. To get the looong list of translatable WordPress strings just use: ``` print '<pre>' . htmlspecialchars( print_r( $GLOBALS['l10n']['default'], TRUE ) ) . '</pre>'; ``` **Do not use these strings in your theme or plugin.** They are internal, de facto *pri...
62,612
<p>I use the following code to extract the attached images from a post with ID:</p> <pre><code>$args = array( 'post_type' =&gt; 'attachment', 'post_parent' =&gt; $product_id, 'post_mime_type' =&gt; 'image', 'orderby' =&gt; 'menu_order', 'order' =&gt; 'ASC', ...
[ { "answer_id": 62613, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": 1, "selected": false, "text": "<p>Yes, </p>\n\n<p>basicaly what you want is this</p>\n\n<pre><code>&lt;?php \n//get post thumbnail url \n$post_t...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62612", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7850/" ]
I use the following code to extract the attached images from a post with ID: ``` $args = array( 'post_type' => 'attachment', 'post_parent' => $product_id, 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => -1 ); $a...
Simply add an `post__not_in` argument and use the `get_post_thumbnail_id()` function. ``` $args = array( 'post_type' => 'attachment', 'post_parent' => $product_id, 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => -1, 'post...
62,614
<p>Whenever somebody writes a post on our site, the Paly Voice (http://palyvoice.com) there are automatically a lot of <code>&lt;div&gt;</code> elements created. This is bad for layout, since we have a style that applies to divs that we don't want to apply to story styles.</p> <p>Is there a way to remove the automatic...
[ { "answer_id": 62613, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": 1, "selected": false, "text": "<p>Yes, </p>\n\n<p>basicaly what you want is this</p>\n\n<pre><code>&lt;?php \n//get post thumbnail url \n$post_t...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62614", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2714/" ]
Whenever somebody writes a post on our site, the Paly Voice (http://palyvoice.com) there are automatically a lot of `<div>` elements created. This is bad for layout, since we have a style that applies to divs that we don't want to apply to story styles. Is there a way to remove the automatic div insertion? If not, can...
Simply add an `post__not_in` argument and use the `get_post_thumbnail_id()` function. ``` $args = array( 'post_type' => 'attachment', 'post_parent' => $product_id, 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => -1, 'post...
62,623
<p>how can I use Cron to delete posts of a certain post type once they reach a certain limit, like keep maximum 50 posts?</p> <p>The reason is that these posts are being imported automatically periodically, so I want to prevent the DB getting too large, apart from the fact that the older posts won't be needed.</p>
[ { "answer_id": 63278, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 5, "selected": true, "text": "<p>Although I do not understand the motivation for truncating posts, I think this exercise is valuable for you ...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62623", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
how can I use Cron to delete posts of a certain post type once they reach a certain limit, like keep maximum 50 posts? The reason is that these posts are being imported automatically periodically, so I want to prevent the DB getting too large, apart from the fact that the older posts won't be needed.
Although I do not understand the motivation for truncating posts, I think this exercise is valuable for you to understand how to use cron + WordPress. Create a function to truncate posts ----------------------------------- This can be used for both methods below WP-cron or UNIX cron. ``` function foobar_truncate_pos...
62,626
<p>I need to customize the output of the shortcode of plugin A by using a function of plugin B. So I alter the shortcode function of plugin A by inserting a condition to check the value of the function of plugin B but I need to include the php file that supports this function. I tried all require_once, require and incl...
[ { "answer_id": 62629, "author": "pbd", "author_id": 18968, "author_profile": "https://wordpress.stackexchange.com/users/18968", "pm_score": 4, "selected": true, "text": "<p>The first error message means that there is restrictions in place on where you can include files from, set by the s...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62626", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19543/" ]
I need to customize the output of the shortcode of plugin A by using a function of plugin B. So I alter the shortcode function of plugin A by inserting a condition to check the value of the function of plugin B but I need to include the php file that supports this function. I tried all require\_once, require and includ...
The first error message means that there is restrictions in place on where you can include files from, set by the server. You could try with ``` require_once ABSPATH . '/wp-content/plugins/pluginname/pluginfunctions.php'; ``` but I'm not sure if it would work. With the second include you're trying to include an URL...
62,630
<p>I'm developing a "single page" WordPress based site that has content in multiple languages (using the plug-in WPML) and I need to retrieve it in a more efficient manner to avoid slow page load time.<br><br> An example of the code that I'm currently using -</p> <pre><code>$query = new WP_Query(); $query-&gt;query( a...
[ { "answer_id": 62637, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": 0, "selected": false, "text": "<p>Have a decent look at wp_query.</p>\n\n<p><a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62630", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3390/" ]
I'm developing a "single page" WordPress based site that has content in multiple languages (using the plug-in WPML) and I need to retrieve it in a more efficient manner to avoid slow page load time. An example of the code that I'm currently using - ``` $query = new WP_Query(); $query->query( array( 'post_type' => '...
WPML has a global to check for the language, though it might be outside the scope of WPSE because this is a commercial plugin. It works like: ``` if (ICL_LANGUAGE_CODE == 'en'){ //do something like a custom query... }else{ // do something else ```
62,645
<p>I'm using the WP Supersized plugin to load background images on posts and works fine. </p> <p>The problem I have at this point is I want to show the latest post in cat 17, with custom field key FeaturedOnHomepage, with value yes on my homepage and display the background images from that post. Below the query I use:...
[ { "answer_id": 62637, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": 0, "selected": false, "text": "<p>Have a decent look at wp_query.</p>\n\n<p><a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62645", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9442/" ]
I'm using the WP Supersized plugin to load background images on posts and works fine. The problem I have at this point is I want to show the latest post in cat 17, with custom field key FeaturedOnHomepage, with value yes on my homepage and display the background images from that post. Below the query I use: ``` ...
WPML has a global to check for the language, though it might be outside the scope of WPSE because this is a commercial plugin. It works like: ``` if (ICL_LANGUAGE_CODE == 'en'){ //do something like a custom query... }else{ // do something else ```
62,667
<p>I have run into this problem where the following piece of code always returns true for any <code>post ID</code> supplied to it.</p> <p><code>current_user_can('delete_posts', $post_id);</code></p> <p>Normally, the above code should return false when the user is not the author of the post or does not have the capabi...
[ { "answer_id": 62670, "author": "Mamaduka", "author_id": 888, "author_profile": "https://wordpress.stackexchange.com/users/888", "pm_score": 1, "selected": false, "text": "<p>If you want to check if user can delete posts of other authors, you need to use proper capability - <code>delete_...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62667", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9094/" ]
I have run into this problem where the following piece of code always returns true for any `post ID` supplied to it. `current_user_can('delete_posts', $post_id);` Normally, the above code should return false when the user is not the author of the post or does not have the capability to delete others post. However, it...
After hours of fighting to get this to work, it was just a matter of changing `delete_posts` to `delete_post`. So, in it's entirety this would be: `current_user_can('delete_posts', $post_id);` to `current_user_can('delete_post', $post_id);` `current_user_can` does accept a second parameter. Though it's weird that...
62,672
<p>I notice in the Codex that the --add-drop-table option is displayed for backing up a database. Before I screw anything up, does this just mean that when the backup is eventually imported, the tables will overwrite if they exist in the destination db?</p> <p>I don't want to drop the tables when I back them up!</p> ...
[ { "answer_id": 62736, "author": "Jake", "author_id": 11966, "author_profile": "https://wordpress.stackexchange.com/users/11966", "pm_score": 5, "selected": true, "text": "<p>It only affects the output of your MySQL dump in the file that is created.</p>\n\n<p>It isn't necessary. It is jus...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62672", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10099/" ]
I notice in the Codex that the --add-drop-table option is displayed for backing up a database. Before I screw anything up, does this just mean that when the backup is eventually imported, the tables will overwrite if they exist in the destination db? I don't want to drop the tables when I back them up! ``` user@linux...
It only affects the output of your MySQL dump in the file that is created. It isn't necessary. It is just there so that if you import the created dump file into a database that already has a table with the same name, it will drop that table and then add the new table in its place. Otherwise you will get an error, and ...
62,675
<p>I know there have been a couple of questions in relation to this and had a look at them, but mine differs slightly on the problem experienced and the code. I am basically building my first theme and hoping to implement PrettyPhoto, I have been careful with enqueue'ing scripts and jQuery and have NivoSlider working ...
[ { "answer_id": 62773, "author": "woony", "author_id": 17541, "author_profile": "https://wordpress.stackexchange.com/users/17541", "pm_score": 0, "selected": false, "text": "<p>Make sure you initialize it aswell.</p>\n\n<p>Put this in your header as test. </p>\n\n<pre><code>&lt;script typ...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62675", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18677/" ]
I know there have been a couple of questions in relation to this and had a look at them, but mine differs slightly on the problem experienced and the code. I am basically building my first theme and hoping to implement PrettyPhoto, I have been careful with enqueue'ing scripts and jQuery and have NivoSlider working ok, ...
Ok, after a few days trying various variations on the code I was originally using I still had no success. I took my theme right back to the bare bones, and tried the code again, I even tested the code of the TwentyEleven theme but still had no joy. I have an answer but not using the code above. To register and enqueue...
62,678
<p>I am trying to create a custom post type with taxonomy and a shortcode for my custom search in a plugin.When I activate my plugin I see my CPT and taxonomy on dashboard. But when I publish the post I do not see the data in form of the single-{CPT}.php page I created. Instead, it displays list of all posts from my CP...
[ { "answer_id": 62690, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 0, "selected": false, "text": "<p>You use the following code:</p>\n\n<pre><code>add_filter( \"template_redirect\", \"get_custom_post_type_templ...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62678", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19561/" ]
I am trying to create a custom post type with taxonomy and a shortcode for my custom search in a plugin.When I activate my plugin I see my CPT and taxonomy on dashboard. But when I publish the post I do not see the data in form of the single-{CPT}.php page I created. Instead, it displays list of all posts from my CPT. ...
You need to rename `loop-{custom-post-type}.php` to `single-{custom-post-type}.php`. And to be explicit, the *actual* filename, based on your code above, should be: **`single-vfic_publications.php`**. Get rid of any other template redirects or anything else similar that you're using. As per the [Template Hierarchy](...
62,696
<p>I am finding difficulty in returning the wp_login_form() and register link at the same time. </p> <p>Here is my code which i am working to make shortcode. How to send the login_form and <strong><em>register link</em></strong> if user is <strong><em>not logged in</em></strong>?</p> <pre><code>function add_login_for...
[ { "answer_id": 62692, "author": "Patrick Forget", "author_id": 19564, "author_profile": "https://wordpress.stackexchange.com/users/19564", "pm_score": 2, "selected": false, "text": "<p>I find the export tools very slow and not so reliable. If imporitng fails you probably have a timeout ...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62696", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18666/" ]
I am finding difficulty in returning the wp\_login\_form() and register link at the same time. Here is my code which i am working to make shortcode. How to send the login\_form and ***register link*** if user is ***not logged in***? ``` function add_login_form() { if(!is_user_logged_in()){ return wp_logi...
I find the export tools very slow and not so reliable. If imporitng fails you probably have a timeout with your server or your dump file is too big. Here's the way I do it, and it's much faster: 1. extract a fresh copy of wordpress code in production 2. replace the wp-content folder with the one from dev 3. copy the ...
62,702
<p>I'm using <code>wp_list_pages()</code> to display a menu of child pages. </p> <p>The structure is nice and simple. Looks like this: <a href="http://cl.ly/image/0w1Q1q2D3D18" rel="nofollow">http://cl.ly/image/0w1Q1q2D3D18</a></p> <p>The menu works perfectly when on a child page: <a href="http://cl.ly/image/3O310E0s...
[ { "answer_id": 62704, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": true, "text": "<p>Your code won't work if you have more than one parent page or multiple levels of child pages. Use <a href=\"http://c...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62702", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3877/" ]
I'm using `wp_list_pages()` to display a menu of child pages. The structure is nice and simple. Looks like this: <http://cl.ly/image/0w1Q1q2D3D18> The menu works perfectly when on a child page: <http://cl.ly/image/3O310E0s2B3d> But, alas, does not work when on the parent page: <http://cl.ly/image/3w0T3Q2s4347> See...
Your code won't work if you have more than one parent page or multiple levels of child pages. Use [`get_ancestors`](http://codex.wordpress.org/Function_Reference/get_ancestors) to get the top parent page, and use the `child_of` argument of `wp_list_pages` rather than `exclude` to only output pages from that branch.
62,714
<p>I'm not a novice to Wordpress Theme Design &amp; Development. I've actually been doing it for a few years now and in recent years, it has become more than a hobby and is slowing shaping into a career choice.</p> <p>However, I have a somewhat simple yet puzzling question to ask here...</p> <p>Forever, I've been upl...
[ { "answer_id": 62719, "author": "chifliiiii", "author_id": 4130, "author_profile": "https://wordpress.stackexchange.com/users/4130", "pm_score": 0, "selected": false, "text": "<p>In my opnion, yes you are using it right. I always think in 2 main things when i develop wordpress themes:</p...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62714", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19566/" ]
I'm not a novice to Wordpress Theme Design & Development. I've actually been doing it for a few years now and in recent years, it has become more than a hobby and is slowing shaping into a career choice. However, I have a somewhat simple yet puzzling question to ask here... Forever, I've been uploading the images I u...
I guess from the question you are asking, is there a way to code the image url that is better than typing in the whole url? This is what I do, to ensure that if the domain name ever changes...(which they do in my work because I always build the sites on a project domain and then move them over), you will want to do it ...
62,720
<p>I'm having an issue creating an ajax search on my single post pages. I need to limit the search results to the custom post types "fod_videos" and "post" and category 12. My issue is the search is returning all the posts under those filters and not taking the search value. I'm guessing I'm missing something obvious b...
[ { "answer_id": 63001, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>Instead of <code>'cat' =&gt; 12</code> and <code>$wp_query</code> use <code>'category_name' =&gt; slug</code> and <a hr...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62720", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12700/" ]
I'm having an issue creating an ajax search on my single post pages. I need to limit the search results to the custom post types "fod\_videos" and "post" and category 12. My issue is the search is returning all the posts under those filters and not taking the search value. I'm guessing I'm missing something obvious but...
Instead of `'cat' => 12` and `$wp_query` use `'category_name' => slug` and [`get_posts()`](http://queryposts.com/function/get_posts/). Here is a basic example how it works: ### PHP ```php add_action( 'wp_loaded', array ( 'T5_Ajax_Search', 'init' ) ); /** * Ajaxify the search form. */ class T5_Ajax_Search { /*...
62,729
<p>I'm trying to embed an iFrame, and because I set up some CSS using responsive design, I wish to NOT have <code>width=""</code> and <code>height=""</code> attributes whatsoever. </p> <p>When I type this into the HTML editor field..</p> <pre><code>&lt;iframe src="https://docs.google.com/document/pub?id=1fsm-cvpdfX-8...
[ { "answer_id": 63001, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>Instead of <code>'cat' =&gt; 12</code> and <code>$wp_query</code> use <code>'category_name' =&gt; slug</code> and <a hr...
2012/08/22
[ "https://wordpress.stackexchange.com/questions/62729", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1631/" ]
I'm trying to embed an iFrame, and because I set up some CSS using responsive design, I wish to NOT have `width=""` and `height=""` attributes whatsoever. When I type this into the HTML editor field.. ``` <iframe src="https://docs.google.com/document/pub?id=1fsm-cvpdfX-8tXauGrQgRmgWONTpX8J3almvZhzBeCA&amp;embedded=t...
Instead of `'cat' => 12` and `$wp_query` use `'category_name' => slug` and [`get_posts()`](http://queryposts.com/function/get_posts/). Here is a basic example how it works: ### PHP ```php add_action( 'wp_loaded', array ( 'T5_Ajax_Search', 'init' ) ); /** * Ajaxify the search form. */ class T5_Ajax_Search { /*...
62,742
<p>I have been trying to add to the default WordPress comment form. I need to add placeholder="" to each field. I can't figure out the filter. I don't get any errors but I don't see the placeholder either.</p> <p>After searching the posts here for an hour, I came up with this so far</p> <pre><code>function my_fields(...
[ { "answer_id": 62744, "author": "Jake", "author_id": 11966, "author_profile": "https://wordpress.stackexchange.com/users/11966", "pm_score": 0, "selected": false, "text": "<p>I think you want to use this filter:</p>\n\n<pre><code>comment_form_default_fields\n</code></pre>\n\n<p>Can also ...
2012/08/23
[ "https://wordpress.stackexchange.com/questions/62742", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14761/" ]
I have been trying to add to the default WordPress comment form. I need to add placeholder="" to each field. I can't figure out the filter. I don't get any errors but I don't see the placeholder either. After searching the posts here for an hour, I came up with this so far ``` function my_fields($args){ $comm...
You should filter `'comment_form_default_fields'` to add the `placeholder` attribute. Sample code ----------- ``` add_filter( 'comment_form_default_fields', 'wpse_62742_comment_placeholders' ); /** * Change default fields, add placeholder and change type attributes. * * @param array $fields * @return array */...
62,751
<p>I have one page in my template where I would like to set a custom posts_per_page. Here is the code I have used:</p> <pre><code>&lt;?php global $query_string; query_posts($query_string . '&amp;posts_per_page=4'); if ( have_posts() ) : while ( have_posts() ) : the_post(); ... </code></pre> <p>Now this code limits o...
[ { "answer_id": 62753, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>Use a <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\" rel=\"nofollow\"><code>pre_ge...
2012/08/23
[ "https://wordpress.stackexchange.com/questions/62751", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19527/" ]
I have one page in my template where I would like to set a custom posts\_per\_page. Here is the code I have used: ``` <?php global $query_string; query_posts($query_string . '&posts_per_page=4'); if ( have_posts() ) : while ( have_posts() ) : the_post(); ... ``` Now this code limits only 4 items per page and shows ...
Use a [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action in your `functions.php` with [conditional tags](http://codex.wordpress.org/Conditional_Tags), and remove the call to `query_posts`: ``` function wpa62751_pre_get_posts( $query ) { if ( is_category( 'my-category' ) ...
62,785
<p>i have created a sidebar in my wordpress site.</p> <p>i want this sidebar to be displayed on each of my pages and subpages in their respective admin editors.</p> <p>i want the sidebar to contain a list of specific posts with checkboxes to select them independantly or together.</p> <p>each checked post must then b...
[ { "answer_id": 62753, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>Use a <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\" rel=\"nofollow\"><code>pre_ge...
2012/08/23
[ "https://wordpress.stackexchange.com/questions/62785", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19602/" ]
i have created a sidebar in my wordpress site. i want this sidebar to be displayed on each of my pages and subpages in their respective admin editors. i want the sidebar to contain a list of specific posts with checkboxes to select them independantly or together. each checked post must then be displayed on my site w...
Use a [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action in your `functions.php` with [conditional tags](http://codex.wordpress.org/Conditional_Tags), and remove the call to `query_posts`: ``` function wpa62751_pre_get_posts( $query ) { if ( is_category( 'my-category' ) ...
62,793
<ul> <li><p>When adding an image attachment to a post, the Title field is always filled automatically with the file name.</p></li> <li><p>For some images I change this into something more meaningful, for other images I want this field to be empty (in my theme I'm displaying this title field as a caption below each imag...
[ { "answer_id": 62753, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>Use a <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\" rel=\"nofollow\"><code>pre_ge...
2012/08/23
[ "https://wordpress.stackexchange.com/questions/62793", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9134/" ]
* When adding an image attachment to a post, the Title field is always filled automatically with the file name. * For some images I change this into something more meaningful, for other images I want this field to be empty (in my theme I'm displaying this title field as a caption below each image, but not all images sh...
Use a [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action in your `functions.php` with [conditional tags](http://codex.wordpress.org/Conditional_Tags), and remove the call to `query_posts`: ``` function wpa62751_pre_get_posts( $query ) { if ( is_category( 'my-category' ) ...
62,810
<p>I have the following code and while get_the_ID() works, $post->ID does not, why?</p> <pre><code> $the_query = new WP_Query( array( 'post_type' =&gt; 'custompost', ) ); while ( $the_query-&gt;have_posts() ) : $the_query-&gt;the_post(); echo $post-&gt;ID; endwhile; </code></pre>
[ { "answer_id": 62812, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 4, "selected": true, "text": "<p>Your WP_Query loop is incomplete. Your not checking if any posts were actually found before looping, nor are y...
2012/08/23
[ "https://wordpress.stackexchange.com/questions/62810", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
I have the following code and while get\_the\_ID() works, $post->ID does not, why? ``` $the_query = new WP_Query( array( 'post_type' => 'custompost', ) ); while ( $the_query->have_posts() ) : $the_query->the_post(); echo $post->ID; endwhile; ```
Your WP\_Query loop is incomplete. Your not checking if any posts were actually found before looping, nor are you presenting a message to show none were found, nor are you cleaning up afterwards. You're also using the 'other' syntax that breaks brace matching in IDEs, making your life harder. Try adding `global $post;...
62,846
<p>I have a custom page which uses a template called "Stores" <code>http://example.com/stores/</code>. This page will have a list of states and/or companies as categories. For this system I have a custom post type "store" which can be assigned to a single category (either state or company),</p> <p>Each store is not a ...
[ { "answer_id": 62854, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 5, "selected": true, "text": "<h1>Create a Page Template</h1>\n\n<p>Add a new page and give it the slug <code>stores</code></p>\n\n<h1>Add A ...
2012/08/23
[ "https://wordpress.stackexchange.com/questions/62846", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19105/" ]
I have a custom page which uses a template called "Stores" `http://example.com/stores/`. This page will have a list of states and/or companies as categories. For this system I have a custom post type "store" which can be assigned to a single category (either state or company), Each store is not a specific page, but co...
Create a Page Template ====================== Add a new page and give it the slug `stores` Add A Public Query Variable =========================== ``` add_filter('query_vars', 'add_state_var', 0, 1); function add_state_var($vars){ $vars[] = 'state'; return $vars; } ``` Add a rewrite rule ==================...
62,856
<p>I'm developing a custom theme and I added some widgetized sidebars like so:</p> <pre><code>register_sidebars(2, array('name'=&gt;'Foobar %d')); </code></pre> <p>I then recreated them so that I could give them semantic names. Like so:</p> <pre><code>register_sidebar(register_sidebar( array( 'name' =&gt...
[ { "answer_id": 62859, "author": "asadasad", "author_id": 19621, "author_profile": "https://wordpress.stackexchange.com/users/19621", "pm_score": -1, "selected": false, "text": "<p>I am not sure whether you want to remove sidebar or widget areas, what i think is that you want to remove 2 ...
2012/08/23
[ "https://wordpress.stackexchange.com/questions/62856", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19620/" ]
I'm developing a custom theme and I added some widgetized sidebars like so: ``` register_sidebars(2, array('name'=>'Foobar %d')); ``` I then recreated them so that I could give them semantic names. Like so: ``` register_sidebar(register_sidebar( array( 'name' => 'Sidebar' ) )); register_sidebar(regi...
Thanks for the comment @Rarst! That was the issue. For whatever reason I had that extra sidebar method call in there and that was causing the problem. ``` register_sidebar( array( 'name' => 'Sidebar' ) ); register_sidebar( array( 'name' => 'Sub Menu' ) ); ``` WordPress saves the data ...
62,860
<p>How can I show my latest tweet in my wordpress blog?</p> <p>in functions.php not use any plugin</p>
[ { "answer_id": 62866, "author": "JohnDevelops", "author_id": 19316, "author_profile": "https://wordpress.stackexchange.com/users/19316", "pm_score": 0, "selected": false, "text": "<p>To do this without a plugin is pretty simple, you can utilise built in WordPress functionality such as a ...
2012/08/23
[ "https://wordpress.stackexchange.com/questions/62860", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19623/" ]
How can I show my latest tweet in my wordpress blog? in functions.php not use any plugin
``` function get_twitter_feed(){ $userID = 'ImOttoman'; //your twiter username $url = 'http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=$userID&count=1'; $xml = simplexml_load_file($url) or die("could not connect"); foreach($xml->status as $status){ $text = $status->text; } ...
62,888
<p>I cant see any settings and cant see much in the php api docs regarding this?</p> <p>for instance if the original file upload is a <code>png</code> wordpress converts to <code>jpg</code></p>
[ { "answer_id": 62901, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 1, "selected": false, "text": "<p>The thumbnails will be saved using the mime type of the file. </p>\n\n<p>You will need to create your own functio...
2012/08/24
[ "https://wordpress.stackexchange.com/questions/62888", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14485/" ]
I cant see any settings and cant see much in the php api docs regarding this? for instance if the original file upload is a `png` wordpress converts to `jpg`
Here's something I wrote because my clients were using very high quality pngs, when they could be more lossy jpgs for web. Note this still preserves the original image, only changes the thumbnails. Add this to your functions.php ``` <?php //Force PNG Thumbnails into JPGs add_filter('wp_generate_attachment_metadata','...
62,889
<p>Is there a way to prevent visitors, whether logged in or not, from reaching <code>mysite.com/wp-login.php</code>?</p> <p>I have a separate login form which is all we need. I know I can re-style the form generated by <code>wp-login</code> but I'd rather not have to deal with it at all. I've tried various filters and...
[ { "answer_id": 62892, "author": "Androliyah", "author_id": 17636, "author_profile": "https://wordpress.stackexchange.com/users/17636", "pm_score": 4, "selected": false, "text": "<p>Try this in your theme's functions.php</p>\n\n<pre><code>add_action('init','custom_login');\n\nfunction cus...
2012/08/24
[ "https://wordpress.stackexchange.com/questions/62889", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17248/" ]
Is there a way to prevent visitors, whether logged in or not, from reaching `mysite.com/wp-login.php`? I have a separate login form which is all we need. I know I can re-style the form generated by `wp-login` but I'd rather not have to deal with it at all. I've tried various filters and hooks and I can't seem to get i...
After finding this question, and testing a few of the answers, the below is a "cleaned up" version of what I am using in a production environment. This version does not throw any notices / errors, and also allows for password resets to work: ``` // Hook the appropriate WordPress action add_action('init', 'prevent_wp_...
62,899
<p>I need a plugin to do the following:</p> <ul> <li>Add custom posttypes such as "Books" or "Cars"</li> <li>Add custom fields such as "Url", "Label", "Number of wheels", "Name of passenger" or "Age of passenger"</li> </ul> <p>There are some requirements</p> <ol> <li>This should work on a multisite installation and ...
[ { "answer_id": 62892, "author": "Androliyah", "author_id": 17636, "author_profile": "https://wordpress.stackexchange.com/users/17636", "pm_score": 4, "selected": false, "text": "<p>Try this in your theme's functions.php</p>\n\n<pre><code>add_action('init','custom_login');\n\nfunction cus...
2012/08/24
[ "https://wordpress.stackexchange.com/questions/62899", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19632/" ]
I need a plugin to do the following: * Add custom posttypes such as "Books" or "Cars" * Add custom fields such as "Url", "Label", "Number of wheels", "Name of passenger" or "Age of passenger" There are some requirements 1. This should work on a multisite installation and it should be possible to fetch posts and the ...
After finding this question, and testing a few of the answers, the below is a "cleaned up" version of what I am using in a production environment. This version does not throw any notices / errors, and also allows for password resets to work: ``` // Hook the appropriate WordPress action add_action('init', 'prevent_wp_...
62,907
<p>I am using a breadcrumb code that will not place a link on two custom single post pages linking back to two custom post type index pages. The full Breadcrumb code can be seen here: <a href="http://pastebin.com/xNwXxWv6" rel="nofollow">http://pastebin.com/xNwXxWv6</a></p> <p><br></p> <pre><code>if(get_post_type() =...
[ { "answer_id": 62909, "author": "janw", "author_id": 10911, "author_profile": "https://wordpress.stackexchange.com/users/10911", "pm_score": 2, "selected": true, "text": "<p>If you read the <a href=\"http://codex.wordpress.org/is_single\" rel=\"nofollow\">codex</a> you will see that <cod...
2012/08/24
[ "https://wordpress.stackexchange.com/questions/62907", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19636/" ]
I am using a breadcrumb code that will not place a link on two custom single post pages linking back to two custom post type index pages. The full Breadcrumb code can be seen here: <http://pastebin.com/xNwXxWv6> ``` if(get_post_type() == 'Portfolio'){ echo '<a href="' . 'http://www.mysite.com/web-portfolio' . '">' ....
If you read the [codex](http://codex.wordpress.org/is_single) you will see that `is_single` accepts post id's / titles / slugs and **EDIT** If you are using two custom post types then WP will select the right `single-POSTNAME.php` And in your check you best check the posttype like: ``` if ( get_post_type() == 'pos...
62,917
<p>I'm not entirely sure this is Wordpress' fault, but I figure I'd ask anyway and see if anyone else has experienced any problems like this before.</p> <p>I'm trying to save an array to a wp_options table row. The data is coming from a custom metabox and is being saved when the save_post hook is triggered. I assumed ...
[ { "answer_id": 62929, "author": "MZAweb", "author_id": 5223, "author_profile": "https://wordpress.stackexchange.com/users/5223", "pm_score": 0, "selected": false, "text": "<p>save_post is called multiple times while you edit a post (autosave). That's a common gotcha, but it'd be cool if ...
2012/08/24
[ "https://wordpress.stackexchange.com/questions/62917", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13176/" ]
I'm not entirely sure this is Wordpress' fault, but I figure I'd ask anyway and see if anyone else has experienced any problems like this before. I'm trying to save an array to a wp\_options table row. The data is coming from a custom metabox and is being saved when the save\_post hook is triggered. I assumed this sho...
I had something similar going on when I tried to use the `wp_editor()` function while inside a custom metabox. It was wanting to save multiple times. Take a look at this. ``` // SAVE Metabox for admin response add_action('post_updated', 'display_jwl_wp_etickets_response_meta_box_save'); function display_jwl_wp_eticke...
62,920
<p>I'm in the process of creating rather complex sites with Wordpress. I'll have a page template that collects data from other pages and shows them on one page.</p> <p>These pages are not used anywhere else than in the page template and shouldn't be indexed for search engines or be accessible via a slug.</p> <p>They ...
[ { "answer_id": 62929, "author": "MZAweb", "author_id": 5223, "author_profile": "https://wordpress.stackexchange.com/users/5223", "pm_score": 0, "selected": false, "text": "<p>save_post is called multiple times while you edit a post (autosave). That's a common gotcha, but it'd be cool if ...
2012/08/24
[ "https://wordpress.stackexchange.com/questions/62920", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19548/" ]
I'm in the process of creating rather complex sites with Wordpress. I'll have a page template that collects data from other pages and shows them on one page. These pages are not used anywhere else than in the page template and shouldn't be indexed for search engines or be accessible via a slug. They are supposed to a...
I had something similar going on when I tried to use the `wp_editor()` function while inside a custom metabox. It was wanting to save multiple times. Take a look at this. ``` // SAVE Metabox for admin response add_action('post_updated', 'display_jwl_wp_etickets_response_meta_box_save'); function display_jwl_wp_eticke...