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
34,935
<p>On My category.php page i've got a list of categories with the title and the description.</p> <p><strong>Here's the code:</strong></p> <pre><code>&lt;?php $cat_id = get_query_var('cat'); $catlist = get_categories('hide_empty=0&amp;child_of=' . $cat_id); echo "&lt;ul&gt;"; foreach($catlist as $categories_item) { ...
[ { "answer_id": 34930, "author": "Kaaviar", "author_id": 3071, "author_profile": "https://wordpress.stackexchange.com/users/3071", "pm_score": 1, "selected": false, "text": "<p>I'd say neither one nor the other :)</p>\n\n<p>You should take a look at custom fields with some plugins you can...
2011/11/28
[ "https://wordpress.stackexchange.com/questions/34935", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9218/" ]
On My category.php page i've got a list of categories with the title and the description. **Here's the code:** ``` <?php $cat_id = get_query_var('cat'); $catlist = get_categories('hide_empty=0&child_of=' . $cat_id); echo "<ul>"; foreach($catlist as $categories_item) { echo '<h1><a href="' . get_category_link( $cate...
If you need to display the flags of the countries in the post then the best option would be to use custom fields with your own function that will know to translate the value of the custom field in to the right country's image. You can also create a custom taxonomy for that with a custom field (best tutorial in the wor...
34,943
<p>I'm looking to format the bullets for the last item of the list.</p> <p>I'm using Firebug to pinpoint where the menu item is and I have two options in front of me:</p> <p><a href="https://i.imgur.com/RMx09.png" rel="nofollow noreferrer">Screenshot 1</a></p> <p><a href="https://i.imgur.com/N1RNO.png" rel="nofollow...
[ { "answer_id": 34945, "author": "ZweiBlumen", "author_id": 10617, "author_profile": "https://wordpress.stackexchange.com/users/10617", "pm_score": 0, "selected": false, "text": "<p>If you post your HTML that would be help in figuring out what the CSS needs to be. Also, please indicate in...
2011/11/28
[ "https://wordpress.stackexchange.com/questions/34943", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10099/" ]
I'm looking to format the bullets for the last item of the list. I'm using Firebug to pinpoint where the menu item is and I have two options in front of me: [Screenshot 1](https://i.imgur.com/RMx09.png) [Screenshot 2 - Includes bullet](https://i.imgur.com/N1RNO.png) Now I'm looking at either using CSS or jQuery to ...
You can use jQuery like this: ``` jQuery('ul.children li:last').addClass('last'); ``` And then CSS it with: ``` ul.children li.last { color: red; } ``` Hope this helps. Good luck!
34,948
<p>I have built a custom options panel which allows site owners to enter their social profiles. I then use the second code to make the links appear in the theme.</p> <p><strong>When no link is entered in the options panel, I would like there to be no link called on the page where the code is being called. Currently,...
[ { "answer_id": 34951, "author": "ptriek", "author_id": 9134, "author_profile": "https://wordpress.stackexchange.com/users/9134", "pm_score": 1, "selected": false, "text": "<p>You could try something like:</p>\n\n<pre><code>if( get_option('to_facebook') ) { \n?&gt;\n &lt;a href=\"&lt;?...
2011/11/28
[ "https://wordpress.stackexchange.com/questions/34948", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
I have built a custom options panel which allows site owners to enter their social profiles. I then use the second code to make the links appear in the theme. **When no link is entered in the options panel, I would like there to be no link called on the page where the code is being called. Currently, it provides me wi...
Check if get\_option returns a value and if it is not blank, then output the links. This should work for you: ``` <?php if(get_option('to_facebook') && get_option('to_facebook') != '') { ?> <a href="<?php echo get_option('to_facebook'); ?>"></a> <?php } if(get_option('to_google_plus') && get_opti...
34,956
<p>I'm looking for a way to set the default "View" options under post types in the admin area. For example, by default Posts will default to a "list" view instead of "excerpt" - I'd like to change this to excerpt by default - what would be the best way to achieve this? I've done a bit of searching on this, but am stuck...
[ { "answer_id": 47390, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 3, "selected": false, "text": "<p>The post view screen switches from list view to excerpt view based on the value of the &quot;mode&quot; parameter in ...
2011/11/28
[ "https://wordpress.stackexchange.com/questions/34956", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9605/" ]
I'm looking for a way to set the default "View" options under post types in the admin area. For example, by default Posts will default to a "list" view instead of "excerpt" - I'd like to change this to excerpt by default - what would be the best way to achieve this? I've done a bit of searching on this, but am stuck in...
Although having the feature of persistent settings in core is nice, it may take quite a while before it's actually accepted. WordPress 3.5 is still quite far away. So let's augment the global `$_REQUEST` array instead. ``` add_action( 'load-edit.php', 'wpse34956_force_excerpt' ); function wpse34956_force_excerpt() { ...
34,963
<p>I'm looking for a way to set the default "Automatically add new top-level pages" to be checked when creating a new menu. I haven't been able to find anything on this - any help you could give me? Thanks!</p>
[ { "answer_id": 35009, "author": "Mohit Bumb", "author_id": 8184, "author_profile": "https://wordpress.stackexchange.com/users/8184", "pm_score": 0, "selected": false, "text": "<p>When you create menu check there's a check box \"Automatically add new top-level pages\n\" just check it and ...
2011/11/28
[ "https://wordpress.stackexchange.com/questions/34963", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9605/" ]
I'm looking for a way to set the default "Automatically add new top-level pages" to be checked when creating a new menu. I haven't been able to find anything on this - any help you could give me? Thanks!
``` <?php add_action( 'wp_create_nav_menu', 'PREFIX_nav_menu_auto_add_by_default' ); function PREFIX_nav_menu_auto_add_by_default( $id ) { $options = (array) get_option( 'nav_menu_options' ); if ( ! isset( $options['auto_add'] ) ) { $options['auto_add'] = array(); } $options['auto_add'][] = $id;...
34,965
<p>I dont know how/why this happened. I was working on my site over the weekend and it was fine. When I came into the office this morning, I went to the site and got this:</p> <pre><code>Fatal error: Allowed memory size of 146800640 bytes exhausted (tried to allocate 57 bytes) in public_html/wp-includes/rewrite.php on...
[ { "answer_id": 34973, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": -1, "selected": false, "text": "<p>Open your wp-config.php and make sure it has the following placed inside of it:</p>\n\n<pre><code>define('...
2011/11/28
[ "https://wordpress.stackexchange.com/questions/34965", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1893/" ]
I dont know how/why this happened. I was working on my site over the weekend and it was fine. When I came into the office this morning, I went to the site and got this: ``` Fatal error: Allowed memory size of 146800640 bytes exhausted (tried to allocate 57 bytes) in public_html/wp-includes/rewrite.php on line 1561 ``...
There really is nothing anyone here can do for you with such limited information. It is obviously something within your recent changes. If you use a version control system (as everybody really should), I would roll back the changes and then from there slowly re-implement the changes that were causing this error to tra...
34,992
<p>I have a custom taxonomy called <code>coauthor</code>. On the <code>edit.php</code> screen, I am trying filter and only show posts authored by the current user <strong>OR</strong> posts coauthored by the current user. I can get the posts <strong><em>authored</em></strong> by the current user:</p> <pre><code>functio...
[ { "answer_id": 35033, "author": "ZweiBlumen", "author_id": 10617, "author_profile": "https://wordpress.stackexchange.com/users/10617", "pm_score": 2, "selected": false, "text": "<p>I am not sure if you can easily add OR queries to the $query object. </p>\n\n<p>It seems possible when quer...
2011/11/29
[ "https://wordpress.stackexchange.com/questions/34992", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6228/" ]
I have a custom taxonomy called `coauthor`. On the `edit.php` screen, I am trying filter and only show posts authored by the current user **OR** posts coauthored by the current user. I can get the posts ***authored*** by the current user: ``` function get_authored_posts($query) { global $user_ID; $query->set('...
When I implemented something similar for a company that needed multiple authors, we did much the same with an author taxonomy. But in that case, we didn't use the original author field at all. Basically, it's not possible to create a standard WP\_Query with author=X OR coauthor=Y using standard methods. You'd have to ...
35,023
<p>I run apache2 on Ubuntu, i'm sure there is a configuration or permission problem causing this. When I attempt to update plugins through the admin control panel, after I enter the FTP login/pass and click Proceed. I get the error "Unable to locate WordPress Content directory (wp-content)."</p> <p>And wp-content does...
[ { "answer_id": 35098, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 0, "selected": false, "text": "<p>The FTP user account likely does not have access to the wp-content directory. Are you able to access wp-content u...
2011/11/29
[ "https://wordpress.stackexchange.com/questions/35023", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10413/" ]
I run apache2 on Ubuntu, i'm sure there is a configuration or permission problem causing this. When I attempt to update plugins through the admin control panel, after I enter the FTP login/pass and click Proceed. I get the error "Unable to locate WordPress Content directory (wp-content)." And wp-content does exist and...
I ended up using code from [this post on WordPress.org](http://wordpress.org/support/topic/upgrade-plugin-unable-to-locate-wordpress-content-directory-wp-content?replies=11#post-1329826) Place this into my wp-config.php file ``` if(is_admin()) { add_filter('filesystem_method', create_function('$a', 'return "direc...
35,049
<p><strong>Edit:</strong> The Q narrowed down to the following:</p> <blockquote> <p>"How would I retrieve the screen IDs of all admin UI screens at one time?"</p> </blockquote> <hr> <p><strong>Edit:</strong> I added a bunch of more plugin globals.</p> <hr> <p><strong>Q</strong> is the following: Check <strong>wh...
[ { "answer_id": 35061, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>Since admin menu itself knows how to display where you are at, it is reasonable to look at code responsible for that...
2011/11/29
[ "https://wordpress.stackexchange.com/questions/35049", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/385/" ]
**Edit:** The Q narrowed down to the following: > > "How would I retrieve the screen IDs of all admin UI screens at one time?" > > > --- **Edit:** I added a bunch of more plugin globals. --- **Q** is the following: Check **which AdminUI submenu page/screen you're viewing** and check this **against some global ...
Since we now have `get_current_screen()`, which returns a nice object, it's become fairly easy to just use that.
35,053
<p>I have some wordpress websites on one server that I want to download. The problem is I don't know what url or what server I am moving it to. The problem is I do want the original to work. Suggestions on what I should do? </p> <p><a href="http://codex.wordpress.org/Moving_WordPress" rel="nofollow">This Wordpress Cod...
[ { "answer_id": 35054, "author": "ptriek", "author_id": 9134, "author_profile": "https://wordpress.stackexchange.com/users/9134", "pm_score": 3, "selected": true, "text": "<p>I wouldn't worry too much about it - just download all databases and files.</p>\n\n<p>And if you're uploading them...
2011/11/29
[ "https://wordpress.stackexchange.com/questions/35053", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7355/" ]
I have some wordpress websites on one server that I want to download. The problem is I don't know what url or what server I am moving it to. The problem is I do want the original to work. Suggestions on what I should do? [This Wordpress Codex](http://codex.wordpress.org/Moving_WordPress) suggests I already know where...
I wouldn't worry too much about it - just download all databases and files. And if you're uploading them to the new server, change the wp-config files and run the following queries on the databases: ``` UPDATE wp_options SET option_value = replace(option_value, 'http://www.example.com', 'http://www.newurl.com') WHERE...
35,062
<p>I've created a function to call in a page template, inside of which is the following query:</p> <pre><code>$custom_news = new WP_Query(array( 'post_type' =&gt; array('post', 'resource', 'job'), 'posts_per_page' =&gt; 5, 'tag' =&gt; 'justice', 'orderby' =&gt; 'post_date', 'order' =&gt; 'DESC...
[ { "answer_id": 49511, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>It seems that your Theme is modifying the query after you're adding your query. Propably the <code>pre_get_posts</c...
2011/11/29
[ "https://wordpress.stackexchange.com/questions/35062", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10583/" ]
I've created a function to call in a page template, inside of which is the following query: ``` $custom_news = new WP_Query(array( 'post_type' => array('post', 'resource', 'job'), 'posts_per_page' => 5, 'tag' => 'justice', 'orderby' => 'post_date', 'order' => 'DESC', ) ); ``` The proble...
I just got the same problem and the problem was `exclude_from_search` `post_type` option. It seems that WordPress got a bug (I'm just going to report it), that when you got `exclude_from_search` `false`, the posts do not show on tax pages
35,076
<p>I'm working with the admin bar and trying to debug some of the menus and their priorities.</p> <p>I know several callbacks get bound to actions, such as this one:</p> <pre><code>add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 ); </code></pre> <p>How can I see what is lined up to be called when a hook lik...
[ { "answer_id": 35085, "author": "Anh Tran", "author_id": 2051, "author_profile": "https://wordpress.stackexchange.com/users/2051", "pm_score": 6, "selected": true, "text": "<p>You can see the detailed list of the hook using this snippet:</p>\n\n<pre><code>$hook_name = 'admin_bar_menu';\n...
2011/11/29
[ "https://wordpress.stackexchange.com/questions/35076", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4400/" ]
I'm working with the admin bar and trying to debug some of the menus and their priorities. I know several callbacks get bound to actions, such as this one: ``` add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 ); ``` How can I see what is lined up to be called when a hook like `admin_bar_menu` is called?
You can see the detailed list of the hook using this snippet: ``` $hook_name = 'admin_bar_menu'; global $wp_filter; var_dump( $wp_filter[$hook_name] ); ```
35,077
<p>I asked this question without a clue what was going on. I got an answer with the code below. It worked when I got it. I tested it with shirts only, assuming it worked with the other cats. it doesn't work with hoodies. Why.. idk. Gallery still hides from blog post. Any one see why?</p> <pre><code>&lt;?php $gallery =...
[ { "answer_id": 35080, "author": "Ciprian", "author_id": 9869, "author_profile": "https://wordpress.stackexchange.com/users/9869", "pm_score": 0, "selected": false, "text": "<p>This is how I exclude categories on my home page:</p>\n\n<pre><code> &lt;?php if ( is_home() ) { quer...
2011/11/29
[ "https://wordpress.stackexchange.com/questions/35077", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10636/" ]
I asked this question without a clue what was going on. I got an answer with the code below. It worked when I got it. I tested it with shirts only, assuming it worked with the other cats. it doesn't work with hoodies. Why.. idk. Gallery still hides from blog post. Any one see why? ``` <?php $gallery = get_cat_id('gall...
You have missed a `&` before showposts in the query. Also showposts is depracated. Try using posts\_per\_page instead. ``` <?php $gallery = get_cat_id('gallery'); $shirts = get_cat_id('shirts'); $hoodies = get_cat_id('hoodies'); $excluded_cats = '-'.$gallery.',-'.$shirts.',-'.$hoodies; $limit = 5; $paged = (get_query_...
35,087
<p>I have 40+ sites showing up in the "My Sites" page with more planned. Unfortunately WordPress doesn't sort them alphabetically, and that makes it a pain to move from site to site during routine updates and maintenance. I've tried adding</p> <pre><code>asort($blogs); </code></pre> <p>to wp-admin/my-sites.php, but t...
[ { "answer_id": 35089, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 5, "selected": true, "text": "<p>Easy one.</p>\n\n<pre><code>&lt;?php\n/*\nPlugin Name: Sort My-Sites\nDescription: Sorts the My Sites listing on bot...
2011/11/30
[ "https://wordpress.stackexchange.com/questions/35087", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6800/" ]
I have 40+ sites showing up in the "My Sites" page with more planned. Unfortunately WordPress doesn't sort them alphabetically, and that makes it a pain to move from site to site during routine updates and maintenance. I've tried adding ``` asort($blogs); ``` to wp-admin/my-sites.php, but that doesn't help either. A...
Easy one. ``` <?php /* Plugin Name: Sort My-Sites Description: Sorts the My Sites listing on both the page and in the 3.3 admin bar dropdown Author: Otto */ add_filter('get_blogs_of_user','sort_my_sites'); function sort_my_sites($blogs) { $f = create_function('$a,$b','return strcasecmp($a->blogname,$b->blogna...
35,103
<p>I have two sidebars using the <code>register_sidebars</code> function that display each widget as a list item with a class of <code>.box</code>:</p> <pre><code>&lt;?php if(function_exists('register_sidebars')){ register_sidebars(2, array( 'name'=&gt;'sidebar%d', 'id' =&gt;'sidebar', 'before_widget'=&g...
[ { "answer_id": 35105, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 0, "selected": false, "text": "<p>You can actually try that using jQuery.</p>\n\n<pre><code>jQuery('.xoxo').parent().removeClass('box');...
2011/11/30
[ "https://wordpress.stackexchange.com/questions/35103", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10417/" ]
I have two sidebars using the `register_sidebars` function that display each widget as a list item with a class of `.box`: ``` <?php if(function_exists('register_sidebars')){ register_sidebars(2, array( 'name'=>'sidebar%d', 'id' =>'sidebar', 'before_widget'=>'<li class="box">', 'after_widget'=>'</li>...
I coded my own answer together using a filter and `dynamic_sidebar_params`: ``` <?php add_filter('dynamic_sidebar_params','io_blogroll_class'); function io_blogroll_class($params){ $params[0]['before_widget'] = '<li class="'.$params[0]['widget_name'].' box">'; $params[0]['after_widget'] = '</li><!--'.$params[0][...
35,115
<p>I'm trying what I thought would be something really simple of masking my url but cannot seem to get it to work. I want to be able to link to images in my img tag without having to type in the full url.</p> <p>i.e.</p> <pre><code>Current url: http://server.com/wp-content/themes/standard/images/img.jpg or &lt;img...
[ { "answer_id": 35116, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 2, "selected": false, "text": "<p>Why don't you create a shortcode for that in the following manner.</p>\n\n<pre><code>function img_fold...
2011/11/30
[ "https://wordpress.stackexchange.com/questions/35115", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10708/" ]
I'm trying what I thought would be something really simple of masking my url but cannot seem to get it to work. I want to be able to link to images in my img tag without having to type in the full url. i.e. ``` Current url: http://server.com/wp-content/themes/standard/images/img.jpg or <img src = "http://server.com/...
Check out the [Roots WordPress Theme](http://www.rootstheme.com/). They seem to do exactly what you want with the URLs. Here's a snippet from their [roots-htaccess.php](https://github.com/roots/roots/blob/master/lib/rewrites.php) file: ``` add_action( 'generate_rewrite_rules', 'roots_add_rewrites' ); function roots_...
35,123
<p>Here is my code</p> <pre><code>$my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query-&gt;query(array('post_type' =&gt; 'page','post_parent'=&gt;$parid,'orderby'=&gt;'title','order'=&gt;'ASC' )); </code></pre> <p>It displays the first level sub pages only. I need all the sub page, sub's sub page ... and all. ...
[ { "answer_id": 35151, "author": "Kris Nielsen", "author_id": 10466, "author_profile": "https://wordpress.stackexchange.com/users/10466", "pm_score": 2, "selected": false, "text": "<p>Not sure if this is exactly what you are after, but you could use the wp_list_pages function, and use the...
2011/11/30
[ "https://wordpress.stackexchange.com/questions/35123", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10711/" ]
Here is my code ``` $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array('post_type' => 'page','post_parent'=>$parid,'orderby'=>'title','order'=>'ASC' )); ``` It displays the first level sub pages only. I need all the sub page, sub's sub page ... and all. I searched for a solution and i can get a...
Why not just use [`get_pages()`](http://codex.wordpress.org/Function_Reference/get_pages)? e.g. ``` <?php // Determine parent page ID $parent_page_id = ( '0' != $post->post_parent ? $post->post_parent : $post->ID ); // Get child pages as array $page_tree_array = get_pages( array( 'child_of' => $parent_page_id; ) ...
35,146
<p>My pagination links are failing for a custom post type here <a href="http://mjw.view-wireframes.com/about-us/press/" rel="nofollow">http://mjw.view-wireframes.com/about-us/press/</a></p> <p>the page reloads <a href="http://mjw.view-wireframes.com/about-us/press/page/2/" rel="nofollow">http://mjw.view-wireframes.com...
[ { "answer_id": 35151, "author": "Kris Nielsen", "author_id": 10466, "author_profile": "https://wordpress.stackexchange.com/users/10466", "pm_score": 2, "selected": false, "text": "<p>Not sure if this is exactly what you are after, but you could use the wp_list_pages function, and use the...
2011/11/30
[ "https://wordpress.stackexchange.com/questions/35146", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3782/" ]
My pagination links are failing for a custom post type here <http://mjw.view-wireframes.com/about-us/press/> the page reloads <http://mjw.view-wireframes.com/about-us/press/page/2/> but this has no effect on the displayed posts. Flushing the permalink structure has no effect so my guess is the problem is in the query....
Why not just use [`get_pages()`](http://codex.wordpress.org/Function_Reference/get_pages)? e.g. ``` <?php // Determine parent page ID $parent_page_id = ( '0' != $post->post_parent ? $post->post_parent : $post->ID ); // Get child pages as array $page_tree_array = get_pages( array( 'child_of' => $parent_page_id; ) ...
35,163
<p>In the wordpress menu I would like to add a link to the buddypress user profile and messages. These links are dynamic based on the username like, <a href="http://buddypress.org/community/members/username/messages/" rel="nofollow">http://buddypress.org/community/members/username/messages/</a>, for example.</p> <p>I ...
[ { "answer_id": 35172, "author": "bow-viper1", "author_id": 10724, "author_profile": "https://wordpress.stackexchange.com/users/10724", "pm_score": 1, "selected": false, "text": "<p>I believe <a href=\"https://wordpress.stackexchange.com/questions/16223/add-buddypress-profile-menu-item\">...
2011/11/30
[ "https://wordpress.stackexchange.com/questions/35163", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10722/" ]
In the wordpress menu I would like to add a link to the buddypress user profile and messages. These links are dynamic based on the username like, <http://buddypress.org/community/members/username/messages/>, for example. I know you can get the username with php but that is not allowed within wordpress menus (wp-admin/...
This will give you the user-specific profile URL: ``` <? echo bp_loggedin_user_domain(); ?> ``` If you'd the link to go to the user's Messages page, just add to the end like so: ``` <? echo bp_loggedin_user_domain().'messages/'; ?> ```
35,165
<p>I wish to create a custom capability for accessing the interface of my plugin. </p> <ul> <li>Should the plugin manage adding this capability to all the administrator accounts on activation?</li> <li>If so: Does WordPress manage adding the capability to all administrators of sub blogs and super administrators in mul...
[ { "answer_id": 35199, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 4, "selected": false, "text": "<h3>Remove what you add</h3>\n\n<p>First, please make sure that everything you <em>add on activation</em> also gets <e...
2011/11/30
[ "https://wordpress.stackexchange.com/questions/35165", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/353/" ]
I wish to create a custom capability for accessing the interface of my plugin. * Should the plugin manage adding this capability to all the administrator accounts on activation? * If so: Does WordPress manage adding the capability to all administrators of sub blogs and super administrators in multisite installations,...
Tested with WordPress 6.0, and it works: ``` add_action( 'activated_plugin',function( $plugin,$network_activation ){ add_role( 'your_custom_role_slug', __( 'Your custom role title','your-plugin-domain' ), array( 'read' => true, 'view_admin_dashboard' => true, 'activate_p...
35,169
<p>I have an older theme that is loading jQuery 'manually', and this conflicts with all plugins that are trying to use jQuery. The following lines are included in the theme header:</p> <pre><code>&lt;script type="text/javascript" src="&lt;?php bloginfo('template_url'); ?&gt;/js/jquery-1.3.2.min.js"&gt;&lt;/script&gt; ...
[ { "answer_id": 35173, "author": "ptriek", "author_id": 9134, "author_profile": "https://wordpress.stackexchange.com/users/9134", "pm_score": 0, "selected": false, "text": "<p>Add the following code to your functions.php for each script:</p>\n\n<pre><code>wp_enqueue_script('handle', get_...
2011/11/30
[ "https://wordpress.stackexchange.com/questions/35169", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7679/" ]
I have an older theme that is loading jQuery 'manually', and this conflicts with all plugins that are trying to use jQuery. The following lines are included in the theme header: ``` <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery-1.3.2.min.js"></script> <script type="text/javascript" s...
Taking a stab at a general answer, since we don't (yet?) have access to the specific Theme. **Note: all of these edits can - and perhaps *should* - be implemented via Child Theme.** First, you need to remove ALL of those lines from `header.php`. Scripts should be *enqueued*, rather than *hard-coded* into the template...
35,196
<p>Theres a way to use <code>$query-&gt;set('tax_query', ...)</code> in <code>pre_get_posts</code> filter? for example next code is not altering the query. Note that I'm building $taxonomies from and custom search.</p> <pre><code>function custom_search_filter($query) { ... // array('taxonomy' =&gt; 'c...
[ { "answer_id": 35263, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 6, "selected": true, "text": "<p>The <code>$query</code> variable in the filter represents a <code>WP_Query</code> object, so you shouldn't be pas...
2011/11/30
[ "https://wordpress.stackexchange.com/questions/35196", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2011/" ]
Theres a way to use `$query->set('tax_query', ...)` in `pre_get_posts` filter? for example next code is not altering the query. Note that I'm building $taxonomies from and custom search. ``` function custom_search_filter($query) { ... // array('taxonomy' => 'category', 'field' => 'id', 'terms' => arra...
The `$query` variable in the filter represents a `WP_Query` object, so you shouldn't be passing a new `WP_Query` object into the method for setting that object's properties. The [question](https://wordpress.stackexchange.com/questions/25076/how-to-filter-wordpress-search-excluding-post-in-some-custom-taxonomies) you c...
35,208
<p>I wonder if is it possible to have a shortcode inside another one?</p> <p>My scenario is this:</p> <p>I create a shortcodes to display content into columns so I can manage the layout of the page more easily. Now the problem comes, when I try to use for sample nextgen gallery into one of those shortcodes. For some ...
[ { "answer_id": 35210, "author": "patnz", "author_id": 4093, "author_profile": "https://wordpress.stackexchange.com/users/4093", "pm_score": 4, "selected": true, "text": "<p>I usually apply the_content filters to $content to do this. I think you can aslo use do_shortcode($content);</p>\n\...
2011/11/30
[ "https://wordpress.stackexchange.com/questions/35208", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4907/" ]
I wonder if is it possible to have a shortcode inside another one? My scenario is this: I create a shortcodes to display content into columns so I can manage the layout of the page more easily. Now the problem comes, when I try to use for sample nextgen gallery into one of those shortcodes. For some reason it just ge...
I usually apply the\_content filters to $content to do this. I think you can aslo use do\_shortcode($content); ``` // Column ShortCode Description function column_scdescription($atts, $content="null") { return '<div class="description">' .apply_filters('the_content', $content) . '</div> <!-- description ends here ...
35,221
<p>When I register my custom post type, I set this:</p> <pre><code>'hierarchical' =&gt; true, 'supports' =&gt; array( 'title','author', 'page-attributes' ), </code></pre> <p>So, I am supose to see 'order', 'templates', 'parents' in Attributes box when create new post. But, I don't see the 'templates' drop dow...
[ { "answer_id": 35229, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 4, "selected": true, "text": "<p>You can't apply templates to custom post types in this manner. That will show up only if the post type ...
2011/12/01
[ "https://wordpress.stackexchange.com/questions/35221", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5210/" ]
When I register my custom post type, I set this: ``` 'hierarchical' => true, 'supports' => array( 'title','author', 'page-attributes' ), ``` So, I am supose to see 'order', 'templates', 'parents' in Attributes box when create new post. But, I don't see the 'templates' drop down showing up. Anything else I sh...
You can't apply templates to custom post types in this manner. That will show up only if the post type is 'page' ( Check the wp-admin/includes/meta-boxes.php line 568 ). However if you want to style all your single custom post types in the same manner but different from other post types you could use the single-[postty...
35,230
<p>Wanted some opinions on a solution I'm trying to come up with:</p> <p>I have a fan/enthusiast plugin I'm working on for fans of TV shows. One of the custom post types attached to the plugin is a release type which stores data on dvd releases of a show. Some of the meta data that I weant stored is info from Amazon...
[ { "answer_id": 35271, "author": "sanchothefat", "author_id": 1733, "author_profile": "https://wordpress.stackexchange.com/users/1733", "pm_score": 2, "selected": false, "text": "<p>When implementing caching with an API I've used the transients route. Mainly because they're set up for it ...
2011/12/01
[ "https://wordpress.stackexchange.com/questions/35230", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2234/" ]
Wanted some opinions on a solution I'm trying to come up with: I have a fan/enthusiast plugin I'm working on for fans of TV shows. One of the custom post types attached to the plugin is a release type which stores data on dvd releases of a show. Some of the meta data that I weant stored is info from Amazon using their...
I think I would write a wrapper function around custom fields, something like this: ``` function get_post_transient( $post_ID, $meta_key, $update_function ) { $current_value = get_post_meta( $post_ID, $meta_key, true ); if ( is_array( $current_value ) && $current_value['expiration'] < date('U') ) retur...
35,249
<p>This is probably a super simple question.</p> <p>But how do I echo the ID of a user on author.php?</p> <p>I've tried</p> <pre><code>the_author_meta('ID') </code></pre> <p>But it didn't seem to want to work. I want to echo it at the end of a URL, for example;</p> <p><a href="http:///www.domain.com/author/samplea...
[ { "answer_id": 35251, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 6, "selected": true, "text": "<p>Try this code.</p>\n\n<pre><code>$author = get_user_by( 'slug', get_query_var( 'author_name' ) );\necho...
2011/12/01
[ "https://wordpress.stackexchange.com/questions/35249", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7999/" ]
This is probably a super simple question. But how do I echo the ID of a user on author.php? I've tried ``` the_author_meta('ID') ``` But it didn't seem to want to work. I want to echo it at the end of a URL, for example; <http:///www.domain.com/author/sampleauthor-id> Obviously, where "id" is that particular aut...
Try this code. ``` $author = get_user_by( 'slug', get_query_var( 'author_name' ) ); echo $author->ID; ``` Alternatively, if author name has not been set use: ``` if ( $author_id = get_query_var( 'author' ) ) { $author = get_user_by( 'id', $author_id ); } ``` *credit @AndyAdams in the easily missed comments bellow...
35,258
<p>I am having problems getting this plugin to run but have had little success getting it to work, even after reading past entries. I would be grateful if you could see if the code is right.</p> <p>Code in functions.php:</p> <pre><code>'// Add secondary thumbnail (featured image) in posts */ if (class_exists('MultiPo...
[ { "answer_id": 35270, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 0, "selected": false, "text": "<p>For your code to work you need to change your code to this in the functions.php file:</p>\n\n<pre><code>&lt...
2011/12/01
[ "https://wordpress.stackexchange.com/questions/35258", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10085/" ]
I am having problems getting this plugin to run but have had little success getting it to work, even after reading past entries. I would be grateful if you could see if the code is right. Code in functions.php: ``` '// Add secondary thumbnail (featured image) in posts */ if (class_exists('MultiPostThumbnails')) { ne...
Here is a complete example using the code you provided: For your functions.php file: ``` <?php // Add secondary thumbnail (featured image) in posts */ if (class_exists('MultiPostThumbnails')) { new MultiPostThumbnails(array ( 'label' => 'Secondary Image', 'id' => 'secondary-image', 'post_type' => 'post'...
35,259
<p>We have a set of five health blogs which have been running for about six months. Other than using the same theme (styled slightly differently for each one), they are currently completely separate. We are now trying to figure out how best to combine them into a "network" of blogs. Note: this doesn't have to mean WPMU...
[ { "answer_id": 35270, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 0, "selected": false, "text": "<p>For your code to work you need to change your code to this in the functions.php file:</p>\n\n<pre><code>&lt...
2011/12/01
[ "https://wordpress.stackexchange.com/questions/35259", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10617/" ]
We have a set of five health blogs which have been running for about six months. Other than using the same theme (styled slightly differently for each one), they are currently completely separate. We are now trying to figure out how best to combine them into a "network" of blogs. Note: this doesn't have to mean WPMU, t...
Here is a complete example using the code you provided: For your functions.php file: ``` <?php // Add secondary thumbnail (featured image) in posts */ if (class_exists('MultiPostThumbnails')) { new MultiPostThumbnails(array ( 'label' => 'Secondary Image', 'id' => 'secondary-image', 'post_type' => 'post'...
35,264
<p><em>I solved the problem with the page, the correct answer is ptriek's comment below.</em></p> <p>Well I'm having a bit of an odd problem here, wp_nav_menu works on all pages EXCEPT my category pages (probably my archive page too but there's no links on the website to the archive pages so that's alright).</p> <p>A...
[ { "answer_id": 125242, "author": "Implode", "author_id": 43447, "author_profile": "https://wordpress.stackexchange.com/users/43447", "pm_score": 4, "selected": true, "text": "<p>I had the same problem, but with a newer version of Wordpress (3.7.1).</p>\n\n<p>On pages with custom taxonomi...
2011/12/01
[ "https://wordpress.stackexchange.com/questions/35264", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2415/" ]
*I solved the problem with the page, the correct answer is ptriek's comment below.* Well I'm having a bit of an odd problem here, wp\_nav\_menu works on all pages EXCEPT my category pages (probably my archive page too but there's no links on the website to the archive pages so that's alright). Although there is archi...
I had the same problem, but with a newer version of Wordpress (3.7.1). On pages with custom taxonomies of custom posts, the wp\_nav\_menu was not shown. The solution below worked for me. in functions.php of the theme: ``` add_action( 'pre_get_posts', 'my_pre_get_posts' ); function my_pre_get_posts($query) { if ($q...
35,275
<p>Can someone tell, how to check whether it's empty?</p> <pre><code>&lt;?php bloginfo('description'); ?&gt; </code></pre> <p>Something like:</p> <pre><code>&lt;?php if (!empty bloginfo('description');) ?&gt; </code></pre> <p>Thanks a lot.</p>
[ { "answer_id": 35277, "author": "ptriek", "author_id": 9134, "author_profile": "https://wordpress.stackexchange.com/users/9134", "pm_score": 3, "selected": true, "text": "<pre><code>if ( get_bloginfo( 'description' ) ) {\n //do something\n}\n</code></pre>\n\n<p>bloginfo echoes the des...
2011/12/01
[ "https://wordpress.stackexchange.com/questions/35275", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10760/" ]
Can someone tell, how to check whether it's empty? ``` <?php bloginfo('description'); ?> ``` Something like: ``` <?php if (!empty bloginfo('description');) ?> ``` Thanks a lot.
``` if ( get_bloginfo( 'description' ) ) { //do something } ``` bloginfo echoes the description, get\_bloginfo returns php variable
35,315
<p>Is it true that slugs must always be unique, regardless of the rest of the url, or if it's used by different post-types or taxonomies?</p> <p>For example, is it possible to have both of these urls?</p> <pre><code>mysite.com/industry/biotech/report/ mysite.com/industry/retail/report/ </code></pre> <p>Thanks, todd...
[ { "answer_id": 35321, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 1, "selected": false, "text": "<p>Yes, post slugs must be unique, regardless of the post type; it's enforced at the database level. Same for term slu...
2011/12/02
[ "https://wordpress.stackexchange.com/questions/35315", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4548/" ]
Is it true that slugs must always be unique, regardless of the rest of the url, or if it's used by different post-types or taxonomies? For example, is it possible to have both of these urls? ``` mysite.com/industry/biotech/report/ mysite.com/industry/retail/report/ ``` Thanks, todd
In [wp\_unique\_term\_slug()](http://queryposts.com/function/wp_unique_term_slug/): > > The $slug has to be unique global to every taxonomy, meaning that one taxonomy term can’t have a matching slug with another taxonomy term. Each slug has to be globally unique for every taxonomy. > > > In [wp\_unique\_post\_slu...
35,331
<p>I have a suitable page, archives.php, located in the theme's root directory, but I cannot get it to show up as a page template. Is there something else I need to do so that it is recognized?</p>
[ { "answer_id": 35332, "author": "krembo99", "author_id": 13256, "author_profile": "https://wordpress.stackexchange.com/users/13256", "pm_score": 3, "selected": true, "text": "<p>Archives.php is usually not a page template - it is a file used to display all the archived posts (usually som...
2011/12/02
[ "https://wordpress.stackexchange.com/questions/35331", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10783/" ]
I have a suitable page, archives.php, located in the theme's root directory, but I cannot get it to show up as a page template. Is there something else I need to do so that it is recognized?
Archives.php is usually not a page template - it is a file used to display all the archived posts (usually some sort of list ...) It is usually triggered by a function that deals with archived posts like ``` <?php wp_get_archives('type=monthly'); ?> ``` Anyhow - A page template file has to have this code in the b...
35,364
<p>We have an install of WordPress Network (Multisite) that has multiple blogs running under the url blogs.exampleurl.com where each subsite is blogs.exampleurl.com/site1 /site2 etc...</p> <p>We have a user that already has a URL (www.exampleurl.com/usersite/) and would like to keep his URL but also use our install of...
[ { "answer_id": 35379, "author": "ZweiBlumen", "author_id": 10617, "author_profile": "https://wordpress.stackexchange.com/users/10617", "pm_score": 1, "selected": false, "text": "<p>This is straightforward if I understand the question properly. Use the \"WordPress MU Domain Mapping\" plug...
2011/12/02
[ "https://wordpress.stackexchange.com/questions/35364", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6031/" ]
We have an install of WordPress Network (Multisite) that has multiple blogs running under the url blogs.exampleurl.com where each subsite is blogs.exampleurl.com/site1 /site2 etc... We have a user that already has a URL (www.exampleurl.com/usersite/) and would like to keep his URL but also use our install of WordPress...
This is straightforward if I understand the question properly. Use the "WordPress MU Domain Mapping" plugin: <http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/> **Update** I think something like the following should work in your .htaccess: ``` RewriteCond %{HTTP_HOST} www.exampleurl.com RewriteCond %...
35,365
<p>I've got this inside my functions.php file.</p> <pre><code> function add_product_category_automatically($post_ID) { global $wpdb; if(!has_term('','product_relation',$post_ID)){ $cat = get_the_title($post_ID); wp_set_object_terms($post_ID, $cat, 'product_relation'); } } add_action('publish_product', 'add_...
[ { "answer_id": 35367, "author": "cr0z3r", "author_id": 4513, "author_profile": "https://wordpress.stackexchange.com/users/4513", "pm_score": -1, "selected": false, "text": "<p>Instead of deleting the taxonomy, wouldn't you rather simply hide it from queries (if empty)?</p>\n\n<p>Whenever...
2011/12/02
[ "https://wordpress.stackexchange.com/questions/35365", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9218/" ]
I've got this inside my functions.php file. ``` function add_product_category_automatically($post_ID) { global $wpdb; if(!has_term('','product_relation',$post_ID)){ $cat = get_the_title($post_ID); wp_set_object_terms($post_ID, $cat, 'product_relation'); } } add_action('publish_product', 'add_product_catego...
There was some confusion in the original question with the terminology i used. I didn't find a way to do what i was after but it's to late for me to do it now.
35,368
<p>I have removed the edit profile page from WP admin as I don't want users to be able to edit their details as this is a closed intranet and their details are fed from AD.</p> <p>However I do want them to be able to publish their own user description (Biography). So I've set out to add a new admin page to give the us...
[ { "answer_id": 35375, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 3, "selected": true, "text": "<pre><code>update_user_meta($current_user-&gt;ID, 'description', $_POST['user_description']);\n</code></pre>\...
2011/12/02
[ "https://wordpress.stackexchange.com/questions/35368", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
I have removed the edit profile page from WP admin as I don't want users to be able to edit their details as this is a closed intranet and their details are fed from AD. However I do want them to be able to publish their own user description (Biography). So I've set out to add a new admin page to give the user the abi...
``` update_user_meta($current_user->ID, 'description', $_POST['user_description']); ``` in the form processing function will save the bio. I would keep the form action on the same admin page. As for data validation, I don't see what there is to validate in the first place. It's just a string - not an email, address ...
35,377
<p>I have 100 posts to the ( states meta_key ), and different meta_value (AK,AR,CA,FL,HW,MN,SC,TX,MN,NJ). I want to show the post count on my site sidebar for posts AK-11 posts,AR-9 posts....</p>
[ { "answer_id": 35392, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 3, "selected": false, "text": "<pre><code>// retrieve all meta_values with key 'state' from database\n$state_posts = $wpdb-&gt;get_results(...
2011/12/02
[ "https://wordpress.stackexchange.com/questions/35377", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10797/" ]
I have 100 posts to the ( states meta\_key ), and different meta\_value (AK,AR,CA,FL,HW,MN,SC,TX,MN,NJ). I want to show the post count on my site sidebar for posts AK-11 posts,AR-9 posts....
``` // retrieve all meta_values with key 'state' from database $state_posts = $wpdb->get_results(" SELECT meta_value FROM ". $wpdb->prefix."postmeta WHERE meta_key = 'state' ORDER BY meta_value ASC", ARRAY_A ); // define counting array $state_count = array(); // iterate through meta_values, count ...
35,410
<p>I've tried a few plugins to add mime types including the <a href="http://wordpress.org/extend/plugins/pjw-mime-config/" rel="nofollow noreferrer">PJW Mime Config</a> plugin. And adding this to a themes <code>functions.php</code> file would work fine, too, for a non-WPMS site. But I need these to be allowable through...
[ { "answer_id": 35412, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 2, "selected": false, "text": "<p>Obviously your plugin is producing an error!</p>\n\n<p>More specifically, those allowed mime types are ca...
2011/12/02
[ "https://wordpress.stackexchange.com/questions/35410", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5887/" ]
I've tried a few plugins to add mime types including the [PJW Mime Config](http://wordpress.org/extend/plugins/pjw-mime-config/) plugin. And adding this to a themes `functions.php` file would work fine, too, for a non-WPMS site. But I need these to be allowable throughout the network. So I've written my own plugin to...
Figured it out! :D Here's the new code: ``` // Add the filter add_filter('upload_mimes', 'tqps_extended_mime_types'); // Function to add mime types function tqps_extended_mime_types ( $mime_types=array() ) { // add your extension & app info to mime-types.txt in this format // doc,doct application/msword ...
35,411
<p>I'm creating a custom walker for my nav menu. The goal is to split the menu in to columns like so:</p> <p><img src="https://i.stack.imgur.com/Cr9xo.png" alt="enter image description here"></p> <p>I can easily determine where I am in the list by looking at <code>$item-&gt;menu_order</code>. What I don't know is h...
[ { "answer_id": 35413, "author": "Sagive", "author_id": 7990, "author_profile": "https://wordpress.stackexchange.com/users/7990", "pm_score": 0, "selected": false, "text": "<p>Dont you think (and sorry if i am rude) that its much simpler and easier<br>\nto just float:left; all the \"li\" ...
2011/12/02
[ "https://wordpress.stackexchange.com/questions/35411", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10328/" ]
I'm creating a custom walker for my nav menu. The goal is to split the menu in to columns like so: ![enter image description here](https://i.stack.imgur.com/Cr9xo.png) I can easily determine where I am in the list by looking at `$item->menu_order`. What I don't know is how many items are in the menu total. How can I...
Call [`wp_get_nav_menu_object`](https://developer.wordpress.org/reference/functions/wp_get_nav_menu_object/) to get a menu object. The count will be one of the object properties, reference like so: **Example:** ``` // Get menu object $my_menu = wp_get_nav_menu_object( 'your-menu-name-or-slug' ); // Echo count of ite...
35,416
<p>I want to reorder stuff in a custom post. I got the meta box and editor working together, but currently the editor is above the meta box<br> and I need it to be the other way around. </p> <p>This is the code for my meta box:</p> <pre><code>// adding the meta boxes add_action("admin_init", "tl_admin_init"); functio...
[ { "answer_id": 35419, "author": "krembo99", "author_id": 13256, "author_profile": "https://wordpress.stackexchange.com/users/13256", "pm_score": 1, "selected": false, "text": "<p>Have you tried to set <code>$priority</code> to <code>high</code> and change context?</p>\n\n<p>If this is no...
2011/12/03
[ "https://wordpress.stackexchange.com/questions/35416", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7990/" ]
I want to reorder stuff in a custom post. I got the meta box and editor working together, but currently the editor is above the meta box and I need it to be the other way around. This is the code for my meta box: ``` // adding the meta boxes add_action("admin_init", "tl_admin_init"); function tl_admin_init(){ a...
This will allow the post editor to be moved like the other sortable post boxes. ``` function move_posteditor( $hook ) { if ( $hook == 'post.php' OR $hook == 'post-new.php' ) { wp_enqueue_script( 'jquery' ); add_action('admin_print_footer_scripts', 'move_posteditor_scripts'); } } add_action( 'a...
35,432
<p>How can i get the <code>total</code> value from the following URL <code>http://tradephonein.com/checkout-swap/?total=$18.00&amp;broken=No&amp;water=%20No&amp;power=Yes,%20battery%20included&amp;lcd=No&amp;charger=&amp;manual=Owner%20Manual&amp;box=&amp;other=</code></p> <p>I have this kind of a string query, you'll...
[ { "answer_id": 35419, "author": "krembo99", "author_id": 13256, "author_profile": "https://wordpress.stackexchange.com/users/13256", "pm_score": 1, "selected": false, "text": "<p>Have you tried to set <code>$priority</code> to <code>high</code> and change context?</p>\n\n<p>If this is no...
2011/12/03
[ "https://wordpress.stackexchange.com/questions/35432", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9583/" ]
How can i get the `total` value from the following URL `http://tradephonein.com/checkout-swap/?total=$18.00&broken=No&water=%20No&power=Yes,%20battery%20included&lcd=No&charger=&manual=Owner%20Manual&box=&other=` I have this kind of a string query, you'll see that there is a `total=$18.00`, my question is, how can I g...
This will allow the post editor to be moved like the other sortable post boxes. ``` function move_posteditor( $hook ) { if ( $hook == 'post.php' OR $hook == 'post-new.php' ) { wp_enqueue_script( 'jquery' ); add_action('admin_print_footer_scripts', 'move_posteditor_scripts'); } } add_action( 'a...
35,471
<p>I am trying to pass a variable from a URL to PHP using mod_rewrite while maintaining standard WordPress functionality.</p> <p>Here's my mod_rewrite rules:</p> <pre><code>RewriteEngine On RewriteBase / RewriteRule ^(\w+)/$ /index.php?state=$1 [L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f Re...
[ { "answer_id": 35484, "author": "Olivier Pons", "author_id": 4347, "author_profile": "https://wordpress.stackexchange.com/users/4347", "pm_score": 1, "selected": false, "text": "<p>I suppose you've forgotten the QSA directive, to add properly the query string:</p>\n\n<pre><code>RewriteEn...
2011/12/04
[ "https://wordpress.stackexchange.com/questions/35471", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10784/" ]
I am trying to pass a variable from a URL to PHP using mod\_rewrite while maintaining standard WordPress functionality. Here's my mod\_rewrite rules: ``` RewriteEngine On RewriteBase / RewriteRule ^(\w+)/$ /index.php?state=$1 [L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST...
Ok, I ended up figuring this out. Like I thought, the problem had nothing to do with mod\_rewrite and everything to do with WordPress. To solve the issue, I had to use the following code: ``` if(isset($_GET['state'])) { $url = explode("/", $_SERVER['REQUEST_URI']); $url = end($url); $_SERVER['REQUEST_URI'] = "/" . $u...
35,473
<p>Using a pre_get_posts filter to search a given string on all meta_values:</p> <pre><code>$query-&gt;set('meta_value', 'first string'); </code></pre> <p>debug:</p> <pre><code>AND ( (CAST(wp_postmeta.meta_value AS CHAR) = 'first string') ) </code></pre> <p>Works Ok :) but how can I search on all meta_values for an...
[ { "answer_id": 35505, "author": "José Pablo Orozco Marín", "author_id": 2011, "author_profile": "https://wordpress.stackexchange.com/users/2011", "pm_score": 1, "selected": true, "text": "<p>Yes, I got it:</p>\n\n<pre><code>function custom_search_where( $where = '' ) {\n\n global $wpd...
2011/12/04
[ "https://wordpress.stackexchange.com/questions/35473", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2011/" ]
Using a pre\_get\_posts filter to search a given string on all meta\_values: ``` $query->set('meta_value', 'first string'); ``` debug: ``` AND ( (CAST(wp_postmeta.meta_value AS CHAR) = 'first string') ) ``` Works Ok :) but how can I search on all meta\_values for an array of strings? For example. I need somethin...
Yes, I got it: ``` function custom_search_where( $where = '' ) { global $wpdb; if ( is_search() ) { if ( isset($_GET['my-terms']) ) { $count = count($_GET['my-terms']); if ( $count > 0 ) { foreach ( $_GET['my-terms'] as $term ) { // htt...
35,509
<p>I've recently switched from linux to windows hosting on IIS7. I have permalinks working fine, but for some reason when I try to view the site index (index.php) I get an internal wordpress 404. I can only assume this has something to do with the migration but am baffled as to the cause. My web.config contains this:</...
[ { "answer_id": 35581, "author": "mgyura", "author_id": 10765, "author_profile": "https://wordpress.stackexchange.com/users/10765", "pm_score": 2, "selected": true, "text": "<p>If you're in need of Meta Boxes for WordPress, check out the amazing code in github by jaredatch. </p>\n\n<p><a ...
2011/12/04
[ "https://wordpress.stackexchange.com/questions/35509", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10839/" ]
I've recently switched from linux to windows hosting on IIS7. I have permalinks working fine, but for some reason when I try to view the site index (index.php) I get an internal wordpress 404. I can only assume this has something to do with the migration but am baffled as to the cause. My web.config contains this: ```...
If you're in need of Meta Boxes for WordPress, check out the amazing code in github by jaredatch. <https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress> This allows you to add all sorts of metaboxes to your WP theme (or plugin). Date Picker, file upload, wysiwyg, text areas, text boxes...it's reall...
35,521
<p>In my functions I'm registering multiple metaboxes with custom fields. A single metabox array for instance, looks like this:</p> <p>In functions.php</p> <pre><code>$meta_boxes[] = array( 'id' =&gt; 'general_info', 'title' =&gt; 'General Information', 'pages' =&gt; array('post', 'page', 'link'), // mult...
[ { "answer_id": 35581, "author": "mgyura", "author_id": 10765, "author_profile": "https://wordpress.stackexchange.com/users/10765", "pm_score": 2, "selected": true, "text": "<p>If you're in need of Meta Boxes for WordPress, check out the amazing code in github by jaredatch. </p>\n\n<p><a ...
2011/12/04
[ "https://wordpress.stackexchange.com/questions/35521", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1613/" ]
In my functions I'm registering multiple metaboxes with custom fields. A single metabox array for instance, looks like this: In functions.php ``` $meta_boxes[] = array( 'id' => 'general_info', 'title' => 'General Information', 'pages' => array('post', 'page', 'link'), // multiple post types, accept custom...
If you're in need of Meta Boxes for WordPress, check out the amazing code in github by jaredatch. <https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress> This allows you to add all sorts of metaboxes to your WP theme (or plugin). Date Picker, file upload, wysiwyg, text areas, text boxes...it's reall...
35,552
<p>I want to style a current state with CSS to indicate the page currently being viewed, but <a href="http://wordpress.org/extend/plugins/list-category-posts/" rel="nofollow noreferrer">List category posts</a> doesn't generate a class hook. All it would need is something similar to the <a href="https://wordpress.stacke...
[ { "answer_id": 35641, "author": "Michelle", "author_id": 16, "author_profile": "https://wordpress.stackexchange.com/users/16", "pm_score": 0, "selected": false, "text": "<p>I'm not clear on exactly what you're trying to style, but if you can edit your theme, you can add classes to the bo...
2011/12/05
[ "https://wordpress.stackexchange.com/questions/35552", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10858/" ]
I want to style a current state with CSS to indicate the page currently being viewed, but [List category posts](http://wordpress.org/extend/plugins/list-category-posts/) doesn't generate a class hook. All it would need is something similar to the [solution posted here](https://wordpress.stackexchange.com/questions/2684...
Fernando, the plugin's developer, has graciously added the feature to a new version of the plugin. I'm impressed and very grateful.
35,557
<p>I'm having a hard time figuring this one out.</p> <p>I'm running a simple users query :</p> <pre><code>$args = array( 'role' =&gt; 'custom_role', 'orderby' =&gt; 'ID', 'order' =&gt; 'DESC', 'number' =&gt; 3 ); $users = get_users( $args ); </code></pre> <p>And the resulting array has duplicate entr...
[ { "answer_id": 62021, "author": "Eric Holmes", "author_id": 23454, "author_profile": "https://wordpress.stackexchange.com/users/23454", "pm_score": 2, "selected": true, "text": "<p>Seems like a silly question, but are there exactly 2 users in the database? Or are there more.</p>\n\n<p>Th...
2011/12/05
[ "https://wordpress.stackexchange.com/questions/35557", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1381/" ]
I'm having a hard time figuring this one out. I'm running a simple users query : ``` $args = array( 'role' => 'custom_role', 'orderby' => 'ID', 'order' => 'DESC', 'number' => 3 ); $users = get_users( $args ); ``` And the resulting array has duplicate entries : ``` Array ( [0] => stdClass Object...
Seems like a silly question, but are there exactly 2 users in the database? Or are there more. The only thing I can see happening is because you are setting to 3, it's looping back through. Another thing to try is checking the peterpanpan user, to see if he has the custom\_role twice in his user\_meta.
35,564
<p>I have a defined set of seven different post types and would like to display an icon for each one in the search results list.</p> <p>I've got the following code to display the post type but have no idea how to extend it into an if </p> <pre><code>&lt;?php $post_type = get_post_type_object( get_post_type($post) ); ...
[ { "answer_id": 62021, "author": "Eric Holmes", "author_id": 23454, "author_profile": "https://wordpress.stackexchange.com/users/23454", "pm_score": 2, "selected": true, "text": "<p>Seems like a silly question, but are there exactly 2 users in the database? Or are there more.</p>\n\n<p>Th...
2011/12/05
[ "https://wordpress.stackexchange.com/questions/35564", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3782/" ]
I have a defined set of seven different post types and would like to display an icon for each one in the search results list. I've got the following code to display the post type but have no idea how to extend it into an if ``` <?php $post_type = get_post_type_object( get_post_type($post) ); echo $post_type->label ;...
Seems like a silly question, but are there exactly 2 users in the database? Or are there more. The only thing I can see happening is because you are setting to 3, it's looping back through. Another thing to try is checking the peterpanpan user, to see if he has the custom\_role twice in his user\_meta.
35,580
<p>I'm trying to make a registration form with a registration process like the following. Can it be done?</p> <p>These are the fields for the registration form.</p> <pre><code>Username Email Address First Name Last Name Contact Tel No Company Name Address (room for 3 lines of text) Postcode Industry (drop down list) ...
[ { "answer_id": 62021, "author": "Eric Holmes", "author_id": 23454, "author_profile": "https://wordpress.stackexchange.com/users/23454", "pm_score": 2, "selected": true, "text": "<p>Seems like a silly question, but are there exactly 2 users in the database? Or are there more.</p>\n\n<p>Th...
2011/12/05
[ "https://wordpress.stackexchange.com/questions/35580", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9218/" ]
I'm trying to make a registration form with a registration process like the following. Can it be done? These are the fields for the registration form. ``` Username Email Address First Name Last Name Contact Tel No Company Name Address (room for 3 lines of text) Postcode Industry (drop down list) Product Interests (ti...
Seems like a silly question, but are there exactly 2 users in the database? Or are there more. The only thing I can see happening is because you are setting to 3, it's looping back through. Another thing to try is checking the peterpanpan user, to see if he has the custom\_role twice in his user\_meta.
35,588
<p>is there a way to bind some extra script to the WPSetAsThumbnail function? the function automatically inserts the image into the post's metabox, but what if i wanted to do something else with it? could i make it alert('bacon') after the thumbnail is set via ajax?</p> <p>i'm trying to get a way to set the thumbnai...
[ { "answer_id": 36597, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 2, "selected": false, "text": "<p>Yes, on your 2nd question :)</p>\n\n<p>From what I saw in <a href=\"http://core.trac.wordpress.org/browser/...
2011/12/05
[ "https://wordpress.stackexchange.com/questions/35588", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6477/" ]
is there a way to bind some extra script to the WPSetAsThumbnail function? the function automatically inserts the image into the post's metabox, but what if i wanted to do something else with it? could i make it alert('bacon') after the thumbnail is set via ajax? i'm trying to get a way to set the thumbnails from the ...
In the end I found that I could not bind or trigger this action. I had to duplicate it as follows with the javascript and then an ajax callback. **Javascript:** ``` function PrismSetAsThumbnail(id, nonce){ var $link = jQuery('a#wp-post-thumbnail-' + id); $link.text( setPostThumbnailL10n.saving ); jQuer...
35,593
<p>I cannot figure this out. There seems to be no checkbox or anything similar in function to add the newly created custom post type archive page into the menu.</p> <p>Also the link must be active, if you are on the page. This probably isn't possible, but is there some plugin for it? For the love of me, I cannot find ...
[ { "answer_id": 35597, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": true, "text": "<p>This is one method that I think should work (though it's not tested).</p>\n\n<pre><code>//Hook on to the f...
2011/12/05
[ "https://wordpress.stackexchange.com/questions/35593", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7712/" ]
I cannot figure this out. There seems to be no checkbox or anything similar in function to add the newly created custom post type archive page into the menu. Also the link must be active, if you are on the page. This probably isn't possible, but is there some plugin for it? For the love of me, I cannot find it :( I o...
This is one method that I think should work (though it's not tested). ``` //Hook on to the filter for the (custom) main menu // 'wp_list_pages' filter is a fallback, when a custom menu isn't being used add_filter( 'wp_list_pages', 'new_nav_menu_items' ); add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' ); //Can ...
35,614
<p>When Twenty Eleven theme is activated, it inserts several default widgets into its sidebars. How can I code my theme to do the same?</p>
[ { "answer_id": 35615, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 1, "selected": false, "text": "<p>The (pseudo-)widgets titled \"Archives\" and \"Meta\" are hardcoded into TwentyEleven's <em>sidebar.php</...
2011/12/05
[ "https://wordpress.stackexchange.com/questions/35614", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6620/" ]
When Twenty Eleven theme is activated, it inserts several default widgets into its sidebars. How can I code my theme to do the same?
Johannes Pille is right TwentyEleven's widgets such as Archives and Meta are hardcoded into their sidebar.php Here is what I would do: First define your sidebars in your functions.php like so: ``` if ( function_exists('register_sidebars') ) register_sidebar(array( 'name'=>'Left Sidebar', 'before_title' ...
35,622
<p>The goal is to offer a button/select drop-down or similar to switch the <em>public interface<sup>1)</sup></em> language on the fly.</p> <p>What I'm searching for</p> <ul> <li>Plugin <em>or</em> Theme Code...</li> <li>... <em>or</em> Ideas</li> <li>Using a work-around with <code>load_textdomain()</code> would be ap...
[ { "answer_id": 35627, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 3, "selected": false, "text": "<p>If you can settle for a page refresh, redefining the <code>WPLANG</code> constant could be an option. I'm...
2011/12/05
[ "https://wordpress.stackexchange.com/questions/35622", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/385/" ]
The goal is to offer a button/select drop-down or similar to switch the *public interface1)* language on the fly. What I'm searching for * Plugin *or* Theme Code... * ... *or* Ideas * Using a work-around with `load_textdomain()` would be appreciated to leave translation to .po/.mo files * Ideas on how to parse the st...
By far the best (easiest) way is to use the locale filter (inside [`get_locale()`](http://queryposts.com/function/get_locale/)). First set up a quick function for retrieving a different language to use on the `locale` filter. ``` /** * A function returns with returns the user's selectd locale, if stored. */ funct...
35,629
<p>Is there a way to use the wordpress theme / plugin editor inside my plugin to give the user the ability to edit the css file of my plugin ?</p> <p>Im building a plugin that gives the user an option to add some CSS. First i was going to use just a textarea but then i thought it would be pretty could if i can use the...
[ { "answer_id": 35839, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 1, "selected": true, "text": "<p>To start with you could use the following code. For security you could also add some nonce check and ev...
2011/12/05
[ "https://wordpress.stackexchange.com/questions/35629", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4130/" ]
Is there a way to use the wordpress theme / plugin editor inside my plugin to give the user the ability to edit the css file of my plugin ? Im building a plugin that gives the user an option to add some CSS. First i was going to use just a textarea but then i thought it would be pretty could if i can use the Wordpress...
To start with you could use the following code. For security you could also add some nonce check and even use the settings api. Here `plugin-test` is your plugin folder name. ``` $file = stripslashes('plugin-test/style.css'); $plugin_files = get_plugin_files($file); $file = validate_file_to_edit($file, $plugin_files);...
35,645
<p><em>I have very little experience with WordPress and PHP, so I apologize in advance for syntax problems.</em></p> <p>I'd like to know if it's possible to implement If/Else logic as short codes. Something like:</p> <pre><code>[if] Version: IF [elseif] Version: ELSEIF [else] Version: ELSE [/if] // OR... [if] Versio...
[ { "answer_id": 35672, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 1, "selected": false, "text": "<p>Not easily, and anyway it would be painful and an incoherent mess.</p>\n\n<p>Instead, I recommend writing your own ...
2011/12/05
[ "https://wordpress.stackexchange.com/questions/35645", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1139/" ]
*I have very little experience with WordPress and PHP, so I apologize in advance for syntax problems.* I'd like to know if it's possible to implement If/Else logic as short codes. Something like: ``` [if] Version: IF [elseif] Version: ELSEIF [else] Version: ELSE [/if] // OR... [if] Version: IF [if branch="elseif"] Ve...
Having a look at your SO post, seeing the CF Tag output, then seeing what you're trying to attempt here with shortcodes is, as Otto said, going to be an incoherent mess. There already exists plugins that allow you to write PHP logic amongst your post content, and the following [Allow PHP in Posts and Pages](http://wor...
35,675
<p>How i can add "Post Options" section under wysiwyg editor? <a href="http://themeblvd.com/demo/assets/framework/shortcode_generator.png" rel="nofollow"><strong>Like this</strong></a></p>
[ { "answer_id": 35672, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 1, "selected": false, "text": "<p>Not easily, and anyway it would be painful and an incoherent mess.</p>\n\n<p>Instead, I recommend writing your own ...
2011/12/06
[ "https://wordpress.stackexchange.com/questions/35675", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5716/" ]
How i can add "Post Options" section under wysiwyg editor? [**Like this**](http://themeblvd.com/demo/assets/framework/shortcode_generator.png)
Having a look at your SO post, seeing the CF Tag output, then seeing what you're trying to attempt here with shortcodes is, as Otto said, going to be an incoherent mess. There already exists plugins that allow you to write PHP logic amongst your post content, and the following [Allow PHP in Posts and Pages](http://wor...
35,677
<p>I would like to query for images attached to ALL posts of certain custom post type (e.g. 'gallery').</p> <p>I can't see a way to do this by using only WP_Query. The workaround would be to query for all posts of a custom post type, then get the attachments and stuff everything together. But i don't think that this w...
[ { "answer_id": 35679, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 1, "selected": false, "text": "<p>Try this code and replace <code>custom-post</code> with your custom post type.</p>\n\n<pre><code>$quer...
2011/12/06
[ "https://wordpress.stackexchange.com/questions/35677", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9374/" ]
I would like to query for images attached to ALL posts of certain custom post type (e.g. 'gallery'). I can't see a way to do this by using only WP\_Query. The workaround would be to query for all posts of a custom post type, then get the attachments and stuff everything together. But i don't think that this would be a...
Try this code and replace `custom-post` with your custom post type. ``` $query = new WP_Query( array( 'post_type' => 'custom-post', 'posts_per_page' => -1 ) ); if( $query->have_posts() ){ while($query->have_posts()){ $query->the_post(); $image_query = new WP_Query( array( 'post_type' => 'attachment...
35,680
<p>trying to make a custom column sortable in the media library. Found lots of examples for posts, and users but can't get them to work on the media library page.</p> <pre><code>function wpse_hook_isv_columns() { add_action('manage_media_custom_column', 'isv_custom_media_column_content',10,2); add_filter('mana...
[ { "answer_id": 35693, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<p>First: If you're adding stuff to hooks or filters, you should allways wrap the action calls in a separate function ...
2011/12/06
[ "https://wordpress.stackexchange.com/questions/35680", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3978/" ]
trying to make a custom column sortable in the media library. Found lots of examples for posts, and users but can't get them to work on the media library page. ``` function wpse_hook_isv_columns() { add_action('manage_media_custom_column', 'isv_custom_media_column_content',10,2); add_filter('manage_media_colum...
You cannot do a sort on the attachment meta data specifically because it's stored in a serialized string. Whilst `WP_Query` can sort on meta values it can't sort on data that's serialized. For example `wp_get_attachment_metadata` fetches and unserializes that for you inside the column callback, but MySQL queries can't...
35,690
<p>I'm developing a plugin which uses wordpress's thickbox media library to handle media upload and selection. All is well but for the fact that I would like to automatically 'redirect' to the 'media library'-tab after I uploaded/ wordpress finished crunching the file. </p> <p>So basically i'm looking for a hook that'...
[ { "answer_id": 61859, "author": "Jonathan DS", "author_id": 14319, "author_profile": "https://wordpress.stackexchange.com/users/14319", "pm_score": 2, "selected": false, "text": "<p>it's a longshot but,</p>\n<p><code>add_attachment</code> hook actually fires after the first file finished...
2011/12/06
[ "https://wordpress.stackexchange.com/questions/35690", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10894/" ]
I'm developing a plugin which uses wordpress's thickbox media library to handle media upload and selection. All is well but for the fact that I would like to automatically 'redirect' to the 'media library'-tab after I uploaded/ wordpress finished crunching the file. So basically i'm looking for a hook that's fired af...
it's a longshot but, `add_attachment` hook actually fires after the first file finished uploading: ``` add_action('add_attachment','redirect_uploader_flow'); ``` I'm using it to load a custom interface for resizing an Image loading in the current TB window: ``` jQuery("#TB_iframeContent",window.parent.document).at...
35,712
<p>So I see everyone's arguements against using this, but that seems like a huge flaw in Wordpress because a domain name as close to the root is crucial to a site's SEO. </p> <p>I want my site which has rough 8 pages total to be able to be found by their simple titles, if they're preprended by a date, it just look con...
[ { "answer_id": 36855, "author": "Harish Sharma", "author_id": 11266, "author_profile": "https://wordpress.stackexchange.com/users/11266", "pm_score": 1, "selected": false, "text": "<p>What I did was reinstalled WordPress from the Dashboard Update area...then I made the Permalinks like th...
2011/12/06
[ "https://wordpress.stackexchange.com/questions/35712", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8798/" ]
So I see everyone's arguements against using this, but that seems like a huge flaw in Wordpress because a domain name as close to the root is crucial to a site's SEO. I want my site which has rough 8 pages total to be able to be found by their simple titles, if they're preprended by a date, it just look convoluted an...
What I did was reinstalled WordPress from the Dashboard Update area...then I made the Permalinks like this /index.php/%postname%/ It worked fine
35,724
<p>I'm trying to create a simple function to do a "status test". Goal is to test and see if the current page being viewed has any child pages or not. Using this to alter layout to accomodate child pages. The following code seems like it should work, but alas, no dice.</p> <p>Anyone see what I'm missing?</p> <pre><...
[ { "answer_id": 35725, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 5, "selected": true, "text": "<p>Your above function tests whether a page <em>is</em> a child page of some other page, not whether it has c...
2011/12/07
[ "https://wordpress.stackexchange.com/questions/35724", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2527/" ]
I'm trying to create a simple function to do a "status test". Goal is to test and see if the current page being viewed has any child pages or not. Using this to alter layout to accomodate child pages. The following code seems like it should work, but alas, no dice. Anyone see what I'm missing? ``` function is_subpage...
Your above function tests whether a page *is* a child page of some other page, not whether it has children. You can test for children of the current page like so: ``` function has_children() { global $post; $children = get_pages( array( 'child_of' => $post->ID ) ); if( count( $children ) == 0 ) { ...
35,735
<p>I am looking for a way to create a Photo Post type. Basically a post that is a title and a single image. Where I am getting stuck is the actual attaching an image to a post. I would like to have an image upload field in a metabox. I followed this <a href="http://austinpassy.com/2010/03/creating-custom-metaboxes-and-...
[ { "answer_id": 35725, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 5, "selected": true, "text": "<p>Your above function tests whether a page <em>is</em> a child page of some other page, not whether it has c...
2011/12/07
[ "https://wordpress.stackexchange.com/questions/35735", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10909/" ]
I am looking for a way to create a Photo Post type. Basically a post that is a title and a single image. Where I am getting stuck is the actual attaching an image to a post. I would like to have an image upload field in a metabox. I followed this [guide](http://austinpassy.com/2010/03/creating-custom-metaboxes-and-the-...
Your above function tests whether a page *is* a child page of some other page, not whether it has children. You can test for children of the current page like so: ``` function has_children() { global $post; $children = get_pages( array( 'child_of' => $post->ID ) ); if( count( $children ) == 0 ) { ...
35,746
<p>I am trying to implement fancybox into WP without using a plugin. I did some research and went over few examples but there is still an issue. Any help would be greatly appreciated. Here's the code:</p> <p>in functions.php:</p> <pre><code>function loadFancyBox() { if (is_single() &amp;&amp; strpos($post-&gt;post_co...
[ { "answer_id": 35748, "author": "helenhousandi", "author_id": 2226, "author_profile": "https://wordpress.stackexchange.com/users/2226", "pm_score": 1, "selected": false, "text": "<p>If you check your console for errors as @patnz suggested, you'll likely see that $ is undefined. This is b...
2011/12/07
[ "https://wordpress.stackexchange.com/questions/35746", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10910/" ]
I am trying to implement fancybox into WP without using a plugin. I did some research and went over few examples but there is still an issue. Any help would be greatly appreciated. Here's the code: in functions.php: ``` function loadFancyBox() { if (is_single() && strpos($post->post_content,'class="fancy"') !== false...
If you check your console for errors as @patnz suggested, you'll likely see that $ is undefined. This is because WordPress loads jQuery in noConflict mode. Try this instead: ``` <script> jQuery(document).ready(function($) { $("a.fancy").fancybox({ 'transitionIn' : 'elastic' }); }); </script> ```
35,773
<p>I have full names as title posts and want to order it by the surname.</p> <p>How could i do this with wordpress?</p> <p>in PHP it would be along the lines of - </p> <pre><code> SELECT * from posts ORDER BY SUBSTR(LTRIM(post_title), LOCATE(' ',LTRIM(post_title))) </code></pre> <p>current code getting people categ...
[ { "answer_id": 35779, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 2, "selected": false, "text": "<p>Your first example is an SQL query, there is no native WordPress function that does this.</p>\n\n<p>So that leaves ...
2011/12/07
[ "https://wordpress.stackexchange.com/questions/35773", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3978/" ]
I have full names as title posts and want to order it by the surname. How could i do this with wordpress? in PHP it would be along the lines of - ``` SELECT * from posts ORDER BY SUBSTR(LTRIM(post_title), LOCATE(' ',LTRIM(post_title))) ``` current code getting people category is; ``` $args = array( 'posts_p...
There is a filter, 'posts\_orderby', which allows you to specify your own ORDER BY clauses. In your case, the code would look something like this: ``` add_filter( 'posts_orderby', 'order_by_surname' ); function order_by_surname( $orderby, $query ) { // first you should check to make sure sure you're only filteri...
35,775
<p>I would like to get the ID (or permalink) of the page the visitor visited just before visiting the current page - in other words the ID of the last page in the browser history.</p> <p>Can this be done? Any idea how to do it?</p>
[ { "answer_id": 35791, "author": "cr0z3r", "author_id": 4513, "author_profile": "https://wordpress.stackexchange.com/users/4513", "pm_score": 4, "selected": true, "text": "<p>Break this down into two parts:</p>\n\n<p>First, we create a variable that stores that last-visited page URL, like...
2011/12/07
[ "https://wordpress.stackexchange.com/questions/35775", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9134/" ]
I would like to get the ID (or permalink) of the page the visitor visited just before visiting the current page - in other words the ID of the last page in the browser history. Can this be done? Any idea how to do it?
Break this down into two parts: First, we create a variable that stores that last-visited page URL, like this: ``` $prev_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; ``` Then, you could either use [substr](http://php.net/manual/en/function.substr.php) and [strpos](http://php.net/manual/en/...
35,812
<p>I would am using the code below so that on my wordpress site if <code>?logout</code> is appended to the end of the URL the user will be logged out. This works well - if the user visits a page such as <code>mysite.com/?logout</code> or <code>mysite.com/test-page/?logout</code> or any page where the <code>$_GET['logou...
[ { "answer_id": 35813, "author": "Joseph Leedy", "author_id": 8554, "author_profile": "https://wordpress.stackexchange.com/users/8554", "pm_score": 0, "selected": false, "text": "<p>Trying using either the <code>wp</code> or <code>init</code> hook instead.</p>\n" }, { "answer_id":...
2011/12/07
[ "https://wordpress.stackexchange.com/questions/35812", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4400/" ]
I would am using the code below so that on my wordpress site if `?logout` is appended to the end of the URL the user will be logged out. This works well - if the user visits a page such as `mysite.com/?logout` or `mysite.com/test-page/?logout` or any page where the `$_GET['logout']` variable is set s/he will be logged ...
This should do it: ``` add_action('plugins_loaded', function(){ wp_set_current_user(0); },0); ```
35,817
<p>Is there a way to completely remove (unset) the left hand side admin menu? I examined the ozh-admin-drop-down-menu plugin, since it removes the entire admin menu and adds a top menu bar in order to get a clue.. I made a few snippets, but probably I am missing sth.. I couldn't manage to find a way out..</p>
[ { "answer_id": 35831, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 0, "selected": false, "text": "<p>I don't think you can remove it globally, maybe with traversing the global <code>$menu</code> array.</p>\n\n<p>But ...
2011/12/07
[ "https://wordpress.stackexchange.com/questions/35817", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8709/" ]
Is there a way to completely remove (unset) the left hand side admin menu? I examined the ozh-admin-drop-down-menu plugin, since it removes the entire admin menu and adds a top menu bar in order to get a clue.. I made a few snippets, but probably I am missing sth.. I couldn't manage to find a way out..
Just to explain the solution better: I made below additions to theme's function.php in order to remove visually (hide) left hand admin menu: ``` add_action('admin_init', 'add_custom_admin_style'); function add_custom_admin_style(){ wp_register_style('custom_admin_style', content_url('themes').'/custom_admin.css...
35,818
<p>I'm having a difficult time writing out the PHP for this magazine layout I'm making.</p> <p>Here's the prototype: <a href="http://socalnpo.org" rel="nofollow">http://socalnpo.org</a></p> <p>Here's what I currently have: <a href="http://socalnpo.org/wp" rel="nofollow">http://socalnpo.org/wp</a></p> <p>The first 3 ...
[ { "answer_id": 35825, "author": "Nick", "author_id": 10943, "author_profile": "https://wordpress.stackexchange.com/users/10943", "pm_score": 0, "selected": false, "text": "<p>It looks to me like the best way to do this is to use two separate loops. You can use the default loop for the fi...
2011/12/07
[ "https://wordpress.stackexchange.com/questions/35818", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10942/" ]
I'm having a difficult time writing out the PHP for this magazine layout I'm making. Here's the prototype: <http://socalnpo.org> Here's what I currently have: <http://socalnpo.org/wp> The first 3 are the most recent (left to right) and the next 6 are the older ones. They all go in reverse chronological order. I'm n...
There is no reason to need 2 loops or to alter the query in any way if your are just showing the 9 most recent posts. You can use a loop counter to create the extra divs you need. ``` <div id="featured"> <?php $count = 0; if (have_posts()) : while (have_posts()) : the_post(); $count++; if ( $count < 4 ) { //d...
35,821
<p>I recently migrated a WordPress install from a subdirectory to the root. After the migration everything worked great, except that I can no longer set a featured thumbnail or add a picture in the WYSIWYG. On a possibly related note, I can only set post tags from the Quick Edit screen and not the post edit screen.</p>...
[ { "answer_id": 35825, "author": "Nick", "author_id": 10943, "author_profile": "https://wordpress.stackexchange.com/users/10943", "pm_score": 0, "selected": false, "text": "<p>It looks to me like the best way to do this is to use two separate loops. You can use the default loop for the fi...
2011/12/07
[ "https://wordpress.stackexchange.com/questions/35821", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10943/" ]
I recently migrated a WordPress install from a subdirectory to the root. After the migration everything worked great, except that I can no longer set a featured thumbnail or add a picture in the WYSIWYG. On a possibly related note, I can only set post tags from the Quick Edit screen and not the post edit screen. When ...
There is no reason to need 2 loops or to alter the query in any way if your are just showing the 9 most recent posts. You can use a loop counter to create the extra divs you need. ``` <div id="featured"> <?php $count = 0; if (have_posts()) : while (have_posts()) : the_post(); $count++; if ( $count < 4 ) { //d...
35,826
<p>I have a website in local development at test:8888 and I am trying to get the following to work in my functions.php file.</p> <pre><code>$response = wp_remote_get( 'test:8888/?p=1' ); print_r($response); </code></pre> <p>Unfortunately this is printing </p> <pre><code>WP_Error Object ( [errors] =&gt; Array ( [http...
[ { "answer_id": 35827, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 1, "selected": false, "text": "<p>'test:8888/?p=1' isn't a valid URL.</p>\n\n<p>Try '<a href=\"http://test:8888/?p=1\" rel=\"nofollow\">http://test:8...
2011/12/07
[ "https://wordpress.stackexchange.com/questions/35826", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6811/" ]
I have a website in local development at test:8888 and I am trying to get the following to work in my functions.php file. ``` $response = wp_remote_get( 'test:8888/?p=1' ); print_r($response); ``` Unfortunately this is printing ``` WP_Error Object ( [errors] => Array ( [http_request_failed] => Array ( [0] => A val...
Ad Timeout ---------- You should be able to get around the timeout using a filter ``` add_filter( 'http_request_timeout', 'wpse35826_timeout_extd' ); function wpse35826_timeout_extd( $time ) { // Default timeout is 5 return 10; } ``` Choose the right protocol/scheme -------------------------------- About y...
35,833
<p>No matter what I do - I can't get the hard cropping mode in the_post_thumbnail to work.</p> <p>Here's what I have:</p> <pre><code>add_image_size( 'Blog', 300, 300, true ); the_post_thumbnail('Blog'); </code></pre> <p>I've also tried:</p> <pre><code>set_post_thumbnail_size( 300, 300, true ); the_post_thumbnail()...
[ { "answer_id": 37578, "author": "Adam", "author_id": 11550, "author_profile": "https://wordpress.stackexchange.com/users/11550", "pm_score": 2, "selected": false, "text": "<p>Instead of defining the post thumbnail size as blog why not just set the post thumbnail explicitly in the templat...
2011/12/08
[ "https://wordpress.stackexchange.com/questions/35833", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10946/" ]
No matter what I do - I can't get the hard cropping mode in the\_post\_thumbnail to work. Here's what I have: ``` add_image_size( 'Blog', 300, 300, true ); the_post_thumbnail('Blog'); ``` I've also tried: ``` set_post_thumbnail_size( 300, 300, true ); the_post_thumbnail(); ``` I've tried uploading new images, a...
I've actually finally fixed this issue. It seems that the hard-cropping works if you set the image size inside a function that is hooked into the "after\_setup\_theme" hook. So, the below would work: ``` function add_custom_sizes() { add_image_size( 'portfolio-thumb', 243, 163, true ); add_image_size( 'portf...
35,864
<p>I have a site using <a href="http://plugins.elliotcondon.com/advanced-custom-fields/" rel="noreferrer">Advanced Custom Fields</a> to create and store various bits of relevant info. These need to be included in the main general search, which by default only searches the title and main content.</p> <p>I've found plen...
[ { "answer_id": 35935, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 3, "selected": true, "text": "<p>If your up for using a plugin, <a href=\"http://wordpress.org/extend/plugins/relevanssi/\" rel=\"nofollow\">R...
2011/12/08
[ "https://wordpress.stackexchange.com/questions/35864", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5581/" ]
I have a site using [Advanced Custom Fields](http://plugins.elliotcondon.com/advanced-custom-fields/) to create and store various bits of relevant info. These need to be included in the main general search, which by default only searches the title and main content. I've found plenty of info about getting search result...
If your up for using a plugin, [Relevanssi - A Better Search](http://wordpress.org/extend/plugins/relevanssi/) might be worth trying out. The standard (free) version supports searching post meta.
35,865
<p>As we know we can usually make changes to "the content" by calling the_content(). is there any equivalent function available for comments? or any such way do you know?</p>
[ { "answer_id": 35884, "author": "Tara", "author_id": 5021, "author_profile": "https://wordpress.stackexchange.com/users/5021", "pm_score": -1, "selected": false, "text": "<p>This <a href=\"http://codex.wordpress.org/Function_Reference#Comment.2C_Ping.2C_and_Trackback_Functions\" rel=\"no...
2011/12/08
[ "https://wordpress.stackexchange.com/questions/35865", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10398/" ]
As we know we can usually make changes to "the content" by calling the\_content(). is there any equivalent function available for comments? or any such way do you know?
I do hope I understand what you're asking, as you're not giving much information. From what I specifically to customize the output of your comments. Well, there partially is. The [wp\_list\_comments](http://codex.wordpress.org/Function_Reference/wp_list_comments) accepts a *callback* argument among several others. Thi...
35,875
<p>I am developing a site on MAMP and everything is going fine except that I thought I would check how all the default archive pages look. I typed 2011 at the end of the base url and it retrieved a yearly archive as expected.</p> <p>The problem is that the font sizes of every element change to a smaller size. I unde...
[ { "answer_id": 35884, "author": "Tara", "author_id": 5021, "author_profile": "https://wordpress.stackexchange.com/users/5021", "pm_score": -1, "selected": false, "text": "<p>This <a href=\"http://codex.wordpress.org/Function_Reference#Comment.2C_Ping.2C_and_Trackback_Functions\" rel=\"no...
2011/12/08
[ "https://wordpress.stackexchange.com/questions/35875", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10209/" ]
I am developing a site on MAMP and everything is going fine except that I thought I would check how all the default archive pages look. I typed 2011 at the end of the base url and it retrieved a yearly archive as expected. The problem is that the font sizes of every element change to a smaller size. I understand that ...
I do hope I understand what you're asking, as you're not giving much information. From what I specifically to customize the output of your comments. Well, there partially is. The [wp\_list\_comments](http://codex.wordpress.org/Function_Reference/wp_list_comments) accepts a *callback* argument among several others. Thi...
35,892
<p>I'm wondering if it is possible to use different image sizes (medium, large) for the content on the homepage and single post pages. I have a narrow column on the homepage than on the single post pages and different image sizes would be nice.</p> <p>Thanks.</p>
[ { "answer_id": 35896, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 0, "selected": false, "text": "<p>If you are using featured images you could use the following inside your loop.</p>\n\n<pre><code>if( h...
2011/12/08
[ "https://wordpress.stackexchange.com/questions/35892", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10964/" ]
I'm wondering if it is possible to use different image sizes (medium, large) for the content on the homepage and single post pages. I have a narrow column on the homepage than on the single post pages and different image sizes would be nice. Thanks.
If your talking about the images that are written into $post->post\_content (the\_content()) you'll either need to write a filter that strips out all images and replaces them with the smaller version. Or you could just use CSS. For CSS make sure you have body\_class() in your body tag then you can localise a maxwidth t...
35,898
<p>Anyone know of a nice way to disable that pop-up dialogue when exiting the post-editor? It says "This page is asking you to confirm that you want to leave - data you have entered may not be saved."</p> <p>Nice feature, but annoying in certain blogs where I have to edit a ton of posts</p>
[ { "answer_id": 35913, "author": "Naoise Golden", "author_id": 5048, "author_profile": "https://wordpress.stackexchange.com/users/5048", "pm_score": 1, "selected": false, "text": "<p>You can use the method described <a href=\"https://stackoverflow.com/questions/5705671/how-to-disable-tiny...
2011/12/08
[ "https://wordpress.stackexchange.com/questions/35898", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9355/" ]
Anyone know of a nice way to disable that pop-up dialogue when exiting the post-editor? It says "This page is asking you to confirm that you want to leave - data you have entered may not be saved." Nice feature, but annoying in certain blogs where I have to edit a ton of posts
You can use the method described [here](https://stackoverflow.com/questions/5705671/how-to-disable-tinymce-confirm-dialog). Add the following to your `functions.php` ``` <?php function wpse35898_admin_head() { ?> <script type="text/javascript"> window.onbeforeunload = function() {}; </script> ...
35,921
<p>I created a custom "events" post type for a client that basically "hides" the post once it has expired (ie. the event already happened). The events are displayed in the order of the start date rather than the order that they are posted in. This is, ultimately, all working fine. However, now that we're closing in on ...
[ { "answer_id": 35905, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>I guess the best would be to simply merge synonyms. You can use <a href=\"http://wordpress.org/extend/plugins/merge...
2011/12/08
[ "https://wordpress.stackexchange.com/questions/35921", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32496/" ]
I created a custom "events" post type for a client that basically "hides" the post once it has expired (ie. the event already happened). The events are displayed in the order of the start date rather than the order that they are posted in. This is, ultimately, all working fine. However, now that we're closing in on the...
Have *not* tested tested yet, but I see in the Codex page for [wp\_insert\_term](http://codex.wordpress.org/Function_Reference/wp_insert_term) there's one argument `alias_of`, which is described: > > There is no default, but if added, expected is the slug that the term > will be an alias of. Expected to be a string....
35,927
<p>I'm currently using Ian Stewart's <a href="http://themeshaper.com/2010/06/03/sample-theme-options/" rel="nofollow">A Sample WordPress Theme Options Page</a> trying to create an inputfield and two textareas.</p> <p>Probably overlooking something somewhere I seem to be having some difficulties adding the second texta...
[ { "answer_id": 35905, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>I guess the best would be to simply merge synonyms. You can use <a href=\"http://wordpress.org/extend/plugins/merge...
2011/12/08
[ "https://wordpress.stackexchange.com/questions/35927", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm currently using Ian Stewart's [A Sample WordPress Theme Options Page](http://themeshaper.com/2010/06/03/sample-theme-options/) trying to create an inputfield and two textareas. Probably overlooking something somewhere I seem to be having some difficulties adding the second textarea. Does someone know what I'm doi...
Have *not* tested tested yet, but I see in the Codex page for [wp\_insert\_term](http://codex.wordpress.org/Function_Reference/wp_insert_term) there's one argument `alias_of`, which is described: > > There is no default, but if added, expected is the slug that the term > will be an alias of. Expected to be a string....
35,931
<p>I have a plugin and I would like to be able to run the post content through some filters before it is saved to the database. From looking at the <a href="http://codex.wordpress.org/Plugin_API">plugin api</a>, I see that two hooks that look like they might be helpful:</p> <pre><code>save_post wp_insert_post </code><...
[ { "answer_id": 35942, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": -1, "selected": false, "text": "<p>If you just want to add something similar at the end of all the posts, then I would suggest you use t...
2011/12/09
[ "https://wordpress.stackexchange.com/questions/35931", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4400/" ]
I have a plugin and I would like to be able to run the post content through some filters before it is saved to the database. From looking at the [plugin api](http://codex.wordpress.org/Plugin_API), I see that two hooks that look like they might be helpful: ``` save_post wp_insert_post ``` The only problem is that it...
The [wp\_insert\_post\_data](http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data) filter can do that: ``` add_filter( 'wp_insert_post_data' , 'filter_post_data' , '99', 2 ); function filter_post_data( $data , $postarr ) { // Change post title $data['post_title'] .= '_suffix'; return...
35,954
<p>I'm trying to make a Custom Twitter Button in my content.php so where it's placed at the bottom of each post and a button appears that when clicked it can send a Tweet this to Twitter with the post id's url. However, I can't figure out this "bug" that I'm running into and I thought possibly one of you Stackoverflow ...
[ { "answer_id": 35985, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 1, "selected": false, "text": "<p>Well, you're missing several of the data bits. Notably, data-text and data-url.</p>\n\n<p>See here for the parts of...
2011/12/09
[ "https://wordpress.stackexchange.com/questions/35954", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10978/" ]
I'm trying to make a Custom Twitter Button in my content.php so where it's placed at the bottom of each post and a button appears that when clicked it can send a Tweet this to Twitter with the post id's url. However, I can't figure out this "bug" that I'm running into and I thought possibly one of you Stackoverflow Wor...
Well, you're missing several of the data bits. Notably, data-text and data-url. See here for the parts of the tweet button code you should be including: <https://dev.twitter.com/docs/tweet-button>
35,958
<p>I need to add a custom field in admin section (below the title field) which insert the values of that custom field in the db table.</p> <p>but all this i want to do through coding like</p> <pre><code>&lt;input type="text" name="post_title" size="30" tabindex="1" value="&lt;?php echo esc_attr( htmlspecialchars( $po...
[ { "answer_id": 35959, "author": "Brooke.", "author_id": 2204, "author_profile": "https://wordpress.stackexchange.com/users/2204", "pm_score": 0, "selected": false, "text": "<p>Why not just use <a href=\"http://codex.wordpress.org/Custom_Fields\" rel=\"nofollow\">custom field post meta</a...
2011/12/09
[ "https://wordpress.stackexchange.com/questions/35958", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10980/" ]
I need to add a custom field in admin section (below the title field) which insert the values of that custom field in the db table. but all this i want to do through coding like ``` <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id=...
To insert your own custom field after the title field you will have to invoke the hook [`edit_form_after_title`](https://developer.wordpress.org/reference/hooks/edit_form_after_title/). You may at the following to your plugin or theme: ``` add_action('edit_form_after_title', function() { global $post; print '<inpu...
35,962
<p>I'm quite familiar with WordPress, but have just minimal experience with PHP frameworks such as Codeigniter. When building a custom application, say for example an invoicing system or time management app for my company, does it make sense to use WordPress as a framework, or would it be more advisable to use somethin...
[ { "answer_id": 35959, "author": "Brooke.", "author_id": 2204, "author_profile": "https://wordpress.stackexchange.com/users/2204", "pm_score": 0, "selected": false, "text": "<p>Why not just use <a href=\"http://codex.wordpress.org/Custom_Fields\" rel=\"nofollow\">custom field post meta</a...
2011/12/09
[ "https://wordpress.stackexchange.com/questions/35962", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
I'm quite familiar with WordPress, but have just minimal experience with PHP frameworks such as Codeigniter. When building a custom application, say for example an invoicing system or time management app for my company, does it make sense to use WordPress as a framework, or would it be more advisable to use something l...
To insert your own custom field after the title field you will have to invoke the hook [`edit_form_after_title`](https://developer.wordpress.org/reference/hooks/edit_form_after_title/). You may at the following to your plugin or theme: ``` add_action('edit_form_after_title', function() { global $post; print '<inpu...
35,979
<p>I have a query were I'm grabbing all post types of "news" in 2010, but it doesn't select the posts from that year. What am I doing wrong?</p> <pre><code>$querystr = " SELECT $wpdb-&gt;posts.* FROM $wpdb-&gt;posts, $wpdb-&gt;postmeta WHERE $wpdb-&gt;posts.ID = $wpdb-&gt;postmeta.post_id AND $wpdb-&gt...
[ { "answer_id": 35982, "author": "WouterB", "author_id": 6828, "author_profile": "https://wordpress.stackexchange.com/users/6828", "pm_score": 0, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>AND year($wpdb-&gt;posts.post_date)='2010',\n</code></pre>\n\n<p>instead of:</p>\n\n...
2011/12/09
[ "https://wordpress.stackexchange.com/questions/35979", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8063/" ]
I have a query were I'm grabbing all post types of "news" in 2010, but it doesn't select the posts from that year. What am I doing wrong? ``` $querystr = " SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->posts.post_status = 'publish' ...
Don't use the direct SQL query, there's no point and it's bad practice. Instead use WP\_Query: ``` $year = date('Y'); $query = new WP_Query( array( 'year' => $year, 'post_type' => 'news' ) ); ```
35,983
<p>The following code hides "the_content" output </p> <pre><code>add_filter( "the_content", "cp_module_pcontent_post_content" ); function cp_module_pcontent_post_content($content){ global $post; global $cp_module_pcontent_hide; if(!in_array($post-&gt;ID,(array)$cp_module_pcontent_hide)){ ...
[ { "answer_id": 36001, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 3, "selected": true, "text": "<p>The most prudent way is to use a staging server.</p>\n\n<p>The workflow would be:</p>\n\n<ul>\n<li>DVCS (git, mercu...
2011/12/09
[ "https://wordpress.stackexchange.com/questions/35983", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5074/" ]
The following code hides "the\_content" output ``` add_filter( "the_content", "cp_module_pcontent_post_content" ); function cp_module_pcontent_post_content($content){ global $post; global $cp_module_pcontent_hide; if(!in_array($post->ID,(array)$cp_module_pcontent_hide)){ return $co...
The most prudent way is to use a staging server. The workflow would be: * DVCS (git, mercurial) * Remote repository for multiple users (self hosted, github, bitbucket, etc,). * Staging server, push master files to. * If all is good send the files from staging to live. Some Notes: Have only one/two people actually m...
36,003
<p>I'm having trouble getting the second argument in wp_enque_style. Here's how my site is setup: </p> <ul> <li>style.css </li> <li>custom_style.css</li> <li>index.php</li> </ul> <p>In a template, I have this code: </p> <pre><code>$stylesheet_url = bloginfo('template_directory') . '/custom_style.css'; wp_enqueue_st...
[ { "answer_id": 36005, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 3, "selected": true, "text": "<p>To enqueue extra styles you should place the following code in your functions.php</p>\n\n<pre><code>fun...
2011/12/09
[ "https://wordpress.stackexchange.com/questions/36003", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8902/" ]
I'm having trouble getting the second argument in wp\_enque\_style. Here's how my site is setup: * style.css * custom\_style.css * index.php In a template, I have this code: ``` $stylesheet_url = bloginfo('template_directory') . '/custom_style.css'; wp_enqueue_style( 'custom_style', $stylesheet_url ); ``` Whic...
To enqueue extra styles you should place the following code in your functions.php ``` function my_custom_styles() { wp_enqueue_style( 'custom-style', get_stylesheet_directory_uri() . '/custom_style.css'); } add_action( 'wp_print_styles', 'my_custom_styles' ); ```
36,013
<p>In a situation where a plugin has encapsulated its methods within a class and then registered a filter or action against one of those methods, how do you remove the action or the filter if you no longer have access to that class' instance?</p> <p>For example, suppose you have a plugin that does this:</p> <pre><cod...
[ { "answer_id": 36106, "author": "mfields", "author_id": 11019, "author_profile": "https://wordpress.stackexchange.com/users/11019", "pm_score": 6, "selected": true, "text": "<p>The best thing to do here is to use a static class. The following code should be instructional:</p>\n\n<pre><co...
2011/12/09
[ "https://wordpress.stackexchange.com/questions/36013", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3687/" ]
In a situation where a plugin has encapsulated its methods within a class and then registered a filter or action against one of those methods, how do you remove the action or the filter if you no longer have access to that class' instance? For example, suppose you have a plugin that does this: ``` class MyClass { ...
The best thing to do here is to use a static class. The following code should be instructional: ``` class MyClass { function __construct() { add_action( 'wp_footer', array( $this, 'my_action' ) ); } function my_action() { print '<h1>' . __class__ . ' - ' . __function__ . '</h1>'; } } ne...
36,025
<p>I've upgraded a handful of WPMU sites from 2.9 to WP3. I've never had problems with that process .. until today, when all of a sudden, one install tells me that the DB is missing some tables. The tables WordPress can't find are not actually supposed to be there in a multisite.</p> <p>The tables I have are:</p> <pr...
[ { "answer_id": 36032, "author": "Brooke.", "author_id": 2204, "author_profile": "https://wordpress.stackexchange.com/users/2204", "pm_score": 0, "selected": false, "text": "<p>WPMU 2.9 was the last standalone install of WPMU after that it was added to the standard WP 3.0+ core. See if th...
2011/12/09
[ "https://wordpress.stackexchange.com/questions/36025", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2071/" ]
I've upgraded a handful of WPMU sites from 2.9 to WP3. I've never had problems with that process .. until today, when all of a sudden, one install tells me that the DB is missing some tables. The tables WordPress can't find are not actually supposed to be there in a multisite. The tables I have are: ``` wp_1_comment...
I've finally found the answer. Yes WP was 'triggered' to think it was evaluating a WordPress and not a WordPress-MU table structure. This was caused by the following lines: ``` define('WP_ALLOW_MULTISITE', true); define( 'MULTISITE', true ); ``` in the wp-config.php that should NOT be there in a WordPress-MU 2.9.2...
36,033
<p>I have custom post type "Art masters". Each post is master's profile. </p> <p>In their profiles isset custom fiels name "master_email". I need to send for master email notification every time if new comment is posted. </p> <p>How i can call post new comment function for use wp_mail? Thank you for help!</p>
[ { "answer_id": 36052, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 4, "selected": true, "text": "<p>You can try something like this in your functions.php</p>\n\n<pre><code>function send_comment_email_not...
2011/12/09
[ "https://wordpress.stackexchange.com/questions/36033", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10380/" ]
I have custom post type "Art masters". Each post is master's profile. In their profiles isset custom fiels name "master\_email". I need to send for master email notification every time if new comment is posted. How i can call post new comment function for use wp\_mail? Thank you for help!
You can try something like this in your functions.php ``` function send_comment_email_notification( $comment_ID, $commentdata ) { $comment = get_comment( $comment_id ); $postid = $comment->comment_post_ID; $master_email = get_post_meta( $postid, 'master_email', true); if( isset( $master_email ) && is_e...
36,047
<p>After modifying the code in my functions.php file to display a different logo on my login page, I'm getting a blank square instead.</p> <p>I've added a custom .png image (326x67) to my (child) theme's image folder, and the code I've added to <code>functions.php</code> is as follows:</p> <pre><code>function custom_...
[ { "answer_id": 36049, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 2, "selected": true, "text": "<p>If you are using a child theme then maybe you should try the following code. Not necessary to put <code...
2011/12/10
[ "https://wordpress.stackexchange.com/questions/36047", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8425/" ]
After modifying the code in my functions.php file to display a different logo on my login page, I'm getting a blank square instead. I've added a custom .png image (326x67) to my (child) theme's image folder, and the code I've added to `functions.php` is as follows: ``` function custom_loginlogo() { echo '<style t...
If you are using a child theme then maybe you should try the following code. Not necessary to put `!important` too unless some other plugin or code is overwriting it. ``` function custom_loginlogo() { echo '<style type="text/css"> h1 a { background-image: url('. get_stylesheet_directory_uri().'/images/login_l...
36,048
<p>I have this little code to insert posts via custom form:</p> <pre><code> $post = array( 'post_author' =&gt; 1, 'post_title' =&gt; 'my title, 'post_content' =&gt; 'my content', 'post_category' =&gt; array(3), 'post_type' =&gt; 'post', ); if ( $post_id = wp_insert_post( $post ) ){ echo...
[ { "answer_id": 36079, "author": "adrian7", "author_id": 7171, "author_profile": "https://wordpress.stackexchange.com/users/7171", "pm_score": 3, "selected": true, "text": "<p>Check this <a href=\"http://codex.wordpress.org/Function_Reference/wp_set_object_terms\" rel=\"nofollow\">wp_set_...
2011/12/10
[ "https://wordpress.stackexchange.com/questions/36048", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3294/" ]
I have this little code to insert posts via custom form: ``` $post = array( 'post_author' => 1, 'post_title' => 'my title, 'post_content' => 'my content', 'post_category' => array(3), 'post_type' => 'post', ); if ( $post_id = wp_insert_post( $post ) ){ echo 'post added!'; } ``` but ...
Check this [wp\_set\_object\_terms()](http://codex.wordpress.org/Function_Reference/wp_set_object_terms).
36,050
<p>Can I mess up my Wordpress site if I change <code>functions.php</code> file for my custom theme?</p> <p>One time I added some code to it and it gave me some PHP errors and my site was inaccessible. Luckily it was in the early stage of the website so I just reinstalled Wordpress.</p> <p>So, my actual question is - ...
[ { "answer_id": 36079, "author": "adrian7", "author_id": 7171, "author_profile": "https://wordpress.stackexchange.com/users/7171", "pm_score": 3, "selected": true, "text": "<p>Check this <a href=\"http://codex.wordpress.org/Function_Reference/wp_set_object_terms\" rel=\"nofollow\">wp_set_...
2011/12/10
[ "https://wordpress.stackexchange.com/questions/36050", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10187/" ]
Can I mess up my Wordpress site if I change `functions.php` file for my custom theme? One time I added some code to it and it gave me some PHP errors and my site was inaccessible. Luckily it was in the early stage of the website so I just reinstalled Wordpress. So, my actual question is - does `functions.php` file ha...
Check this [wp\_set\_object\_terms()](http://codex.wordpress.org/Function_Reference/wp_set_object_terms).
36,051
<p>I'm doing an archive page for a theme that will contain only images thumbnails. The maximum amount of thumbnails that the page layout can contains is 12. So as query I would like to been able to get two different results.</p> <p>If there is 12 thumbnails, show them all.</p> <p>If there is less than that maximum, f...
[ { "answer_id": 36057, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 0, "selected": false, "text": "<p>Hopefully this should do the trick. If you add <code>meta_key =&gt; _thumbnail_id</code> to your query...
2011/12/10
[ "https://wordpress.stackexchange.com/questions/36051", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6695/" ]
I'm doing an archive page for a theme that will contain only images thumbnails. The maximum amount of thumbnails that the page layout can contains is 12. So as query I would like to been able to get two different results. If there is 12 thumbnails, show them all. If there is less than that maximum, fill the rest with...
There are two kinds of loops in PHP: * With a unknown amount of elements ( while(), foreach(), do() while, etc) * With a specific number of elements (for() ) You need a loop with a specific number of elements (in this case 12 elements). So a while loop is not what you need. At first take a look at the loop which is n...
36,066
<p>I'm using: <code>wp_localize_script( $handle, $namespace, $variables );</code> to declare some variables before the initial AJAX call is made, but I imagine I can't do the same thing again within a callback function? I need to declare a newly created ID for use in another function, what's the best way?</p>
[ { "answer_id": 36069, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 1, "selected": false, "text": "<p>What you could do is break down your functions and let the first function call return the newly create...
2011/12/10
[ "https://wordpress.stackexchange.com/questions/36066", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10990/" ]
I'm using: `wp_localize_script( $handle, $namespace, $variables );` to declare some variables before the initial AJAX call is made, but I imagine I can't do the same thing again within a callback function? I need to declare a newly created ID for use in another function, what's the best way?
The right way is to post the data back to the WordPress admin ajax url then in your PHP function access them using the `$_POST` variables. Example jQuery function that passed a category id back to wordpress: ``` function cat_edit_get() { jQuery( "#loading-animation").show(); var catID = jQuery("#cat :selected...
36,067
<p>This should be a simple question. On websites like themeforest where you can buy themes others have built, when you preview the themes almost all the themes will have seperate pages for you to view seperate functionality </p> <p>For example if a theme has a portfolio, a blog with sidebars, a blog without sidebar,...
[ { "answer_id": 36087, "author": "Anatol", "author_id": 10571, "author_profile": "https://wordpress.stackexchange.com/users/10571", "pm_score": 2, "selected": true, "text": "<p>Paste the Following code to the top of your template:</p>\n\n<pre><code>&lt;?php \n\n/* Template Name: Portfolio...
2011/12/10
[ "https://wordpress.stackexchange.com/questions/36067", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8668/" ]
This should be a simple question. On websites like themeforest where you can buy themes others have built, when you preview the themes almost all the themes will have seperate pages for you to view seperate functionality For example if a theme has a portfolio, a blog with sidebars, a blog without sidebar, a blog with...
Paste the Following code to the top of your template: ``` <?php /* Template Name: Portfolio*/ ?> <!-- Do stuff here--> ``` This will make the Template selectable as a page template in the Backend :)
36,089
<p>I'm trying to remove the shortcodes from a child theme. In my functions.php file (for the child theme), I've put:</p> <pre><code>function my_remove_shortcode(){ return ''; } add_shortcode('entry-twitter-link', 'my_remove_shortcode'); </code></pre> <p>Where entry-twitter-link is a shortcode created in the paren...
[ { "answer_id": 36092, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 5, "selected": true, "text": "<p>Try this out. Remove the already added shortcode then add the new shortcode on the init hook.</p>\n\n<p...
2011/12/10
[ "https://wordpress.stackexchange.com/questions/36089", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8425/" ]
I'm trying to remove the shortcodes from a child theme. In my functions.php file (for the child theme), I've put: ``` function my_remove_shortcode(){ return ''; } add_shortcode('entry-twitter-link', 'my_remove_shortcode'); ``` Where entry-twitter-link is a shortcode created in the parent. However, the entry stil...
Try this out. Remove the already added shortcode then add the new shortcode on the init hook. ``` function shortcode_cleaner() { remove_shortcode( 'entry-twitter-link' ); // Not exactly required add_shortcode( 'entry-twitter-link', 'my_remove_shortcode' ); } add_action( 'init', 'shortcode_cleaner' ); function...
36,096
<p>It's working fine with Firefox, Chrome and IE &lt;= 8. But with IE9 the header disappears. Anybody an idea how to fix this?</p> <p>It's about this theme: <a href="http://thethemefoundry.com/paperpunch/" rel="nofollow">http://thethemefoundry.com/paperpunch/</a> and I'm using the free version</p>
[ { "answer_id": 36092, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 5, "selected": true, "text": "<p>Try this out. Remove the already added shortcode then add the new shortcode on the init hook.</p>\n\n<p...
2011/12/10
[ "https://wordpress.stackexchange.com/questions/36096", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5280/" ]
It's working fine with Firefox, Chrome and IE <= 8. But with IE9 the header disappears. Anybody an idea how to fix this? It's about this theme: <http://thethemefoundry.com/paperpunch/> and I'm using the free version
Try this out. Remove the already added shortcode then add the new shortcode on the init hook. ``` function shortcode_cleaner() { remove_shortcode( 'entry-twitter-link' ); // Not exactly required add_shortcode( 'entry-twitter-link', 'my_remove_shortcode' ); } add_action( 'init', 'shortcode_cleaner' ); function...
36,098
<p>hi and thanks for reading i try to grab the authors slug in the backend.</p> <pre><code>get_the_author_meta( 'user_nicename' ); </code></pre> <p>is empty. i tried to google this issue, but cant find any concrete info on how to handle the backend. any hints would be nice. i keep writing to meet the quality standard...
[ { "answer_id": 36092, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 5, "selected": true, "text": "<p>Try this out. Remove the already added shortcode then add the new shortcode on the init hook.</p>\n\n<p...
2011/12/10
[ "https://wordpress.stackexchange.com/questions/36098", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10994/" ]
hi and thanks for reading i try to grab the authors slug in the backend. ``` get_the_author_meta( 'user_nicename' ); ``` is empty. i tried to google this issue, but cant find any concrete info on how to handle the backend. any hints would be nice. i keep writing to meet the quality standards. sorry for spaming but t...
Try this out. Remove the already added shortcode then add the new shortcode on the init hook. ``` function shortcode_cleaner() { remove_shortcode( 'entry-twitter-link' ); // Not exactly required add_shortcode( 'entry-twitter-link', 'my_remove_shortcode' ); } add_action( 'init', 'shortcode_cleaner' ); function...
36,101
<p>I am developing the blog-template of my theme, which works as following: The user can input the total post-count to display on each blog-page (<code>$blogpost_count</code>). The blog itself lists post-entries in two different fashions, like so:</p> <ul> <li>first, the newest X (X being equal to $blogpost_count) pos...
[ { "answer_id": 36102, "author": "cr0z3r", "author_id": 4513, "author_profile": "https://wordpress.stackexchange.com/users/4513", "pm_score": 0, "selected": false, "text": "<p>Sorry - answered to myself to soon. My solution partially fixed the offset, but it caused other issues. That said...
2011/12/10
[ "https://wordpress.stackexchange.com/questions/36101", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4513/" ]
I am developing the blog-template of my theme, which works as following: The user can input the total post-count to display on each blog-page (`$blogpost_count`). The blog itself lists post-entries in two different fashions, like so: * first, the newest X (X being equal to $blogpost\_count) posts are listed regularly ...
try: ``` if(!is_paged()) { $post_offset = $blogpost_count; } else { $post_offset = (get_query_var('paged')-1)*2+$blogpost_count; } ... ... 'offset' => $post_offset; ```
36,105
<p>I have a custom post type called 'contacts'. I want want to remove the status, post date and change the button from PUBLISH to SAVE. From what I can tell this may not be possible without changing core files (please correct me if I am wrong).</p> <p>So, instead of trying to hack the PUBLISH metabox, I have the abili...
[ { "answer_id": 36115, "author": "weston deboer", "author_id": 8926, "author_profile": "https://wordpress.stackexchange.com/users/8926", "pm_score": 4, "selected": true, "text": "<p>Not mine but modified from <a href=\"https://wordpress.stackexchange.com/questions/3578/change-the-text-on-...
2011/12/10
[ "https://wordpress.stackexchange.com/questions/36105", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11016/" ]
I have a custom post type called 'contacts'. I want want to remove the status, post date and change the button from PUBLISH to SAVE. From what I can tell this may not be possible without changing core files (please correct me if I am wrong). So, instead of trying to hack the PUBLISH metabox, I have the ability to remo...
Not mine but modified from [here](https://wordpress.stackexchange.com/questions/3578/change-the-text-on-the-publish-button). But if you pop this into functions.php or a plugin it will work. ``` add_filter( 'gettext', 'change_publish_button', 10, 2 ); function change_publish_button( $translation, $text ) { if ( 'yourc...
36,117
<p>Toward the top of the edit.php screens there is a list that displays post statuses along with the post count. I believe this is generated by WP_Post_List_Table::get_views. For example <code>All (7) | Published (6) | Draft (1)</code></p> <p>Unfortunately, those post counts do not respect filters. I am using <code>pr...
[ { "answer_id": 36124, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 4, "selected": true, "text": "<p>You might want to remove those counts and replace them with your own.</p>\n\n<pre><code>function insert_post...
2011/12/11
[ "https://wordpress.stackexchange.com/questions/36117", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6228/" ]
Toward the top of the edit.php screens there is a list that displays post statuses along with the post count. I believe this is generated by WP\_Post\_List\_Table::get\_views. For example `All (7) | Published (6) | Draft (1)` Unfortunately, those post counts do not respect filters. I am using `pre_get_posts` to exclud...
You might want to remove those counts and replace them with your own. ``` function insert_post_counts($views){ //Run your query to count posts //use wp_cache_set and wp_cache_get to optimize performance $edit_url = admin_url( 'edit.php' ); $views['all'] = 'All <a href="'.$edit_url.'">('.$all_count.')...
36,118
<p>I have a custom post type (called contacts). Since this post type is not working like a post, I don't want to show SAVE DRAFT, PREVIEW, Status, Visibility or Publish Date.</p> <p>The only options I want to show are PUBLISH &amp; Move to Trash buttons. </p> <p>Is there a way to hide these other options? If not, how...
[ { "answer_id": 36121, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 5, "selected": true, "text": "<p>You can simply hide the options using CSS. This will add a display:none style to the misc and minor publishi...
2011/12/11
[ "https://wordpress.stackexchange.com/questions/36118", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11016/" ]
I have a custom post type (called contacts). Since this post type is not working like a post, I don't want to show SAVE DRAFT, PREVIEW, Status, Visibility or Publish Date. The only options I want to show are PUBLISH & Move to Trash buttons. Is there a way to hide these other options? If not, how do I create a new PU...
You can simply hide the options using CSS. This will add a display:none style to the misc and minor publishing actions on the post.php and post-new.php pages. It checks for a specific post type as well since all post types use these two files. ``` function hide_publishing_actions(){ $my_post_type = 'POST_TYPE'...