Nate Reist
Forum Replies Created
-
Forum: Hacks
In reply to: WP_Query and paging problemso because
$paged = 0
it is always grabbing the first 4 posts. As long as paged isn’t defined it won’t grab anything but those 4 posts. You can define paged on your own, but it doesn’t have a global value when you are on a single, because the post could be on different pages for different archives, categories, tags, etc.If you are trying to show the next 4 posts, you might try this on your single pages. get_adjacent_post
<?php // get the 4 on the single posts. global $post; $i = 0; while( $i < 4 ){ $next_post = get_adjacent_post( false, '', false); if( !empty( $next_post ) ){ $post = $next_post; // needs to be $post for setup_postdata... setup_postdata( $post ); ?> <div style="width: 224px; float: left; margin-right: 10px;"> <a href="<?php the_permalink() ?>"><h4><?php the_title(); ?></h4></a><br /> <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(array(224,224)); ?></a> </div> <?php } else{ echo 'not found'; } // end if $i++; } // end while wp_reset_postdata(); // reset your post ?> <div style="clear: both;"></div> <?php next_post_link(); ?> <?php previous_post_link(); ?>
Forum: Hacks
In reply to: WP_Query and paging problemwhat happens if you declare the global post variable before your wp_query?
<?php global $post; ?>
I also can’t help but wonder what the $paged variable does on a single, considering it is not an archive when viewing a single, I think that would return nothing, try this before your query:
<?php echo 'Paged: '.$paged.'<br/>'; ?>
And see what it returns on the single.
Ally22, sorry for the delay on the response to this. Are you logged in still to wordpress? or just into the post? This plugin only destroys the cookie set to access password protected posts, but not the wordpress login cookie.
Forum: Hacks
In reply to: Creating a Google Maps plugin with API vs3I notice your id selectors are inconsistent:
Please enter country and update to preview Google Map <div id="mapcanvas" sty></div>
and
#map_canvas { width: 400px; height: 400px; }
Are you getting a javascript error or just a displaying error from the CSS?
Sorry that functions.php file I refer to is located in
wp-content/plugins/wpematico/app/
Hey There,
I am also running into this issue and think I may have uncovered the problem.
In the functions.php file is the function
function wpematico_cron() { $args = array( 'post_type' => 'wpematico', 'orderby' => 'ID', 'order' => 'ASC' ); $campaigns = get_posts( $args ); foreach( $campaigns as $post ) { $campaign = WPeMatico :: get_campaign( $post->ID ); $activated = $campaign['activated']; $cronnextrun = $campaign['cronnextrun']; if ( !$activated ) continue; if ( $cronnextrun <= current_time('timestamp') ) { WPeMatico :: wpematico_dojob( $post->ID ); } } }
If you are at all familiar with the function with get_posts for wordpress you would instantly notice what might cause an issue. the parameter of the function
numberposts
is not set. By default wordpress get_posts will only get 5 posts. So in this case 5 campaigns will run. If you are fortunate to only have 5 campaigns that need to run you would be fine. If you have more though, like your 30, it will not get to all of them. The case I am working on has 570 campaigns in it.The Fix:
add the argument'numberposts' => -1
to that function. However be careful, editing a plugin file can have undesired results, and if you upgrade the plugin it will be overwritten.function wpematico_cron() { $args = array( 'post_type' => 'wpematico', 'orderby' => 'ID', 'order' => 'ASC' , 'numberposts' => -1 ); $campaigns = get_posts( $args ); foreach( $campaigns as $post ) { $campaign = WPeMatico :: get_campaign( $post->ID ); $activated = $campaign['activated']; $cronnextrun = $campaign['cronnextrun']; if ( !$activated ) continue; if ( $cronnextrun <= current_time('timestamp') ) { WPeMatico :: wpematico_dojob( $post->ID ); } } }
A safer route maybe to create a simliar function and access the WPeMatico class to use it’s functions, but for a quick fix that should do it.
That is a good idea. The purpose of this was just to add a logout button, but I can see how adding a option for that could be helpful. I will look into how I could add that in the next version. I’m glad it could help you.
Forum: Hacks
In reply to: wp_insert_post & wp_update_postHey Godthor,
Nothing about that function included should trigger an infinite loop, unless I am missing something. Have you added this function as an action ( with
add_action();
) somewhere else in your plugin?For clarification
wp_insert_post()
does fire thesave_post
action. This is one way you could potentially create an infinite loop, if you have a function hooked tosave_post
that calls towp_insert_posts()
.Forum: Fixing WordPress
In reply to: Posts not related to my blogIt usually isn’t someone linking your blog to their spam account, more often than not it is the evil bots perusing the web looking for forms to spam, keeps them from getting blacklisted as spam but still gets the spam out.
That being said, the important thing is stopping it. If you are using the standard comments template from wordpress you may want to look into getting a Captcha on it, there are several plugins that do this. A good one is WP reCaptcha.
Alternatively there is a good plugin that will also help stop spam called Akismet. It comes standard with Jetpack I believe but it usually does the trick.
Let me know if that helps.
Forum: Developing with WordPress
In reply to: How to exclude a single category from sliderYou could also accomplish this by adding the
tax_query
parameter to the WP_Query argumentsSee https://codex.www.ads-software.com/Class_Reference/WP_Query#Taxonomy_Parameters
Using the operator argument you can specify NOT IN example below:
'tax_query' => array( 'taxonomy' => %tax_name%, 'field' => 'id', 'terms' => %terms_string _or_array%, 'operator' => 'NOT IN' )
Forum: Hacks
In reply to: wp_headers hook vs admin dashboardThere are a couple of ways to approach this. the hook
init
runs when wordpress is loaded on both the frontend and backend. However, you may not want to add a filteradd_filter
there, you’d more likely want to add an actionadd_action
, but then again you may, depending on what you are trying to accomplish.-Nate
Forum: Hacks
In reply to: Using Meta query to find value in Custom Field arrayOmatan, couple suggestions:
Advanced Custom Fields allows for relationship field types, are you using that?Have you tried
"compare"=>"IN"
instead of"compare" => "LIKE"
?What about
"type" => "NUMERIC"
?The reason you are running into a problem I can see are your
type
parameter for the meta query is set tochar
(that’s the default). 45 is actuallyLIKE
345 in terms of achar
basedLIKE
comparison, because it is part of the string345
.NUMERIC
will compare the integersAn easier way to accomplish this though might be with a tax_query and some taxonomy to achieve post association.
Hope that helps, let me know if you have any questions.
Forum: Fixing WordPress
In reply to: Error 404-Page Not FoundLooks like you may need to change that link in your menu in WordPress. ( Appearance > Menus ).
You may notice: https://robgphotography.net/?page_id=41 is the address that doens’t exist, however https://robgphotography.net/?p_id=41 does which is the address for the your home page. if you switch that query variable page_id with p_id it will probably work.
If you aren’t using the menu settings in your theme, you may try changing the permalinks in Settings > Permalinks.
I usually use Month and Name as my setting usually.