question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I know how to display content from one page on another page. Here is the code I use to display the last three video-titles, submitted to my video-page, on another page (using Advanced Custom Fields for the content) <code> &lt;?php $other_page = 5; ?&gt; &lt;?php if(get_field('video', $other_page)): $count = 0; ?&gt; &l...
you can use the number param to limit the number of pages you want and get the custom field in the foreach loop :) (child of = your parent page, or the current page) <code> $mypages = get_pages( array( 'child_of' =&gt; $post-&gt;ID, 'sort_column' =&gt; 'post_date', 'sort_order' =&gt; 'desc', 'number' =&gt; 3, ) ); fore...
Display the latest content from subpages of another page
wordpress
I have pages like this with a lot of social buttons. A lot means more than 50 buttons because each posts on that page has its own buttons. So maybe I'll make the page smaller, with less posts but this is not the main reason and not what I am looking for. I want to know how can I make the buttons faster.. <code> Use XFB...
There is a solution that came up recently that is growingly popular especially in the German speaking part of the net called the two-click-method. It loads the buttons only after the user has clicked a grayed out image of the button. This has the advantage of saving the privacy of your users as facebook and twitter are...
Multiple social buttons with a fast loading?
wordpress
I am trying to echo the image src of an image I have uploaded for my custom post type outside of the while loop. I have used the following: <code> $custom_fields = get_post_custom($_GET['id']); </code> I can easily now use this code to get, for example the phone number: <code> echo $custom_fields['telephone'][0]; // e....
I believe you can get away with <code> $image_upload = get_post_meta($post-&gt;ID, 'logo', true); // CALL IMAGE </code> and then display it with <code> echo wp_get_attachment_image($image_upload); // Echo image </code>
Getting a custom post type image using 'get_post_custom'
wordpress
I have a basic understanding of serialize (I come across it often when I'm migrating WordPress installs) and I just discovered json_encode. Given that serialize causes so much trouble with replacing strings in the database (eg. editing an optinos field directly), why does WordPress prefer serialize to (the seemingly si...
serialize representation can be stored in text and reversed JSON representation can be stored in text but cannot always be precisely reversed Run this example: <code> $query = new WP_Query(); var_dump( $query ); var_dump( unserialize( serialize( $query ) ) ); var_dump( json_decode( json_encode( $query ) ) ); </code> Af...
Why does WordPress use serialize rather than json_encode for the options table?
wordpress
I need to add a box so a client can put their own images onto a carousel type slideshow, javascript just outputs the li of each instance it finds. However I cant find a way to create a box where the user can just press enter, add an image, press enter, add an image etc. How can I achieve this? Many thanks
If you want to create an option page with image upload/select fields you can use the Option Framework plugin. It is straighforward and easy to use for anyone. If you want to add upload/select fields to a wordpress page or post use Custom Fields Creator or the more powerful plugin: Advanced Custom Fields. NB you have to...
How to add a box for list items?
wordpress
I use Advanced Custom Fields to show Vimeo videoes on a site I am creating for a client - The client pastes the vimeo ID (the last letters in the url) in a field, and the video is shown. But I would also like to show thumbnail of the video, I am using the following (not working code) for this: <code> &lt;?php $imgid = ...
Maybe this can help <code> $videoID = the_field('video_link'); $jsonurl = 'http://vimeo.com/api/v2/video/'.$videoID.'.json'; $json = file_get_contents($jsonurl,0,null,null); $json_output = json_decode($json,true); echo '&lt;img src="'. $json_output[0]['thumbnail_large'] .'" /&gt;'; </code> It's the same call using json...
Vimeo thumbnails
wordpress
I'm trying to load scripts only when needed on a particular page. I've got the following in my footer, but am struggling with the 'is nots' and also chaining the PHP together in an else if statement - which i think will be more elegant than the way i've written it now. Code is as follows: <code> &lt;?php if (is_page('h...
You should be using <code> wp_enqueue_script </code> rather than putting script tags directly in template files: <code> function wpa61143_enqueue_scripts() { if( is_page( 'home' ) ) : wp_enqueue_script( 'jcarousel', get_template_directory_uri() . '/scripts/jquery.jcarousel.min.js', array( 'jquery' ), null, true, ); els...
Loading scripts on specific pages using PHP in footer.php
wordpress
I'm actually just trying to mirror a GoDaddy site on a subdirectory of my personal 1&amp;1 hosting. I just strait up copy-pasted the file structure, and copied the Database, using a search replace tool to replace the base url with my new one. I then editted the wp-config with the new DB stuff. When I navigate to http:/...
Ok, I'm a jerk. Somehow I overlooked the welcome.html file in the root of the wp install (for some reason this is a GoDaddy 404 page). Not sure what code is causing that to load instead of index.php, but there it is. I deleted this file, and voila! Everything works as expected. That was a waste of 6 hours haha.
Moved site to 1&1 hosting, but is broken and redirecting to GoDaddy 404
wordpress
Multisite 3.4.1 wordpress I redirected wp-admin with htaccess rules, and renamed wp-content and plugins with via wp-config http://codex.wordpress.org/Editing_wp-config.php#Moving_wp-content now I can no longer upload images. when I try to upload an image it starts crunching but then either has an http error or says are...
The issue was that half of the site still used the old wp-content for images under this method so I ended up changing the wp-admin doing a find and replace instead of a htacess redirect.
Problem uploading images
wordpress
Situation: Is header.php file where is code: <code> if(is_single()){ global $my_global_var; $my_global_var == true; } </code> Is functions.php file where is code: <code> global $my_global_var; if($my_global_var == true) { echo "OK"; } </code> But this is not working, what im doing wrong? In sidebar all is fine. Fixed 0...
<code> is_single() </code> is a function returning a <code> boolean </code> value. You could simply use it for your conditional check rather than passing the global variable. Other than that, your first line of code should be setting <code> $my_global_var </code> with a single equal sign, i.e.: <code> $my_global_var = ...
Passing global variable from header.php to functions.php
wordpress
I use Advanced Custom Fields to show Vimeo videoes on a site I am creating for a client - The client pastes the vimeo ID (the last letters in the url) in a field, and the video is shown. But I would also like to show thumbnail of the video, I am using the following (not working code) for this: <code> &lt;?php $imgid = ...
Maybe this can help <code> $videoID = the_field('video_link'); $jsonurl = 'http://vimeo.com/api/v2/video/'.$videoID.'.json'; $json = file_get_contents($jsonurl,0,null,null); $json_output = json_decode($json,true); echo '&lt;img src="'. $json_output[0]['thumbnail_large'] .'" /&gt;'; </code> It's the same call using json...
Vimeo thumbnails
wordpress
I want to find a long-term GUI/plugin-based solution to working with custom posts types, custom taxonomies, and custom fields/metaboxes. To this end I have been reviewing all the major custom post-type related plugins. A long list. I have discovered something which I am confused about, hence my question. I was not able...
Let's start by looking at the Action Reference page in Codex: Actions Run During a Typical Request . When a page is loaded on the front or back end, WordPress goes through the load process- loading its own code, loading plugins, the theme, calling each action in sequence. You can see in the second and third actions whe...
I want to understand plugin implementation of custom posts / taxonomies / metaboxes
wordpress
There are many scripts/hacks out there to insert ads into the middle of the post (after 'x' number of paragraphs), however I haven't found a good enough script that can do the above. This is the script that comes close, <code> &lt;?php $post_counter=0; ?&gt; &lt;?php if (have_posts()) : ?&gt; &lt;?php while (have_posts...
instead of a post counter, you could use the variable <code> $wp_query-&gt;current_post </code> - which starts with 0 for the first post in the loop; for some output after the third post, use for instance this before the line with <code> endwhile; </code> : <code> &lt;?php if( $wp_query-&gt;current_post == 2 ) { ?&gt; ...
Insert image or ad script after 3 posts using the loop
wordpress
I am trying to set up a multi-level custom post type structure with permalinks that look like <code> authors/books/chapters </code> , with authors, books, and chapters all set up as their own custom post type. For example, a typical URL on this site might look like <code> example.com/authors/stephen-king/the-shining/ch...
If you want to keep 'authors' as the base slug in the permalinks, i.e. example.com/authors/stephen-king/ for the 'authors' CPT, example.com/authors/stephen-king/the-shining/ for the 'books' CPT and example.com/authors/stephen-king/the-shining/chapter-3/ for the 'chapters' CPT, WordPress will think pretty much everythin...
Nested custom post types with permalinks
wordpress
I wonder if Wordpress is the best CMS or solution for what I wannt to do? I need to find some way to upload images to a post that I can loop as background images. Just like I can upload multiple images and Wordpress automatically creates a <code> gallery </code> I don't want that to happen, but use those images directl...
You can do that within the loop using <code> wp_get_attachment_image </code> . Something like (not tested): <code> //loop starts //values for get_posts ( or wp query if you prefer) $args = array( 'post_type' =&gt; 'attachment', //gets the attachments aka your images 'numberposts' =&gt; -1, 'post_parent' =&gt; $post-&gt...
Wordpress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
wordpress
I’m using the T5 Comment Textarea On Top -Plugin for the comment_field. I’m a newbie to wordpress. So I don’t know, how can i edit the Style of the comment_field or edit the Label? Usually I would put in the array of comment_form in my comments.php like this: <code> 'comment_field' =&gt; '&lt;p class="comment-form-comm...
Change the textarea earlier than the plugin. The plugin runs with a default priority of 10, so you could use 9: <code> add_filter( 'comment_form_defaults', 'wpse_61103_change_textarea', 9 ); function wpse_61103_change_textarea( $fields ) { $fields['comment_field'] = '&lt;div class="comment-field-wrapper"&gt;' . $fields...
Edit Comment_Field while using T5 Comment Textarea On Top-Plugin
wordpress
I think I may have painted myself into a corner. I need to find a plugin, if such a thing exists, that will be a slider/text combo. My client loves the way the pics on this page slide up to show some text:http://p3mma.com/. The sliders here look like they are a. all images and b. just some sort of javascript and not in...
I don't know of a plugin, but you could do it yourself. Structure : Each slide is a post. Each post contains text and one image (uploaded throught media uploader) To target the proper post, you could use differents techniques, the simpleiet is to use a category i.e. : "slider". Where you want to use the slider, I propo...
Slider/text combination plugin
wordpress
I'm trying to display posts within the WP loop and am able to successfully do so with <code> &lt;?php query_posts('tag_id=10'); ?&gt; </code> Here the loop will display all posts with the tag ID of 10, but I'd also like the loop to display posts from within a Custom Post type by the same tag. I'm able to successfully d...
may i suggest you use instead get_posts()? example <code> $args_t10 = array( 'tag_id' =&gt; 10, ); $postslist_t10 = get_posts( $args_t10 ); ?&gt; $args_t10_v = array( 'tag_id' =&gt; 10, 'post_type' =&gt; 'videos' ); $postslist_t10_v = get_posts( $args_t10_v ); </code> you then can merge and filter the duplicates <code>...
Display by tag from different post types
wordpress
So I've been working on created a catalog based off of wordpress's metabox functionality with a custom post type, but now as it comes time to start searching the database to return specific data sets, I'm realizing that I cannot query the data that has been stored inside a metabox because it is being stored as a serial...
As Kaiser suggested, the Metabox script available over at http://www.deluxeblogtips.com/2011/03/meta-box-script-update-v30.html propagates metadata to the database as individual entries instead of a serialized array. I suppose it is ultimately a matter of preference between how you want your data to be stored in the da...
How to create metabox that can be queried in the database?
wordpress
I'm able to display a message by activation of my theme with the 'new' after_switch_theme hook this way: <code> function themeActivationFunction($oldname, $oldtheme=false) { $msg = ' &lt;div class="error"&gt; &lt;p&gt;The ' . get_option( 'current_theme' ) . ' theme has been ACTIVATED.&lt;/p&gt; &lt;/div&gt;'; add_actio...
It's impossible, because after deactivation your theme isn't even loaded! It's possible, but hacky. Essentially, we unset the <code> action </code> param, load in the themes admin page &amp; then exit before the redirect-on-success occurs. <code> add_action( 'switch_theme', 'wpse_60972_theme_deactivate_message' ); func...
How to display message (with switch_theme hook) after deactivating My theme?
wordpress
I'm trying to attach an object to every post of any type. This will require post ID to populate or create my object. So, I either call <code> global $post, or get_the_ID(), or do get_post() </code> . I hope there is a simple way to do the job, and I found a plugin "wp-post-ratings" uses global $id, it gets the id withi...
If you are using netbeans and xdebug, or have set up your debugging environment correctly then you can observe the variables, objects e.t.c as they change. To see when they are created and what is contained within objects such as wp_query or wp_rewrite your posts-> ID is set once the function wp() is called in wp-blog-...
Does WP have a global of $id?
wordpress
I am attempting to build out a dashboard widget that will perform a validation check on a site RSS feed using the W3 Validator. Their API docs (http://feed2.w3.org/docs/soap.html) provide the method. Here is my function to get the data: <code> $feed = 'http://domain.com/feed/'; $request = new WP_Http; $url = 'http://va...
Lots of places in WordPress use xml_parse including the Atom library, the XML-RPC Library that we use, and SimplePie The oembed class uses SimpleXML. The WordPress Importer and Jetpack actually use both (Jetpack for different things, and the importer tries to use SimpleXML and falls back if it doesn't exist). Basically...
parse XML from URL (via SOAP)
wordpress
To integrate Zurb´s Orbit Slider in my theme, I´m trying to generate this HTML with WordPress: <code> &lt;div id="featured"&gt; &lt;img src="featured-image-1.jpg" alt="the-alt-tag" data-caption="#htmlCaption-1" /&gt; &lt;img src="featured-image-2.jpg" alt="the-alt-tag" data-caption="#htmlCaption-2" /&gt; &lt;img src="f...
I'd use the this code to print the image instead of using <code> the_post_thumbnail(); </code> . So that the <code> $slider_query-&gt;current_post </code> can be used to print the current iteration of post in WP_Query loop. Eg. <code> &lt;img src="&lt;?php wp_get_attachment_url( get_post_thumbnail_id() ); ?&gt;" alt="t...
Featured images loop for Orbit Slider
wordpress
I've got two custom fields for event posts: <code> event-start </code> and <code> event-end </code> . When I'm querying for current events, I'd like to show any post where the <code> event-start </code> OR the <code> event-end </code> is greater than or equal to today's date and I'd like to order them by <code> event-s...
Here's the best solution that I've found: <code> $args = array( 'post_type' =&gt; 'post', 'posts_per_page' =&gt; $number, 'meta_key' =&gt; 'event-start', 'meta_value' =&gt; $today_is, 'meta_query' =&gt; array( 'relation' =&gt; 'OR', array( 'key' =&gt; 'event-start', 'value' =&gt; $today_is, 'type' =&gt; 'NUMERIC', 'com...
Trying to perform complex custom field query with order by set to field value
wordpress
Does anyone know of a wordpress plugin or widget that uses Google Analytics to display the page views to the user of the page they are on? The reason it need to integrate with google analytics is that I have page views from existing posts that I wish to be counted and the normal page view plugins don't show the histori...
Please check out the WordPress Post Analytics Plugin that we ( WisdmLabs) have created. http://wordpress.org/extend/plugins/wordpress-post-analytics/ This is available on the WordPress plugin repository as a free download. We link your Google Analytics account to the plugin and pull data from the Analytics backend to s...
Google Analytics post views in WordPress?
wordpress
I'm very confused with an "Email" custom field, how I can make it automatically clickable as "mailto:" link, inside a loop like this: <code> while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post(); $mail = get_post_meta($post-&gt;ID, 'mail', true); if ($mail) { echo the_title()."&lt;/br&gt;", echo $mail; } /*... rest o...
well you did all the hard stuff, so you can try this: <code> while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post(); $mail = get_post_meta($post-&gt;ID, 'mail', true); if ($mail) { echo '&lt;a href="mailto:'.$mail.'"&gt;email me at '.$mail.'&lt;/a&gt;'; } /* ... */ </code>
Display custom field value as a mailto: link
wordpress
When sorting through my images in Apple Aperture I regularly find myself wanting to post one, or a few dozen, of them to one of my WordPress sites. Does anyone know of an Aperture plugin or some way to create a quick post directly from the app? If Aperture was written in PHP, I'd be set! Thanks, Mark EDIT: I mistakenly...
As this is a matter of Aperture/Lightroom plugins, maybe this Question could be posed in other sites of the Stack: stackexchange-url ("Photography") stackexchange-url ("Ask Different") The Aperture side seems to have less options: the only plugin I've found seems outdated, Pixelpipe an Applescript that may be of use if...
Posting From Apple Aperture?
wordpress
It looks to me that when saving data to the database via the settings API Wordpress sanitizes data by default. By that I mean that if I look at the raw settings options in the database they have (at the very least) been through the wordpress equivalent of htmlentities(). Is there any documentation of the exact sanitiza...
WordPress will not do any data sanitization for you. It does do sanitization/validation of the default options. You have to pass in the third argument of <code> register_setting </code> and either role your own validation callback or or use one of the builtins. If your options is only going to contain a string, you cou...
Default Wordpress settings API data sanitization
wordpress
I've been looking for a plugin that limits the tags dislayed in the tag cloud by date. Basically, I want all tags from a certain date forward. I've searched current plugins and haven't found anything that limits by date. Doing some research, I think I just need to modify the following line from: <code> $tags = get_term...
Well it's not that it's not possible it just means it will take some effort. I am able to use an SQL query that combines the posts, term_relationships and terms tables. This allows a tag or name to be associated with a post which was published on a particular date. This was the sql statement i used -> <code> select * f...
Limit tag cloud terms by date
wordpress
I'm creating a (calendar) plugin where one feature is the ability to download an event as a .ics-file. To do that I have a file called ics.php in which I generate an .ics-file based on the id of the event, passed by a querystring. So far everything works. <code> header('Content-type: text/calendar; charset=utf-8'); hea...
I was bootstrapping Wordpress in ics.php by including wp-blog-header.php (which usually works for me), but after changing it to include wp-load.php instead, the files generated were no longer not being found.
Changing permalink structure breaks link to .php file which generates files dynamically
wordpress
How can I select the first/last object from the list returned by get_posts()? How can I select the preceding/following object relative to an arbitrary object in the object list returned by get_posts? How can I extract a sublist from the list returned by get_posts()?
This sounds like more of PHP question than a WordPress one - <code> get_posts() </code> just returns an array of objects; interact with them like you would any other numerical array: <code> $posts = get_posts(); $first_post = $posts[0]; $last_post = array_slice( $posts, -1, 1 ); $everything_but_first_last = array_slice...
Select objects from get_posts()
wordpress
How would this be done with javascript or a plugin? This would prevent widows from happening in my WordPress posts. Shaun Inman has created a similar plugin for post titles, but not for actual posts. Can his plugin be modified to include posts? http://shauninman.com/archive/2006/08/22/widont_wordpress_plugin Here is a ...
Drop in <code> add_filter( 'the_content', 'widont' ); </code> (and the same for <code> the_excerpt </code> if required). This'll apply the function to the post content in addition to the title ( <code> the_title </code> ).
Adding “&nbsp;” before the last word in multiple defined areas with a plugin
wordpress
I'm trying to display a saved option of a url inside a text input on my themes' options page, but it's just simply not displaying. I've checked the database and my url is saved using the specified option name, I've tried simply echoing the option without escaping and I've also tried using the same esc_url() function ou...
I'm assuming <code> $settings </code> is an assigned variable elsewhere in your code? If so, then ya gotta globalise it son ( variable scope in PHP ): <code> function outputFavIcon() { global $settings; ?&gt; </code> And spell it right too ;) <code> &lt;?php if ( isset ( $settings['generel_settings' /* &lt;- typo? */][...
esc_url not working within add_settings_field callback
wordpress
Question Is there a way that my registered users (if they are not the form is hidden so I don't need that) are restricted to submit the form more than 5 times per day, or 20 per month or whatever value I would use? And I would also need to display the number of sumbmissions they have left. If they already sent the form...
As @amit wrote, the submission should have a daily counter that saves the count for that user, in the wp_usermeta table. If you can run a cron job that runs daily, you can save the submission counter only. The daily cron can reset the counter on assigned time. But if you don't you should save the counter and the day al...
How to allow registered users to submit the form only 5 times per day?
wordpress
We would like to post some html during a specific time on a given day of the week. For instance: Imagine a website for a TV station that wants to show what is on the air right now. I am looking for a plugin that will do this. We will pay. I found something at this site: http://premium.wpmudev.org/project/scheduled-cont...
It turns out that you can join their group for free and then buy a one month subscription with one product for $39. YOU MUST remember to discontinue the subscription before the month is up or you will be billed again automatically. Not my favorite solution. But it IS a solution.
is ther a plugin that will hide/show content for a scheduled period of time?
wordpress
I think I'm pretty close to what I need, but just need a little direction. I'm trying to show a content widget in the backend to users of a certain role. Right now, I'm just testing it out with a user that has a role of <code> subscriber </code> . This works perfect : <code> &lt;?php // Add a widget to the WordPress da...
Possible Reasons - <code> current_user_can() </code> function needs an input of a capability not user role , though it works sometime but we should not use user role as a input to this function. you're passing the <code> subscriber </code> object to function which is a lowest possible role we can have on Wordpress. Tha...
Show special backend content for certain roles
wordpress
I wonder if there is a way to scale down uploaded media exactly to 50%. From what I see, with <code> add_image_size </code> you can only specify a width and a height in pixel. The idea is to upload high resolution images for Retina displays and then let Wordpress generate a custom image size scaled down for standard di...
You can use <code> image_downsize </code> filter and to catch when WordPress wants a downscaled image and not original, and actually a size what doesn't exist. <code> add_filter( 'image_downsize', 'wpse_60890_retina_scale', 10, 3 ); function wpse_60890_retina_scale( $value, $id, $size ) { if ( $size == 'wpse_60890_reti...
There's a way to scale media (images) at 50%?
wordpress
I'm building a site's navigation bar programmatically, using the following code: <code> wp_update_nav_menu_item($menu-&gt;term_id, 0, array( 'menu-item-title' =&gt; $page_data-&gt;post_title, 'menu-item-classes' =&gt; 'main', 'menu-item-url' =&gt; '/', 'menu-item-status' =&gt; 'publish')); </code> this adds menu items ...
As the menu Items are stored as a post type. Not sure but I think we can use <code> wp_delete_post() </code> to programmatically remove it. That will completely remove the menu item from database, So you cant ever have that menu item again.
how do I delete (not exclude) a menu item from navigation bar
wordpress
I hope you guys can help me with this little bug I've encountered. I am using a shortcode to display an audio player in the entries. This is the code i've put in my functions.php: <code> function html5_audio($atts, $content = null) { extract(shortcode_atts(array( "src" =&gt; '', "preload"=&gt; 'none', "loop" =&gt; '' )...
You forgot the closing <code> &lt;/audio&gt; </code> tag at the end. <code> function html5_audio($atts, $content = null) { extract(shortcode_atts(array( "src" =&gt; '', "preload"=&gt; 'none', "loop" =&gt; '' ), $atts)); return '&lt;audio src="'.$src.'" preload="'.$preload.'" loop="'.$loop.'" /&gt;&lt;/audio&gt;'; } add...
no content after shortcode
wordpress
i am using below code which should render next and previous post thumbnail but it is showing the current post thumbnail in Custom Post Type single page <code> &lt;?php $prevpost = get_previous_post(true); $prevThumbnail = get_the_post_thumbnail($prevpost-&gt;ID, array(80,80) ); next_post_link('%link', '&lt;span&gt;' . ...
Try without passing the <code> true </code> argument to <code> get_previous_post() </code> function, because that paramters is used to get link of previous post of same category . Possibly you've not registered the <code> category </code> taxonomy while registering that custom post type.
Next Prev Post link rendering current post thumbnail
wordpress
At the moment to view a category of posts I have a url like <code> http://server/category/tag </code> Is there a way in wordpress I can do this as: <code> http://server/tag </code>
If you want to remove the <code> /category/ </code> base from wordpress urls then I recommend that you use WP No Catgeory base plugin Quote from plugin discription - This plugin will completely remove the mandatory 'Category Base' from your category permalinks e.g. <code> myblog.com/category/my-category/ </code> to <co...
Nicer URL for viewing category of posts?
wordpress
I have a theme with a sidebar and 3 widgets. I want to change the color of one of those widgets. The problem is that all the widgets have the same code: <code> &lt;div class="box_outer"&gt; &lt;div class="widget"&gt; &lt;h3 class="widget_title"&gt;Widget title&lt;/h3&gt; &lt;div class="wid_border"&gt;&lt;/div&gt; &lt;d...
If you register your sidebar this way, your all dynamic widgets gets a unique class automatically e.g. - <code> class="widget-container widget_archive" </code> <code> register_sidebar( array( 'name' =&gt; __( 'Primary Widget Area', 'twentyten' ), 'id' =&gt; 'primary-widget-area', 'description' =&gt; __( 'The primary wi...
Add a specific css to a widget
wordpress
In wordpress, an unattached attachment URL is <code> http://domain.com/?attachment=$id </code> Once after it's attached to a parent, it goes with parent's URL structure, for example: <code> http://domain.com/parent-title/attachment-title </code> I need my attachments URL contains only root domain as the unattached ones...
You can add a filter to the function that gets attachment links to force that format: <code> function wpa60888_attachment_link( $link, $id ){ return home_url() . '/?attachment_id=' . $id; } add_filter( 'attachment_link', 'wpa60888_attachment_link', 10, 2 ); </code> Calls to <code> get_attachment_link </code> will have ...
How to remove parent section in an attachment URL in wordpress?
wordpress
How do I send the new user activation link to my own email address instead of the user? Is there a simple function I can use to switch things out? <code> function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) { $activate_url = bp_get_activation_page() . "?key=$key"; $activate_url = esc_...
Reading the code I would try something like this: <code> add_filter( 'bp_core_signup_send_validation_email_to', 'wpse_60858_catch_user_signup_mail' ); function wpse_60858_catch_user_signup_mail() { // make sure to use a valid email. test it with different addresses return get_site_option( 'admin_email', 'fallback-addre...
Buddypress - Send New User Activation Link to Admin
wordpress
In TwentyEleven the "posted on" text is well above the title. I want it to replace the "posted in category" text. Is there a php file that populates the page where I can just edit where this stuff pops out? I checked my <code> pages.php </code> file but I couldn't seem to figure out what to change.
If you are using the twentyeleven theme which it looks like you are, there is a function called twentyeleven_posted_on(), on line 24 within your content.php file. If you want to move the posted on below then move this piece of code -> <code> &lt;?php if ( 'post' == get_post_type() ) : ?&gt; &lt;div class="entry-meta"&g...
Changing where "posted on" text is located in TwentyEleven?
wordpress
I'm trying to figure how to scale the_post_thumbnail to a specific width? Can you guys help? Currently I'm using <code> &lt;?php //Resize post thumbnail $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'single-post-thumbnail' ); $thumbnailHeight = $thumbnail[1]; $thumbnailWidth = $thumbn...
This should work: You could use: <code> add_image_size( 'category-thumb', 220, 9999 ); //220 pixels wide (and unlimited height) </code> and then to display: <code> if ( has_post_thumbnail() ) { the_post_thumbnail( 'category-thumb' ); } </code> This will create a thumbnail size of 220 by "unlimited"... Set the featured ...
the post thumbnail, scale
wordpress
I have a post with 2 column layout. The first column has an mp3 player. I am thinking of adding a Lyrics window in the second column. Based on the song selected by the user, the Lyrics window will display the Song Lyrics. (without refreshing the whole page). Is this possible in a self-hosted wordpress site? Thanks for ...
You can use jquery to accomplish this or javascript, without looking at your code I would hazard a guess at what is required, this might take some effort. Some things you will need to think about include how you are going to retrieve the lyrics, i.e. are you going to get the information from another site, store the lyr...
Passing inputs from one column to the Other within a post
wordpress
i am trying to add a profile based search option into my existing plugin. my plugin already search members by distance within a certain radius and i want to add the option to filter results by profile fields. what i am trying to do is getting the user id that has the matching values entered in the search form. i am try...
Off the top of my head... I can think of a plugin that does this: http://buddypress.org/community/groups/bp-profile-search/ Perhaps this will provide you with a good starting point for what you're trying to get done.
SQL Query members by profile fields Buddypress
wordpress
If you do a radical update of a theme, can you prevent people from unintentionally upgrading until they have read and approved a warning telling them the changes might break their child themes? Or, is it best to fork your theme and call it Theme2 or something similar?
If you're making a radical change in a framework style theme, I would most definitely fork it into a new &amp; separate version. Particularly if it's going to have a potentially adverse affect on a lot of existing child themes. I'm sure I could come up with a creative way to warn your users of a change -- but that'd be...
Automatic Theme Upgrade hooks?
wordpress
For example I have this code which gets the post title: <code> function baracuda_sinlge_post_title(){ // Single Post Title $post_title = single_post_title('','0'); return $post_title; } </code> Where do you think it would run faster, in functions.php or direcly in the template I need it to be like this: <code> $post_ti...
It doesn't matter. I know you think it matters, but it doesn't. The reason it doesn't matter has nothing to do with which one is actually faster. The speed of your website will NEVER be influenced by the placement of this function. Theoretically, sure, but in practice you'll never see it. The only two places to spend t...
Does code run faster in functions.php than in different theme templates?
wordpress
I have declared a variable in my single.php <code> $title = 'myvar'; </code> Can I get it in my comments.php without re-declaring it again? I use this code to get the comments.php templage: <code> &lt;? comments_template( '', true ); ?&gt; </code> Ty
The <code> comments_template() </code> only accepts two parameters: <code> $file </code> (string) and <code> $separate_comments </code> (Boolean). So, it does not have a way to pass an arbitrary variable as a parameter. The two methods I generally use are: Globalize the variable Wrap the variable inside a function that...
Get declared variable in single.php to work in comments.php without re-declaring it
wordpress
Where would I begin if I wanted to rename a string in the buddypress activity stream? Instead of it saying "so and so wrote a new post", I would like it to say "so and so wrote a new article " (or whatever word I choose) Thanx.
Got it <code> add_filter('bp_blogs_activity_new_post_action', 'record_cpt_activity_action', 1, 3); function record_cpt_activity_action( $activity_action, $post, $post_permalink ) { global $bp; if( $post-&gt;post_type == 'post' ) { if ( is_multisite() ) $activity_action = sprintf( __( '%1$s wrote a new article, %2$s, on...
Customize Activity Stream - Buddypress
wordpress
I want to apply jquery lazyload plugin. For this to work I have to create a new attribute which is data-src place there the src value and then replace the src value with a specific value <code> '...nothing.gif' </code> . I found a solution on wordpress.org support This is my adapted code - <code> function add_lazyload(...
instead of replacing the alt tag you could stackexchange-url ("add-an-attribute-to-a-tag") <code> function add_lazyload($content) { $dom = new DOMDocument(); @$dom-&gt;loadHTML($content); foreach ($dom-&gt;getElementsByTagName('img') as $node) { $oldsrc = $node-&gt;getAttribute('src'); $node-&gt;setAttribute("data-orig...
Replace image attributes for lazyload plugin (data-src)
wordpress
The majority of pages of one of my sites can only be accessed by registered users. While these pages do share some common, static content (headers, etc) most of the information on the page is populated specifically for that user using a variety of usermeta, postmeta and custom table data. Further, a user is unlikely to...
Caching full pages is not going to do you any good for a situation like you described. Users will update things and expect to see their updates right away -- meaning you spend more server time invalidating cached pages. The database server is likely to be your biggest bottleneck in just about any webapp. Two things you...
How effective are cacheing plugins for dynamic pages?
wordpress
This is for a gallery that's populated automatically, images are pulled in from child pages. Layout is: 2 images in a row and they must be left- and right-aligned respectively. I can't figure out a way to add a space between them. When I add margin or padding, the 2nd image gets pushed off to the next line; Without mar...
Use PHP modulo operator (%) to determine the classes and use CSS to float them all left and set clear:right to the odd class. Kind of hard to picture how you're pulling the images without the code though. Could you post a clip of the code you used to pull the images? If not you can resort to JS to add the classes dynam...
Alternating CSS classes for dynamic content
wordpress
We have a plugin that allows us to manage custom post types and we'd like to add AJAX functionality in saving, editing, and deleting posts. I couldn't find similar problems in the internet so I'm wondering if this isn't something easily doable?
You can technically make a XHR to post.php via JavaScript. Below is a proof-of-concept for saving/editing posts only. I haven't tested it at all, so I'm sure you will need to tweak it. I wanted to give you a basic workflow for accomplishing something like this. You can take it and run with it if you need to extend it. ...
Is there an easy way to AJAX-ify saving of post?
wordpress
I have the following code to save the uploaded file to a static directory. <code> &lt;?php //set the image size in mb $max_upload_size='10'; $MAXIMUM_FILESIZE = $max_upload_size * 1024 * 1024; $uploaddir = './uploads/file/'; $file = $uploaddir . basename($_FILES['uploadfile']['name']); if ($_FILES['uploadfile']['size']...
Note - User needs to be logged in to work <code> global $current_user; get_currentuserinfo(); $uploaddir = './uploads/file/'.$current_user-&gt;user_login.'/'; wp_mkdir_p( $uploaddir ); </code> Reference - <code> wp_mkdir_p() </code> -
How to create directory using username within theme
wordpress
How can I make the wordpress comments work with: <code> include(TEMPLATEPATH."/comments.php"); </code> instead of: <code> comments_template( '', true ); </code> Ay ideas? Ty
Short answer: you can't . Longer answer: You can include <code> comments.php </code> as a template-part file inside another template, via: <code> get_template_part( 'comments.php' ) </code> ...but that won't actually make comments work , because the <code> comments_template() </code> template tag does far more than mer...
Make wordpress comments work with include templatepath
wordpress
I'm using my own upload.php file to upload images to: <code> $upload_dir = wp_upload_dir(); $targetDir = $upload_dir['path'].'/'; </code> It works like it should with this exception that images uploaded to <code> uploads/2012/08/ </code> don't appear in <code> Media Library </code> . Is there any function to "register"...
It's because you're not registering them as a media type. Every upload is a WordPress post of the <code> attachment </code> type. To start, it would be something like this: <code> $file_name = 'Some Name'; $file_path = '/path/to/uploads/2012/08/04/newfile.jpg'; $file_url = 'http://url/to/uploads/2012/08/04/newfile.jpg'...
How to register images uploaded via FTP in media library?
wordpress
It's seems that this bug of WP never was solved by WP team. I have custom post-type, my url structure is /%category%/%postname%/ And if i click on 2nd page i will get 404 error. I tried everything i found on internet, plugins, codes.. i even changed my pagination base url to NOT be page, so wp don't think that i'm sear...
Have you tried this? I had gotten the same problem before. I did these steps, and it works for me. I use this code in my functions.php <code> // New method of WordPress Query since 3.4.1 if ( ! function_exists( 'ucc_add_cpts_to_pre_get_posts' ) ) { function ucc_add_cpts_to_pre_get_posts( $query ) { if ( $query-&gt;is_m...
Pagination gives 404 error
wordpress
I just can't win with this project! All of a sudden, each post's gallery photos are showing up in the excerpt/preview of the post. Each post has a gallery of images that should only be visible on the actual post's page. Can anyone see what might be causing this? Here is my code: <code> if ( has_post_thumbnail() ) { the...
<code> if( ( is_page() || is_single() ) &amp;&amp; ( !is_home() &amp;&amp; !is_front_page() ) ){ $content = strip_shortcodes( $original_content); } </code> if its home or front page don't show gallery <code> if( is_home() || is_front_page() ) { // don't show gallery $content = strip_shortcodes( $original_content); } el...
My Gallery Photos are showing in the post's excerpts
wordpress
I'm working on a plugin that sets admin menu submenu pages on all different post types. I need to be able to associate these new submenu pages with the corresponding post type of the top level menu item. Is this possible without having to rely on using <code> $_GET </code> ? I see that <code> $typenow </code> is used o...
You need the information about the current post type in your callback function that renders the submenu page output. And at this point there is a lot of information ready: <code> add_action( 'admin_menu', 'wpse_60730_demo_submenu' ); /** * Register sub menu pages. * * Note that get_current_screen() is still NULL now. *...
Associating custom submenu item with post type of top level menu item
wordpress
I am working on a Mini Job Site. i want to give rating to posts manually from admin / editor side Best rated people will be on top. so visitor'll get better choice. visitor are not allowed to rate posts like this how to do this ? {1} Meta-box uses {2} Custom Field help me please
Here's something I'd use if I want to do that without using plugins Create a custom field as <code> rating </code> and provide the value while doing post. Suppose I gave a rating of 6, Now wordpress save it into the database as. <code> meta_key </code> => rating <code> meta_value </code> => 6 Now to show the rating on ...
How to rate a post from Admin Side / Manually?
wordpress
I want to add some more tabs like photos, videos on the user profiles of my buddypress site. Is there any shortcodes or functions to add the tabs?
Use the following code, <code> function custom_add_activity_tab() { ?&gt; &lt;li id="custom-tab"&gt; &lt;a href="&lt;?php echo site_url( BP_ACTIVITY_SLUG . '/' ) ?&gt;" title="&lt;?php _e( 'Tab.', 'buddypress' ) ?&gt;"&gt; &lt;?php printf( __( 'tab' , 'buddypress' ) ); ?&gt; &lt;/a&gt; &lt;/li&gt; &lt;?php } add_action...
Buddypress shortcode for tabs
wordpress
I have a term that I'd like logged in admin users to see while they're browsing the site while keeping it hidden from the public. I'd prefer to have it done at the lowest level possible, even so far as to prevent the term from showing up publicly with any of the functions (e.g wp_list_categories). What's the best way t...
Currently we can not pass user_ID or user_role to <code> wp_list_category() </code> function, So it is not possible unless you use filter to do this, that is bit complicated so here I has a solution that does exact what you want without using filter. <code> &lt;?php if ( current_user_can( 'manage_options' ) ) { /* A us...
How do I hide a term from non-admin users in get_the_term_list?
wordpress
I will soon be building a site for a local Non-Profit Art Community, and they would like a to have a powerful contact/member management system that can do these key things: Store User Contact info (Address, Phone, Email, Website, regdate, etc.) Synchronize with a newsletter mailing service, their preference is Emma. (A...
Buddypress will probably help you too. I guess you'll want your community members to interact? Also just search the wordpress.org plugins repository , for "membership" or "members" plugins to compare with. The plugin "s2member" , for example, is very popular.
Contact Management Plugin suggestions, or tutorials/resources recommendations
wordpress
Is there a code that i can place in the header that will call a certain div and the content i place inside it for every custom post type i have, Somthething like this. <code> &lt;?php if (is_post_type('pretty-little-liars') ) {echo '&lt;div id="headerimg"&gt;&lt;img src="http://tv-cafe.com/wp-content/uploads/2012/08/li...
I think that will only work in the loop, but what you can do outside of the loop is use <code> &lt;?php if (get_post_type() == 'pretty-little-liars') { echo '&lt;div id="headerimg"&gt;&lt;img src="http://tv-cafe.com/wp-content/uploads/2012/08/liars.png"&gt;&lt;/div&gt;'; } ?&gt; </code>
Calling a div and content in php?
wordpress
Hi i'm using this php code that allows me to call a div in different post type, but the only problem is when i add a second line instead of it showing only on the post type page it shows on the home page as well. When it's only one line it works but when i added the second line the div shows on the homepage as well and...
just use the code below <code> &lt;?php if ( ! is_home() ) { if ( get_post_type() == 'pretty-little-liars' ) { echo '&lt;div id="headerimg"&gt;&lt;img src="http://tv-cafe.com/wp-content/uploads/2012/08/liars.png"&gt;&lt;/div&gt;'; } if ( get_post_type() == 'revenge' ) { echo '&lt;div id="headerimg"&gt;&lt;img src="http...
Post type Echo code is repeating on homepage
wordpress
Here is an ideal workflow for my situation: Upload a folder full of images Resize images according to a specified size Have the ability to organize these images into folders (collection1, collection2, etc) Display the images within these folders in a non-flash gallery (collection1 on page 1, collection2 on page 2, etc)...
i've been using nextgen gallery and i believe it fits your needs: 1. Upload a folder full of images : yes 2. Resize images according to a specified size : yes , on the gallery option you can set the standard size. 3. Have the ability to organize these images into folders (collection1, collection2, etc) : yes , they're ...
Any plugins that upload, resize, and display images?
wordpress
I have a live site and a testing server (XAMPP) that I built the site on originally before publishing it. Obviously, there are a number of things you need to do to migrate a site from one place to another. I was hoping to tap into collective experience to find out the best way of doing this, keeping fuss to a minimum. ...
there are quite a few threads on here about this topic ... just look at these examples: stackexchange-url ("Database synchronization between dev/staging and production") I would also recommend you read Mark Jaquith's post on Local and Dev Tip's .
How do you keep your live and and testing server?
wordpress
I've encountered a strange error while developing a custom theme. After finishing editing the template for a custom post type single view, I passed onto working at the template files for pages and I ealized that Wordpress was actually pointing to index.php template file rather than page.php in my theme for generating t...
I'm going to answer my own question for the sake of people who might run in the same issue as me in my setup I had a plugin handling taxonomies; one of these had the rewrite slug set to "year" - well, it turns out this conflicts probably with date based archives (?) and caused my posts and pages not loading but rather ...
Wordpress not respecting template hierarchy (fetches index.php instead of single.php or page.php)
wordpress
I was looking at the discussion settings in WordPress and near the "Default Avatar" option I saw that it said the following: For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their e-mail address. (I bolded the second part.) I'm just curious as to how thes...
The way gravatar works is that it creates an MD5 of the email address and passes that to gravatar.com. If an avatar exists for that hashed email address, then it gets returned. If not, then it generates a random one based on the data in the hash. Essentially, it's arbitrary. There's code in there that basically says "i...
Display "a generated one [avatar] based on their e-mail address"
wordpress
Add a term for a certain taxonomy with the name: Test Add another term for a different taxonomy with the same name: Test In the wp_terms table you find one record for both terms. In the wp_term_taxonomy table you find two records with the taxonomy and description and other information about the terms. Now, if you edit ...
It is because terms.slug and terms.name are both unique indexes with the MySQL table structure. <code> Unique Packed Column Cardinality Collation PRIMARY BTREE Yes No term_id 13 A slug BTREE Yes No slug 13 A name BTREE No No name 13 A </code> WordPress uses canonical redirects which mainly rely on a viable single <code...
Why does WordPress combine a term with the same name in the wp_terms table?
wordpress
I have this piece of code that I am calling within the loop to get image metadata ( title/caption and description ). It works fine but it only works for the first post in the loop. So I assume it needs to be reset. From looking here I think <code> wp_rest_postdata(); </code> is the right way to reset the query, but sti...
When using <code> get_posts() </code> you don't actually setup post data unless you do so explicitly, via <code> setup_postdata() </code> inside your (usually a <code> foreach </code> ) loop. So, since you're not setting up post data, you shouldn't need to reset post data. but still the output fails for all but the fir...
How to reset post data properly
wordpress
Task: What I'm trying to do I'm fetching data via the WP Http API from a remote server. The data I'm getting back is <code> JSON </code> encoded. In one of my methods, I'm converting them back and then push it into a class variable, so I can use it later in some scripts. Example: How I'm trying to do it <code> // Simpl...
How does core do it? After thinking again about it, I thought there might be a case where WP does the same thing internally. And right: It does it. Example <code> ~/wp-admin/load-scripts.php </code> <code> $wp_scripts = new WP_Scripts(); wp_default_scripts($wp_scripts); // inside wp_default_scripts( &amp;$scripts ) $sc...
Use wp_localize_script for non existing script
wordpress
For the site I am making, I have a few post types: News, Events, Projects, Placements. Each one of these post types will need its own archive page, accessible through the navigation. I am able to create these post types using the Types plugin, but my question is how do I create a archive page for them? I can't figure o...
When a post type is registered , you need to at least set <code> has_archive </code> to true. This will use the post type name as the slug for archive. You can also specify a string representing the slug for <code> has_archive </code> : <code> 'has_archive' =&gt; 'projects' </code> This should be accessible under Type'...
How should I structure my post types?
wordpress
on my posts page i have a share thing in the side bar, however the side bar over laps the main content even though there is plenty of room on the right, i have tried changing single right column and single left column but nothing makes any difference, any advice would be appreciated. <code> http://79.170.40.241/shadder...
Your <code> #primary </code> container is only <code> 620px </code> wide: <code> #primary { float: left; width: 620px; } </code>
Share Bar over laps left column
wordpress
I simply want a second menu in my sidebar to show on all pages. My theme only supports one custom menu though. I am using the first custom menu for the top level nav, and I wanted my 2nd custom menu in the sidebar. I created a second menu and tried adding it using the custom menu widget, however this just adds my first...
Search for the code give here in your themes <code> functions.php </code> file. and register second nave menu as show here. <code> register_nav_menus( array( 'primary-nav' =&gt; "Primary Menu", // file may have this with different name 'sidebar-nav' =&gt; "Sidebar Menu" //add this line ) ); </code> Use custom menu widg...
How to add a second custom menu in my sidebar when theme only supports one?
wordpress
I am planning to sell themes on Themeforest... But i don't have any idea about Theme stuffs... I include some third party stuffs like jQuery, BootStrap, etc., I will include their license. No problem with that. But what about my work? What license should i use for premium WordPress theme? Is it ok to sell my themes wit...
There are two ways of going about licensing WordPress theme, You can License under GNU GPL or you can make your own license. Most of the big brand WordPress Theme Creators like WPMU Dev license under GNU GPL and then make you pay for the download. You could also do it where the download is free or you need a license ke...
How to license my commercial WordPress theme?
wordpress
I don't get it why jQuery function is not working. I read on the interned how to load jQuery in wordpress, but with no success. Can anyone help me? What I did so far: I've put this in header.php inside tags: <code> &lt;?php wp_enqueue_script("jquery"); ?&gt; &lt;?php wp_head(); ?&gt; &lt;script type="text/javascript" s...
Used this approach and it worked: <code> var $j = jQuery.noConflict(); </code> // code <code> $j(function() { </code> //code });
can't make jQuery work (change image on time interval)
wordpress
I've just started learning so this might be a noob question . Displaying Custom Fields With a Custom Field added to the post, it's time to display your books and mood to the world. To display the Custom Fields for each post, use the the_meta() template tag. The tag must be put within The Loop in order to work. Many peo...
you should add <code> &lt;?php the_meta(); ?&gt; </code> in your <code> single.php </code> or in other relevant file. reference how to edit your theme files
Basics: adding template tag to display custom fields in the post
wordpress
I'm looking for a way to protect content by user roles. Example: you have to be registered to view posts (frontend). If a user is a subscriber he can read post 1, 2 and 3, but if the user is a contributor he can view post 1,2,3 and 4,5,6... does anyone know how I can do this?
Although I haven't used this personally you are probably looking at a plugin like this Seems to provide all the functionality you have requested above.
Limit access to posts/pages by user roles
wordpress
I was wondering if there any direct hook to inject some javascript into tinymce iframe?
Not possible, Tinymce uses this javascript to create iframe , so you've to edit the javascript to load additional javascript file into iframe. Thats why there will not be any hook to inject javascript into iframe.
Easy way to inject js in tinymce iframe?
wordpress
I am using this code to get the url of first inserted image in a post. Is there any way I can get the ID of that image. <code> global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/&lt;img.+src=['"]([^'"]+)['"].*&gt;/i', $post-&gt;post_content, $matches); $first_image = $matches ...
No, an image placed inside a post/page content don't reference in your database other than inside your content only. That's why an image attached is better: you have full control over your images since they are in your server and referenced in your database. An attachment is a child post, once you attach an file to a p...
Can I get the ID of an inserted / linked image?
wordpress
I have a WordPress theme built with Masonry script , I added a new template file for list gallery, is working ok in FF and IE but in Google Chrome gallery images (inside containers) are overlapped. Seems like the content is loading faster than images but they don't adjust afterwards.
I can't find any reference about it but it seems Google Chrome (v 21.0.1180.60) do need specified image sizes, in image tag or passing this in css (either class or local): <code> style="display:block;width:333px;height:333px" </code> Or: <code> container.img { display:block;width:333px;height:333px } </code> Maybe this...
Theme using masonry layout script rendering overlaped images in Google Chrome
wordpress
I'm looking for a function that allows admins (only) to activate new users. When a user registers he have to be approved by the admin before he gets access to log in. Does anyone know how I can do this?
We are using this wordpress plug in - New User Approve Provides functionality to approve/deny new user registrations.
How to manually activate user in dashboard only by admin
wordpress
I would like to implement a section of my site that can be used for Q&amp;A, like Quora or the SE sites. So far, the only solution I can find is to use a specialist theme, which I don't want to do - I want the feature to be part of an existing site. What methods or solutions can I use that might work for me in this ins...
To make that part of my existing site, I'd use custom post type , Say a post type as <code> QA </code> and registered users can do post( ask questions) and others can comment(give answers). Using the Roles and Capability feature of wordpress we can create moderators/editors/users for question answer section. We can con...
How can I create a Quora or Stack Exchange facility without using a specialist theme?
wordpress
I like this theme . But I don't want it to use with a wordpress.com blog but download it to use with my WordPress site at my own domain. But I can't find a download link. Is it possible?
For custom installation you should search for the theme on wordpress.org site. The Wordpress.com hosts themes that are available for use only on wordpress.com blogs and they do not provide download link there. - See stackexchange-url ("@songdogtech's answer") below. Here's the link to download that theme - http://www.w...
Download WordPress.com theme: how?
wordpress
I have the following function I wrote … <code> add_filter('post_type_link', 'events_permalink_structure', 10, 4); function events_permalink_structure($post_link, $post, $leavename, $sample) { if ( false !== strpos( $post_link, '%event_type%' ) ) { $event_type_term = get_the_terms( $post-&gt;ID, 'event_type' ); $post_li...
get_the_terms() is probably returning false. Do a print_r($event_type_term) to see what you have in it. From: http://codex.wordpress.org/Function_Reference/get_the_terms Array of term objects on success. False if no terms are found in the given taxonomy and a wp_error object if an invalid taxonomy is entered.
array_pop() expects array, boolean given for $event_type_term -> slug
wordpress
I've got a custom media uploader setup and trying to remove attachment fields from only this uploader, while leaving the fields intact for the default WP post/page media uploader. Everything works great except getting the fields to be excluded behaves oddly. Here's a bit of code on how it works: First, open uploader th...
I know this isn't an in depth answer (I'm at work and can't really test any code) but, maybe you need to look at directly creating hooks for your upload - which should mean that the flash uploader will act as you expect. The hook for the flash loader is: pre-flash-upload-ui You can see where this hook appears here: htt...
Remove attachment fields from custom media uploader
wordpress
How can I display a gallery shortcode for pages who are children of the page with an ID of 9, and the regular content for pages who aren't? This is what I've tried so far, but it's not working: <code> &lt;?php global $wp_query; if( (9 == $ $wp_query-&gt;post-&gt;post_parent ) :?&gt; &lt;?php echo do_shortcode('[gallery...
<code> $thispageid = get_the_ID(); $thispageparent = get_ancestors($thispageid); if( in_array( 9, $thispageparent ) ) echo do_shortcode('[gallery link="file" columns="1" size="large"]'); else the_content(); </code> reference get_ancestors()
Determine page content based on page parent
wordpress
Hi I was wondering if it is possible to create a custom post type called "Gallery" where i only upload photos and ad captions and when i post it, it post as a gallery. Also when it shows on the homepage it shows as "View Photos" instead of read more, and goes straight to the gallery page. Also i want to be able to add ...
Can I show different text for linking to gallery posts ? YES, Here's how to do it, put this where you want to output text as - readmore/view photos, depending on theme or way you're generating these text we can use filter to change it as per custom post type. <code> &lt;?php echo '&lt;a href="'.the_permalink().'"&gt;';...
Creating a gallery custom post type?
wordpress
I want to hide the tag and category boxes from the post editor, the theme I've just developed doesn't need them, thus I want to hide them. I am aware they could be hidden using the 'screen options' menu, however I'd prefer to do this with a bit of code. Is this possible?
Using <code> remove metabox </code> function you can do this. Simply put this inside your themes <code> functions.php </code> file at very end. NOTE - unwrap <code> &lt;?php </code> <code> ?&gt; </code> if necessary. <code> &lt;?php function wpse60590_remove_metaboxes() { remove_meta_box( 'categorydiv' , 'post' , 'norm...
Hide tag and category boxes from the post editor
wordpress
I want WordPress to return the first post image or a default image if no featured image has been set. My theme uses <code> the_post_thumbnail </code> many times, so I don't want to go through and change all references to a new function. I'd rather filter the core. Here's what I've added to <code> functions.php </code> ...
Figured it out: <code> function get_attachment_id_from_src( $image_src ) { global $wpdb; $query = "SELECT ID FROM {$wpdb-&gt;posts} WHERE guid='$image_src'"; $id = $wpdb-&gt;get_var($query); return $id; } add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 5 ); function my_post_image_html( $html, $post_id, $po...
How to replace the_post_thumbnail template tag and show the first inside the post image instead
wordpress
I've tried a number of solutions posted here regarding converting custom fields to featured images - of course in reverse; but non seem to work for me. What I'm trying to do is grab the Featured Image URL once the image is uploaded and set as a featured image; then automatically set the full size image URL as a custom ...
The function <code> get_post_thumbnail_id() </code> needs a value to be passed if using outside the wordpress loop. You forgot to pass it. The code you're using will create a new custom field on each update so here's the modified code that'll perform <code> update_post_meta </code> function if that meta_key is already ...
Getting the Featured image URL and inserting it as Custom Field on Post update / publish
wordpress
My hosting account has a file limit so, to reduce files I don't bother uploading the licence file. Is this breaking the GPL License? I am not redistributing it without the license or anything just using the code.
No, it is not a violation of the GPL to remove any files (including the license file) before uploading. The GPL does not place any restriction on use or modification of a work, but rather only on redistribution of the work or distribution of a modified/derivative work. In fact, the license states this scope explicitly:...
Is it breaking the GPL if you remove license.txt before uploading?
wordpress
I have the following code that I can't get working. I have two cloneable fields that are being output as one entity (URL and thumbnail image). These are cloned fields using the Meta Box Plugin by Deluxe Blogging, so I need to be able to do an if statement if there is nothing at all and then I need to be able to repeat ...
amit helped you out, but while we're at it you really shouldn't be echoing everything like that. Should probably try this instead: <code> &lt;?php foreach ( $videoID as $value ) { ?&gt; &lt;div class="video-pops"&gt; &lt;a class="thumb video-pop-lb" data-video-pid="&lt;?php echo $videoID; ?&gt;"&gt;&lt;/a&gt; &lt;?php ...
Meta Box Plugin Cloned Fields - Multiple Foreach values
wordpress
So our website has about 20k "collaborators" type of users and we'd like to stop loading all of them on the select box on the "add new post" or "add new page" PAGE. Maybe load only authors and above type of users using functions.php Could anybody help? =)
This meta box is using the function <code> wp_dropdown_users() </code> to list all users. It has only one filter to change the output: <code> wp_dropdown_users </code> . But this filter offers just the complete markup and users. It’s neither easy nor fast to parse this via regex for user names, check their roles and th...
Stop loading "collaborators" users on add new post or page?
wordpress
When I call the following code: <code> echo get_avatar( get_the_author_meta('user_email'), '70', get_bloginfo('template_directory')."/images/default.png" ); </code> It generates the following: <code> [http://1.gravatar.com/avatar/f456a030d4086504d0796f0134139410?s=70&amp;d=http%3A%2F%2Fblogs.com%2Fscience-and-medical%2...
I worked out I needed to add quotes around the parameter. <code> echo get_avatar(get_the_author_meta('user_email'), '70', "'" . get_bloginfo('template_directory')."/images/default.png'"); </code>
Gravatar always shows default image
wordpress
Im sorry that I am asking this but I have been searching for ages and for some reaseon the suggested custom user table dosn't work, it just gives me a username error. This is the code I am taking about: <code> define('CUSTOM_USER_TABLE','new_user_table'); define('CUSTOM_USER_META_TABLE', 'new_usermeta_table'); </code> ...
OK Guys. There is a way to do this without editing the core files! 1) Open up your WP-config.php file and add to the file the following code. This will change where WordPress gets it's users from. <code> define('CUSTOM_USER_TABLE','wp_users'); define('CUSTOM_USER_META_TABLE', 'wp_usermeta'); </code> Remember to replace...
Multiple Single Installs of Wordpress with a central user base
wordpress