Jeremy Felt
Forum Replies Created
-
By default, the taxonomy it uses is ‘category’. It seems your last two examples would work for any category and your first example would work for any category except ‘case-study’.
Are you wanting to navigate by custom taxonomy or post tags?
be_next_post_link( $format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '', $taxonomy = 'category')
Marking this as resolved.
Both examples are close, but a little tweaking is needed.
The filter you are trying to use is
afip_new_post_content
, so that will always be the first argument foradd_filter()
. The second argument should be the function you are using to handle the content, in this casediww_default_post_content()
. The third argument is for priority, and the fourth for number of arguments to pass to the filter.In this case, you are replacing the content entirely rather than appending, so you can probably leave out the third and fourth arguments.
Try this:
// Default post editor text function diww_default_post_content() { $content = '<ul class="details"> <li>Jaar:</li> <li>Afmeting b x h:</li> <li>Techniek: </li> <li>Prijs:</li> <li>Beschikbaar: Ja (<a href="mailto:[email protected]">stuur een e-mail</a>)</li> </ul>'; return $content; } add_filter( 'afip_new_post_content', 'diww_default_post_content' );
For more information on the arguments used with
add_filter()
, check out the Codex article.Forum: Plugins
In reply to: [Ad Code Manager] [Plugin: Ad Code Manager] Setup for Novice DFP Users?For a very detailed start, your 2 best references are going to be the other notes section on the plugin page, which helps explain what needs to be configured, and the example gist, which gives a good rundown of the configuration itself. We’re pushing quickly towards the next release, which adds more flexibility.
I’ll run through some of the basics here, which should get you going down the right path. Definitely follow up with any questions that you have and we can fill in the blanks.
To display an ad code on your site, you’ll need to use the
acm_tag
action.Adding
<?php do_action( 'acm_tag', 'my-728x90-banner' ); ?>
to a spot in one of your theme templates will cause Ad Code Manager to process themy-728x90-banner
tag.Every time you use the
acm_tag
action, an ad code will display in that spot.You can have multiple ads defined so that using
<?php do_action( 'acm_tag', 'my-300x250-sidebar' ); ?>
displays a different sized ad or one with different parameters thanmy-728x90-banner
.Before they will work in your
do_action
call,my-728x90-banner
andmy-300x250-sidebar
, must be defined by adding a filter to your theme. Check out theacm_ad_tag_ids
section of the plugin notes for an example.Once the tags have been defined, you’ll also need to add the URL used by your DFP configuration. Check out the section for
acm_default_url
in the plugin notes for an example of how%site_name%
,%zone1%
and other parameters are defined as part of the URL.The URL defined by
acm_default_url
is then used as part of of theacm_output_html
filter. Check out the section foracm_output_html
in the plugin notes. This is where the full HTML for your DFP code can be placed, including Javascript or iframes. The URL specified earlier will automatically replace the%url%
parameter as this output HTML is parsed by the plugin.And finally, check out the filter for
acm_whitelisted_script_urls
at the bottom of the plugin notes. This is required to add the Doubleclick server address that you will be using in order to prevent injection from other sources.@jen – You are correct. Because all of the image crunching is done by WordPress via AJAX after the upload is complete, there is only one image size available. Even if I request the source for a different image size, it returns the only one it has.
Two (maybe more) ways to handle this on your end.
First:
$my_uploaded_image = wp_get_attachment_image_src( $attachment_id ); $post_content = '<img src="' . $my_uploaded_image[0] . '">'; return $post_content;
In this example (pulled partly from the gist I have in this writeup), the array
$my_uploaded_image
also has keys[1]
and[2]
that give you the image size. (See codex docs for wp_get_attachment_image_src()). You could then perform some math to resize those values before using them in the IMG element like so:<img src="$my_uploaded_image[0]" width="$my_image_width" height="$my_image_height">
That at least sizes the IMG element correctly, though it will still have the browser load the full size image in the background, which could be less than ideal.
OR
If you can modify the theme you are using to use featured images (See codex docs for Post Thumbnails), you can add code to template files to display whichever size you want in any given area.
As a way too brief example, something like this in your
single.php
template:<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h1>Post Title: <?php the_title() ?></h1> <div class="my-post-featured-image"> <?php the_post_thumbnail( 'my-custom-size' ); ?> </div> <?php endif; endwhile; ?>
This would give you a display of the post title and the
my-custom-size
version of your featured image, which, for the sake of being detailed enough, is defined infunctions.php
like so:add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 'my-custom-size', 640, 9999 );
This adds support for a custom size thumbnail that will resize the image to 640 and keep the height automatic.
The second option is my favorite, as this is what the plugin is really intended to help with.
It also allows you to change your mind over time with your photo posts. If you decide next week that you’d rather have images with an 800px width in your layout, it would be a matter of using a different post thumbnail size in your template rather than having to go back and manually change things.
Also (you can tell I like this option), it becomes easier to display different size images depending on the template – archive, search, home, author, etc…
Hope that helps!
Version 0.6 has just been posted and adds filters that allow you to change the new post’s title, content, and categories as files are uploaded.
A full write up with examples is here:
https://www.jeremyfelt.com/wordpress/2012/04/14/filters-in-automatic-featured-image-posts/
@nuessly – check out https://codex.www.ads-software.com/Post_Thumbnails as an option for the theme you are using. You really do have more flexibility when using featured images rather than relying on the post content. A different size can be pulled and displayed whenever and on whichever template you need it.
Hey Tim,
Glad you’re enjoying the plugin.
I’ve taken care of the attached image section of the clip you shared in the latest update (0.5). Attachments will now be ‘attached’ correctly to the new post that was created.
I’ll explore adding an action/filter in the next release so that updating extra post meta during this plugin’s operation can be something added to your theme’s functions.php file.
Hi Jen,
I explored a couple different ways of doing this today, but wasn’t able to get to anything solid.
To make the plugin fill the post content in a useful way, I need to determine the best way to present and handle options for what size the image should be by default and how it should be aligned. When a theme has featured image support, these decisions are already taken care of by displaying the image separately from the post content.
I’ll keep rolling some ideas around in my head to see if I can figure out a good solution.
Hey Li-An – sorry, I forgot to subscribe to the RSS feed for this forum and there are no other notifications apparently.
I think you’ll be happy with the latest update as custom post types are now supported. Let me know if you have any issues using the plugin with yours.
Cheers!
Can you describe the issue in more detail? Is there an issue with the plugin or are you trying to use that code separately? Thanks!