tiaanswart
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Display Not Corrrect on IE, OK on Firefox@franksplace2 your IE document mode is not correctly setup. Press F12 and change thee document mode to ‘IE 9 Standards’
Forum: Fixing WordPress
In reply to: Custom Post Type, pre_get_posts and dynamic validationI finally found a solution for this issue… Each time a post is saved or published i check if the posts are valid then change all the invalid posts to draft, here is my code if this helps anyone else.
/******************************* Make Showcase Posts That Are Not Valid Drafts ********************************/ function ts1_showcase_invalid() { $showcase_invalid = array(); $ts1_showcase_invalid = get_posts(array( 'numberposts' => -1, 'post_type' => array('show-case') ) ); foreach($ts1_showcase_invalid as $post) { setup_postdata($post); $redirect_url = ''; $redirect_url = get_post_meta($post->ID, 'show_case_format_meta_redirect_url', true); if ( !has_post_thumbnail( $post->ID ) ) { array_push( $showcase_invalid , $post->ID ); } elseif ( !empty($redirect_url) && validateURL($redirect_url) !== 'good' ) { array_push( $showcase_invalid , $post->ID ); } } set_transient( 'showcase_invalid', $showcase_invalid ); wp_reset_postdata(); return $showcase_invalid; } add_action("publish_post", "ts1_showcase_invalid_draft"); add_action("save_post", "ts1_showcase_invalid_draft"); add_action("publish_future_post", "ts1_showcase_invalid_draft"); add_action("publish_phone", "ts1_showcase_invalid_draft"); add_action("wp_insert_post", "ts1_showcase_invalid_draft"); add_action("xmlrpc_publish_post", "ts1_showcase_invalid_draft"); function ts1_showcase_invalid_draft() { $showcase_invalid_array = ts1_showcase_invalid(); while (list($var,$value) = each ($showcase_invalid_array)) { $showcase_invalid = array(); $showcase_invalid['ID'] = $value; $showcase_invalid['post_status'] = 'draft'; wp_update_post( $showcase_invalid ); } }
Forum: Fixing WordPress
In reply to: Custom Post Type, pre_get_posts and dynamic validationThanks again for the reply. So do I edit the code from my query that shows the ‘show-case’ post items or can I make this a a global filter?
Forum: Fixing WordPress
In reply to: Custom Post Type, pre_get_posts and dynamic validationI tried the below as well and it still did not populate the ‘post__not_in’:
add_filter('pre_get_posts', 'ts1_remove_showcase_invalid'); function ts1_remove_showcase_invalid( $query ) { if( !$query->is_admin || isset($query->query_vars['post_type']) && 'nav_menu_item' == $query->query_vars['post_type'] ) { //Stupid pre_get_posts and navigation in WordPress return; } elseif( !is_admin() && !ts1_showcase_invalid() ) { $query->set( 'post__not_in', ts1_showcase_invalid() ); } return $query; }
Forum: Fixing WordPress
In reply to: Custom Post Type, pre_get_posts and dynamic validationThanks a mil for the feedback! However isn’t there a way that I can exclude these ‘invalid’ posts from any query on the front end with just one function?
The conditional tags will limit me to page content and exclude queries performed by my sidebars, like the recent posts widget?
Forum: Fixing WordPress
In reply to: Custom Post Type, pre_get_posts and dynamic validationHello, anyone’s help world be greatly appreciated here! ??
Forum: Fixing WordPress
In reply to: problem with capabilities and current_user_can()Try using:
if ( current_user_can( 'edit_posts' ) ) {
instead of:
if ( current_user_can( 'manage_options' ) ) {
Forum: Fixing WordPress
In reply to: Twenty Eleven Adding category title in single postsNope see below code tested works fine now with normal categories:
<header class="page-header"> <h1 class="page-title">Category Archive: <?php $seperator = ' • '; $parents = ''; $post_id = $post->ID; the_category( $seperator , $parents, $post_id ); ?> </h1> </header>
Paste this code just below the following line in single.php:
<?php while ( have_posts() ) : the_post(); ?>
Forum: Fixing WordPress
In reply to: Twenty Eleven Adding category title in single postsI finaly got the category to show in single.php but the below code needs to be pasted below the loop start:
<header class="page-header"> <h1 class="page-title"><?php the_terms( $post->ID, 'Skills', 'Category Archives: <span>', '</span>, <span>', '</span> ' ); ?></h1> </header>
remember to change skills to your own custom taxonomy
Forum: Fixing WordPress
In reply to: Twenty Eleven Adding category title in single postsi’m busy trying to solve the issue from my last post…
you’ve got me intrigued here so if i get impatient it would only be a good thing as it would confirm your suspicion that single.php is really not playing nice…
or i’m just not clever enough to figure it out
Forum: Fixing WordPress
In reply to: Twenty Eleven Adding category title in single postsno hahaha i’m truly lost here i think i know what you want now but i tested it in my code and a weird result with pagination…
when paginating singe.php it worked but the post that i wanted to diplay did not display instead i got another post from that very same category??
Forum: Fixing WordPress
In reply to: Twenty Eleven Adding category title in single postsopening and closing are different as i changed it from a header to a div tag
Forum: Fixing WordPress
In reply to: Twenty Eleven Adding category title in single postsok i give up hahaha….
are you also from SA and do you understand Afrikaans?
Maybe if you explain it that way i can get a fresh look at it?
the first though that comes to mind would be to copy ALL the code from category.php to single.php since the loop in single.php will only find one post but keep the look and feel of category.php it should be what you were looking for in :https://www.ads-software.com/support/topic/twenty-eleven-set-all-posts-to-use-one-navigation-template?replies=19#post-3126786
in this specific string of posts here i would suggest that you amend your above code to something like this:
<div class="page-header"> <h1 class="page-title"><?php printf( __( '%s', 'twentyeleven' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1> <?php $category_description = category_description(); if ( ! empty( $category_description ) ) echo apply_filters( 'category_archive_meta', '<div class="category-archive-meta">' . $category_description . '</div>' ); ?> </div>
and then paste it above the below line of code:
<?php while ( have_posts() ) : the_post(); ?>
however i am not to sure how the pagination would be done then as pagination on the twenty eleven theme goes through the below code:
<?php twentyeleven_content_nav( 'nav-above' ); ?>
from function.php:
if ( ! function_exists( 'twentyeleven_content_nav' ) ) : /** * Display navigation to next/previous pages when applicable */ function twentyeleven_content_nav( $nav_id ) { global $wp_query; if ( $wp_query->max_num_pages > 1 ) : ?> <nav id="<?php echo $nav_id; ?>"> <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyeleven' ) ); ?></div> <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?></div> </nav><!-- #nav-above --> <?php endif; } endif; // twentyeleven_content_nav
Forum: Fixing WordPress
In reply to: Twenty Eleven Adding category title in single postsWell my code is a bit different i did the below to get the skills with their links:
<?php if ( get_the_terms( $post->ID, 'Skills' ) ) : ?> <div class="meta-values"> <p>More Info on this Portfolio Item:</p> <table border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td valign="top" width="200"> Skills: </td> <td valign="top" width="400"> <?php the_terms( $post->ID, 'Skills', '', ', ', ' ' ); ?> </td> </tr> </tbody> </table> </div> <?php endif; ?>
Forum: Fixing WordPress
In reply to: Twenty Eleven Adding category title in single postsWell mine works so i don’t know i’m probably just not understanding you correctly?