RoamFree
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Author page instead shows home pageSigh… a plugin was helpfully blocking the author archive. Fixed.
Nope, I don’t know how ‘ngg-‘ got changed to ‘ngg_’. Used to be ‘ngg-‘, as it should be.
The above TimThumb code can’t handle NGG image IDs (ie, “ngg-1”) because wp_get_attachment() refuses to activate its filters when the image ID is not found. So NGG can’t add a filter to handle NGG images.
The theme can be patched with code similar to what is in another comment.
Themes which need to handle NGG images might be able to be patched with a child theme which uses something similar to this:
/* * Function which returns the URL for a NextGen Gallery (NGG) image. It was inspired by a theme which uses a line similar to: * $image_url = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ); * The above can be fixed to work with NGG by adding the following line after it: * if( function_exists( 'ngg_a_theme_child_theme_thumbnail_id_url' ) ) $image_url = ngg_a_theme_child_theme_thumbnail_id_url( $image_url, get_post_thumbnail_id( $post->ID ) ); * * The first parameter, $image_url, must be FALSE or empty() in order for the function to look up the NGG image ID. If the first parameter has anything in it, that value is returned. * * This function is needed because wp_get_attachment_url() does not invoke its filters when it does not recognize the NGG image IDs (ie, "ngg-1"), thus NGG cannot insert similar code. */ function ngg_a_theme_child_theme_thumbnail_id_url( $url='', $attachment_id='' ) { $return_url = $url; // Default value is whatever was passed in for the URL. if( $url === false || empty($url) ) { if( is_string($attachment_id) ) { $attachment_id = trim($attachment_id); if( substr($attachment_id, 0, 4) == 'ngg_' ) { $numeric_id = substr($attachment_id, 4); // Get the number after 'ngg-' if( is_numeric($numeric_id) ) { if( class_exists('nggdb') ) { $ngg_image = nggdb::find_image($numeric_id); // Find the image info in NGG's database if( $ngg_image ) { $ngg_url = $ngg_image->thumbURL; if( ! empty($ngg_url) ) { $return_url = $ngg_url; // found the needed URL } // if NGG gave us a URL } // if ngg_image not null } // if NGG DB call exists } // if ends with numeric } // if ID starts with 'ngg-' } // if is_string } // if no URL defined // Return the result return $return_url; }
Sigh. Won’t work, if I’m reading it right. wp_get_attachment_url() tries to do a get_post() on the ID, and when that fails it returns false… without running the filters on the function. So code which does the proper lookup for NGG can’t be inserted.
Forum: Plugins
In reply to: [WP Manage Plugins] [Plugin: WP Manage Plugins] PHP errors (patch included)This plugin was last updated in 2009. Maybe it needs a little fix.
Yes, that function is also mentioned near the top of this discussion. The documentation for the Types API says “To insert Types fields using PHP code, use the following syntax:” but gives no hint where to insert such code.
The two hints in “Using Custom Fields” are shortcodes and Views. Shortcodes will only display what is in the current post (or is there a loop-post shortcode?). This discussion seems to be about Types — and not Views, which does provide ways to display what is in Types.
Some of us can insert PHP in pages, but that’s not a general solution and is probably not what was intended. I suspect this does not belong in the loop either, but I’m not certain.
I just tried what is in the Views Template document. That does let you define the appearance of a post of a certain type. If you previously used Types to define a custom post type (ie, vehicle or DVD), then you can attach a View template to that post type so when you look at the post it displays what you’ve defined.
What is missing from that document is having to go back to Types > Custom Fields, edit the Types, and select that the Type should be displayed with this View Template (click Edit next to “Content templates:”). It seems to not be sufficient to select your custom post type in “Post Types:”. When you create a custom post, on the right side should be a pulldown menu to let you select your custom View Template. (EDIT: Hmm… that pulldown menu has also appeared on old non-custom post edit pages also.)
That still doesn’t help a Types-only user to merge Types into their design or theme.
I’m not sure, but I think step 4 in the View Templates document is what connects a View template to a custom post type. The phrasing mostly can mean that, and I suspect that the image is trying to show a connection being made from a View to a custom post type. A better image would be one which shows the first item (post) with a certain View template already chosen, the second item (page) with that pulldown menu, and text indicating what I’m describing… so we who are trying to confirm our weak understanding can strengthen the certainty of understanding.
Of course, that only helps those who are using the Views plugin, not those only using Types.
I haven’t tried the File field type, but the Image field type does let you choose an image using the usual image-selection popup (ie, upload/Media library). But I don’t know why you think it is not useful whether a URL or an internal ID is stored, as long as the user can access the image or file.
candy2012, I suspect the gap in the documentation is because programmers often forget that people don’t know the basic concepts which the programmers learned long ago. In this case, the basic methods of how to make the data be displayed automatically are not documented where we’re looking.
How to manually make data appear is documented, but it’s outdated. One of the example pages shows fields being created, and the field editing page includes the shortcodes needed to display the data. The current version of Types has replaced that with a Types shortcode generator (an icon at the top of the edit page, in the same row as the image-insertion icon).
But inserting a shortcode in the same post which contains the data is only useful in some situations (ie, providing a fill-in-the-blanks tool so someone doesn’t have to edit some messy HTML). How to make a certain custom post type emit data automatically is not pointed out — at least not well enough. Even in the “Views” documentation, they seem to show how to make a page emit data from Types, but I haven’t noticed a way to define how a custom post type should be displayed.
For example, if custom posts are searchable, a search result should find the single entry for a specific house or magazine article (using their Realty and Magazine examples). But how to define the default display for that custom post type is not apparent. We who haven’t yet tried it can hope that is because there is an admin menu option which makes such definitions obvious. But it’s hard to decide on what technology to use in a site if the needed details are hard to find.
The Views PHP Integration document does say:
“Function ‘render_view’
Renders a view and returns the HTML output.”
That’s fine and dandy for a WordPress programmer who knows where to use that. I know plenty of PHP, but for WordPress I know what “the loop” is for, that there seems to be something “single” for posts, and how a plugin hooks in. If there are common places to use that PHP, it would help if those were mentioned.(Me, I’m pretty sure that I need Types and Views, but I’m waiting for a reply to a question related to subdomain sensitivity which was sent to them recently.)
Hmm. Look at the report for that URL on https://www.webpagetest.org/ and you find it takes 7 seconds for the first data to appear… and later several images take 3 seconds. I wouldn’t expect your logo image to be served through Types.
I wonder if a cache plugin would help.
The Types plugin lets you create a custom post type, and connect it to a taxonomy. By “post filtration”, I think what you’re looking for is a category selection or “faceted search” tool. Do a WordPress plugin search for “categories search” and see if one of those will do what you want. This Types plugin can use the normal WP Category or a custom taxonomy, so keep that in mind when reading the options of search tools.
I also encourage support of custom taxonomies and posts.
I’m about to migrate a client to using the plugins “Types – Custom Fields and Custom Post Types Management” and “Views”. I find that I can’t define a custom field of type Image for use with NextGEN gallery, because NGG is only able to insert in the default post data and not in a custom field (although NGG does let me browse the images in the custom field interface).
Fortunately, it appears that we will be able to use NGG because the Featured Image tool still works with NGG. The site only needs one image per post, so we’ll just use Featured Image for the image.
I don’t see the documentation mention it, but some images show that at the top of the edit area, next to the icons for add-an-image, is a “T” icon. Click on that, and it lets you select a shortcode to insert to display a custom field. I had no trouble creating a custom post type which requires the entry of an image and description, and then inserting the shortcodes in the post so the image and description were shown when the post was viewed. Yes, I could have just inserted the image and description in the post, but then I would have lost the enforcement of the fields being required — and I’d be using Views to actually show the posts, which will contain the shortcode definitions. (There also is a checkbox to omit the editor panel in a custom post, which can change post creation into a fill-in-the-blanks activity.)
The Views plugin adds a way to format and display groups of posts, such as showing the newest three posts in the “Android” category in a certain part of a page.