Jeremy Boggs
Forum Replies Created
-
Forum: Plugins
In reply to: Modifiying the post title with filterYou can also use the
in_the_loop()
conditional tag to only alter the title if you are in the loop, and not elsewhere in WP. Something like this might work:add_filter( 'the_title', 'ta_modified_post_title'); function ta_modified_post_title ($title) { if ( in_the_loop() && !is_page() ) { $title = $title." (modified title)"; } return $title; }
Forum: Fixing WordPress
In reply to: Converting Normal Post To Custom Post TypeIt sounds like your rewrite rules need flushed. Try just going to Admin > Settings > Permalinks and saving that form again as-is, then try reloading your 404’d post. It should work after this.
If you’d like all your Film Review post types to use ‘movies’ as their rewrite base, you can specify that in your register_post_type function. See the URLs section of the Post Types page for some details on this.
Having only some Film Review posts use one url base, and others using a different base, is a bit more complicated.
Forum: Fixing WordPress
In reply to: Tried to upgrade by taking a shortcut – problem HelpCheck your user profile subpanel to see whether you inadvertently disabled the visual editor.
If this isn’t it, it might make more sense to backup your site and replace all the WP files with the latest release, to make sure you get all the necessary files.
Forum: Fixing WordPress
In reply to: Conditonal Gget_post_metaHave you tried printing
get_post_meta($post->ID, 'wider_text_column', true);
to confirm you actually have a value for that custom field for the post?Forum: Themes and Templates
In reply to: Query two previous and next postsI was a bit curious how to do this as well, so I wrote a rough plugin to accomplish this. It’s available right now in my GitHub repository.
it makes two functions available:
multiple_next_post_links()
andmultiple_previous_post_links()
that will display any number of previous or next links. Passing a number as an argument to either function will return that many posts if available. You should use these instead of next_post_link or previous_post_link, at least as the plugin is currently written.I’d be curious to see if this works for you. I may improve it and release if it seems useful.
Forum: Themes and Templates
In reply to: Display custom post type by custom taxonomy?Otto has a a nice post on doing advanced taxonomy queries that might be helpful in your case. I’ve not tried anything like this myself, but it seems like a good place to start.
Forum: Themes and Templates
In reply to: get_page() Parameters Optional?The codex page says it’s option, but you do need to pass it an ID by reference, which the codex page also says. Assuming you know your page’s ID, you can do:
<?php $pageId = '12'; $slug = get_page($pageId)->post_name; ?>
Of course, if you’re on the page template and want to get the slug of the current page, the easiest way to do that is to use the global
$post
variable that’s available:<?php $slug = $post->post_name; ?>
Forum: Themes and Templates
In reply to: Adding auto post summary and thumbnail of first postNot sure about any good tutorials, but you can do this by setting a
$count
variable before your loop, and adding to that incrementally to check for specific post numbers. Something like this:<?php $count = 0; ?> <?php if( have_posts() ) : while( have_posts() ) : the_post(); ++$count; ?> <div class="post"> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> <?php if (($count == '1') && (!is_paged())): // If it's the first post on the first page. ?> <?php if ( has_post_thumbnail() ) the_post_thumbnail(); ?> <?php the_excerpt(); ?> <?php else: // If it's any other post on any other page. ?> <?php the_content(); ?> <?php endif; ?> </div> <?php endwhile; endif; ?>
Forum: Themes and Templates
In reply to: How to add subpages to static Pages templateIt isn’t quite clear from your code example how exactly you want to add the child pages. You can get the child pages using
get_pages()
function, and loop through each of those pages. There is an example on that Codex page dealing with child pages, which you should be able to modify to suit your needs. Something like:<?php $pages = get_pages('child_of=8'); ?>
From there, you can loop through those pages, displaying them as list items or however you’d like to on your page template. If you’d just like a list of links to subpages, you could do:
<?php $pages = get_pages('child_of=8'); foreach ($pages as $page) { echo '<a href="' . get_page_link($page->ID) .'">'.$page->post_title .'</a>'; }
There are plenty of parameters for
get_pages()
, which are all described on the Codex page.Forum: Fixing WordPress
In reply to: Call to undefined function xmlrpc_encode_request()I am just puzzled, why if I send a post to my blog from a remote computer with the same php scipt it works perfect. It should crash all the time with this function call.
Whether the script works or not will depend on whether the server you are running it from supports
xmlrpc_encode_request()
. You said earlier:I can execute the php script from my locate wamp server to my blog with no problems.
This sounds like your local wamp server has or supports
xmlrpc_encode_request()
, and likely other things in the XML-RPC extension for PHP, while the other servers where your running your scripts do not.There likely are other alternatives to this function. I recommend consulting the PHP documentation for the function, which I linked to in my previous post.
If you think you should be able to use the XML-RPC extension on your server, you should contact you server administrator or host for support, because this doesn’t sound like a WordPress-specific issue.
Forum: Fixing WordPress
In reply to: Linking Two Search Functions in BlogsProbably is possible with a bit of work. Haven’t tried this myself, but it looks like someone talked about this a few months ago, and provided a possible solution. Maybe start there? If not, there are plenty of results with a search for ‘one search multiple blogs’ on the forums that might provide some ideas.
Forum: Fixing WordPress
In reply to: Showing Categories on Pages in Post form? Also problem with title.It sounds like you’re running into problems trying to run multiple loops on one template. The Loop page on the Codex has specific instructions on how to work with multiple loops. Doing this correctly will prevent the page title for showing up for you second loop of posts, and likely will solve your issue of not returning all your posts. There are a few examples on the codex page that might help you out.
Forum: Fixing WordPress
In reply to: Posts in Categories IndentingIt seems like your just missing a closing
</div>
tag; Each subsequent post on your categories template is a child of the previous post. Closing that div in your post loop should fix the indenting.Forum: Fixing WordPress
In reply to: Call to undefined function xmlrpc_encode_request()xmlrpc_encode_request()
is not used, as far as I can tell, in the current version of WordPress, so it may be in a plugin. Try deactivating your plugins until you find the culprit. The PHP documentation for this function includes a warning about the experimental status of this function, and it sounds like your host doesn’t support it.Forum: Fixing WordPress
In reply to: Custom post type permalinks 404, and flushing the rewrite rulesThe most elegant solution I’ve found is to set an option on your plugin’s activation, then check for that option in the init. Here’s a gist of what I mean. In a nutshell:
- Set an option called ‘my_plugin_flush_rules’ to ‘true’ on activation
- On init, when you create your custom post type, check that ‘my_plugin_flush_rules’ option, and flush your rules if it is true, then delete the option so it is only flushed once.
The code I link to has more detailed comments. You could easily check this option on a variety of other actions available to plugins.