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
13,113
<p>I am pretty new to this and hence facing a bit of a problem. Currently I am designing a website on my localhost using WordPress.</p> <p>I noticed that the permalink structure wasn't very appealing in the default mode. I then found that it can be changed through settings and after looking around I found that I want...
[ { "answer_id": 13114, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>Your line breaks are wrong. This is the correct code:</p>\n\n<pre><code># BEGIN WordPress\n&lt;IfModule mod_rewrite.c&...
2011/03/26
[ "https://wordpress.stackexchange.com/questions/13113", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4230/" ]
I am pretty new to this and hence facing a bit of a problem. Currently I am designing a website on my localhost using WordPress. I noticed that the permalink structure wasn't very appealing in the default mode. I then found that it can be changed through settings and after looking around I found that I wanted `%postna...
You should never have to touch the mod\_rewrite rules. WordPress flushes/rewrites them to .htaccess whenever you save settings on Dashboard -> Settings -> Permalinks. If that's not happening, then something is wrong, either with your file permissions, or your local server setup. Also, it is strongly advised NOT to use...
13,119
<p>For example, I want to query posts in a page. But I don't want to show them when the user clicks the pagination links. </p> <p>Pretty much like what happens in Youtube. You only see the Top comments in the first page but when you click <code>Next</code> they disappear.</p> <p>Any suggestions to accomplish this?</p...
[ { "answer_id": 13120, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": true, "text": "<p>The current page number is available in a global variable <code>$paged</code>. </p>\n\n<pre><code>if ( ! isset ( $GLOBA...
2011/03/26
[ "https://wordpress.stackexchange.com/questions/13119", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/781/" ]
For example, I want to query posts in a page. But I don't want to show them when the user clicks the pagination links. Pretty much like what happens in Youtube. You only see the Top comments in the first page but when you click `Next` they disappear. Any suggestions to accomplish this? URL example: Query the posts...
The current page number is available in a global variable `$paged`. ``` if ( ! isset ( $GLOBALS['paged'] ) or ( $GLOBALS['paged'] < 2 ) ) { // run your code } ```
13,126
<p>I have posts that use a custom field for start date and end date. <code>query_posts</code> returns an array of posts that exist in the category I'm filtering. How do I query posts using this custom field that has date i.e. 03/11/2010 and not the full array. Pagination works on the full array so it returns all posts....
[ { "answer_id": 13127, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 1, "selected": false, "text": "<pre><code>&lt;?php\n\n $querystr = \"\n SELECT wposts.* \n FROM $wpdb-&gt;posts wposts, $wpdb-&gt;postmeta wpo...
2010/03/11
[ "https://wordpress.stackexchange.com/questions/13126", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I have posts that use a custom field for start date and end date. `query_posts` returns an array of posts that exist in the category I'm filtering. How do I query posts using this custom field that has date i.e. 03/11/2010 and not the full array. Pagination works on the full array so it returns all posts. I can use an ...
``` <?php $querystr = " SELECT wposts.* FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'date_field' AND wpostmeta.meta_value = '03/11/2010' AND wposts.post_status = 'publish' AND wposts.post_type = 'post' ORDER BY ...
13,129
<p>I am trying to get all products from the wpsc-product post type and then display them by a custom meta field called release_date_year. However, it doesn't appear to be ordering my posts by this custom meta value.</p> <p>I have read through countless blog posts, support posts on the Wordpress forums and a lot of que...
[ { "answer_id": 13140, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 1, "selected": false, "text": "<p>It looks like your 'orderby' parameter is completely ignored.</p>\n\n<p>Try setting <code>'suppress_filters' =&gt; ...
2011/03/26
[ "https://wordpress.stackexchange.com/questions/13129", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1687/" ]
I am trying to get all products from the wpsc-product post type and then display them by a custom meta field called release\_date\_year. However, it doesn't appear to be ordering my posts by this custom meta value. I have read through countless blog posts, support posts on the Wordpress forums and a lot of questions a...
The plugin '**Post Types Order**' was the culprit. As Scribu pointed out above the plugin is filtering the Raw SQL query which it shouldn't be doing. As a result, the argument '**suppress\_filters**' wasn't stopping the query being modified and the '**orderby**' argument was being completely ignored. As to how this be...
13,136
<p>hey, i have the following page template for a sitemap.</p> <pre><code>&lt;?php /** * Template Name: Sitemap */ ?&gt; &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt; &lt;div&gt; &lt;h3&gt;Pages&lt;/h3&gt; &lt;ul&gt; &lt;?php wp_list_pages('title_li=&am...
[ { "answer_id": 13142, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 0, "selected": false, "text": "<p>How are you loading this template? Is it being included <em>within</em> another template file that already ...
2011/03/26
[ "https://wordpress.stackexchange.com/questions/13136", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
hey, i have the following page template for a sitemap. ``` <?php /** * Template Name: Sitemap */ ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div> <h3>Pages</h3> <ul> <?php wp_list_pages('title_li=&depth=0&exclude='); ?> </ul> <h3>Po...
Search all your theme and plugin files for: ``` <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ``` Disable all plugins and re-enable them step by step. This document type declaration is not part of WordPress’ core files; there is a filter active somewhere. ### Update Try to remove all filters from t...
13,137
<p>I want to load some of the pages(not wordpress page, a template file other than wordpress's default template file) according to the url came on the address bar.</p> <p>for instance, I have page in my template file ie my_account.php to show my profile pic and other informations from to my wordpress pofile. and it is...
[ { "answer_id": 13138, "author": "zeo", "author_id": 1241, "author_profile": "https://wordpress.stackexchange.com/users/1241", "pm_score": 1, "selected": false, "text": "<p>See this: <a href=\"http://codex.wordpress.org/Pages#Templates_by_page-ID_or_page-Slug\" rel=\"nofollow\">http://cod...
2011/03/26
[ "https://wordpress.stackexchange.com/questions/13137", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/389/" ]
I want to load some of the pages(not wordpress page, a template file other than wordpress's default template file) according to the url came on the address bar. for instance, I have page in my template file ie my\_account.php to show my profile pic and other informations from to my wordpress pofile. and it is placed i...
You should be able to use template\_redirect. I haven't tested it though, should be something like this. ``` function page_redirect() { if ($_SERVER['REQUEST_URI'] == 'your_url') { require(TEMPLATEPATH . '/mY-account.php'); } } add_action('template_redirect', 'page_redirect'); ```
13,152
<p>I've been pounding my head on the pavement for some time now regarding implementing the_editor functionality outside the post/page/cpt editor and retaining the look and feel of the function without having to rewrite a ton of things.</p> <p>The problems I've run into are all problems within WP Core. the_editor and i...
[ { "answer_id": 13138, "author": "zeo", "author_id": 1241, "author_profile": "https://wordpress.stackexchange.com/users/1241", "pm_score": 1, "selected": false, "text": "<p>See this: <a href=\"http://codex.wordpress.org/Pages#Templates_by_page-ID_or_page-Slug\" rel=\"nofollow\">http://cod...
2011/03/26
[ "https://wordpress.stackexchange.com/questions/13152", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/296/" ]
I've been pounding my head on the pavement for some time now regarding implementing the\_editor functionality outside the post/page/cpt editor and retaining the look and feel of the function without having to rewrite a ton of things. The problems I've run into are all problems within WP Core. the\_editor and it's surr...
You should be able to use template\_redirect. I haven't tested it though, should be something like this. ``` function page_redirect() { if ($_SERVER['REQUEST_URI'] == 'your_url') { require(TEMPLATEPATH . '/mY-account.php'); } } add_action('template_redirect', 'page_redirect'); ```
13,161
<p>How can you trigger a 404 when using custom query vars? I've got re-write rules written for a custom query var, but if you were to request a URL for the query var that should technically be a 404 it returns a normal WP page, but no content, because nothing technically exists for the URL.</p>
[ { "answer_id": 13162, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>Add a 404.php to your theme and look if it is called.</p>\n\n<h3>Sample 404.php</h3>\n\n<pre><code>&lt;!doctype&gt;\n&...
2011/03/26
[ "https://wordpress.stackexchange.com/questions/13161", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3736/" ]
How can you trigger a 404 when using custom query vars? I've got re-write rules written for a custom query var, but if you were to request a URL for the query var that should technically be a 404 it returns a normal WP page, but no content, because nothing technically exists for the URL.
There is an action specifically for this: ``` function my_parse_query( $wp_query ) { if ( $wp_query->get( 'my_custom_var' ) > 42 ) { $wp_query->set_404(); status_header( 404 ); } } add_action( 'parse_query', 'my_parse_query' ); ``` That should load the 404.php template in your theme, if you h...
13,179
<p>I don't want to support Categories in my WordPress site.</p> <p>I know I can have an empty category.php page to cater for users using a URL to directly query the default Category (/category/Uncategorized), but I was wondering if there's a way to shut off WordPress's recognition of the category URLs, so that any att...
[ { "answer_id": 13180, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 1, "selected": false, "text": "<p>I don't know offhand if it is possible to \"shut off\" category's in WordPress, but you can accomplish what your as...
2011/03/26
[ "https://wordpress.stackexchange.com/questions/13179", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I don't want to support Categories in my WordPress site. I know I can have an empty category.php page to cater for users using a URL to directly query the default Category (/category/Uncategorized), but I was wondering if there's a way to shut off WordPress's recognition of the category URLs, so that any attempt to ac...
Look at [the code @scribu suggested](http://core.trac.wordpress.org/ticket/11058) for a function `unregister_taxonomy_from_object_type($taxonomy, $object_type)` (the last patch currently). Until the code has found its way into the core, add it to your functions.php, wrap it into a `function_exists()` and call it on ...
13,181
<p>I've managed to get my "semi noob proof" site installer plugin 98% complete, but I'm having a slight issue with the theme activation. The plugin is able to copy the theme into the themes directory fine. However, my switch_theme statement that attempts to set it to the active theme is missing something.</p> <p>I'm u...
[ { "answer_id": 13441, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 3, "selected": true, "text": "<p>I think, you must also set the options <code>template</code> and <code>stylesheet</code>, thats all.\nI use this vi...
2011/03/26
[ "https://wordpress.stackexchange.com/questions/13181", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
I've managed to get my "semi noob proof" site installer plugin 98% complete, but I'm having a slight issue with the theme activation. The plugin is able to copy the theme into the themes directory fine. However, my switch\_theme statement that attempts to set it to the active theme is missing something. I'm using... ...
I think, you must also set the options `template` and `stylesheet`, thats all. I use this via filter to set a theme for testing or on a category, post-type and so on. But you must change the fields in table options for active the theme ready. I hope this help, i dont tested - only my idea.
13,193
<p>Hi WordPress Experts please help me i want to get nav_menu_item_id and slug from wp database by given a page template like (store.php) this a page template and how we can get nave menu item id and slug that use this page template</p>
[ { "answer_id": 13199, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>Multiple pages may use the same template. There is no 1:1 relation between templates and pages or nav menu items, so y...
2011/03/27
[ "https://wordpress.stackexchange.com/questions/13193", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3311/" ]
Hi WordPress Experts please help me i want to get nav\_menu\_item\_id and slug from wp database by given a page template like (store.php) this a page template and how we can get nave menu item id and slug that use this page template
Hi **@Anjum:** I think the function `get_nav_menu_id_by_page_template()`is what you are looking for? You can place the code for this function in your theme's `functions.php` file, or in a `.php` for a plugin you are writing: ``` function get_nav_menu_id_by_page_template($template) { static $nav_menu_id; if (!isse...
13,209
<p>I'm working on a website where the client wants a static page displaying information about a certain category. Then under the static information she wants all the posts from that category in a 2 column list.</p> <p>So I need to have an alphabetically ordered list linking to all the post in a selected category. I ha...
[ { "answer_id": 13199, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>Multiple pages may use the same template. There is no 1:1 relation between templates and pages or nav menu items, so y...
2011/03/27
[ "https://wordpress.stackexchange.com/questions/13209", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4247/" ]
I'm working on a website where the client wants a static page displaying information about a certain category. Then under the static information she wants all the posts from that category in a 2 column list. So I need to have an alphabetically ordered list linking to all the post in a selected category. I have the cod...
Hi **@Anjum:** I think the function `get_nav_menu_id_by_page_template()`is what you are looking for? You can place the code for this function in your theme's `functions.php` file, or in a `.php` for a plugin you are writing: ``` function get_nav_menu_id_by_page_template($template) { static $nav_menu_id; if (!isse...
13,225
<p>I am quite new in WP Plugin World. I am trying to develop a plugin in WP 3.1 when I am trying to insert data into my table named "<code>wp_enam</code>" in the following way:</p> <pre><code>$wpdb-&gt;insert($wpdb-&gt;enam, array('username' =&gt; "enam" , 'useremail' =&gt; "myemail@so...
[ { "answer_id": 13227, "author": "Patriek", "author_id": 2434, "author_profile": "https://wordpress.stackexchange.com/users/2434", "pm_score": 0, "selected": false, "text": "<p>I think the wpdb->enam is incorrect, it doesnt exist , you just have to enter tablename there.</p>\n\n<pre><code...
2011/03/27
[ "https://wordpress.stackexchange.com/questions/13225", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3918/" ]
I am quite new in WP Plugin World. I am trying to develop a plugin in WP 3.1 when I am trying to insert data into my table named "`wp_enam`" in the following way: ``` $wpdb->insert($wpdb->enam, array('username' => "enam" , 'useremail' => "myemail@somedomain.com")); ``` it is not work...
You can check database function for database [here](https://developer.wordpress.org/reference/classes/wpdb). For the table prefix matter you should use `$wpdb->prefix . 'enam'` and it will return the table prefix. Just add the table name with this. So the total code would be : ``` $yourtablename = $wpdb->prefix . 'en...
13,226
<p>I added a TinyMCE editor to my plugin settings page, but once I move (drag) the metabox, editor's content get lost. (the TinyMCE editor is completely not editable until refresh)</p> <p>Here is how I added TinyMCE editor:</p> <pre><code>add_action( 'admin_head', 'add_tinymce_editor' ); function add_tinymce_editor(...
[ { "answer_id": 13249, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 2, "selected": false, "text": "<p>It seems to be caused by jQuery UI:</p>\n\n<p><a href=\"http://core.trac.wordpress.org/ticket/16972\" rel=\"nofollo...
2011/03/27
[ "https://wordpress.stackexchange.com/questions/13226", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4212/" ]
I added a TinyMCE editor to my plugin settings page, but once I move (drag) the metabox, editor's content get lost. (the TinyMCE editor is completely not editable until refresh) Here is how I added TinyMCE editor: ``` add_action( 'admin_head', 'add_tinymce_editor' ); function add_tinymce_editor() { if ( function...
I had a similar problem with radio buttons losing their status when I dragged a metabox on a settings page. I hacked together a workaround and posted it as a reply to the original wordpress trac ticket <http://core.trac.wordpress.org/ticket/16972#comment:4>
13,235
<p>have a site w/a static home page and a posts page and then a number of other static pages - i set up a custom header for the home page and then another all other pages like this in the header</p> <pre><code>&lt;?php if(is_home()){ include(TEMPLATEPATH.'/header_front.php');} else { include(TEMPLATEPATH.'/header_def...
[ { "answer_id": 13356, "author": "j1mmy", "author_id": 2174, "author_profile": "https://wordpress.stackexchange.com/users/2174", "pm_score": 0, "selected": false, "text": "<p>ok so i guess there was some code in the template for the home page that i c&amp;ped off some site that was makin...
2011/03/27
[ "https://wordpress.stackexchange.com/questions/13235", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2174/" ]
have a site w/a static home page and a posts page and then a number of other static pages - i set up a custom header for the home page and then another all other pages like this in the header ``` <?php if(is_home()){ include(TEMPLATEPATH.'/header_front.php');} else { include(TEMPLATEPATH.'/header_default.php');} ?> ...
Instead of using include(TEMPLATEPATH use the built in WordPress API. --------------------------------------------------------------------- The WordPress API accommodates for using different headers. ``` <?php if (is_front_page() ) { get_header( 'front' ); } else { get_h...
13,237
<p>I have registered a custom post type with the right parameters. By that I mean I have added <code>'taxonomies' =&gt; array('post_tag','category')</code>,</p> <p>I have also tried using <code>register_taxonomy_for_object_type('post_tag', 'custom-post-type-name');</code></p> <p>I have a custom function in my functio...
[ { "answer_id": 13254, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 0, "selected": false, "text": "<p>You need to run the loop before the conditional statement.</p>\n\n<pre><code>&lt;?php if (have_posts()) : while (h...
2011/03/27
[ "https://wordpress.stackexchange.com/questions/13237", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1509/" ]
I have registered a custom post type with the right parameters. By that I mean I have added `'taxonomies' => array('post_tag','category')`, I have also tried using `register_taxonomy_for_object_type('post_tag', 'custom-post-type-name');` I have a custom function in my functions.php to load a basic loop using a condit...
Down the rabbit hole..... I found a fix. From this post [Custom Post Type Archives by Date and Taxonomy](https://wordpress.stackexchange.com/questions/1878/custom-post-type-archives-by-date-and-taxonomy) Which let me to this trac ticket <http://core.trac.wordpress.org/ticket/14589> and the following ``` function ...
13,240
<p>I know how to add an image and a gallery. I need to have one image from the galley show on the page at random each time the page is loaded.</p> <p>The page should only show one image at a time.</p> <p>Is there a plugin or short code to do this? I know how to make gallery's random, but they show all the images.</p>...
[ { "answer_id": 13244, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 3, "selected": true, "text": "<p>You should use the <code>'orderby' =&gt; 'rand'</code> parameter for the <a href=\"http://codex.wordpress.org/Functi...
2011/03/27
[ "https://wordpress.stackexchange.com/questions/13240", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/197/" ]
I know how to add an image and a gallery. I need to have one image from the galley show on the page at random each time the page is loaded. The page should only show one image at a time. Is there a plugin or short code to do this? I know how to make gallery's random, but they show all the images. **Answer**: ``` $a...
You should use the `'orderby' => 'rand'` parameter for the [`get_children()`](http://codex.wordpress.org/Function_Reference/get_children) attachments function. For instance: ``` $images = get_children( array( 'orderby' => 'rand', // this is random param 'post_type' => 'attachment', 'post...
13,246
<p>I have added a custom button to the tinymce to insert my shortcodes, but I have so many and I want to make a splitbutton instead and I can't figure how. Anyone can help. Here's the code that I've used to create the normal button:</p> <p>in functions.php :</p> <pre><code>/** Hook into WordPress */ add_action('init...
[ { "answer_id": 13268, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 3, "selected": true, "text": "<p>It should be pretty straight-forward, copy the relevant pieces of code from the page you linked to into your exis...
2011/03/27
[ "https://wordpress.stackexchange.com/questions/13246", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4257/" ]
I have added a custom button to the tinymce to insert my shortcodes, but I have so many and I want to make a splitbutton instead and I can't figure how. Anyone can help. Here's the code that I've used to create the normal button: in functions.php : ``` /** Hook into WordPress */ add_action('init', 'onehalf_button');...
It should be pretty straight-forward, copy the relevant pieces of code from the page you linked to into your existing TinyMCE plugin, update a few strings... done!.. Start with this for your TinyMCE plugin JS and see how you get on.. ``` // JavaScript Document (function() { // Creates a new plugin class and a cu...
13,247
<p>Here's how I have my code set up in the functions file:</p> <pre><code>register_sidebar(array( 'name' =&gt; 'Latest Updates', 'before_widget' =&gt; '&lt;span&gt;', 'after_widget' =&gt; '&lt;/span&gt;', 'before_title' =&gt; '', 'after_title' =&gt; '' )); register_sidebar(array( 'name' =&gt; '...
[ { "answer_id": 13268, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 3, "selected": true, "text": "<p>It should be pretty straight-forward, copy the relevant pieces of code from the page you linked to into your exis...
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13247", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3714/" ]
Here's how I have my code set up in the functions file: ``` register_sidebar(array( 'name' => 'Latest Updates', 'before_widget' => '<span>', 'after_widget' => '</span>', 'before_title' => '', 'after_title' => '' )); register_sidebar(array( 'name' => 'BBRB Loves (Video Width - 200px)', 'befo...
It should be pretty straight-forward, copy the relevant pieces of code from the page you linked to into your existing TinyMCE plugin, update a few strings... done!.. Start with this for your TinyMCE plugin JS and see how you get on.. ``` // JavaScript Document (function() { // Creates a new plugin class and a cu...
13,260
<p>This is a sample of the <a href="http://wordpress.org/extend/plugins/vote-it-up/" rel="nofollow">Vote it Up</a> plugin:</p> <pre><code>//Run this to create an entry for a post in the voting system. Will check if the post exists. If it doesn't, it will create an entry. function SetPost($post_ID) { global $wpdb; ...
[ { "answer_id": 13261, "author": "marvinhagemeister", "author_id": 3701, "author_profile": "https://wordpress.stackexchange.com/users/3701", "pm_score": 1, "selected": false, "text": "<p>For most plugins it is sufficient to use the WordPress <a href=\"http://codex.wordpress.org/Options_AP...
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13260", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/781/" ]
This is a sample of the [Vote it Up](http://wordpress.org/extend/plugins/vote-it-up/) plugin: ``` //Run this to create an entry for a post in the voting system. Will check if the post exists. If it doesn't, it will create an entry. function SetPost($post_ID) { global $wpdb; //prevents SQL injection $p_ID ...
Hi **@janoChen:** The correct answer is: ***"It depends."*** In general it is better to use built-in WordPress functions than to use direct SQL *when there are built-in functions that can provide you what you need.* However, the answers to many of the questions I see here on WPSE are *(unfortunately) "you need to use...
13,263
<p>I need urgent help figuring this out please - I've been working on a WordPress theme locally without problems, and now that I've uploaded it to the live server I'm getting this error:</p> <blockquote> <p><strong>Warning: Invalid argument supplied for foreach() in /homepages/42/d357924500/htdocs/wp-includes/post...
[ { "answer_id": 13264, "author": "Patriek", "author_id": 2434, "author_profile": "https://wordpress.stackexchange.com/users/2434", "pm_score": 2, "selected": false, "text": "<p>My assumption would be that your args->taxonomy is empty, invalid or non-existent. without more code its hard to...
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13263", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4027/" ]
I need urgent help figuring this out please - I've been working on a WordPress theme locally without problems, and now that I've uploaded it to the live server I'm getting this error: > > **Warning: Invalid argument supplied for foreach() in > /homepages/42/d357924500/htdocs/wp-includes/post.php > on line 1011** > ...
Ran into the same issue. @Patriek is correct. The 'taxonomies' argument must be an array, hence the plural. E.g. `$args = array( 'taxonomies' => array( 'myTaxonomy' ) );` This corrects the error. I only noticed this when moving a site to another server which leads me to think the register\_post\_type() function re...
13,277
<p>hey guys, weird situation... I'm trying to use wp_ajax() for the first time. I'm normally using a normal jQuery ajax request but in my current case I get a lot of bugs so I thought about trying wp_ajax().</p> <p><strong>I don't get it though!</strong></p> <p>The following piece of code...</p> <pre><code>// embed ...
[ { "answer_id": 13281, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 4, "selected": true, "text": "<p>Ok, firstly let me just break it down a little, so you understand the purpose of these functions.</p>\n\n<ul>\n<l...
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13277", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
hey guys, weird situation... I'm trying to use wp\_ajax() for the first time. I'm normally using a normal jQuery ajax request but in my current case I get a lot of bugs so I thought about trying wp\_ajax(). **I don't get it though!** The following piece of code... ``` // embed the javascript file that makes the AJAX...
Ok, firstly let me just break it down a little, so you understand the purpose of these functions. * [wp\_enqueue\_script()](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) **Description:** A safe way of adding javascripts to a WordPress generated page. Basically, include the script if it hasn't a...
13,288
<p>I'm trying to display a monthly archive but only for a certain category. How can I do this?</p>
[ { "answer_id": 13281, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 4, "selected": true, "text": "<p>Ok, firstly let me just break it down a little, so you understand the purpose of these functions.</p>\n\n<ul>\n<l...
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13288", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1136/" ]
I'm trying to display a monthly archive but only for a certain category. How can I do this?
Ok, firstly let me just break it down a little, so you understand the purpose of these functions. * [wp\_enqueue\_script()](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) **Description:** A safe way of adding javascripts to a WordPress generated page. Basically, include the script if it hasn't a...
13,292
<p>When creating a new post, by entering either manually or pasting from another document, TinyMCE (the default WordPress editor) does not seem to hold any type of formatting. For instance I create a two paragraph entry. When viewing it on the page it will come through as a single chunk of text within <code>&lt;div cla...
[ { "answer_id": 13281, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 4, "selected": true, "text": "<p>Ok, firstly let me just break it down a little, so you understand the purpose of these functions.</p>\n\n<ul>\n<l...
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13292", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3296/" ]
When creating a new post, by entering either manually or pasting from another document, TinyMCE (the default WordPress editor) does not seem to hold any type of formatting. For instance I create a two paragraph entry. When viewing it on the page it will come through as a single chunk of text within `<div class="entry-c...
Ok, firstly let me just break it down a little, so you understand the purpose of these functions. * [wp\_enqueue\_script()](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) **Description:** A safe way of adding javascripts to a WordPress generated page. Basically, include the script if it hasn't a...
13,294
<p>So, I've read through <a href="https://wordpress.stackexchange.com/questions/5744/what-does-exactly-gpl-license-mean-for-my-wordpress-theme">this question</a> about licensing of PHP code under the GPL v2. As well as the compromise of the Thesis theme developer, as far as licensing all PHP under the GPL, but copyrigh...
[ { "answer_id": 13281, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 4, "selected": true, "text": "<p>Ok, firstly let me just break it down a little, so you understand the purpose of these functions.</p>\n\n<ul>\n<l...
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13294", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3357/" ]
So, I've read through [this question](https://wordpress.stackexchange.com/questions/5744/what-does-exactly-gpl-license-mean-for-my-wordpress-theme) about licensing of PHP code under the GPL v2. As well as the compromise of the Thesis theme developer, as far as licensing all PHP under the GPL, but copyrighting js, css, ...
Ok, firstly let me just break it down a little, so you understand the purpose of these functions. * [wp\_enqueue\_script()](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) **Description:** A safe way of adding javascripts to a WordPress generated page. Basically, include the script if it hasn't a...
13,305
<p>Is it possible within the current theme file naming hierarchy to define a template for for all pages that are a child of a specific page? For example, in this navigation:</p> <p>About Us</p> <ul> <li>Contact</li> <li>Who We Are</li> <li>Message Statement</li> </ul> <p>Is there any way to just make a theme file n...
[ { "answer_id": 13306, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>This is not possible, by default, in the WordPress templating system. The <a href=\"http://codex.wordpress....
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13305", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3032/" ]
Is it possible within the current theme file naming hierarchy to define a template for for all pages that are a child of a specific page? For example, in this navigation: About Us * Contact * Who We Are * Message Statement Is there any way to just make a theme file named something like: page-about-us-all.php That ...
I have a handy little custom made conditional function that would do the job for you. **The function:** ``` function is_child_page($page = NULL){ global $post; if ($page == NULL){ $p = get_post($post->ID); if ($p->post_parent > 0 ){ return true; }else{ return f...
13,308
<p>I'm creating a theme with a custom post type for team members, I've also got the following page structure:</p> <pre><code>about &lt;-- this is a page about/team-members &lt;-- this is a page, lists all the team members about/team-members/joe-bloggs &lt;-- this is a custom post type (team member) entry </code></p...
[ { "answer_id": 13317, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": false, "text": "<p>When Working with pages you can select a parent page and that value is saved as the parent page id number in ...
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13308", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29/" ]
I'm creating a theme with a custom post type for team members, I've also got the following page structure: ``` about <-- this is a page about/team-members <-- this is a page, lists all the team members about/team-members/joe-bloggs <-- this is a custom post type (team member) entry ``` The third structure here us...
When Working with pages you can select a parent page and that value is saved as the parent page id number in the child page's `post_parent` field in the database. In your case, you are using a custom post type so you would need to create your own metabox for the parent page; something like: ``` /* Define the custom ...
13,312
<pre><code>wp_list_pages('title_li=&amp;depth=&amp;exclude='); </code></pre> <p>lists all pages of my site. If there are childpages of a certain page the output looks like this:</p> <pre><code>&lt;li class="page_item page-item-2"&gt; &lt;a href="http://domain.com/about" title="About"&gt;About&lt;/a&gt; &lt;u...
[ { "answer_id": 13313, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": true, "text": "<p>you can use <a href=\"http://codex.wordpress.org/Function_Reference/get_pages\" rel=\"nofollow\"><strong>get_p...
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13312", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
``` wp_list_pages('title_li=&depth=&exclude='); ``` lists all pages of my site. If there are childpages of a certain page the output looks like this: ``` <li class="page_item page-item-2"> <a href="http://domain.com/about" title="About">About</a> <ul class="children"> <li class="page_item page-item-...
you can use [**get\_pages()**](http://codex.wordpress.org/Function_Reference/get_pages) function, something like this: ``` $mypages = get_pages(); echo '<ul>'; foreach($mypages as $page){ echo '<li class="page_item page-item-'.$page->ID.'"><a href="'.get_page_link($page->ID).'">'.$page->post_title.'</a></li>'...
13,319
<p>quick question. I'm using jquery for my current project (the latest release). A few plugins I'm using are using jquery as well and they are inserted through wp_head(). Since I want my website to ber fairly slim and fast this redundant scripts should be removed.</p> <p>is there any way I can filter for the string "j...
[ { "answer_id": 13323, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>You can use wp_deregister_style() and wp_deregister_script() to clean up overly aggressive Plugin script/st...
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13319", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
quick question. I'm using jquery for my current project (the latest release). A few plugins I'm using are using jquery as well and they are inserted through wp\_head(). Since I want my website to ber fairly slim and fast this redundant scripts should be removed. is there any way I can filter for the string "jquery.js"...
There's no filter that covers the entire output produced during wp\_head(). You would have to use a fairly complicated process of output buffering starting before wp\_head, then filtering out what you don't want afterwards, before releasing the buffer. Lets assume that you're dealing with plugins that have registered ...
13,329
<p>I'm using <a href="http://adambrown.info/p/wp_hooks/hook/admin_footer-%7B%24hook_suffix%7D" rel="nofollow"><code>admin_footer-{$hook_suffix}</code></a> to selectively print scripts on the new post page and comments page. This hook is depreciated in 3.1.</p> <p>I <a href="http://adambrown.info/p/wp_hooks/hook/admin_...
[ { "answer_id": 13335, "author": "goldenapples", "author_id": 290, "author_profile": "https://wordpress.stackexchange.com/users/290", "pm_score": 3, "selected": true, "text": "<p>There's an <code>in_footer</code> parameter that you can pass to wp_enqueue_scripts - does that work?</p>\n\n<...
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13329", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1860/" ]
I'm using [`admin_footer-{$hook_suffix}`](http://adambrown.info/p/wp_hooks/hook/admin_footer-%7B%24hook_suffix%7D) to selectively print scripts on the new post page and comments page. This hook is depreciated in 3.1. I [see](http://adambrown.info/p/wp_hooks/hook/admin_print_scripts-%7B%24hook_suffix%7D?version=3.1&fil...
There's an `in_footer` parameter that you can pass to wp\_enqueue\_scripts - does that work? I would hook to `admin_enqueue_scripts`, check the $page for location, and enqueue your script there, with 'in\_footer' as true. Example: ``` add_action( 'admin_enqueue_scripts', 'enqueue_my_script' ); function enqueue_my_s...
13,330
<p>The original urls for users look like <code>/author/login/</code></p> <p><strong>Is it possible to replace login by user's id?</strong></p> <p>In my dream urls should become to <code>/users/34/</code> (34 is user id).</p> <p>Thanks.</p>
[ { "answer_id": 13332, "author": "AutoBlogged", "author_id": 3973, "author_profile": "https://wordpress.stackexchange.com/users/3973", "pm_score": 0, "selected": false, "text": "<p>You could use an htaccess rule to rewrite /users/34 to /?author=34</p>\n" }, { "answer_id": 13343, ...
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13330", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/876/" ]
The original urls for users look like `/author/login/` **Is it possible to replace login by user's id?** In my dream urls should become to `/users/34/` (34 is user id). Thanks.
you need 3 simple functions and hooks first change the author base: ``` //change author/username base to users/userID function change_author_permalinks() { global $wp_rewrite; // Change the value of the author permalink base to whatever you want here $wp_rewrite->author_base = 'users'; $wp_rewrite->flush_ru...
13,333
<p>I noticed ShareDaddy has "Show sharing buttons on this post" for default post types but not for custom post types. I'm guessing I need to add something in <code>'supports' =&gt; array('title','editor','thumbnail')</code>. Does anybody know what I need to add in order for "Show sharing buttons on this post" to show u...
[ { "answer_id": 13336, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>ShareDaddy uses two filter hooks either <code>the_content</code> or <code>the_excerpt</code> this means that y...
2011/03/28
[ "https://wordpress.stackexchange.com/questions/13333", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3714/" ]
I noticed ShareDaddy has "Show sharing buttons on this post" for default post types but not for custom post types. I'm guessing I need to add something in `'supports' => array('title','editor','thumbnail')`. Does anybody know what I need to add in order for "Show sharing buttons on this post" to show up for custom post...
ShareDaddy uses two filter hooks either `the_content` or `the_excerpt` this means that your custom post type theme template file has to use one of these two functions `the_content();` or `the_excerpt();`. Update ------ Ok I guess i didn't get the question. So to add the metabox to your custom post type add this: ```...
13,353
<p>I am writing a function that adds an ID number to an array and puts the array in the <em>usermeta</em>. <code>$_GET['auction']</code> is the <code>post_id</code>.</p> <p>Below is the function:</p> <pre><code>$reminders = get_user_meta( $current_user-&gt;ID, "reminders" ); print_r( $reminders ); if( in_array( $_GET...
[ { "answer_id": 13386, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": true, "text": "<p>Haven't used the function for quite a time, but i guess your problem is that you are pushing an array into an array....
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13353", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4224/" ]
I am writing a function that adds an ID number to an array and puts the array in the *usermeta*. `$_GET['auction']` is the `post_id`. Below is the function: ``` $reminders = get_user_meta( $current_user->ID, "reminders" ); print_r( $reminders ); if( in_array( $_GET['auction'], $reminders ) ) { echo "Failed: Aucti...
Haven't used the function for quite a time, but i guess your problem is that you are pushing an array into an array. So check if `intval($_GET['auction'])` is an array: ``` echo '<pre>'; print_r(intval($_GET['auction'])); echo '</pre>'; ``` **Edit #1:** You maybe need to get the value from that array and then array\...
13,363
<p>I am trying to create a small plugin but it not creating table in database when i activate the plugin. please have a look the code given below there is function <code>function jal_install ()</code> it not called.</p> <pre><code> &lt;?php /* Plugin Name: My-Ads Plugin URI: http://wordpre...
[ { "answer_id": 13400, "author": "AutoBlogged", "author_id": 3973, "author_profile": "https://wordpress.stackexchange.com/users/3973", "pm_score": 0, "selected": false, "text": "<p>Here's one problem:</p>\n\n<pre><code>register_activation_hook(_FILE_,'my_first_install');\n</code></pre>\n\...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13363", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1850/" ]
I am trying to create a small plugin but it not creating table in database when i activate the plugin. please have a look the code given below there is function `function jal_install ()` it not called. ``` <?php /* Plugin Name: My-Ads Plugin URI: http://wordpress.org/# Description...
The first issue as AutoBLogged pointed out is that you've incorrectly referenced `_FILE_` and not `__FILE__` in the first activation hook. There's a possible secondary problem, and i say possible because i've never had to use the activation or deactivation hooks extensively myself, and that's with calling `register_ac...
13,368
<p>How can i get the posts using get_posts from let's say post 10 and beyond?So if i have 200 posts i will get from post 10 to post 200(190 posts)?</p> <p>Because as i see if i use</p> <pre><code>&lt;?php $args = array( 'numberposts' =&gt; -1, 'offset' =&gt; 10 ); ?&gt; </code></pre> <p>i ju...
[ { "answer_id": 13371, "author": "Anton", "author_id": 4287, "author_profile": "https://wordpress.stackexchange.com/users/4287", "pm_score": 0, "selected": false, "text": "<pre><code>$myposts = get_posts( $args );\nforeach( $myposts as $key =&gt; $post ) : setup_postdata($post); ?&gt;\n\n...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13368", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1731/" ]
How can i get the posts using get\_posts from let's say post 10 and beyond?So if i have 200 posts i will get from post 10 to post 200(190 posts)? Because as i see if i use ``` <?php $args = array( 'numberposts' => -1, 'offset' => 10 ); ?> ``` i just get all the posts Cheers
It's strange, you'd have thought if you disable paging and grab all posts, that you could naturally set an offset to, eg. ``` array( 'nopaging' => true, 'offset' => 10 ) ``` or ``` array( 'posts_per_page' => -1, 'offset' => 10 ) ``` or ``` array( 'numberposts' => -1, 'offset' => 10 ) ``` This unfortunately ...
13,378
<p>I'm trying to add template page from a plugin,and my template page is in this plugin folder.Is this posible?Here is my code:</p> <pre><code> global $user_ID; $new_post = array( 'post_title' =&gt; 'Test Template Page', 'post_content' =&gt; 'Some text', 'post_status' =&gt; 'publish', ...
[ { "answer_id": 13451, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 5, "selected": true, "text": "<p>The article linked is on the right track, but i'll make it more simple for you.. ;)</p>\n\n<pre><code>add_filter(...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13378", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1147/" ]
I'm trying to add template page from a plugin,and my template page is in this plugin folder.Is this posible?Here is my code: ``` global $user_ID; $new_post = array( 'post_title' => 'Test Template Page', 'post_content' => 'Some text', 'post_status' => 'publish', 'post_date' => date(...
The article linked is on the right track, but i'll make it more simple for you.. ;) ``` add_filter( 'page_template', 'catch_plugin_template' ); function catch_plugin_template( $template ) { if( 'tp-file.php' == basename( $template ) ) $template = WP_PLUGIN_DIR . '/yourpluginname/tp-file.php'; return $...
13,389
<p>I have this code which is located on the search.php page and retrieves all the categories for each post and echo's out a link to the first category:</p> <pre><code>$category = get_the_category(); //print_r($category); if ($category) { echo '&lt;a href="' . get_category_link( $category[0]-&gt;term_id ) . '" title=...
[ { "answer_id": 13391, "author": "Ashfame", "author_id": 1521, "author_profile": "https://wordpress.stackexchange.com/users/1521", "pm_score": 3, "selected": true, "text": "<p>Yes, there is a risk! I can put up a check on date to change your password, create a new user and what not. Don't...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13389", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/912/" ]
I have this code which is located on the search.php page and retrieves all the categories for each post and echo's out a link to the first category: ``` $category = get_the_category(); //print_r($category); if ($category) { echo '<a href="' . get_category_link( $category[0]->term_id ) . '" title="' . sprintf( __( "V...
Yes, there is a risk! I can put up a check on date to change your password, create a new user and what not. Don't give access to someone you don't trust. Hire a professional to do the job. **Edit:** Okay! Upon request, I have explained two cases in a blog post - <http://blog.ashfame.com/?p=903>
13,390
<p>Every time I create a new site under 3.1, my first trip is to the Users > Admin User profile page to uncheck the "admin bar" checkbox.</p> <p>I'd like to place a script in my theme's functions.php to do this automatically.</p> <p>Anyone know what that would be?</p>
[ { "answer_id": 13392, "author": "Ashfame", "author_id": 1521, "author_profile": "https://wordpress.stackexchange.com/users/1521", "pm_score": 0, "selected": false, "text": "<p>I believe you can activate such a plugin sitewide - <a href=\"http://wordpress.org/extend/plugins/disable-admin-...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13390", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
Every time I create a new site under 3.1, my first trip is to the Users > Admin User profile page to uncheck the "admin bar" checkbox. I'd like to place a script in my theme's functions.php to do this automatically. Anyone know what that would be?
You could use a function inside your theme's functions file to selectively disable it for specific users. ``` function disable_bar_for_user( $ids ) { if( !is_user_logged_in() ) return; global $current_user; if( is_numeric( $ids ) ) $ids = (array) $ids; if( !in_array( $current_user->...
13,410
<p>Hay, I'm making a WordPress template, and i have 4 main pages.</p> <pre><code>HOME BLOG CONTACT ABOUT US </code></pre> <p>As you can see "Blog" is a page (i need it to display when i call wp_list_pages()), but how do i edit this blog page? I assigned the "Blog" page a custom temeplate (called blog.php), but when "...
[ { "answer_id": 13426, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>Setting page to be \"posts page\" changes its template hierarchy to follow <a href=\"http://codex.wordpress.org/Templ...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13410", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/376/" ]
Hay, I'm making a WordPress template, and i have 4 main pages. ``` HOME BLOG CONTACT ABOUT US ``` As you can see "Blog" is a page (i need it to display when i call wp\_list\_pages()), but how do i edit this blog page? I assigned the "Blog" page a custom temeplate (called blog.php), but when "Blog" is set as the "Pos...
Setting page to be "posts page" changes its template hierarchy to follow [home page rules](http://codex.wordpress.org/Template_Hierarchy#Home_Page_display). So your custom template is ignored and it looks for `home.php` or `index.php`, which might or might not be the reason it fails to render.
13,411
<p><em><strong>The Dilemma</em></strong></p> <p>I have a few custom post types:</p> <ul> <li>Portfolio Items</li> <li>Testimonials</li> <li>FAQs</li> </ul> <p>The URL structures for these custom post types are:</p> <ul> <li>mysite.com/<strong>portfolio</strong>/name-of-custom-post</li> <li>mysite.com/<strong>testim...
[ { "answer_id": 13421, "author": "mrtsherman", "author_id": 4013, "author_profile": "https://wordpress.stackexchange.com/users/4013", "pm_score": 0, "selected": false, "text": "<p>Alternative - You can setup permanent 301 redirects. This will send people on to the correct link and keep yo...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13411", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4296/" ]
***The Dilemma*** I have a few custom post types: * Portfolio Items * Testimonials * FAQs The URL structures for these custom post types are: * mysite.com/**portfolio**/name-of-custom-post * mysite.com/**testimonial**/name-of-custom-post * mysite.com/**faq**/name-of-custom-post I'd like to use the normal, built-in...
You could do this on custom post type registration. 1) Set your default permalink in the WordPress admin to your desired structure e.g.: ``` /blog/%postname% ``` 2) Add the "slug" and "with\_front" parameter to the rewrite-array in the register\_post\_type function. "slug" must be the name of your post-type. ``` ...
13,413
<p>I am managing a Wordpress network and would like to add the unfiltered_html user capability to the already predefined user role of Admin. In a standard installation of Wordpress the Admin account would already have this capability but in an MU installation only Super Admins are afforded this capability. Wordpress ...
[ { "answer_id": 13470, "author": "Philip", "author_id": 2048, "author_profile": "https://wordpress.stackexchange.com/users/2048", "pm_score": 5, "selected": true, "text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/get_role\" rel=\"noreferrer\">WP_Role</a> clas...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13413", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2362/" ]
I am managing a Wordpress network and would like to add the unfiltered\_html user capability to the already predefined user role of Admin. In a standard installation of Wordpress the Admin account would already have this capability but in an MU installation only Super Admins are afforded this capability. Wordpress [Rol...
You can use [WP\_Role](http://codex.wordpress.org/Function_Reference/get_role) class, ``` // get the the role object $role_object = get_role( $role_name ); // add $cap capability to this role object $role_object->add_cap( $capability_name ); // remove $cap capability from this role object $role_object->remove_cap( $...
13,414
<p>I've got a very basic solution using <code>fetch_feed()</code> and SimplePie to pull in RSS items which is working on my localhost, but for some reason <code>is_wp_error()</code> persists as <code>true</code> on the live server. Is there anyway for me to get specific output about the nature of the error so as to wor...
[ { "answer_id": 13423, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 3, "selected": true, "text": "<p>add this to your feed</p>\n\n<pre><code> $rss = fetch_feed( $url );\n if ( is_wp_error( $rss ) ) {\n ech...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13414", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92/" ]
I've got a very basic solution using `fetch_feed()` and SimplePie to pull in RSS items which is working on my localhost, but for some reason `is_wp_error()` persists as `true` on the live server. Is there anyway for me to get specific output about the nature of the error so as to work towards a solution on the live ser...
add this to your feed ``` $rss = fetch_feed( $url ); if ( is_wp_error( $rss ) ) { echo $rss->get_error_message(); <---this } else { // do your stuff here } ``` I would also suggest installing the debug toolbar extensions, like "debug-bar-extender".
13,417
<p>How do I pass feed URLs with <code>&amp;</code> in the URL to <code>fetch_feed()</code>?</p> <p>The feed is not parsed correctly if there is a <code>&amp;</code> in the feed URL. Actually it works in the example I gave, but now I'm populating the feeds array dynamically with this code :</p> <pre><code>$rss_subscri...
[ { "answer_id": 13425, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>Two methods you use should be identical from PHP viewpoint, I do not see in code any passing by reference or somethi...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13417", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1381/" ]
How do I pass feed URLs with `&` in the URL to `fetch_feed()`? The feed is not parsed correctly if there is a `&` in the feed URL. Actually it works in the example I gave, but now I'm populating the feeds array dynamically with this code : ``` $rss_subscriptions = array(); $terms = get_terms('news_rss','hide_empty=0'...
Further to my comment above, I think it is probably to do with the `&` being converted into `&amp;` or `&#038;`. I had this problem and ended up solving it by running the URL though wp\_specialchars\_decode before passing it to fetch\_feed. I'd suggest you try this (although so much time has passed that I'm really ...
13,424
<p>I am trying to modify the main WordPress loop on my category pages like so:</p> <pre><code>add_filter('parse_query', 'my_modified_query'); function my_modified_query( $q ) { if (!is_admin() &amp;&amp; is_category()) { $q-&gt;set( 'orderby', 'meta_value' ); $q-&gt;set( 'meta_key',...
[ { "answer_id": 13439, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>Servus Sarah. I guess this is for one of your envato-shop themes? Have you already tried to print the query like th...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13424", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4302/" ]
I am trying to modify the main WordPress loop on my category pages like so: ``` add_filter('parse_query', 'my_modified_query'); function my_modified_query( $q ) { if (!is_admin() && is_category()) { $q->set( 'orderby', 'meta_value' ); $q->set( 'meta_key', 'my_key' ); } ...
Ultimately all meta queries get run through `_get_meta_sql`. * [wp-includes/meta.php](http://core.trac.wordpress.org/browser/tags/3.1/wp-includes/meta.php#L377) Line 402 - 403 in the `_get_meta_sql` function The following coditional statement runs for any meta queries. ``` if ( empty( $meta_key ) && empty( $meta_va...
13,432
<p>I'd like to remove the post title from my static frontpage. Just that page. I've created a child theme from a free Press75 theme. So I'd like to make this change in my child theme's function.php.</p> <p>I used this code but it removes the title from all pages, posts and my navigation:</p> <pre><code>add_filter( 't...
[ { "answer_id": 13433, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 0, "selected": false, "text": "<p>One way for header.php:</p>\n\n<pre><code>&lt;?php if (is_page('138')) { echo'\n&lt;style type=\"text/css\" t...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13432", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4295/" ]
I'd like to remove the post title from my static frontpage. Just that page. I've created a child theme from a free Press75 theme. So I'd like to make this change in my child theme's function.php. I used this code but it removes the title from all pages, posts and my navigation: ``` add_filter( 'the_title', 'remove_pa...
wrap your add\_filter function call around a conditional tag and use the builtin return false function: ``` if ( is_page('138') ) { add_filter( 'the_title', '__return_false' ); } ```
13,437
<p>OK, there have been several posts on here about frontend posting forms. I've read them all, which got me to where I am. Now every form I come across has some form of validation which seems to check for a value for the fields you want to make required. I've tried them, and I can't get anything to work. I just can...
[ { "answer_id": 13433, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 0, "selected": false, "text": "<p>One way for header.php:</p>\n\n<pre><code>&lt;?php if (is_page('138')) { echo'\n&lt;style type=\"text/css\" t...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13437", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3429/" ]
OK, there have been several posts on here about frontend posting forms. I've read them all, which got me to where I am. Now every form I come across has some form of validation which seems to check for a value for the fields you want to make required. I've tried them, and I can't get anything to work. I just can't make...
wrap your add\_filter function call around a conditional tag and use the builtin return false function: ``` if ( is_page('138') ) { add_filter( 'the_title', '__return_false' ); } ```
13,445
<p>I'm having an issue with one site in which my plugin is installed. The "settings" page will not load. When I click on "settings", it loads the settings page but the page is blank after the "Upgrade to 3.1" nag div as if there was a die() there.</p> <p>I have two files, plugin.php and plugin-admin.php</p> <p>I've g...
[ { "answer_id": 13456, "author": "Andy", "author_id": 498, "author_profile": "https://wordpress.stackexchange.com/users/498", "pm_score": 1, "selected": false, "text": "<p>When I use the code you provided I see the \"MY! Settings\" menu item as the top item in the Settings menu and it has...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13445", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
I'm having an issue with one site in which my plugin is installed. The "settings" page will not load. When I click on "settings", it loads the settings page but the page is blank after the "Upgrade to 3.1" nag div as if there was a die() there. I have two files, plugin.php and plugin-admin.php I've got code in plugin...
If i had to venture a guess at the cause of the problem my initial thought would be toward the flush rules call. As Andy said, having debug on helps a great deal, and if you really don't want to see the errors, you can always use the debug log instead, using the following in your config file.. ``` define('WP_DEBUG',...
13,448
<p>I have my news in posts and I am trying to display the two latest news articles (posts) on my main page. I've got that solved by getting the title using <a href="http://codex.wordpress.org/Function_Reference/the_title" rel="nofollow"><code>the_title()</code></a> and getting a little bit of the text using <a href="ht...
[ { "answer_id": 13973, "author": "Jan Fabry", "author_id": 8, "author_profile": "https://wordpress.stackexchange.com/users/8", "pm_score": 2, "selected": true, "text": "<p>You can scan the content to see whether it contains a link and then parse it to find the <code>href</code> attribute....
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13448", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4304/" ]
I have my news in posts and I am trying to display the two latest news articles (posts) on my main page. I've got that solved by getting the title using [`the_title()`](http://codex.wordpress.org/Function_Reference/the_title) and getting a little bit of the text using [`the_excerpt()`](http://codex.wordpress.org/Functi...
You can scan the content to see whether it contains a link and then parse it to find the `href` attribute. There are many ways to do this, this example uses the built-in kses functionality, [as demonstrated by Otto](http://ottopress.com/2010/wp-quickie-kses/): ``` $post_link = get_the_permalink(); if ( preg_match('/<a...
13,450
<p>I'm listing all sidebars like that:</p> <pre><code>global $wp_registered_sidebars; echo '&lt;pre&gt;'; print_r($wp_registered_sidebars); echo '&lt;/pre&gt;' </code></pre> <p>So I'm getting something like:</p> <pre><code>Array ( [sidebar-1] =&gt; Array ( [name] =&gt; Sidebar #1 ...
[ { "answer_id": 13453, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 6, "selected": true, "text": "<h3>Loop through the global:</h3>\n\n<pre><code>&lt;select&gt;\n&lt;?php foreach ( $GLOBALS['wp_registered_sidebars'] a...
2011/03/29
[ "https://wordpress.stackexchange.com/questions/13450", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
I'm listing all sidebars like that: ``` global $wp_registered_sidebars; echo '<pre>'; print_r($wp_registered_sidebars); echo '</pre>' ``` So I'm getting something like: ``` Array ( [sidebar-1] => Array ( [name] => Sidebar #1 [id] => sidebar-1 [description] => Sideba...
### Loop through the global: ``` <select> <?php foreach ( $GLOBALS['wp_registered_sidebars'] as $sidebar ) { ?> <option value="<?php echo ucwords( $sidebar['id'] ); ?>"> <?php echo ucwords( $sidebar['name'] ); ?> </option> <?php } ?> </select> ``` Note: The `ucwords()` function is only th...
13,464
<p>I have a custom post type, called <code>articles</code>. I've also created a taxonomy called <code>subject</code>. Each article has a subject, just like posts have categories.</p> <p>Now to the problem. When I'm on the <code>page-articles.php</code> (<code>page-slug.php</code>), it has to check which subject the ar...
[ { "answer_id": 13466, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 0, "selected": false, "text": "<p>Have you tried using wp_get_object_terms?</p>\n\n<p>Something along the lines of</p>\n\n<pre><code>$article_subject...
2011/03/30
[ "https://wordpress.stackexchange.com/questions/13464", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4310/" ]
I have a custom post type, called `articles`. I've also created a taxonomy called `subject`. Each article has a subject, just like posts have categories. Now to the problem. When I'm on the `page-articles.php` (`page-slug.php`), it has to check which subject the article has. How can I do that?! I've been surfin' the w...
``` if( has_term( 'jazz', 'genre' ) ) { // do something } ``` <http://codex.wordpress.org/Function_Reference/has_term>
13,480
<p>Hi when i try to <code>get_terms();</code> in theme options via this code</p> <pre><code>$catalogs_terms = get_terms( 'catalogs' ); $mycatalogs = array( -1 =&gt; 'Select a catalog' ); if ( $catalogs_terms ) { foreach ( $catalogs_terms as $catalog_term ) { $mycatalogs[$catalog_term-&gt;term_id] ...
[ { "answer_id": 13482, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 4, "selected": true, "text": "<p>As i was mentioning before, it's a case of your term fetching occuring before the taxonomy has been registered.</...
2011/03/30
[ "https://wordpress.stackexchange.com/questions/13480", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3311/" ]
Hi when i try to `get_terms();` in theme options via this code ``` $catalogs_terms = get_terms( 'catalogs' ); $mycatalogs = array( -1 => 'Select a catalog' ); if ( $catalogs_terms ) { foreach ( $catalogs_terms as $catalog_term ) { $mycatalogs[$catalog_term->term_id] = $catalog_term->name; } ...
As i was mentioning before, it's a case of your term fetching occuring before the taxonomy has been registered. The init action occurs after the theme's functions file has been included, so if you're looking for terms directly in the functions file, you're doing so before they've actually been registered. Here's a po...
13,484
<p>I am creating a front end dashboard where I need to show all the posts by the current user. So, I need to show posts in all states, mainly <code>published</code>, <code>trashed</code> and the <code>pending</code>. I am now using a simple query but it is returning only the published posts.</p> <pre><code>$query = ar...
[ { "answer_id": 13489, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 8, "selected": true, "text": "<p>You can use the post_status parameter:</p>\n\n<pre><code>* 'publish' - a published post or page\n* 'pending' -...
2011/03/30
[ "https://wordpress.stackexchange.com/questions/13484", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3094/" ]
I am creating a front end dashboard where I need to show all the posts by the current user. So, I need to show posts in all states, mainly `published`, `trashed` and the `pending`. I am now using a simple query but it is returning only the published posts. ``` $query = array( 'post_type' => 'my-post-type', 'po...
You can use the post\_status parameter: ``` * 'publish' - a published post or page * 'pending' - post is pending review * 'draft' - a post in draft status * 'auto-draft' - a newly created post, with no content * 'future' - a post to publish in the future * 'private' - not visible to users who are not logged in * 'inhe...
13,485
<p>How can I get all subcategories from a certain category?</p>
[ { "answer_id": 13487, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 6, "selected": true, "text": "<p>Yes, you can use <a href=\"http://codex.wordpress.org/Function_Reference/get_categories\">get_categories()</a>...
2011/03/30
[ "https://wordpress.stackexchange.com/questions/13485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3030/" ]
How can I get all subcategories from a certain category?
Yes, you can use [get\_categories()](http://codex.wordpress.org/Function_Reference/get_categories) using `'child_of'` attribute. For example all sub categories of category with the ID of 17: ``` $args = array('child_of' => 17); $categories = get_categories( $args ); foreach($categories as $category) { echo '<p>Ca...
13,493
<p>Is it possible to specify two usergroups (e.g. admins and editors) into the admin menu capability field ? I tried the following but it doesnt work:</p> <pre><code>add_submenu_page( 'my-top-level-handle', 'Page title', 'Sub-menu title', array('administrator', 'editor'), 'my-submenu-handle',...
[ { "answer_id": 13500, "author": "Andy", "author_id": 498, "author_profile": "https://wordpress.stackexchange.com/users/498", "pm_score": 1, "selected": false, "text": "<p>As t31os said, you can use capabilities instead of roles there. One way to do this is to use core capabilities. (A mo...
2011/03/30
[ "https://wordpress.stackexchange.com/questions/13493", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2167/" ]
Is it possible to specify two usergroups (e.g. admins and editors) into the admin menu capability field ? I tried the following but it doesnt work: ``` add_submenu_page( 'my-top-level-handle', 'Page title', 'Sub-menu title', array('administrator', 'editor'), 'my-submenu-handle', 'my_magi...
Capability parameter of [add\_submenu\_page()](http://codex.wordpress.org/Function_Reference/add_submenu_page) function can only take a single capability, so if you are using the built in roles you can [select a capability fro the long list](http://codex.wordpress.org/Roles_and_Capabilities) that both administrators a...
13,520
<p>I am using the following code to display a list of posts within a category, but I want to display the title in it's own h2 tag above the list.</p> <pre><code>&lt;ul class="subcats-list"&gt; &lt;?php $weightloss = new WP_Query(); $weightloss-&gt;query('showposts=5&amp;include=4'); while ($weightloss-&gt;have_posts(...
[ { "answer_id": 13534, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 0, "selected": false, "text": "<p>It's not entirely clear what you're referring to, you asked how to get the title of category inside a custom loo...
2011/03/30
[ "https://wordpress.stackexchange.com/questions/13520", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4273/" ]
I am using the following code to display a list of posts within a category, but I want to display the title in it's own h2 tag above the list. ``` <ul class="subcats-list"> <?php $weightloss = new WP_Query(); $weightloss->query('showposts=5&include=4'); while ($weightloss->have_posts()) : $weightloss->the_post(); ?> ...
Since you already have the category ID (you use it in your call to `WP_Query::query()`), you can just use that to request the category name. [`get_cat_name( $cat_id )`](http://codex.wordpress.org/Function_Reference/get_cat_name) will do exactly that. It uses [`get_category( $cat_id )`](http://codex.wordpress.org/Functi...
13,522
<p>I am new to WordPress and I've seen this term passed around.</p>
[ { "answer_id": 13524, "author": "Dillie-O", "author_id": 1165, "author_profile": "https://wordpress.stackexchange.com/users/1165", "pm_score": 4, "selected": true, "text": "<p>\"Shortcode\" is a user friendly way of inserting various WordPress plugins/scripts into a page without having t...
2011/03/30
[ "https://wordpress.stackexchange.com/questions/13522", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2440/" ]
I am new to WordPress and I've seen this term passed around.
"Shortcode" is a user friendly way of inserting various WordPress plugins/scripts into a page without having to know a lot of fancy HTML/JavaScript/PHP in order to make it happen. Take, for example, embedding an mp3 file into a post on a hosted WordPress site. Instead of having to setup the proper code for a flash pla...
13,535
<p>I want to keep a check if the user has a particular password, so I have been trying it with <code>wp_check_password</code> but the account for which it is checked gets logged out and can't login again till there is a call of <code>wp_check_password</code> in the code.</p> <p>Digging into the code, I found out that ...
[ { "answer_id": 13536, "author": "goldenapples", "author_id": 290, "author_profile": "https://wordpress.stackexchange.com/users/290", "pm_score": 2, "selected": false, "text": "<p>You can grab their hashed password from the database, and compare it to the entry you want to check using <a ...
2011/03/30
[ "https://wordpress.stackexchange.com/questions/13535", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1521/" ]
I want to keep a check if the user has a particular password, so I have been trying it with `wp_check_password` but the account for which it is checked gets logged out and can't login again till there is a call of `wp_check_password` in the code. Digging into the code, I found out that it sets the password by using th...
Your example works correctly. You are checking if password `hello` matches hashed `hello` - which it naturally does. Hadn't thought it through. Your example causes following issue: 1. You check if `hello` matches md5 of `hello` (instead of hash from user's profile). 2. It does and then WP thinks this is correct, but ...
13,539
<p><a href="https://wordpress.stackexchange.com/q/13501/3966">As suggested in this question</a>, I am adding this topic as a new question, for community discussion/voting regarding best-practices for Plugin/Theme security.</p> <p>Here is the starting checklist, based on my current (work-in-progress) settings/data secu...
[ { "answer_id": 13540, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<h2>Prefix function and variable names</h2>\n\n<p>Plugins should prefix all options, custom functions, custom ...
2011/03/30
[ "https://wordpress.stackexchange.com/questions/13539", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3966/" ]
[As suggested in this question](https://wordpress.stackexchange.com/q/13501/3966), I am adding this topic as a new question, for community discussion/voting regarding best-practices for Plugin/Theme security. Here is the starting checklist, based on my current (work-in-progress) settings/data security checklist used f...
Sanitize, validate and escape data ---------------------------------- **Sanitize anything that could get in and out of (!) the database both front end and back end!** Plugins and Themes should perform proper data validation: 1. **Validate** and **sanitize** all untrusted data before entering data into the database 2...
13,560
<p>In the course of converting a blog from Blogger to WP and running a script to grab hot-linked images for hosting, I ended up with some funky images names like</p> <pre><code>act%252Bapandas-210x290.png </code></pre> <p>These image names prevent the image from displaying on a webpage, due the url encoding ending up...
[ { "answer_id": 13561, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>General idea would be to loop through all attachments to retrieve, modify and write back their meta.</p>\n\n<p>Someth...
2011/03/30
[ "https://wordpress.stackexchange.com/questions/13560", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4258/" ]
In the course of converting a blog from Blogger to WP and running a script to grab hot-linked images for hosting, I ended up with some funky images names like ``` act%252Bapandas-210x290.png ``` These image names prevent the image from displaying on a webpage, due the url encoding ending up in the file name itself (...
General idea would be to loop through all attachments to retrieve, modify and write back their meta. Something like this (test thoroughly before using on anything important): ``` $posts = get_posts(array( 'post_type' => 'attachment', 'numberposts' => -1, )); foreach( $posts as $post ) { // retrieve data...
13,564
<p>hey all,<br> i'm writing an automated function that generates a menu from a function. it calls wp_nav_menu on each item from an array, because i want this to be dynamic. the problem is, no matter how i set it, if the menu doesn't exist, wp_nav_menu is generating a menu, eg the 'default'. here is my code (items is ju...
[ { "answer_id": 13577, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>Try wrapping your echo inside of a <code>has_nav_menu()</code> conditional:</p>\n\n<pre><code>for($i=0;$i&l...
2011/03/30
[ "https://wordpress.stackexchange.com/questions/13564", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3000/" ]
hey all, i'm writing an automated function that generates a menu from a function. it calls wp\_nav\_menu on each item from an array, because i want this to be dynamic. the problem is, no matter how i set it, if the menu doesn't exist, wp\_nav\_menu is generating a menu, eg the 'default'. here is my code (items is ju...
`wp_nav_menu()` indeed tries a lot to provide you with a menu, and `fallback_cb` is only executed when nothing else works. [From the code](http://core.trac.wordpress.org/browser/tags/3.1/wp-includes/nav-menu-template.php#L148): * If `menu` is provided and refers to an existing menu (looked up via [`wp_get_nav_menu_obj...
13,591
<p>I wanted to clone one wordpress blog I own into another domain .. I simply downloaded the root folder with all the files from Site1 and uploaded to Site2.. and created a complete MySQL script of Site1 and executed in Site2 DB.. Everything in the user side is working fine but if I got to Site2/wp-admin, its automatic...
[ { "answer_id": 13592, "author": "zeo", "author_id": 1241, "author_profile": "https://wordpress.stackexchange.com/users/1241", "pm_score": 1, "selected": false, "text": "<p>Here's 1 way to fix this. Add below inside Site2 wp-config.php:</p>\n\n<pre><code>define('WP_SITEURL', 'http://Site2...
2011/03/31
[ "https://wordpress.stackexchange.com/questions/13591", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4337/" ]
I wanted to clone one wordpress blog I own into another domain .. I simply downloaded the root folder with all the files from Site1 and uploaded to Site2.. and created a complete MySQL script of Site1 and executed in Site2 DB.. Everything in the user side is working fine but if I got to Site2/wp-admin, its automaticall...
Here's 1 way to fix this. Add below inside Site2 wp-config.php: ``` define('WP_SITEURL', 'http://Site2'); define('WP_HOME', 'http://Site2'); ``` Once logged in, go to Settings > General and change WordPress address (URL), Site address (URL) to Site2. Then delete those 2 lines that you add inside wp-config.php.
13,604
<p>I am currently using a custom walker to customize the output of <code>wp_nav_menu()</code>, and I am trying to add additional information to the <code>&lt;a&gt;</code> tags.</p> <p>What I want the output for each menu link to look like is:</p> <pre><code>&lt;a class="boxPAGEID" href="#"&gt;About Me Page&lt;/a&gt; ...
[ { "answer_id": 13614, "author": "Serdar Buyuktemiz", "author_id": 4346, "author_profile": "https://wordpress.stackexchange.com/users/4346", "pm_score": -1, "selected": false, "text": "<p>I could not look at your code deeply but for creating menu maybe you should use get_pages..</p>\n\n<p...
2011/03/31
[ "https://wordpress.stackexchange.com/questions/13604", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4285/" ]
I am currently using a custom walker to customize the output of `wp_nav_menu()`, and I am trying to add additional information to the `<a>` tags. What I want the output for each menu link to look like is: ``` <a class="boxPAGEID" href="#">About Me Page</a> ``` Where `PAGEID` is the ID of the page I'm linking to. T...
The page ID (or object ID, since a menu item can link to any object) is stored in the `postmeta` table, with the key `_menu_item_object_id`. So you can get the page ID with the following code: ``` get_post_meta( $item->ID, '_menu_item_object_id', true ); ```
13,608
<p>We have a custom type <code>music</code>.</p> <pre><code>/music/ /music/post-name/ </code></pre> <p>Also, we have a tag-like taxonomy <code>genres</code>. Its urls are:</p> <pre><code>/music-genres/genre-name/ </code></pre> <p>I'm trying to make urls like:</p> <pre><code>/music/ /music/post-name/ /music/genres/...
[ { "answer_id": 13619, "author": "Roman", "author_id": 3817, "author_profile": "https://wordpress.stackexchange.com/users/3817", "pm_score": 1, "selected": false, "text": "<p>Maybe you can find some information on this post:\n<a href=\"https://wordpress.stackexchange.com/questions/5308/cu...
2011/03/31
[ "https://wordpress.stackexchange.com/questions/13608", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/876/" ]
We have a custom type `music`. ``` /music/ /music/post-name/ ``` Also, we have a tag-like taxonomy `genres`. Its urls are: ``` /music-genres/genre-name/ ``` I'm trying to make urls like: ``` /music/ /music/post-name/ /music/genres/ /music/genres/genre-name/ ``` `/music-genres/` should be replaced by `/music/ge...
Yes, this is possible, because your `genres` structure is `/music/genres/[genre-name]`. If it was `/music/[genre-name]` it would be complicated because it would conflict with `/music/[post-name]`. You just have to keep the order in mind. The rewrite rules should be ordered from most specific to least specific. If you ...
13,611
<p>i have a stupid situation, where i somehow can't find a solution and would really need some help!</p> <p>So... i'm working on a project, where i have in addition to Post and Pages two Custom post types: Photos and Events.</p> <p>I have created a custom taxonomy named "Tags". This taxonomy is applied to Post, Pages...
[ { "answer_id": 13612, "author": "Sarah Neuber", "author_id": 4302, "author_profile": "https://wordpress.stackexchange.com/users/4302", "pm_score": 0, "selected": false, "text": "<p>Have you seen this: <a href=\"http://wordpress.org/support/topic/passing-current-single_tag_title-as-variab...
2011/03/31
[ "https://wordpress.stackexchange.com/questions/13611", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4344/" ]
i have a stupid situation, where i somehow can't find a solution and would really need some help! So... i'm working on a project, where i have in addition to Post and Pages two Custom post types: Photos and Events. I have created a custom taxonomy named "Tags". This taxonomy is applied to Post, Pages, Photos and Even...
To use the built-in tag functionality with a custom post type, you need to add this argument when registering your post type: ``` 'taxonomies' => array( 'post_tag' ), ``` So to register a post type events, you'd do (eg): ``` register_post_type( 'events', array( 'show_ui' => true, 'taxonomies' => array( 'pos...
13,625
<p>How can I debug problems with WordPress Cron? I think it will trigger when users go to your site but any errors wont be shown to them, as the jobs are run "asynchronously". So how might I debug errors?</p> <p>I use <a href="http://codex.wordpress.org/Function_Reference/wp_schedule_event"><code>wp schedule event</co...
[ { "answer_id": 13629, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>You can (and probably should in any case, cron or not) <a href=\"http://codex.wordpress.org/Editing_wp-config.php#Co...
2011/03/31
[ "https://wordpress.stackexchange.com/questions/13625", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/794/" ]
How can I debug problems with WordPress Cron? I think it will trigger when users go to your site but any errors wont be shown to them, as the jobs are run "asynchronously". So how might I debug errors? I use [`wp schedule event`](http://codex.wordpress.org/Function_Reference/wp_schedule_event)
You can run WP cron manually by calling: `http://example.com/wp-cron.php?doing_wp_cron` If you don't want the automatic cron to run while you're debugging, then add this to your `/wp-config.php` file: ``` define('DISABLE_WP_CRON', true); ``` If you're on a development environment and want to output debug informatio...
13,630
<p>Hey all, I see that get_the_excerpt() echoes the post excerpt if it is manually set, but not if it is automatically generated (with just the 55 words, for example). [and its use is deprecated]</p> <p>the_excerpt() on the other hand, echoes directly without giving me a string in return.</p> <p>Is there a function t...
[ { "answer_id": 13632, "author": "ramayac", "author_id": 2507, "author_profile": "https://wordpress.stackexchange.com/users/2507", "pm_score": 3, "selected": true, "text": "<p>Sure thing my friend, you see, the function \"the_excerpt\" (located at \"WORDPRESSINSTALLDIR/wp-includes/post-te...
2011/03/31
[ "https://wordpress.stackexchange.com/questions/13630", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4017/" ]
Hey all, I see that get\_the\_excerpt() echoes the post excerpt if it is manually set, but not if it is automatically generated (with just the 55 words, for example). [and its use is deprecated] the\_excerpt() on the other hand, echoes directly without giving me a string in return. Is there a function to return the e...
Sure thing my friend, you see, the function "the\_excerpt" (located at "WORDPRESSINSTALLDIR/wp-includes/post-template.php") is the one that makes the echo: ``` function the_excerpt() { echo apply_filters('the_excerpt', get_the_excerpt()); } ``` so, what you want is to use the same function "apply\_filters"...
13,636
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://wordpress.stackexchange.com/questions/13173/can-i-add-pages-to-my-custom-menu-via-script">Can I add pages to my custom menu via script?</a> </p> </blockquote> <p>My theme has a custom menu called "Custom Header Menu" and i've got a plugin...
[ { "answer_id": 13639, "author": "Roman", "author_id": 3817, "author_profile": "https://wordpress.stackexchange.com/users/3817", "pm_score": 1, "selected": false, "text": "<p>Can you post the name of your plugin? Maybe someone has already a solution for this specific question. </p>\n\n<p>...
2011/03/31
[ "https://wordpress.stackexchange.com/questions/13636", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
> > **Possible Duplicate:** > > [Can I add pages to my custom menu via script?](https://wordpress.stackexchange.com/questions/13173/can-i-add-pages-to-my-custom-menu-via-script) > > > My theme has a custom menu called "Custom Header Menu" and i've got a plugin that sets up site defaults and creates my static p...
I guess it doesn't need anymore explanation: ``` $mymenu = wp_get_nav_menu_object('Main Navigation Menu'); $menuID = (int) $mymenu->term_id; $myPage = get_page_by_title('About Us'); $itemData = array( 'menu-item-object-id' => $myPage->ID, 'menu-item-parent-id' => 0, 'menu-item-position' => 2, 'menu-...
13,650
<p>I want to add <code>&lt;code&gt;</code> tag to my post, easily. For example, Adding code is very easily in Stackoverflow and other sites. Basically, we can add codes between apostrophes (``) I need something like that for Wordpress .</p> <p>Maybe i can use shortcode function for this. </p> <p>For example : <code>[...
[ { "answer_id": 13653, "author": "John P Bloch", "author_id": 11, "author_profile": "https://wordpress.stackexchange.com/users/11", "pm_score": 3, "selected": true, "text": "<p>I'd suggest using <a href=\"http://wordpress.org/extend/plugins/syntaxhighlighter/\" rel=\"nofollow noreferrer\"...
2011/03/31
[ "https://wordpress.stackexchange.com/questions/13650", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3552/" ]
I want to add `<code>` tag to my post, easily. For example, Adding code is very easily in Stackoverflow and other sites. Basically, we can add codes between apostrophes (``) I need something like that for Wordpress . Maybe i can use shortcode function for this. For example : `[code="<b>Hello</b>"]` will show exactly...
I'd suggest using [Syntax Highlighter Evolved](http://wordpress.org/extend/plugins/syntaxhighlighter/). It's by Viper007Bond. You can use it like this: ``` [sourcecode lang="php"] <?php echo 'Hello World!'; ?> [/sourcecode] ``` Or even like this: ``` [php] <?php echo 'Hello World!'; ?> [/php] ``` A screenshot: !...
13,659
<p>I am having trouble adding a list box to the TinyMCE editor in Wordpress. I have already read entirely through this question but it did not get me all the way there: <a href="https://wordpress.stackexchange.com/questions/13246/how-i-can-i-add-a-split-button-or-list-box-to-the-wordpress-tinymce-instance">How i can i ...
[ { "answer_id": 13653, "author": "John P Bloch", "author_id": 11, "author_profile": "https://wordpress.stackexchange.com/users/11", "pm_score": 3, "selected": true, "text": "<p>I'd suggest using <a href=\"http://wordpress.org/extend/plugins/syntaxhighlighter/\" rel=\"nofollow noreferrer\"...
2011/03/31
[ "https://wordpress.stackexchange.com/questions/13659", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/274/" ]
I am having trouble adding a list box to the TinyMCE editor in Wordpress. I have already read entirely through this question but it did not get me all the way there: [How i can i add a split button or list box to the WordPress TinyMCE instance](https://wordpress.stackexchange.com/questions/13246/how-i-can-i-add-a-split...
I'd suggest using [Syntax Highlighter Evolved](http://wordpress.org/extend/plugins/syntaxhighlighter/). It's by Viper007Bond. You can use it like this: ``` [sourcecode lang="php"] <?php echo 'Hello World!'; ?> [/sourcecode] ``` Or even like this: ``` [php] <?php echo 'Hello World!'; ?> [/php] ``` A screenshot: !...
13,671
<p>I'm using the TwentyTen theme to create a child theme, but I can't seem to get rid of the 'One column, no sidebar' page template that is in the TwentyTen parent theme.</p> <p>I thought just copying it over and deleting the contents would do the trick, but it seems not. Does anyone know how to do this? I'm sure it's...
[ { "answer_id": 13675, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 5, "selected": true, "text": "<p>Overriding that template would be much easier than getting rid of it. Just the way logic goes.</p>\n\n<p>I make no cl...
2011/03/31
[ "https://wordpress.stackexchange.com/questions/13671", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2685/" ]
I'm using the TwentyTen theme to create a child theme, but I can't seem to get rid of the 'One column, no sidebar' page template that is in the TwentyTen parent theme. I thought just copying it over and deleting the contents would do the trick, but it seems not. Does anyone know how to do this? I'm sure it's very simp...
Overriding that template would be much easier than getting rid of it. Just the way logic goes. I make no claim it's efficient idea (late here), but this would get it nuked from edit screen: ``` add_action('admin_head-post.php','remove_template'); function remove_template() { global $wp_themes; get_themes()...
13,688
<p>I need to create a Wordpress Custorm Post Type with the following fields, I am not a developer and would appreciate a cut and paste. The Fields are:</p> <p>Contact Person, Address, Telephone, Cellphone, Fax, Email, Website</p> <p>HELP</p>
[ { "answer_id": 13695, "author": "Xavier", "author_id": 4369, "author_profile": "https://wordpress.stackexchange.com/users/4369", "pm_score": 2, "selected": false, "text": "<p>I think you have misunderstood what Custom Post Types are used for, if your trying to gather data try a plugin ca...
2011/04/01
[ "https://wordpress.stackexchange.com/questions/13688", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4366/" ]
I need to create a Wordpress Custorm Post Type with the following fields, I am not a developer and would appreciate a cut and paste. The Fields are: Contact Person, Address, Telephone, Cellphone, Fax, Email, Website HELP
I think you have misunderstood what Custom Post Types are used for, if your trying to gather data try a plugin called Contact-Form-7 or if you want to post data then try using custom fields with the name of Contact Person, Address, Telephone, Cellphone, Fax, Email, Website. You can echo custom fields into your theme f...
13,690
<p>Hi im looking at hardcoding a wp plugin into a theme, the plugin is <a href="http://wordpress.org/extend/plugins/amr-clearskys-availability-modification-for-27/" rel="nofollow">Calendar</a>.</p> <p>This is what i have done as of yet:</p> <p>1) Moved files from wp-content/plugins into a folder within theme folder a...
[ { "answer_id": 13695, "author": "Xavier", "author_id": 4369, "author_profile": "https://wordpress.stackexchange.com/users/4369", "pm_score": 2, "selected": false, "text": "<p>I think you have misunderstood what Custom Post Types are used for, if your trying to gather data try a plugin ca...
2011/04/01
[ "https://wordpress.stackexchange.com/questions/13690", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3710/" ]
Hi im looking at hardcoding a wp plugin into a theme, the plugin is [Calendar](http://wordpress.org/extend/plugins/amr-clearskys-availability-modification-for-27/). This is what i have done as of yet: 1) Moved files from wp-content/plugins into a folder within theme folder and made the changes so that paths are follo...
I think you have misunderstood what Custom Post Types are used for, if your trying to gather data try a plugin called Contact-Form-7 or if you want to post data then try using custom fields with the name of Contact Person, Address, Telephone, Cellphone, Fax, Email, Website. You can echo custom fields into your theme f...
13,694
<p>i hope you are well today,</p> <p>My question is just breif i am trying to query from a custom post type by a certain taxonomy only;</p> <p>to keep it streamline lets use the below as an example;</p> <p><strong>Custom Post Type:</strong> <em>'Products';</em></p> <p><strong>Taxonomy:</strong> <em>'Categories';</e...
[ { "answer_id": 13696, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 5, "selected": true, "text": "<p>There are 3 ways of doing that:</p>\n\n<p>a)</p>\n\n<pre><code>...\n'category_name' =&gt; 'category-1'\n...\n</code>...
2011/04/01
[ "https://wordpress.stackexchange.com/questions/13694", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4369/" ]
i hope you are well today, My question is just breif i am trying to query from a custom post type by a certain taxonomy only; to keep it streamline lets use the below as an example; **Custom Post Type:** *'Products';* **Taxonomy:** *'Categories';* **Categories within 'Categories';** *(1) Category 1 (2) Category 2...
There are 3 ways of doing that: a) ``` ... 'category_name' => 'category-1' ... ``` b) ``` ... 'taxonomy' => 'category', 'term' => 'category-1', ... ``` c) ``` ... 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => array( 'category-1' ) ) ) ... ``` More info: <http://codex...
13,707
<p>First plugin, basic question... I am trying to print the variable <code>$xavi</code> from a <strong>plugin</strong> into a theme like this:</p> <pre><code>add_action('init', '_load_options'); function _load_options() { global $xavi; } </code></pre> <p>So that I can use it in a <strong>theme</strong> file like t...
[ { "answer_id": 13708, "author": "JanWillem", "author_id": 2356, "author_profile": "https://wordpress.stackexchange.com/users/2356", "pm_score": 0, "selected": false, "text": "<p>You can use functions in themes. If I'm correct you can add the following in your template:</p>\n\n<pre><code>...
2011/04/01
[ "https://wordpress.stackexchange.com/questions/13707", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4217/" ]
First plugin, basic question... I am trying to print the variable `$xavi` from a **plugin** into a theme like this: ``` add_action('init', '_load_options'); function _load_options() { global $xavi; } ``` So that I can use it in a **theme** file like this: ``` <?=$xavi;?> ``` It doesn't look like [`init`](http:...
Your webhost has disabled `register_globals` in the **php.ini**, so you have to "register" your variables manually everytime you want to use it. For example: ``` <?php global $xavi; echo $xavi; ?> ``` Another approach is using the `$GLOBALS` array: ``` <?php echo $GLOBALS['xavi']; ?> ``` But in my opinion, you sh...
13,714
<p>(sorry for my english) in my theme I Breadcrumbs function. I would like to exclude the categories, can you help me? here's the code:</p> <pre><code> function the_breadcrumb() { global $post; if (!is_home()) { echo '&lt;a href="'.get_option('home').'"&gt;'.home.'&lt;/a&gt;'; if (is_category()) { ...
[ { "answer_id": 13716, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>Change this</p>\n\n<pre><code>if (is_category()) {\n echo \" / \";\n echo single_cat_title();\n} elseif(is_sin...
2011/04/01
[ "https://wordpress.stackexchange.com/questions/13714", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3897/" ]
(sorry for my english) in my theme I Breadcrumbs function. I would like to exclude the categories, can you help me? here's the code: ``` function the_breadcrumb() { global $post; if (!is_home()) { echo '<a href="'.get_option('home').'">'.home.'</a>'; if (is_category()) { echo " / "; ech...
You should use [get\_categories](http://codex.wordpress.org/Function_Reference/get_categories). It supports an exclude argument.
13,726
<p>How would I add the capability in Simple Twitter Connect (in the stc-publish.php file) to not tweet pages, either newly published or edited? I don't need it to be an admin option, just a change for a few of my sites.</p> <p>It looks like this function would be a good place to add the "don't tweet pages" capabilty (...
[ { "answer_id": 13719, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>I think that it is a bad idea two have considerably different interfaces stuffed together.</p>\n\n<p>WP admin area i...
2011/04/01
[ "https://wordpress.stackexchange.com/questions/13726", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/268/" ]
How would I add the capability in Simple Twitter Connect (in the stc-publish.php file) to not tweet pages, either newly published or edited? I don't need it to be an admin option, just a change for a few of my sites. It looks like this function would be a good place to add the "don't tweet pages" capabilty (while reta...
Custom UI is great where it improves the experience and makes the task easier. After all, a plugin extends WordPress and therefore a lot of the time is extending the user interface. This might mean a screen that is arranged completely differently to any other screen, but if it is logical and understandable then there's...
13,729
<p>The tinyMCE "kitchen sink" toggle button shows/hides a row of buttons. I have successfully added my row of shortcode buttons to the tinyMCE editor, but I was wondering if there was a way to make my row only display when the kitchen sink button is clicked. I don't want to add the buttons directly to the kitchen sink ...
[ { "answer_id": 13731, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": true, "text": "<p>Yes!</p>\n\n<ul>\n<li>Use the <code>mce_buttons_2</code> filter to add\nbuttons to the <em>second</em> row. ...
2011/04/01
[ "https://wordpress.stackexchange.com/questions/13729", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/274/" ]
The tinyMCE "kitchen sink" toggle button shows/hides a row of buttons. I have successfully added my row of shortcode buttons to the tinyMCE editor, but I was wondering if there was a way to make my row only display when the kitchen sink button is clicked. I don't want to add the buttons directly to the kitchen sink row...
Yes! * Use the `mce_buttons_2` filter to add buttons to the *second* row. * Use the `mce_buttons_3` filter to add buttons to the *third* row. Here's an example of what I use: ``` function mytheme_mce_buttons_row_3($buttons) { $buttons[] = 'fontselect'; $buttons[] = 'fontsizeselect'; $buttons[] = 'cod...
13,738
<p>I don't even know where to start with this one. I'm using a theme that requires me to override server php.ini settings in my own php.ini with <code>allow_url_include = on</code></p> <p>That setting at very least seems to be a security risk, according to many (and my webhost) at most it requires some other users on ...
[ { "answer_id": 13739, "author": "Matteo Riva", "author_id": 745, "author_profile": "https://wordpress.stackexchange.com/users/745", "pm_score": 1, "selected": false, "text": "<p>Requiring <code>allow_url_include</code> seems quite weird for a theme, I can't think of a reason for it to be...
2011/04/01
[ "https://wordpress.stackexchange.com/questions/13738", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/268/" ]
I don't even know where to start with this one. I'm using a theme that requires me to override server php.ini settings in my own php.ini with `allow_url_include = on` That setting at very least seems to be a security risk, according to many (and my webhost) at most it requires some other users on some other hosts to a...
Okay, first off, that's an incredibly badly made theme. Your item number 2 there indicates to me that he making AJAX calls in entirely the wrong way. Secondly, look for anything in the theme that is using http but not in a link. allow\_url\_include basically lets you include some PHP from a remote site, which is indee...
13,749
<p>I've followed a tutorial on Nettuts on how to add a custom button to TinyMCE (<a href="http://net.tutsplus.com/tutorials/wordpress/wordpress-shortcodes-the-right-way/">http://net.tutsplus.com/tutorials/wordpress/wordpress-shortcodes-the-right-way/</a>)</p> <p>It works great and all, but i want to add many buttons a...
[ { "answer_id": 13760, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 3, "selected": true, "text": "<p>First add your additional buttons inside the buttons callback..</p>\n\n<pre><code>function register_button($butto...
2011/04/02
[ "https://wordpress.stackexchange.com/questions/13749", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4380/" ]
I've followed a tutorial on Nettuts on how to add a custom button to TinyMCE (<http://net.tutsplus.com/tutorials/wordpress/wordpress-shortcodes-the-right-way/>) It works great and all, but i want to add many buttons and i wonder if there's a smart way to do this without having to duplicate all the code over and over. ...
First add your additional buttons inside the buttons callback.. ``` function register_button($buttons) { array_push($buttons, "quote","wpse-rules"); return $buttons; } ``` Then add additional buttons function inside the plugin javascript.. ``` init : function(ed, url) { ed.addButton('quote...
13,764
<p>This has me stumped for a while already. Either I am missing something very obvious or something very not obvious. I am also not entirely sure if this has something to do with WP or purely PHP mechanics at work.</p> <pre><code>function test() { global $wp_query; var_dump($wp_query == $GLOBALS['wp_query']);...
[ { "answer_id": 13765, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<h2>Update with a better example</h2>\n\n<pre><code>header( 'Content-Type: text/plain;charset=utf-8' );\nerror_reporting( ...
2011/04/02
[ "https://wordpress.stackexchange.com/questions/13764", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/847/" ]
This has me stumped for a while already. Either I am missing something very obvious or something very not obvious. I am also not entirely sure if this has something to do with WP or purely PHP mechanics at work. ``` function test() { global $wp_query; var_dump($wp_query == $GLOBALS['wp_query']); } function ...
Update with a better example ---------------------------- ``` header( 'Content-Type: text/plain;charset=utf-8' ); error_reporting( E_ALL | E_STRICT ); function failed_unset() { // Copy the variable to the local namespace. global $foo; // Change the value. $foo = 2; // Remove the variable. unse...
13,768
<p>For some reason when i try to put like a embeded video my video has slashes inside the code, but if I add it in the template itself then the code is fine i was told its "escaping quotes" anyhow this is what i have.</p> <p>Functions file</p> <pre><code>&lt;?php add_action ( 'edit_category_form_fields', 'extra_c...
[ { "answer_id": 13770, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>If I remember right WordPress emulates magic quotes in any case and disregards server setting for them. But this is ...
2011/04/02
[ "https://wordpress.stackexchange.com/questions/13768", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2635/" ]
For some reason when i try to put like a embeded video my video has slashes inside the code, but if I add it in the template itself then the code is fine i was told its "escaping quotes" anyhow this is what i have. Functions file ``` <?php add_action ( 'edit_category_form_fields', 'extra_category_fields'); fu...
WordPress emulates magic\_quotes\_gpc and won't be deprecating this for some time due to concerns over plugin security and backward compatibility. To work around this, you need to use stripslashes() or, if you need to strip slashes when data arrives via $\_POST, $\_GET, $\_COOKIE, and $\_REQUEST arrays, you can use t...
13,777
<p>I had recently moved my wp site from a domain to other, but when I type in the new domain's address it gets redirected to the old domain/some_page.</p> <p>Is this any common problem? Is there any known solution to this?</p> <p>I had checked my code and it has no redirects to this page. Can someone give me a hand...
[ { "answer_id": 13778, "author": "Jeremy Visser", "author_id": 27470, "author_profile": "https://wordpress.stackexchange.com/users/27470", "pm_score": 5, "selected": true, "text": "<p>This is because the URL settings inside WordPress are still pointing to the old WordPress site. More info...
2011/04/02
[ "https://wordpress.stackexchange.com/questions/13777", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4416/" ]
I had recently moved my wp site from a domain to other, but when I type in the new domain's address it gets redirected to the old domain/some\_page. Is this any common problem? Is there any known solution to this? I had checked my code and it has no redirects to this page. Can someone give me a hand on this?
This is because the URL settings inside WordPress are still pointing to the old WordPress site. More information is available in the [Moving WordPress](https://wordpress.org/support/article/moving-wordpress/) documentation. If your WordPress admin pages are still working, you can go to Settings → General, and change t...
13,782
<p>I've got a default main menu:</p> <pre><code>wp_nav_menu(); </code></pre> <p>But it gives a list of links in a form:</p> <pre><code>(...) &lt;a href="link" title="PageName"&gt;PageName&lt;/a&gt; (...) </code></pre> <p>The very important question is, how to force WP to display it like:</p> <pre><code> (...) ...
[ { "answer_id": 13783, "author": "MikeSchinkel", "author_id": 89, "author_profile": "https://wordpress.stackexchange.com/users/89", "pm_score": 1, "selected": false, "text": "<p>I'm pretty sure if you clear the <em>\"Title Attribute\"</em> field in the <code>Appearance &gt; Menu</code> ed...
2011/04/03
[ "https://wordpress.stackexchange.com/questions/13782", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
I've got a default main menu: ``` wp_nav_menu(); ``` But it gives a list of links in a form: ``` (...) <a href="link" title="PageName">PageName</a> (...) ``` The very important question is, how to force WP to display it like: ``` (...) <a href="link">PageName</a> (...) ``` I don't like the yellow boxes ...
The title is an accessibility attribute that helps users with screen readers. It is part of the recommended WC3 standard for navigation items. Just think about that before you decide to eliminate it because you find it annoying. Rather than modifying the PHP code, you could think about removing it after it's loaded. I...
13,794
<p>I try to save an option from the frontend but i can't find yet how to do it.<br> So, the idea is to give the blog owner a simple form with a dropdown that can select a different stylesheet.css. I have build it for the wp-admin area and it works fine, but i want to do the same in the frontend,</p> <p>i have tried to...
[ { "answer_id": 13799, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 1, "selected": false, "text": "<p>Maybe <a href=\"http://wordpress.org/extend/plugins/theme-switcher-reloaded/\" rel=\"nofollow\">Theme Switcher Reloa...
2011/04/03
[ "https://wordpress.stackexchange.com/questions/13794", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2048/" ]
I try to save an option from the frontend but i can't find yet how to do it. So, the idea is to give the blog owner a simple form with a dropdown that can select a different stylesheet.css. I have build it for the wp-admin area and it works fine, but i want to do the same in the frontend, i have tried to include th...
**You Do Not want to post /wp-admin/options.php from the front end** , thats a bad idea and can cause problems. To updated Options from the frontend simply use update\_option() and make sure you verify correctly. here is an example using your code with minor fixes: ``` <?php if (isset($_POST['stylesheet']) && i...
13,798
<p>Hey guys, I simply want to prevent the creation of empty paragraphs in my wordpress post. That happens quite often when trying to manually space content.</p> <p>I don't know why this doesn't take effect?</p> <pre><code>/*Remove empty paragraph tags from the_content*/ function removeEmptyParagraphs($content) { ...
[ { "answer_id": 13806, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 6, "selected": true, "text": "<p>WordPress will automatically insert <code>&lt;p&gt;</code> and <code>&lt;/p&gt;</code> tags which separate con...
2011/04/03
[ "https://wordpress.stackexchange.com/questions/13798", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
Hey guys, I simply want to prevent the creation of empty paragraphs in my wordpress post. That happens quite often when trying to manually space content. I don't know why this doesn't take effect? ``` /*Remove empty paragraph tags from the_content*/ function removeEmptyParagraphs($content) { /*$pattern = "/<p[^>...
WordPress will automatically insert `<p>` and `</p>` tags which separate content breaks within a post or page. If, for some reason, you want or need to remove these, you can use either of the following code snippets. To completely disable the wpautop filter, you can use: ``` remove_filter('the_content', 'wpautop'); ...
13,803
<p>Hiya Guys! so I need some help with this:</p> <pre><code> &lt;?php $newsposts = new WP_Query('cat=restaurant'); if ( is_front_page()) { echo '&lt;h3 class="member-review"&gt;Latest Restaurants&lt;/h3&gt; &lt;div id="extra"&gt;if ($newsposts-&gt;have_posts()) : while ($newsposts...
[ { "answer_id": 13807, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": true, "text": "<p>you can't run code inside quote since php treats it as string, try this:</p>\n\n<pre><code>&lt;?php\n $news...
2011/04/03
[ "https://wordpress.stackexchange.com/questions/13803", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4179/" ]
Hiya Guys! so I need some help with this: ``` <?php $newsposts = new WP_Query('cat=restaurant'); if ( is_front_page()) { echo '<h3 class="member-review">Latest Restaurants</h3> <div id="extra">if ($newsposts->have_posts()) : while ($newsposts->have_posts()) : $newsposts->the_post...
you can't run code inside quote since php treats it as string, try this: ``` <?php $newsposts = new WP_Query('cat=restaurant'); if ( is_front_page()) { echo '<h3 class="member-review">Latest Restaurants</h3> <div id="extra">'; if ($newsposts->have_posts()) : while ($newsposts->have_pos...
13,810
<pre><code>&lt;?php echo do_shortcode('[mingleforum]'); ?&gt; </code></pre> <p>inserts the mingle forum into my content!</p> <p>is it possible to use add_filter() on that?</p>
[ { "answer_id": 13813, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>You can change your code to this:</p>\n\n<pre><code>&lt;?php\n$shortcode = do_shortcode('[mingleforum]');\nech...
2011/04/03
[ "https://wordpress.stackexchange.com/questions/13810", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
``` <?php echo do_shortcode('[mingleforum]'); ?> ``` inserts the mingle forum into my content! is it possible to use add\_filter() on that?
You can change your code to this: ``` <?php $shortcode = do_shortcode('[mingleforum]'); echo apply_filters('my_new_filter',$shortcode); ?> ``` and then you can interact with that filter ``` add_filter('my_new_filter','my_new_filter_callback'); function my_new_filter_callback($shortcode){ //to stuff here re...
13,816
<p>I need to call this bit of PHP when a file is uploaded, deleted or edited. </p> <p>$output = shell_exec("bash ./upload.sh"); echo $output;</p> <p>I can't seem to find the right code to execute this when any of the above happen. Examples and help would be greatly appreciated. </p>
[ { "answer_id": 13813, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>You can change your code to this:</p>\n\n<pre><code>&lt;?php\n$shortcode = do_shortcode('[mingleforum]');\nech...
2011/04/03
[ "https://wordpress.stackexchange.com/questions/13816", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I need to call this bit of PHP when a file is uploaded, deleted or edited. $output = shell\_exec("bash ./upload.sh"); echo $output; I can't seem to find the right code to execute this when any of the above happen. Examples and help would be greatly appreciated.
You can change your code to this: ``` <?php $shortcode = do_shortcode('[mingleforum]'); echo apply_filters('my_new_filter',$shortcode); ?> ``` and then you can interact with that filter ``` add_filter('my_new_filter','my_new_filter_callback'); function my_new_filter_callback($shortcode){ //to stuff here re...
13,817
<p>This should be easy. I need to query to display one page in a tab. Just pull one page by one query, but I'm doing something (maybe lots) wrong here:</p> <p><strong>Edit: Hah. I forgot <code>the_content</code> It works now.</strong></p> <pre><code>&lt;?php $the_query = new WP_Query; $the_query-&gt;query ('pagename...
[ { "answer_id": 13818, "author": "anu", "author_id": 490, "author_profile": "https://wordpress.stackexchange.com/users/490", "pm_score": 0, "selected": false, "text": "<p>Shouldn't this be <code>$the_query = new WP_Query('pagename=about');</code> ?</p>\n" }, { "answer_id": 13829, ...
2011/04/03
[ "https://wordpress.stackexchange.com/questions/13817", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/268/" ]
This should be easy. I need to query to display one page in a tab. Just pull one page by one query, but I'm doing something (maybe lots) wrong here: **Edit: Hah. I forgot `the_content` It works now.** ``` <?php $the_query = new WP_Query; $the_query->query ('pagename=about' ); while ($the_query->have_posts()) : $the...
Hah. I forgot `<?php the_content(); ?>`
13,821
<p>I have several virtual hosts setup, three of them pull files via SVN when needed(though only the trunk folder actually <strong>needs</strong> this), using SVN for other versions make for easy patch creation, or easy file replacement if i hack a core file.</p> <p><img src="https://i.stack.imgur.com/zlOLa.jpg" alt="e...
[ { "answer_id": 13823, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>Disclaimer - I am also beginner with SVN.</p>\n\n<blockquote>\n <p>Is this possible?</p>\n</blockquote>\n\n<p>Shoul...
2011/04/03
[ "https://wordpress.stackexchange.com/questions/13821", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31073/" ]
I have several virtual hosts setup, three of them pull files via SVN when needed(though only the trunk folder actually **needs** this), using SVN for other versions make for easy patch creation, or easy file replacement if i hack a core file. ![enter image description here](https://i.stack.imgur.com/zlOLa.jpg) My que...
I run a WordPress checkout of trunk, a branch, or a tag. This way I can switch WordPress versions easily: ``` svn sw http://svn.automattic.com/wordpress/trunk svn sw http://svn.automattic.com/wordpress/tags/3.1 ``` In `wp-content/plugins` I have a trunk checkout for each of my plugins: ``` cd wp-content/plugins svn...
13,822
<p>I think my audience is more capable of answers each others' questions than I am.</p> <p>I need a system for them to do that and I'd like it to integrate with WP so I could use their existing usernames and accounts.</p> <p>Do you know of a good solution?</p>
[ { "answer_id": 13823, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>Disclaimer - I am also beginner with SVN.</p>\n\n<blockquote>\n <p>Is this possible?</p>\n</blockquote>\n\n<p>Shoul...
2011/04/03
[ "https://wordpress.stackexchange.com/questions/13822", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2115/" ]
I think my audience is more capable of answers each others' questions than I am. I need a system for them to do that and I'd like it to integrate with WP so I could use their existing usernames and accounts. Do you know of a good solution?
I run a WordPress checkout of trunk, a branch, or a tag. This way I can switch WordPress versions easily: ``` svn sw http://svn.automattic.com/wordpress/trunk svn sw http://svn.automattic.com/wordpress/tags/3.1 ``` In `wp-content/plugins` I have a trunk checkout for each of my plugins: ``` cd wp-content/plugins svn...
13,830
<p>I always find myself creating posts every time to test layout or design.</p> <p>For example, I create stuff like:</p> <blockquote> <p>Content 1</p> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut w...
[ { "answer_id": 13823, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>Disclaimer - I am also beginner with SVN.</p>\n\n<blockquote>\n <p>Is this possible?</p>\n</blockquote>\n\n<p>Shoul...
2011/04/03
[ "https://wordpress.stackexchange.com/questions/13830", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/781/" ]
I always find myself creating posts every time to test layout or design. For example, I create stuff like: > > Content 1 > > > Lorem ipsum dolor sit amet, > consectetuer adipiscing elit, sed diam > nonummy nibh euismod tincidunt ut > laoreet dolore magna aliquam erat > volutpat. Ut wisi enim ad minim > veniam...
I run a WordPress checkout of trunk, a branch, or a tag. This way I can switch WordPress versions easily: ``` svn sw http://svn.automattic.com/wordpress/trunk svn sw http://svn.automattic.com/wordpress/tags/3.1 ``` In `wp-content/plugins` I have a trunk checkout for each of my plugins: ``` cd wp-content/plugins svn...
13,834
<p>I've got several custom image sizes for my blog. One of these is setup as <code>add_image_size( 'slide', 640, 290, true );</code>. These are used in a header slideshow. </p> <p>My problem is I've upped the dimensions of this size <strong>after</strong> many of them were originally created, and many of the attached ...
[ { "answer_id": 13823, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>Disclaimer - I am also beginner with SVN.</p>\n\n<blockquote>\n <p>Is this possible?</p>\n</blockquote>\n\n<p>Shoul...
2011/04/03
[ "https://wordpress.stackexchange.com/questions/13834", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4258/" ]
I've got several custom image sizes for my blog. One of these is setup as `add_image_size( 'slide', 640, 290, true );`. These are used in a header slideshow. My problem is I've upped the dimensions of this size **after** many of them were originally created, and many of the attached post images are too small to be cr...
I run a WordPress checkout of trunk, a branch, or a tag. This way I can switch WordPress versions easily: ``` svn sw http://svn.automattic.com/wordpress/trunk svn sw http://svn.automattic.com/wordpress/tags/3.1 ``` In `wp-content/plugins` I have a trunk checkout for each of my plugins: ``` cd wp-content/plugins svn...
13,854
<p>Is there a plugin or some php code to do this:</p> <p>I want to disable some categories from the category box on the add/edit message page. I don't want to delete the categories and I want to leave the disabled categories to the previously assigned posts.</p>
[ { "answer_id": 13873, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>Take a look at <a href=\"http://wordpress.org/extend/plugins/admin-only-category/\" rel=\"nofollow\"><strong>...
2011/04/04
[ "https://wordpress.stackexchange.com/questions/13854", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Is there a plugin or some php code to do this: I want to disable some categories from the category box on the add/edit message page. I don't want to delete the categories and I want to leave the disabled categories to the previously assigned posts.
I have solved the problem myself, but it is not a pretty one. With the function attached to the `add_meta_boxes` action hook, I change the callback function that builds the category box. It replaces this function with the customized function `post_categories_meta_box_custom`. `post_categories_meta_box_custom` is a co...
13,859
<p>I need some help with a search plugin: WP Custom Fields Search. I have three drop down menus: 1. City 2. Suburb 3. Cuisine What I need is so that when you select a City, it automatically moves the 2. Suburbs to relevant to that city. 3. is a custom field ie. there can be chinese restaurants in any city. suburb so it...
[ { "answer_id": 13883, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": false, "text": "<p>The problem with custom fields is that there is no relation between them so you can't relate Suburbs to citie...
2011/04/04
[ "https://wordpress.stackexchange.com/questions/13859", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4179/" ]
I need some help with a search plugin: WP Custom Fields Search. I have three drop down menus: 1. City 2. Suburb 3. Cuisine What I need is so that when you select a City, it automatically moves the 2. Suburbs to relevant to that city. 3. is a custom field ie. there can be chinese restaurants in any city. suburb so it do...
The problem with custom fields is that there is no relation between them so you can't relate Suburbs to cities. A better way would be to create an hierarchical [**Custom Taxonomy**](http://codex.wordpress.org/Function_Reference/register_taxonomy) so you can have a parent - child relation (like categories and sub categ...
13,863
<p>I have a new question, how can I limit the amount of posts coming out of this query? I only need 7</p> <pre><code>&lt;?php $newsposts = new WP_Query('cat=restaurant'); if ( is_front_page()) { echo '&lt;h3 class="member-review"&gt;Latest Restaurants&lt;/h3&gt; &lt;div id="extra"&gt;'; if ($newsposts-&gt...
[ { "answer_id": 13864, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 5, "selected": true, "text": "<p>It should be:</p>\n\n<pre><code>$newsposts = new WP_Query('cat=restaurant&amp;posts_per_page=7');\n</code></pre>\n\n<...
2011/04/04
[ "https://wordpress.stackexchange.com/questions/13863", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4179/" ]
I have a new question, how can I limit the amount of posts coming out of this query? I only need 7 ``` <?php $newsposts = new WP_Query('cat=restaurant'); if ( is_front_page()) { echo '<h3 class="member-review">Latest Restaurants</h3> <div id="extra">'; if ($newsposts->have_posts()) : while ($newsposts->ha...
It should be: ``` $newsposts = new WP_Query('cat=restaurant&posts_per_page=7'); ``` Another way to write it (helps readability with larger queries) would be: ``` $newsposts = new WP_Query(array( 'cat' => 'restaurant', 'posts_per_page' => 7, )); ``` See [`WP_Query`](http://codex.wordpress.org/Function_Refe...
13,867
<p>How might I have custom markup for my menus, like I want to give menu items something like <code>id="menuitem-postname"</code> how might I do that?</p>
[ { "answer_id": 14082, "author": "PNMG", "author_id": 1756, "author_profile": "https://wordpress.stackexchange.com/users/1756", "pm_score": 1, "selected": true, "text": "<p>The only way that I could think to do this would be to add a filter to <code>wp_nav_menu_items</code>. Here is the c...
2011/04/04
[ "https://wordpress.stackexchange.com/questions/13867", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3788/" ]
How might I have custom markup for my menus, like I want to give menu items something like `id="menuitem-postname"` how might I do that?
The only way that I could think to do this would be to add a filter to `wp_nav_menu_items`. Here is the code that I got to work (just add it to your themes functions.php file): ``` add_filter('wp_nav_menu_items', 'my_id_name_nav', 10, 2); function my_id_name_nav($items,$args) { if( $args->theme_location == 'primary'...
13,875
<p>I am using the following code to remove the admin bar (client request).</p> <pre><code>add_filter( 'show_admin_bar', '__return_false' ); </code></pre> <p>Trouble is, it leaves some autogenerating CSS, which places a massive white line at the top of my page in its place (via a 28px top margin rule). How can I turn ...
[ { "answer_id": 13881, "author": "anu", "author_id": 490, "author_profile": "https://wordpress.stackexchange.com/users/490", "pm_score": -1, "selected": false, "text": "<p>Can't you just override the CSS - probably the easiest way - add a display: none to whatever the admin bar selector i...
2011/04/04
[ "https://wordpress.stackexchange.com/questions/13875", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/784/" ]
I am using the following code to remove the admin bar (client request). ``` add_filter( 'show_admin_bar', '__return_false' ); ``` Trouble is, it leaves some autogenerating CSS, which places a massive white line at the top of my page in its place (via a 28px top margin rule). How can I turn this off as well?
To completely remove the Admin bar deregister the js and css using wp\_degregister\_script and remove the action. ``` if (!is_admin() && !current_user_can('add_users')){ wp_deregister_script( 'admin-bar' ); wp_deregister_style( 'admin-bar' ); remove_action('wp_footer','wp_admin_bar_render',1000); } ```
13,888
<p>I'm creating common "Single Tag Page" for different Post Types.<br> I'm using next code:</p> <pre><code>$loop = new WP_Query( array( 'post_type' =&gt; 'any', 'tag' =&gt; single_term_title( '', false ), 'posts_per_page' =&gt; 10 ) ); while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post(); ?&gt; &lt;div class="ent...
[ { "answer_id": 13889, "author": "Joe Hoyle", "author_id": 150, "author_profile": "https://wordpress.stackexchange.com/users/150", "pm_score": 2, "selected": false, "text": "<p>There is a reference to the term object in <code>$wp_query</code>, and a shortcut function to grab this (providi...
2011/04/04
[ "https://wordpress.stackexchange.com/questions/13888", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3855/" ]
I'm creating common "Single Tag Page" for different Post Types. I'm using next code: ``` $loop = new WP_Query( array( 'post_type' => 'any', 'tag' => single_term_title( '', false ), 'posts_per_page' => 10 ) ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="entry-content"> <?php the_excerpt(...
Thank you guys for such quick response. Much appreciated! Here is code for "global" Tags page (displaying terms of default 'post\_tag' taxonomy): ``` <?php $term_slug = get_queried_object()->slug; if ( !$term_slug ) return; else $loop = new WP_Query( array( 'post_type' => 'any', 'tag' => $term_slug, '...
13,895
<p>I construction of a administrative back office inside the wordpress theme for running our travel company, monitoring users, bookings and payments, it has come to my attention that it might be better served and more secure if such an area were in face a desktop application or offline webpage that connected to the int...
[ { "answer_id": 13897, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 3, "selected": true, "text": "<p>I'm curious how/where you got the impression that desktop apps are more secure than the WP admin.</p>\n\n<p>For bett...
2011/04/04
[ "https://wordpress.stackexchange.com/questions/13895", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2957/" ]
I construction of a administrative back office inside the wordpress theme for running our travel company, monitoring users, bookings and payments, it has come to my attention that it might be better served and more secure if such an area were in face a desktop application or offline webpage that connected to the intern...
I'm curious how/where you got the impression that desktop apps are more secure than the WP admin. For better security, you can enable SSL for the normal WP admin web interface, by adding this line to wp-config.php: ``` define('FORCE_SSL_ADMIN', true); ``` More info here: <http://codex.wordpress.org/Administration_O...