question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I added two category pages to a site I am working on and I found out the permalink in the url is wrong. I set the permalink as <code> /%category%/%postname% </code> and I created two categories "News" and "Offers" I was supposed to get <code> mydomain.com/news </code> or <code> mydomain.com/offers </code> (I created th...
By setting your permalinks to <code> %category%/%postname% </code> , you are setting the permalinks only for your posts and pages . Below the posts and pages permalinks option is another one for your categories. Just set your categories slug to <code> . </code> and it will just be the category name. Here's a visual exa...
Why do I have "category" in my permalinks?
wordpress
I have an url that looks like this http://apploadny.appload.nu/tjanster/webbutveckling/ I want to get the ID of the page "tjanster", how can i do that?
I think what you need is: <code> &lt;?php $post_id = $post-&gt;ID; //or somehow get the current post ID. $ancestors = get_post_ancestors($post_id) //$ancestors is an array of post IDs starting with the current post going up the root //'Pop' the root ancestor out or returns the current ID if the post has no ancestors. $...
Get ID of "root-page"
wordpress
I have this code in functions.php in order to have a meta box displayed in the backend. The problem is, this was functioning normally until I've moved the website from a subdomain (dev) to the root and now even if the metabox appears in the backend, it doesn't retain the values anymore. <code> &lt;?php define('MY_WORDP...
Many of the comments below refer to code used for debugging, which for clarity I've removed. I should have spotted this soon - you are adding only one row into the postmeta table, and that row has the key <code> _my_meta </code> . Before inserting the array int the table, WordPress serializes the array. When you retrie...
Metabox doesn't retain values
wordpress
I'm using the Wordpress related plugin : http://wordpress.org/extend/plugins/related/ Which uses the following markup to call the plugin: <code> &lt;?php echo $related-&gt;show(get_the_ID()); ?&gt; </code> I would like to add a title and a division around the plugin... but would only like this to display if there is a ...
I don't know for sure if this would work but this is where I'd start: <code> &lt;?php $related_content = $related-&gt;show(get_the_ID()); ?&gt; &lt;?php if($related_content): ?&gt; &lt;div class="related"&gt;&lt;strong&gt;Related products&lt;/strong&gt;&lt;br /&gt; &lt;?php echo $related_content; ?&gt; &lt;/div&gt; &lt...
Wordpress Related Plugin - only show when related content
wordpress
I have troubles saving the data of the meta box in the link part of the admin. My code is working, because when I try it in the post or page part, it saves the data, but in Links it just won't. Here is my code. Should I write something else instead of 'save_post' ? I saw some used 'save_link' ans tried even though peop...
The hook you are after is <code> edit_link </code> (I couldn't find any documentation). It's fired from inside <code> wp_insert_link </code> (itself fired whenever a link is created or updated). The action only passes one argument, the link's ID, to the callback. So you would need to change 2 to 1, on your <code> add_a...
Problem with meta box in Links
wordpress
I have a simple form that users will fill out which will in turn become a post on my site. I have 2 problems: I am using the Post title, Post Custom Field elements (for single line text) and Post Body element (for paragraph text). When I submit my test form though, only the title is appearing, none of the data I wrote ...
I put together a video for you showing you how to use the content template in Gravity Forms, which is the key to formatting content within the post body. Take a look here: http://www.screenr.com/sYT8 If you find yourself needing to do more advanced work, then you'll probably want to investigate setting up a custom temp...
Gravity Forms Post method
wordpress
I have a member section built using the http://www.advancedcustomfields.com plugin. There are 300 members that each have the following data: Company name Specialism (check boxes) Web address Telephone number Region Address Email What's the best way to import into the database? How should I setup a csv file? I haven't a...
Sounds like you have successfully gotten all 300 Pages imported based on the comments. (Regardless of how you did it, either by using the WordPress import plugin or by using some MySQL tool like phpMyAdmin or Sequel Pro or whatever)... You have 300 pages in the <code> wp_posts </code> table. Let's start from here then....
Importing data for advanced custom fields plugin?
wordpress
A few months ago I asked a similar question: stackexchange-url ("Is it possible to remove the main rich Text box editor?") and got the following answer: <code> function remove_pages_editor(){ remove_post_type_support( 'page', 'editor' ); } add_action( 'init', 'remove_pages_editor' ); </code> This code removes the edito...
There is an <code> add_meta_boxes </code> function that fires that you can hook into - it fires whenever the edit post page is rendered. At that point, you can get the ID of the post being edited using <code> get_the_ID() </code> . You can then compare it to the ID for which you want to remove the post editor: <code> f...
Can I remove the Rich Text box editor for a specific post?
wordpress
Basic idea is for any post on the site, I'd like users to be able to assign a category for it by selecting from a set of checkboxes on the frontend. This would be a kind of crowd-sourced categorization of content. Any ideas on the best way to approach this?
I wanted to provide you with a few ideas but once I started I couldn't stop myself and wrote this little plugin with an obscure name to get you started. <code> &lt;?php /* Plugin Name: WPSE Crowded Cats Plugin URI: stackexchange-url Allow visitors to change categories of posts. Ready to use with custom taxonomies and p...
How do I create a way for users to assign categories to a post from the frontend?
wordpress
Thanks for taking a look at this for me. You can see the current behavior at http://dev.citylightphilly.com/blog/ -- Here is my specific problem. We are using a category structure like this: <code> Events [] Meals and Mission [] Service [] </code> Our problem is that our users are categorizing events like this: <code> ...
This isn't THE answer, but it's one answer. Quick fix: Have my clients check two boxes whenever they use a sub-category. (sub-category box + parent category). This will ensure the post-count is correct. <code> Events [x] Meals and Mission [x] </code> Would love a fix that didn't depend on clients checking both boxes al...
How do I make the category sidebar widget (stock) display the total # of posts including those in subcategories?
wordpress
I've recently started revamping and re-releasing some abandoned (yet important) WordPress plugins. As I walk through the code patching other bugs, my IDE highlights deprecated function calls for me, which is fantastic! I fix them immediately when I find them and move on. Anything I don't catch is called out by a Log De...
I was inspired by your question to create a plugin that I've been kicking the can on for several months. I'm calling it Deprecation Checker. By default, it scans the plugin and theme directories (recursively) to find deprecated functions. The functions list is sourced directly from the WP deprecated files. It then outp...
Automating deprecated call checks?
wordpress
I am using wp_nav_menu() and I want to add the search box as a part of the menu. I am having trouble figuring it out and was hoping for some assistance: My code: <code> &lt;?php $args = array('theme_location' =&gt; 'primary', 'container' =&gt; false); wp_nav_menu( $args ); ?&gt; </code> Now I want to add an additional ...
Ended up using wp_get_nav_menu_items() and got each item individually and then built the li manually as shown in this example: http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items#Examples
Adding an additional menu in Wordpress
wordpress
The native search page runs a query like so: <code> SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND (((wp_posts.post_title LIKE '%keyword%') OR (wp_posts.post_content LIKE '%keyword%')) AND (wp_posts.post_password = '') AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status...
Filter <code> posts_where </code> or <code> posts_search </code> . See stackexchange-url ("this answer") for a couple of examples.
Remove WHERE conditions from search query
wordpress
How would I display HTML conditional on a particular category page? Say my permalinks to the category pages are http://www.mysite.com/category/awesome-category How would I cast the <code> &lt;?php if ... ?&gt; </code> to do this, and within what template of my theme? I'm using WP 3.3.1. If I need to provide more inform...
<code> if(is_category('awesome-category')) echo "whoa awesome category here!!; </code> probably in category.php, but it really depends on the setup of your theme... if you are using a child theme, etc. also you could create a special template just for that specific category. category-awesome-category.php see: http://co...
How do I display something on a particular category page?
wordpress
I have a blog. I need to add a functionality. Where Registered user can upload video and Registered user can view all video and Onclick on Particular video That video display and User can comment on video and total view. Is there any plugin that provide this functionality. or Any demo link or code.
I would either create a custom post type, or a category (depends how you wanna organize it...custom post type would be my goto) to store the videos. With that in place, you can setup a form in your frontend, making it only visible to registered users, where they can do their video uploading (this functionality is cover...
Register User can post video
wordpress
I couldn't find any plugin to do that, so I need a help here. This is what I need. One page will have a small form with 6 fields. One field is to upload photo. Another page will show in a matrix layout (2 columns 5 rows) all the users that were registered from my form. On the backend, I just need to be able to see the ...
Try out http://www.cozmoslabs.com/wordpress-profile-builder/ . It has front-end user registration with avatars uploads and user listing. The one thing that it doesn't have is approve user before activating them on the site, but you can delete and edit users from the backend in the users section.
Plugin recommendation for member management
wordpress
Help! I am trying to create a Digg-clone by integrating "BM Shots" (a webpage thumbnail generator) with "Recommended Links" (a social voting plug-in for Wordpress). Recommended Links allows for user submitted URLs to be displayed via "the_permalink" tag. I'm trying to use BM Shots to generate web page thumbnails based ...
<code> the_permalink() </code> is actually filtered in the Recommended Links plugin to echo a custom meta field called <code> _href </code> . If you want access to that field without echoing it, you can use <code> get_post_meta( $post-&gt;ID, '_href', true ) </code> . Try something like this in your loop: <code> global...
How do I get thumbnail generator to recognize the_permalink tag?
wordpress
I'm trying to display related posts by a custom taxonomy (product_tags) in a custom post type (products). The following code works, but it ignores posts_per_page . Any ideas? <code> global $post; $terms = get_the_terms( $post-&gt;ID , 'product_tags', 'string'); $do_not_duplicate[] = $post-&gt;ID; if(!empty($terms)){ ec...
If you want to query for multiple taxonomy terms you can use the more advanced, <code> tax_query </code> argument of WP_Query queries. For instance <code> //Get array of terms $terms = get_the_terms( $post-&gt;ID , 'product_tags', 'string'); //Pluck out the IDs to get an array of IDS $term_ids = wp_list_pluck($terms,'t...
Displaying related posts in a custom post type by a custom taxonomy
wordpress
I have custom post type (Events) with 6 events. <code> $posts = get_posts( array('post_type' =&gt; 'events') ); echo '&lt;!-- '; print_r($posts); echo ' --&gt;'; </code> This code shows the 5 with the most recent published date. I should perhaps note that we have been changing the published date as a hacky sort of way ...
The default nmber of posts returned is <code> 5 </code> . To return more than 5 posts use: <code> $posts = get_posts( array('post_type' =&gt; 'events', 'numberposts' =&gt; 10) ); </code> Or for all of them: <code> $posts = get_posts( array('post_type' =&gt; 'events', 'numberposts' =&gt; -1) ); </code> More info about g...
get_posts seems to be skipping the last Post
wordpress
I want to create a page that lists all the Custom Taxonomies, with each item linking to a page that will list all the terms in a given taxonomy. I can produce a list of taxonomies using this <code> &lt;?php $args=array( 'public' =&gt; true, '_builtin' =&gt; false ); $output = 'names'; // or objects $operator = 'and'; /...
Once you get <code> $taxonomy </code> you can perform further logic: <code> $tax = get_taxonomy( $taxonomy ); if( isset( $tax-&gt;has_archive ) &amp;&amp; $tax-&gt;has_archive == true ) { // do output. archive will be wordpress_url + $taxonomy-&gt;name ?&gt; &lt;p&gt; &lt;a href="&lt;?php echo site_url( $taxonomy-&gt;n...
How to create a page that lists custom taxonomies with links?
wordpress
Post contains: <code> excerpt </code> , <code> read more </code> , <code> content </code> . When browsing category page we see post's <code> excerpt </code> with <code> read more </code> link. When clicking <code> read more </code> we see post's <code> excerpt </code> + <code> content </code> . How to avoid showing exc...
please read codex.wordpress.org/Function_Reference/the_content and use the $stripteaser parameter.
How to show content without excerpt?
wordpress
Is this possible? If so, can someone point me towards a clear tutorial? I have a column of content I want to float right of the_content, so I'd like to be able to use a shortcode to put that content in the post for a page. I've found the following (but want to modify it for get_post_meta): <code> function get_custom_fi...
yeah, the question is a bit unclear. but i think you need shortcode attributes <code> function get_custom_field_fn( $atts) { global $post; extract( shortcode_atts( array( 'meta' =&gt; '' ), $atts ) ); $custom_field_value = get_post_meta($post-&gt;ID, $meta, true); return $custom_field_value; } add_shortcode('cf_name', ...
Use a shortcode to display custom meta box contents
wordpress
I have three different posts types registered: <code> register_post_type( 'foo' , $args ); register_post_type( 'bar' , $args ); register_post_type( 'baz' , $args ); </code> When I am creating a new, say, "foo" post, I only want to save the meta box for "foo", what do I do? add_action('save_post', 'save_details'); So, i...
Since save_post gives you the post_id of the current post, you simply want to check what post_type it is by using get_post_type($post_id) like: <code> add_action('save_post', 'save_details') function save_details($post_id) { $post_type = $_REQUEST['post_type']; if ('foo_post' == $post_type) { // save stuff for foo_post...
Saving data for different custom posts
wordpress
So here is my query: <code> $args = array( 'post_type' =&gt; 'Event', 'posts_per_page' =&gt; 1000, 'meta_key' =&gt; 'event_informations_show_on_the_homepage', 'meta_value' =&gt; 'Show on the homepage', 'meta_compare' =&gt; '==', 'meta_key' =&gt; 'event_informations_date', 'orderby' =&gt; 'meta_value_num', 'order' =&gt;...
@Uffo I would say your args are wrong, should be something like: <code> $args = array( 'post_type' =&gt; 'Event', 'posts_per_page' =&gt; 1000, 'meta_query'=&gt; array( array( 'key'=&gt;'event_informations_show_on_the_homepage', 'value'=&gt; 'Show on the homepage', 'compare' =&gt; '==' ) ), 'meta_key'=&gt;'event_informa...
Wordpress query by multiple Custom fields and order by date
wordpress
I am displaying only thumbs and title on index pages using following code; <code> &lt;div id="column1"&gt; &lt;?php query_posts('cat=22&amp;showposts=2'); ?&gt; &lt;?php $posts = get_posts('cat=22&amp;numberposts=2&amp;offset=0'); foreach ($posts as $post) : start_wp(); ?&gt; &lt;?php static $count1 = 0; if ($count1 ==...
Easiest way to control column and/or row layouts I know of is to make use of modulus. I broke it down in a tutorial and use it with wordpress in my examples. Wordpress and PHP Modulus The first example is basic, while the second is a bit more advanced and utilizes post images/attachments. If it helps let me know or giv...
Show post thumbs in rows instead of columns
wordpress
I would like to add custom contents to post, such as price, options and some others, I dont like to use the custom fields, because always i have to select from a drop down menu, I want these options to be in a separate area such as title, editor, thumbnail... I think its possible, I have seen this in WP Ecommerce plugi...
You're looking for custom meta boxes . These allow you to add sections to the WordPress post and/or page screens that look like standard title, editor, category selection, etc. Generally speaking, you determine where they are rendered and what type of input elements are used. Without knowing exactly what you're trying ...
How to add new custom page or post blocks?
wordpress
I am using the latest version of the My Calendar plugin by Joe Dolson with the latest version of WP. I want to output an events list in a particular place in my code, but I can't seem to find any way to do this. The only thing I've found regarding output is by using shortcodes in the post/page. I guess theoretically I ...
You can use the function do_shortcode in your template to output the content generated by the shortcode that My Calendar provides for listing events. For an example, to show a list of upcoming events use something like: <code> &lt;?php echo do_shortcode('[my_calendar_upcoming before="3" after="3" type="event" fallback=...
My Calendar Plugin - add output directly in template file
wordpress
I'm working on a site and I need to get the type of user the author is so I can mark it. The idea is that if an Admin level user post something it has a [ADMIN] tag or something next to their name. I know how to compare things within php but how do I check to see what user type an author is if possible? I can't seem to...
One way would be to use the <code> get_the_author_meta </code> function and pass it <code> user_level </code> More info on the function: http://codex.wordpress.org/Function_Reference/get_the_author_meta Then, see this chart to convert user levels to roles (unless you have created custom roles): http://codex.wordpress.o...
Get the user type of an author
wordpress
I'm copying over a site from a former developer. I've installed a new instance of wordpress and database on new server, copied all but the wp-config from old server to new, but in admin it does not show the custom post types that are showing in old admin. I would think that these settings are in the functions.php, but ...
the custom post types won't show until you call register_post_type. http://codex.wordpress.org/Function_Reference/register_post_type this was either done in a plugin or the theme that you were previously using. if you are no longer using those you will have to activate it again yourself. i suggest making it a plugin (a...
Copy custom post types and admin
wordpress
I am working in a WP multisite which runs on a classipress theme and there is a custom post type " <code> ad_listing </code> " and custom taxonomy type " <code> ad_cat </code> ". Now the url is like this http://www.example.com/ad-category/transport/ I need to rewrite this URL so it looks like http://www.example.com/new...
When you are adding a custom taxonomy you are able to declare a rewrite slug - <code> $labels = array( 'name' =&gt; _x('Name', 'taxonomy general name'), 'singular_name' =&gt; _x('Singular Name', 'taxonomy singular name'), 'search_items' =&gt; __('Search Items'), 'all_items' =&gt; __('All Names'), 'parent_item' =&gt; __...
How to rewrite custom post type with custom taxonomy urls?
wordpress
My current singlepost.php makes use of the following if conditions and renders the appropriate template. <code> &lt;?php $post = $wp_query-&gt;post; if ( in_category('4') || in_category('59') ) { include(TEMPLATEPATH . '/review-post.php'); } elseif (in_category('5')) { include(TEMPLATEPATH . '/promo-post.php'); } else ...
I'm making a couple of assumptions about how your theme is setup: You have two files: index.php. This is the file that begins the execution of the loop . content.php. This is the file in which your generic content template exists. You are familiar with get_template_part() . If not, it's easy to implement. For example p...
How to display different single post template based on author?
wordpress
I have set the following custom permalink structure (for my blog): <code> /news/%postname% </code> When I browse to <code> /news </code> I was expecting for the <code> archive.php </code> template to be served up, unfortunately, I'm presented with a 404. My rewrite is working properly since I can view all posts such as...
You can override the Post type object settings in the <code> init </code> action and register the proper values for the archive and rewrites: <code> add_action('init', 'my_init'); function my_init() { $args = objectToArray( get_post_type_object('post') ); $args['has_archive'] = 'news'; $args['rewrite'] = array( 'slug' ...
Post custom permalink results in 404 for archive page
wordpress
To help me learn WordPress development, I'd like to go "beyond the blog" and build a personal movie library -- similar to IMDb but on a much smaller scale. I need help understanding how to approach the project in WordPress and what I need to learn. Here are the types of things I'd like to do on the site: When you visit...
Plugin vs. Theme vs. MU-Plugin vs. Drop-In »Would this application require building a plug-in, or just adding code to my theme?« Basically all four are the same. They differ only in two points: Location and MU-Plugins are in the <code> mu-plugins </code> folder 1) Plugins are in the <code> plugins </code> directory Dro...
How to Build a Movie Library in WordPress 3.x
wordpress
I'd like to run an SQL query to find all featured images from posts and delete the file itself and any references to it. Can anyone tell me how to accomplish this? Many thanks!
A MYSQL Query cannot delete the files themselves. You will have to use wp_delete_attachment(). The following is a proof-of-concept for you to alter how you please. The featured image is stored in postmeta as <code> _thumbnail_id </code> . <code> wp_delete_attachment() </code> does the rest for you. <code> &lt;?php /* P...
Query to delete all featured images and remove post meta?
wordpress
So I have created my own template that has a set header for all of my pages home (which is a static front page), about, services, contact, etc.... I have recently created two newer pages products and blog. Products is using CataBlog to list my products and their information so I don't want the same header that I have u...
If the conditional works when using <code> is_page( 'products' ) </code> , but does not work when using <code> is_page( 'blog' ) </code> , then that means that WordPress isn't finding a static page with the slug <code> blog </code> . First thing to do: verify your slug name. A second alternative is that the static page...
Custom Headers on Blog Posts Page
wordpress
Slight problem, I have the following code: <code> $purchaseprodid = $_GET['ids']; $args = array( 'post_type' =&gt; 'prizes', 'post__in' =&gt; array($purchaseprodid) ); query_posts($args); while (have_posts()) : the_post(); </code> I am getting comma seperated numbers for id's in a url, and they dont seem to be querying...
You need to explode the string you obtain from <code> $_GET['ids'] </code> into an array, at the moment you a parsing a to string <code> post__in </code> rather than an array of IDs. Try <code> $purchaseprodid = isset($_GET['ids']) ? explode(',',$_GET['ids']) : array(); </code> However, you can sometimes run into diffi...
Trying to put an array into 'post__in' => array() query not working
wordpress
The task You can register add additional Themes directories using <code> register_theme_directory() </code> for your WP installation. Sadly core doesn't deliver with the same functionality for plugins. We already have MU-Plugin, Drop-Ins, Plugins and Themes. But we need more for a better file organization. Here's the l...
Okay, I'll take a stab at this. Some limitations I encountered along the way: There are not a lot of filters in subclasses of WP_List_Table, at least no where we need them to be. Due to that lack of filters, we can't really maintain an accurate list of plugin types at the top. We also have to use some awesome (read: di...
Add multiple plugin directories
wordpress
I'm trying to create Google calendar links from posts, I do it like so: <code> $base_url = 'http://www.google.com/calendar/event'; $params = array( 'action' =&gt; 'TEMPLATE', 'text' =&gt; strip_tags(get_the_title()), 'dates' =&gt; $dates, 'details' =&gt; strip_tags( get_the_excerpt() ), 'location' =&gt; $location, 'spr...
Have a look at the PHP function <code> urlencode() </code> , that will hopefully help. Also, in the latest update of Wordpress (3.3.1) they have fixed it so that permalinks (post slugs) no longer contain special characters. This of course doesn't help with your already existing slugs, but I'm sure there are ways and me...
UTF-8 Characters in URL - IE problem
wordpress
I have three custom post types created already and their landing pages (page-events.php, etc): Events, Retreats, Coaching But for the first, I need some sort of categories which I am going to list on the landing page (page-events.php) as a menu, and inside them I would need blog posts. I have created a custom taxonomy ...
No, that is the correct way to do it, but with one suggestion - don't give the custom post type and custom taxonomy the same slug (unless you specify a rewrite name, rather then just 'true') as it will cause problems with your rewrite rules. If you have problems with the custom types after adding them then swithc your ...
Structure of custom post type / taxonomy?
wordpress
hello and sorry for yet another beginner question i am extracting wordpress categories form the array but i want them to be separated by comma my code is <code> &lt;?php $args=array( 'child_of' =&gt; 79 ); $categories=get_categories($args); foreach($categories as $category) { echo $category-&gt;cat_id; ?&gt; </code> th...
Welcome to WPSE faq! This type of question is probably best suited for suited for stackexchange-url ("stackoverflow"), rather than here as the question isn't specifically related to WordPress. You just need to get an array of the IDs (a simple foreach loop could do this - or use the Wordpress' <code> wp_list_pluck </co...
separate categories with comma and srounded by single quote
wordpress
I'm trying to add the value of a custom field under the post/page title in wp-admin list of posts/pages (much like excerpt mode in posts list) without hooking into the columns process since other plugins are already doing that and it looks like each cancels the other. Here's a screenshot of what I'm trying to achieve: ...
Just like you add new columns you render the title filed your self <code> add_action( 'manage_posts_custom_column', 'admin_post_data_row', 10, 2); function admin_post_data_row($column_name, $post_id) { switch($column_name){ case 'title': edit_post_link(get_post_title($post_id), '&lt;p&gt;', '&lt;/p&gt;',$post_id); echo...
How to show custom field's value under post/page title in wp-admin
wordpress
I've been searching all around the web for the API of the wp_pagenavi plugin, but seems that I can't find one. I just want to know: In examples that I found, the wp_pagenavi function has from 0 to 3 parameters. What are those parameters and what do they change? Also, what I've been meaning to do is, with WPML, translat...
Why do you dont use the default functions from WP. As example the follow class, there you can use. <code> class fb_pagination_example { public function content_nav( $nav_id, $pag_bar = TRUE ) { if ( $GLOBALS['wp_query'] -&gt; max_num_pages &gt; 1 ) : ?&gt; &lt;nav id="&lt;?php echo $nav_id; ?&gt;"&gt; &lt;h1 class="ass...
wp_pagenavi function parameters
wordpress
I've been changing my Permalinks and changing my site the the "www" version (Which I think has broken my image and video links). All my images are "red x" now, both inside the library and the posts themselves. I have been looking in my cpanel and all the file paths are correct, but if I try to view them through WP or e...
if you've monkeyed with your www structure you can change the image URLs (since they are hard-coded in the img src) using the following plugin: http://wordpress.org/extend/plugins/velvet-blues-update-urls/
Image URLs stopped working due to Permalinks?
wordpress
I found this question: stackexchange-url ("Theres a way to use $query-&gt;set(&#39;tax_query&#39; in pre_get_posts filter?") which seems to indicate that yes, you can alter the taxonomy query on taxonomy archives via pre_get_posts(). so i came up with <code> add_action('pre_get_posts', 'kia_no_child_terms' ); function ...
i could not get this to work with any combination of pre_get_posts or parse_query. i can do it relatively easily by wiping out the query object after it is made. i don't like it b/c then I'm running the query twice, but i'm at my wit's end with trying to be 'efficient' <code> function kia_no_child_taxonomies(){ if(is_t...
Modify Taxonomy pages to exclude items in child taxonomies
wordpress
Very simple question: How can I check when wp is doing an update or a publishing to a post? Because I have to check a postmeta value which could be only true if the post is actually being published and so it has not to be already present in the system. E.g. if( defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE ) it's...
I avoid the problem just checking if the ID of the post is already existing in the db. <code> get_post($id)==NULL </code> That's probably the easiest way to do what I need.
check if wordpress is updating or publishing a post
wordpress
The question says it all. Does permalink equal canonical URL? Or is there another way to get the canonical URL?
Unless you are doing something weird with your URL structure (and maybe even then), the answer is yes according to this blog post .
Is get_permalink also the canonical URL?
wordpress
I am quite new too WP multisite, so forgive me for my ignorance on things. I have set up multisite ok and have setup 4 sites (i am using subdomains) mysite.com // the root site london.mysite.com // subsite oxford.mysite.com // subsite manchester.london.com // subsite All the subsites are using the same template, well c...
You have at least three options: use a Child Theme on mysite.com, in which you replace index.php with whatever you want Use a different Theme entirely on mysite.com - could be a landing-page Theme or whatever. Use your current Theme on mysite.com, but set it to display a static page as front page , put your subsite lin...
Entry page for a wordpress multisite
wordpress
I obviously found the file responsible of displaying the contact form with <code> FireBug </code> , changed the displayed names in the input area and then re-upload my file, however, nothing was changed. The input value of the first area was <code> your name </code> , i changed it to <code> votre nom </code> , but stil...
It is because you are overidding your values in custom.js : <code> $('#quickName').val('your name'); $('#quickEmail').val('your email'); $('#quickComment').val('your message'); </code> Remove these lines and you should be good to go.
My contact form - I've changed the source code but the changes are not being applied
wordpress
I am trying to make a child theme for a premium template. My css isn't overriding the parent though. I'm trying to figure out what's going on. Other than important the parent theme's css, is there anything else I need to import into the child theme folder? Right now there is just style.css. The site is http://wpdallas....
There was a problem in the theme itself, this has been corrected since this question was posted. The parent theme was not properly coded to work with a child theme.
CSS in child theme not overriding the parent theme
wordpress
I have a site with three menus, one per main category of the site. I use pages only. Two main categories have one page in common. Category A with menu a Category B - with menu b - with tarifs page Category C - with menu c - with tarifs page That tarifs page has to be shown with the proper menu depending on what menu th...
Going to use a site setup where each page has only one specific parent and where there is only one main menu and a sidebar that loads page children. Easier and clearer that way.
Show tarifs page with menu a or b depending on menu of origin
wordpress
I've made a custom post type, with a few accompanying widgets, and I was wondering if it is possible to show (some of) these widgets only if you're on a specific page. Currently I've got <code> function widget($args, $instance) { global $post; $links = unserialize(get_post_meta( $post-&gt;ID, 'links', true )); if(!is_s...
Okay, I got it finally! Wouldn't have been able to without looking at the source of Widget Logic This is how it is: First register a function to filter on <code> sidebar_widgets </code> : <code> add_filter( 'sidebars_widgets', 'my_filter_widgets', 10); </code> Then loop through all the widgets, skip over the widgets yo...
Register widget only page is a singular of custom post type
wordpress
I have two page templates and Qtranslate installed. I want to choose one or another depending the language selected. Can I do something like this ? <code> if($q_config['lang'] == 'en'){ // load page-template_en.php }else{ // load page-template_de.php } </code> Any idea ? Thanks!
It is possible using the <code> template_redirect </code> hook. Looks something like this : <code> function language_redirect() { global $q_config; if( $q_config['lang'] == 'en' ) { include( get_template_directory() . '/page-template_en.php' ); exit; } else { include( get_template_directory() . '/page-template_de.php' ...
Change page template programmatically ?
wordpress
I am using the Paragrams theme from the kind folks at wpshower. I have a little different front page that I would like to load with an image rotator and different layout in the for loop. I have tried all of the conditional comments, with no avail. There are some posts on this already that didn't have a solution... stac...
Have you tried creating a page template? Make a copy of page.php and call it page-home.php (if your home page is an actual page in Wordpress with the name of 'Home') or if not, then create a file called front-page.php and Wordpress will use that as the homepage template. These two Wordpress Codex links will help you: P...
is_front_page not working at all in any of the themes .php files
wordpress
This is my attempt at making a child theme, and everything seems to be working well, however when I view the source code I'm seeing this <code> &lt;link rel='stylesheet' id='bootstrap-css' href='http://wpdallas.com/test/wp-content/themes/Standard/css/lib/bootstrap.css?ver=3.3.1' type='text/css' media='all' /&gt; </code...
From your comment: I found this code in the functions.php of the parent theme, is that what you were looking for? <code> // bootstrap wp_register_style('bootstrap', get_template_directory_uri() . '/css/lib/bootstrap.css'); &gt; wp_enqueue_style('bootstrap'); </code> In your Theme's file structure, do you find <code> /c...
Trying to figure out why my child theme is trying to access a file that doesn't exist
wordpress
Is there a way to force log-in even for viewing a WordPress blog that the blog's owner can turn on and off by themselves? I can hardcode it in the template's <code> header.php </code> like so: <code> if ( !is_user_logged_in() ) { wp_redirect( wp_login_url() ); exit; } </code> but this can't be influenced from the blog'...
This simple to implement, you could put this into functions.php if you want it tied to a theme, or else create your own plugin from this: <code> add_action('init','my_force_login'); function my_force_login(){ if ( !is_user_logged_in() &amp;&amp; !in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' )...
Forcing frontend login with UI switch
wordpress
I am trying to use a custom field inside a widget so it's therefore outside the loop. Taking it a step further, the theme I have is using an array to generate listings which makes it hard for me to understand. Basically, the theme uses a feature image to display thumbnails of each post and I want to use a custom field ...
To get a custom field value outside of the loop you need to call <code> global $wp_query </code> to get your post id. <code> global $wp_query; $postid = $wp_query-&gt;post-&gt;ID; $image = get_post_meta($postid, 'Thumbnail', true); </code>
Custom field outside the loop and inside an array
wordpress
I'm trying to filter a capability check in order to work around the lack of filters to customize the user edit page in the admin area. But I can't seem to add filters to a hook, and I'm sure I'm missing something basic here. The hook in question is <code> role_has_cap </code> , located at line 343 of <code> wp-includes...
I finally figured it out: To start with, I was using the wrong hook. I should have been using <code> user_has_cap </code> hook instead, which is what actually has a chance of being called when using <code> current_user_can() </code> . But second, and most important of all, I was seeing the page while logged-in as super...
Problem using role_has_cap hook
wordpress
First, I have to admit I'm not entirely sure on how to explain this best. Currently I have this in my <code> header.php </code> : <code> &lt;?php if ( is_home() OR is_front_page() ): ?&gt; &lt;meta name="description" content="&lt;?php $options = get_option( 'schema_theme_options' ); echo $options['metadescription']; ?&...
Try this: <code> &lt;?php $options = get_option( 'schema_theme_options' ); $meta_desc = $options['metadescription']; ?&gt; &lt;?php if( ( is_home() || is_front_page() ) &amp;&amp; '' !== $meta_desc ) : ?&gt; &lt;meta name="description" content="&lt;?php echo $meta_desc; ?&gt;"&gt; &lt;?php endif; ?&gt; </code> It's a b...
If option: show this. Else show nothing
wordpress
I have a Custom Post Type called <code> glossary </code> . I set up <code> parent </code> posts called "A", "B", etc. The glossary terms themselves are then set with the appropriate initial as their parent post. So, for example, "abdomen" has the "A" post set as its parent and "protein-skimmer" has the "P" post as its ...
Try this, it's the most basic implementation. It could be more effecient to hook into <code> pre_get_posts </code> , and change the query from a 'top level page' to a query for it's children. But that has the potential to break a few things, and in particular would probably require you to alter the template used. <code...
When viewing single parent post, display list of children
wordpress
For security reasons, it should be possible to rename login.php to something different, and change other access shortcuts (eg: wp-admin) to point to the new URL. Is there a documented best practice for this? If not, what would the most correct methodology be? I appreciate that this is not security per se, just obfuscat...
The challenge of course is not "breaking" or "hacking" core to do this. Riffing off of krembo99's filter idea, I wonder whether the following wouldn't be a high-level approach to the solution from a plugin perspective: copy wp-login.php to a new file in the root WP directory. Use the <code> 'login_url' </code> filter t...
Change sign-on URLs for security purposes
wordpress
Any way to change how the date is displayed with get_comments..? I have the following.. <code> &lt;?php $comments = get_comments( array( 'post_id' =&gt; $post-&gt;ID, 'number' =&gt; 4, 'status' =&gt; 'approve' ) ); foreach($comments as $comment) : echo "&lt;li class=clearfix&gt; &lt;span class=comment-details&gt;{$comm...
The way you're doing this, you're going to get the raw SQL date that's stored in the wp_comments table. You can still use the convenience functions like <code> comment_date </code> with <code> get_comments </code> . In this case, we'll use <code> get_comment_date </code> . The first argument is the date format -- if yo...
Display of comment_date within get_comments?
wordpress
So I'm creating user registration. Just simply <code> &lt;?php wp_register(); ?&gt; </code> but then it gives them a link to the admin panel, which in my situation they really don't need. How do I remove the "Site Admin" link and redirect a subscriber if they try to access the admin panel? I guess once they log in I wi...
So I found the answer and thought it might be useful for later viewers. Adding the code below will redirect all users that are not admin to the homepage. <code> function prevent_admin_access() { if (strpos(strtolower($_SERVER['REQUEST_URI']), '/wp-admin') !== false &amp;&amp; !current_user_can('administrator')) { wp_re...
Keep Logged in Users out of Admin Panel
wordpress
I'm migrating our WordPress site from one server to another. I need some hint on how to deploy a database dump (which I have) from the original server to the new one. There is no phpmyadmin (at least I don't have access to it), so I need to copy the dump using console. Or maybe there is some WordPress plugin for this? ...
phpmyadmin as a plugin: WordPress › Portable phpMyAdmin « WordPress Plugins
Migration: Copying database content to a different server
wordpress
I'm trying to limit a meta_box to posts in a specific category. I'm using this method: http://www.farinspace.com/page-specific-wordpress-meta-box/ and it works rather well But I can't seem to get it to work with categories. Heres' my code: <code> &lt;?php // meta box for news category add_action('admin_init','news_init...
Just went a different way on this, didn't end up using categories.
Limit a meta box to a specific category
wordpress
I have been building websites with WordPress for a couple years now, and have become very reliant on the Simple Fields Plugin . Essentially this plugin lets me attach extra fields to the bottom of my "edit" pages; for example: repeatable image upload fields, extra text fields, etc... This plugin is currently out-of-dat...
While you can create this all from scratch in your theme, I have really been liking the plugin Advanced Custom Fields as an alternative. It has a few flaws, but the major ones (such as slowing down your site) seem to have been fixed, and it's super-easy to use. Best of luck to you!
Alternative to simple fields plugin?
wordpress
I am trying to customize the behavior of my blog to serve a specific single post template based on the category the post is assigned to. I came across this filter in my parent theme which is what gave me the idea. The theme is Photo Workshop by Graph Paper Press. <code> //add single post template depending on category ...
The problem was that the <code> remove_filter </code> function wasn't working. Apparently this is not uncommon from what I've read. I tried testing it with different priorities (1, 9, 20, 999), but there was no difference. So my filter in the child theme and the filter I was trying to remove from the parent theme both ...
Problem getting single_template filter to work - I want to serve a different single.php file for posts in a certain category
wordpress
Im new to Wordpress but I'm looking for a way to loop through all the images that have been uploaded to the media library and output the SRC, description and caption of the image when the caption contains the word 'carousel'. Is this possible?
You could do this pretty easily with a simple query: <code> global $wpdb; $results = $wpdb-&gt;get_results("SELECT * FROM $wpdb-&gt;postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE '%carousel%'"); foreach($results as $result){ //$result-&gt;post_id will give you the original attachment post } </c...
Loop through all media library images and return those where caption contains the text carousel
wordpress
Where should I hook into the admin backend to check and see if the user is "active" as defined by the Membership Plugin. Or in other words, where can I hook into the WP admin header to check an if-statement and redirect if it fails?
Not sure about the Membership plug-in bit, but <code> admin_init </code> will be your best bet. I assume that you don't actually what to hook into the admin header though - this would be <code> admin_head </code> or <code> admin_head-(plugin_page) </code> - but you cannot redirect after these hooks (headers already sen...
Where should I hook into admin?
wordpress
So I installed this plugin http://wordpress.org/extend/plugins/wp-email/ I need a Spanish translation. There is a link that takes you to a list of translation files: http://plugins.trac.wordpress.org/browser/wp-email/i18n/ So I downloaded wp-email-es_ES.mo and wp-email-es_ES.po How do I install a translation?
This Plugin uses <code> load_plugin_textdomain() </code> , which by default uses the Plugin's root directory as the path for the translation files. So: simply add the translation files you downloaded to the Plugin root directory, and you should be good to go. Edit And you're using WordPress in es_ES? No, I just want to...
How to install a translation for a WP plugin?
wordpress
I am using wp_enqeue_script to link to a custom.js file in my plugins folder. However I am expecting a link to show up on the page but it doesn't is there something else I am supposed to other than place this in the header. <code> &lt;?php wp_enqueue_script('myscript', '/wp-content/plugins/myplugin/myscript.js'); ?&gt;...
When and where to load styles & scripts 1) & 2) » If you are enqueueing scripts and styles, you will want to use one of these three hooks: « <code> wp_enqueue_scripts </code> (for the frontend) <code> login_enqueue_scripts </code> (for the login screen) <code> admin_enqueue_scripts </code> (for the admin dashboard) » D...
wp_enqueue_script isn't connecting my custom js file
wordpress
When i create a new page, a permalink is created: <code> www.example.com?page_id=29 </code> . This page is always pointing to the page which <code> id </code> is <code> 29 </code> . Now, i want to point it to the root page in my website: <code> www.example.com </code> . I think it has to do with the permalink, but i ca...
I found it, just i had to install this plugin , then when editing the page, in the bottom a new input is added to put on it the link that i want my page point to, in my case i have put <code> www.mydomainname.com </code> . Hope this help people running in the same problem.
How to make my Home button on the menu redirect to my root page
wordpress
What I am trying to achieve is this: I have a simple page and I want to dynamically add multiple images to it on the sidebar one underneath another. I was thinking about either using meta boxes, post thumbnail or custom field. I am looking for a nice and simple method to do that. Here is a screenshot that better explai...
I would recommend using MetaBoxes. A nice tutorial is here: http://www.farinspace.com/wpalchemy-metabox/
Add multiple images to a page sidebar
wordpress
Any idea how I can use the WP function <code> get_page_by_title() </code> with qTranslate installed? for example: <code> $page_contact = get_page_by_title( '_e("[:en]contact");' ,'page' ); $page_contact_ID = $page_contact-&gt;ID; echo '~~~~'.$page_contact_ID; </code> The only way I can get a match is by including the w...
Ok, now that you know your final goal I can try to answer : first , A little background for other people who will read this and might wonder why this question exists (because it can help also in other cases ) the function get_page_by_title() does exactly what the name say . But qTarnslate , as well as other plugins , a...
How to use get_page_by_title() with qTranslate?
wordpress
I have a few different searches on my website: "Species profiles" (custom post type search) "Glossary" (custom post type search) Generic, site-wide search Currently I'm using <code> search.php </code> ; <code> $_POST["type"] </code> to determine which search has been used and and <code> $_POST["s"] </code> for the quer...
You don't need the type variable and other bits of custom search query code, or custom functions like the other answers. In your searchbox, instead of submitting the form to / submit it to /my_post_type/ instead! WordPress will handle all the rest for you automagically, with no effort involved. What's more this means a...
Using next/previous_posts_link with customised search
wordpress
I like to style some post (bold and link) in the post editor (easy and fun) and categorize it as "quote". Then display it based on a CSS in a sidebar, rotating it, like show 1 each 5 second, randomly. Do you know a plugin the just do that ? thanks in advance
You don't need a plugin for that (and I can't imagine that one would exist for that). A plain simple function, that you call in your sidebar, is enough: The Query <code> function quote_posts_list() { // Retrieve 5 random posts: $posts = get_posts( array( 'numberposts' =&gt; 5, 'orderby' =&gt; 'rand', 'tax_query' =&gt; ...
Quote rotator in the sidebar
wordpress
I am currently trying to create a wordpress search function that shows live results underneath the search bar. There is an example on the World Bank website (screens below). I'm not looking for an autofill like you would find on Google.com which completes words you type, rather I want it to find actual posts on the sit...
The following uses jQuery UI Autocomplete, which has been included in WordPress since 3.3. (I've borrowed the format from @Rarst :D). It's still not precisely what you're after, but gives you a good starting point. The following uses a the basic jQuery UI styling, but you can use the one that's currently worked out on ...
How to create live autofill search?
wordpress
my website was installed and fixed on localhost, then i hosted it on a distant server, i also chaged the parameters in the <code> wp-config.php </code> file to meet to distant database. However, when i try to call it in the url tab, i see always the localhost call in the bottom of the browser. This is my url website .
All of your content is linked to your localhost install. I would suggest using a plugin like Search &amp; Replace to amend your URLs. Also if you haven't already, you will need to change the two entries in the wp_options table (where wp_ is the prefix used). They are rows 0 &amp; 37. These are your URLs for moving your...
My blog hosted in distant server is still connecting to localhost
wordpress
I have a custom post type, with children 2 rows deep... Outfit 1 Inner Child 1 Child 1 Child 1 Child 1 Outfit 2 Inner Child 1 Child 1 Child 1 Child 1 On the inner page, i need to show the content of the children, title, custom post types the normal stuff.. I have the following which does show the child content, but als...
If I understand your question correctly, you try to just get the children and ignore the parent. Dont know where <code> post_child =&gt; 0 </code> comes from but I'd use <code> post_parent =&gt; $parent_id </code> instead. In that case you have to catch the parent ID before you do any new queries. If you do something l...
Get Child Custom Post Content on Single.php?
wordpress
I am currently using wordpress menu like this ... <code> $args=array('menu'=&gt;'menu', 'menu_class'=&gt;'', 'before'=&gt;'&lt;span&gt;', 'after'=&gt;'&lt;/span&gt;', 'link_before'=&gt;'', 'link_after'=&gt;'' ); wp_nav_menu($args); </code> But what if want is to add a specific link to a menu item. Other than a wordpres...
You're <code> _doing_it_wrong() </code> . When you call <code> wp_nav_menu() </code> , you should be referencing <code> theme_location </code> , not <code> menu </code> . The way the custom navigation menu functionality is intended to work: The Theme registers locations for navigation menus to appear, via <code> regist...
Adding an external link to wordpress menu
wordpress
I'm trying to ajaxify my Wordpress theme and I use the method described here and I'm now trying get_the_content of post via functions.php. Using jQuery, when I do alert(data) I get the 'title' echo but not the content of the existing post I want (returns 0). The jQuery part <code> $('.ajaxed,.ajaxed a,.menu-item-home a...
I got a solution stackexchange-url ("here") in another post I made about the same problem I had.
Unable to get_the_content(); of a post in Wordpress via AJAX
wordpress
I have this site where most of the Homepage is programmed into the php page. For example: a photo slider, a list of the most recent products, etc. I also need to add a piece of static text to only the Homepage. It's easy just to add it on the php page, but it should be editable from the admin area. Is there a plugin th...
If you'd like to create a dedicated widget area for this plain text content, you can create your own 'sidebar' snippet in the location of your page where you'd like it to be editable. (I'm using the term sidebar here, but a sidebar can be placed anywhere in your template, not just in the side bar For example, in the te...
Plugin for a static piece of text on homepage
wordpress
Is there a plugin that will allow visitors to email a page or post to someone? I found WP-EMail but it was updated last on April 2010 so I'm not sure if I should use it.
Most of the social media sharing plugins include an email option. I know sharedaddy (within jetpack) has a link that allows a permalink to be emailed to a given address.
Plugin to email a post or page to someone
wordpress
Anybody knows how to solve the issues in qTranslate 2.5.28 with WordPress 3.3.1? http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&amp;t=3045 http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&amp;t=2841 http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&amp;t=3004 http://wordpress.org/support/topic/...
In /wp-content/plugins/qtranslate/qtranslate_wphacks.php, line 89, change this: <code> // do some crazy js to alter the admin view $content .="&lt;script type=\"text/javascript\"&gt;\n// &lt;![CDATA[\n"; $content .="function qtrans_editorInit1() {\n"; // include needed js functions $content .= $q_config['js']['qtrans_i...
qTranslate 2.5.28 and WordPress 3.3.1 issues
wordpress
I have stored an array of post IDs and I would like to list the posts as links, meaning I need to get the title and permalink for the post ID - $id. The list should be echoed out by the following if condition, which means I somehow have to replace $id with the permalink and title. At the moment the code merely lists th...
<code> &lt;?php if(count($related)) { echo "&lt;div&gt;Read More&lt;ul&gt;"; foreach($related as $id) { echo '&lt;li&gt;&lt;a href="'.get_permalink( $id ).'"&gt;'.get_the_title( $id ).'&lt;/a&gt;&lt;/li&gt;'; } echo "&lt;/ul&gt;&lt;/div&gt;"; } ?&gt; </code>
How to get permalink and title from post ID?
wordpress
I'm working on a settings API class which I'd like to be able to drop into a plugin, wpmu plugin, theme, or child theme directory, and have it just work. My issue is that I'm having trouble figuring out how to determine the URIs for including scripts and styles on the fly. I'd like this to work no matter how the site's...
For plugins it is : <code> $plugin_url = plugin_dir_url( __FILE__ ); </code> This works even if <code> wp-content </code> is on a separate domain. You may get problems if your class is in a subdirectory of the plugin – you should probably make the <code> __FILE__ </code> a parameter for a function: <code> public functi...
Dynamically determine URI to scripts and styles included with a class which could be added from plugin/theme/child theme/mu plugin
wordpress
I'm looking to pull up an array of posts based on custom field values: <code> function GetPrimaryLinks($product){ echo '&lt;ul&gt;'; $args = array( 'product' =&gt; $product, 'meta_key' =&gt; 'primary_link', 'meta_value' =&gt; array( 'home', 'obj_handling', 'standalone_doc', 'advantages', 'weaknesses', 'top_comments') )...
Look at the meta_query argument, and the <code> "IN" </code> option for the <code> "Compare" </code> operator. Your query would look something like: <code> $args = array( 'product' =&gt; $product, 'meta_query' =&gt; array( array( 'key' =&gt; 'primary_link', 'value' =&gt; array( 'home', 'obj_handling', 'standalone_doc',...
Get array of posts based on custom field values
wordpress
I have a bunch of plugins I have installed but never use, others I am not sure if they are used or not. Is there a way to tell what plugins are not active on any site?
This plugin does what you want. From the site: "Generates a list of plugins that are currently in use, excluding Network-Activated" - hope that helps!
How do I tell what plugins are used on my multisite install?
wordpress
First question and first commercial plugin. Woohoo! I'm trying to create a dashboard widget that leverages user input and a predefined URL structure to create an outbound link that sends the user to his/her desired destination. This is basically a hack created so that users on a blogging network can query another Wordp...
If you set the action of the form to the page which you want to do the processing, it will redirect to that page as well as setting all the <code> $_GET </code> and <code> $_POST </code> variables up for easy access.
Displaying URL Based on User Input from a Form W/in a Dashboard Widget
wordpress
In a plugin class I want to provide simple fields for public data: email, phone number, Twitter etc. The list can be extended. See the plugin Public Contact Data on GitHub for details. To keep the usage simple, I also want to offer shortcodes which are easy to type: <code> [public_email] </code> <code> [public_phone] <...
This is untested , but the callback function is provided with an array of arguments, <code> $args </code> which give (if any) the paramters provided with the shortocode. The zeroth entry sometimes contains the name of the shortcode used (e.g. <code> public_email </code> ). By sometimes I mean... The zeroeth entry of th...
current_shortcode() - detect currently used shortcode
wordpress
So I'm trying to create some custom fields for users. I need to give users access to a 30 day trial of some software and I want to keep track of that in the users page of administration panel. If the user is in the trail I want to add "Trial" at the top and "Yes" or "No" next to the username on the All Users page. I'm ...
You can hook <code> manage_users_columns </code> to add (and I suppose remove) columns from the All users display. This tutorial details that. You might be able to hook <code> user_edit_form_tag </code> to do the trial vs not trial at the top...but I'm not sure, you'd have to tinker with it. I think you'll probably end...
Add More Fields to Users Pages (Admin Panel)
wordpress
I developed a child theme of Twenty Eleven. I need additional theme options, so i added a theme-options.php file inside my child theme's folder. However, it appears the option page is still the 2011 theme's option screen. I can't either replace or add another one. Question: what is the correct procedure to add options ...
This thread suggests that this isn't necessarily an intended Child Theme usecase so theme-options.php isn't explicitly overrideable. It indicates that you should rather be adding extra options using <code> add_settings_field </code> and the <code> admin_init </code> hook.
Add an option to a Child theme of Twenty Eleven
wordpress
I am writing my first plugin to upload PDF files to a user specified directory other than the media directory specified in the Media menu under settings. I need to extend the WP's native uploader so that files of a particular type in this case PDFs are uploaded to a different directory unlike images. In addition files ...
Both of these are possible. Insert Attachment into Media Library By using the <code> wp_insert_attachment </code> function , you can insert your uploaded images to the Media Library. This is the example code from the Docs: <code> &lt;?php $wp_filetype = wp_check_filetype(basename($filename), null ); $wp_upload_dir = wp...
Extending WP's upload/insert media functionality
wordpress
I have a few WordPress sites and I want to make it easier to manage. I was thinking of being able to switch sites in the dashboard like WordPress multi-site, but when I was looking into it I see that's only for blogs inside blogs (if that makes sense). Is there anyway to link to different blogs together (I have around ...
There is an external services that let you manage multiple sites from one dashboard like manageWP . But i would recommend moving them all in to a multisite install and here is a nice codex entry that shows just how to do that Migrating Multiple Blogs into WordPress Multisite
How to make an interface similar to multi-site for switching between multiple (single) sites for administrators?
wordpress
My goal here is to load the blogroll into my theme via ajax. But all that I can get as response is 0 (if I omit the die() line, else I get a blank response). Here is my code: js ajax: <code> $.ajax({ url:"http://domain.com/wp-admin/admin-ajax.php", type:'POST', data:'action=load_men_blog', //dataType:'html', //cache: f...
The issue here is that you haven't queried any posts. Before <code> have_posts </code> try adding something like, <code> query_posts( 'posts_per_page=5' ); </code>
Wordpress theme ajax have_posts()
wordpress
I'm trying to replace an old logo on a site with a new one. The old logo was 222&times;120px and the new one is 222&times;150px. I uploaded the new one and had it overwrite the old one. My site hasn't changed though. The 30px added to the new logo is the only difference between the two and it just says "Productions". T...
Line 429 (or thereabouts) of your theme's style.css, change height: 120px to height: 150px.
Trouble Adding New Logo
wordpress
I'm making a layout for a wordpress page. The layout needs to connect to a second database (both databases are in the same domain). But the problem is, when i execute just the file it works. But when i included inside the wordpress layout i don't get data, no errorrs, nothing The script is just: <code> $con = mysql_con...
I don't know why the mysql_connect isn't working inside WordPress. But an easier way of doing it would be to use the $wpdb class. Try replacing your code with this: <code> $second_db = new $wpdb( 'user', 'pass', 'dbname', 'host' ); $q = $second_db-&gt;get_results( 'SELECT * FROM vars' ); var_dump( $q ); </code> and see...
Query from a different database than the default
wordpress
I have a contact form that each time I refresh the page I get a prompt to resend all the data, I have added a header("location: location.php"); to the bottom of the form function to try and prevent this. However all I get is a Cannot Modify Header Information - Headers already sent error. Here is my code <code> &lt;?ph...
You cannot send headers once you have sent ANY html to the browser...so if you want to do whatever it is you're trying to do with the headers, you'll need it to be before <code> get_header() </code> . On that note, I'm not sure what you're trying to do with the headers, but the 'Confirm Data Resubmission' prompt is com...
Cannot modify header form resubmits data on refresh
wordpress
As per stackexchange-url ("this") thread I'm scheduling a <code> wp_cron </code> every hour which runs a function. The function I'm running is reasonably lengthy and I didn't want authors to have to deal with the waiting times. My question is this - when creating a function which runs from the following code ( <code> $...
I would filter which posts go into the option, that's light enough processing that it can be done on that end. To get the content of the post you can use <code> get_post( $v ); </code> . To get the metavalues for the post you can use <code> get_post_custom( $v ); </code> . To update the meta values you will use <code> ...
Running a function on post content and CPT meta
wordpress
Following this solution to create dynamic css instead of inline css from sorich87 I get an error when requesting the dynamically generated stylesheet. Css is in there but also the default wp error page and a 404 header returned. Solution I used: stackexchange-url ("stackexchange-url My stylesheet url with 404 error: ht...
The solution you're using to get the stylesheets onto the page is a terrible method. Wordpress provides the enqueue functions specifically to do what you're trying to do. The codex page on <code> wp_enqueue_style() </code> explains exactly what you need to do. If you would like to add a dynamic version, there is a para...
404 error on dynamic stylesheet creation
wordpress
I'm working on a theme for a framework, and using shortcode to divide the layout, I've found the following problem: Into a content, I can divide the container into 12 different parts, it also applies for content inside the content (and this is when problem comes), meaning, for sample, if I decide to set 8 and 4 columns...
Referring to the codex article on shortcodes , you cannot use a shortcode within itself...which is to say that the following is invalid: <code> [foo] [foo] [/foo] [/foo] </code> you should probably make an <code> inner-content </code> shortcode or something.
Shortcode into the same shortcode
wordpress