w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Pagination for my custom post type in widget
Try this one and enter your custom post type's name in 'post_type' => 'your custom post type name' <ul class="posts-list"> <?php if (have_posts()) : ?> <?php global $post; $paged1 = isset( $_GET['paged1'] ) ? (int) $_GET['paged1'] : 1; $cats = get_the_category(); $cat_name = $cats[0]->name; $args = array( 'posts_per_page' => 10, 'offset' => 0, 'category' => $cat_name, 'orderby' => 'post_date', 'paged' => $paged1, 'post_type' => 'your custom post type name' 'order' => 'DESC', 'post_status' => 'publish', 'suppress_filters' => true ); $previous_post = get_posts($args); foreach ( $previous_post as $post ) : setup_postdata( $post ); ?>

Categories : Wordpress

Why does my second WP Custom post-type pagination not work?
You do not have any pagination arguments in the code .. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'posts_per_page' => 3, 'paged' => $paged ); or $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts('posts_per_page=3&paged=' . $paged); or also something like $paged = (get_query_var('paged') && get_query_var('paged') > 1) ? get_query_var('paged') : 1;

Categories : Wordpress

Multiple WP_Query With Custom Post Type & Pagination
So here how you can implement the pagination with your custom post types <?php $paged1 = isset( $_GET['paged1'] ) ? (int) $_GET['paged1'] : 1; $cat_query = new WP_Query( array( 'paged' => $paged1, 'posts_per_page' => 2, 'post_type' => 'cat' ) ); if($cat_query->have_posts()) : ?> <div> <?php while($cat_query->have_posts()) : $cat_query->the_post(); ?> <div> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a> </div> <?php endwhile; ?> </div> <?php endif; $pag_args1 = array( 'format' => '?paged1=%#%', 'current' => $paged1, 'total' => $cat_query-&

Categories : PHP

To get pagination in my wiget custom post type list
you may try like the below <ul class="posts-list"> <?php $cats = get_the_category(); $cat_name = $cats[0]->name; if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } query_posts(array ( 'category_name' => $cat_name, 'posts_per_page' => 6, 'paged' => $paged)); while (have_posts()) : the_post(); // do whatever you want ?> <li> <h5><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h5> <p><strong>posted on</strong> <?ph

Categories : Wordpress

Wordpress pagination links empty on custom post type query
Here's the full functional code you can modify to fit your needs: // Note that on your site's blog page the query var is page, not paged // everywhere else it is paged $curpage = (get_query_var('page')) ? get_query_var('page') : 1; $snapshotargs=array( 'posts_per_page' => 10, 'post_type' => 'qd_galleries', 'qd_galleries_cat' => 'snapshot', 'paged' => $curpage ); query_posts($snapshotargs); $pagecount = $wp_query->max_num_pages; while(have_posts()):the_post();?> <h1><a href='<?php the_permalink();?>'><?php the_title();?></a></h1> <p> the_excerpt();?></p> <?php endwhile; ?> // Note that the pagination is outside of the loop <p class='pagination-links'> Showing page <?=$curpage;?> of &

Categories : Wordpress

WordPress custom post type archive-.php not working
It looks like in your URL example you're attempting to get to the actual template file name itself. But if you've defined the slug to be event you should be able to simply visit localhost/websitename/wordpress/event

Categories : PHP

Wordpress the_content not working with custom post type
I am not familiar with the plugins you mentioned, but check if the custom post type really has a "content" field. If the "content" is a custom field the you have to get it with get_post_meta($post->ID, 'field name', true); I had a similiar problem and it was fixed by adding the following to the template. You can also try adding to your content-custom.php: <?php wp_reset_postdata(); ?>

Categories : PHP

Custom pagination in php with POST
I solved the problem by making the code like this: for ($i = 1; $i <= $pagecount; $i++) { if ($i == 1) echo "<ul>"; echo "<li>"; echo "<input type="hidden" id="p" name="p">"; ?> <a href="" onclick="document.getElementById('p').value=<?php echo $i ?>; document.forms['page'].submit(); return false;"> <?php echo "<span>". $i ."</span></a></li>"; if ($i == $pagecount) echo "</ul>"; } The a href code doesn't work under php tag. Don't know the exact reason though it must be something related with the getElementById option.

Categories : PHP

Wordpress custom post type capabilities, admin can't edit post type
thats a strange problem. it should work. the following will work for you (note i just copied paste my code so some of my code creeped in) add_action('init', 'register_custom_event_type'); function register_custom_event_type() { register_post_type('event', array( 'labels' => array( 'name' => _x('Event', 'Event'), 'singular_name' => _x('Event Custom Post', 'domain'), 'add_new' => _x('Add New', 'domain'), 'add_new_item' => _x('Add New Event Custom Post', 'domain'), 'edit' => _x('Edit', 'domain'), 'edit_item' => _x('Edit Event Custom Post', 'domain'), 'new_item' => _x('New Event Custom Post', 'domain'), 'view' => _x('View Event Custom Post', 'domain'), 'view_item' => _x('View Event Custom Post', 'dom

Categories : Wordpress

Display Post image on the Custom Page Template with Pagination
<?php /* Template Name: emoticons-page */ get_header(); ?> <div id="content"> <div id="main"> <?php $paged = (get_query_var('page')) ? get_query_var('page') : 1; $posts_per_page = 20; query_posts('cat=44&post_status=publish&paged=' . $paged . '&posts_per_page=' . $posts_per_page);?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> <p><?php the_content(); ?> <?php endwhile; posts_nav_link(); wp_reset_query(); endif; ?> </div>

Categories : PHP

Pagination in custom loop not working
Usually what I do when something doesn't work is that I strip it from everything and start rebuilding it with bare basics to see what the problem might be. Why don't you try a simpler form of loop to see if you can get it to prin.t <?php query_posts(array('posts_per_page' => 3, 'post_type' => 'strn5_podcasts', 'paged' => get_query_var('page'))); if (have_posts()) : while (have_posts()) : the_post(); ?> <p><?php the_title(); ?></p> <?php endwhile; endif;?> <div class="navigation-links"> <div class="next-post"><?php next_posts_link( '>> Siguiente Entrada' ); ?></div> <div class="previous-post"><?php previous_posts_link( 'Anterior Entrada >>' ); ?></div> </div> It's pretty much the sa

Categories : PHP

how to display custom post type post's title on page
Well, there are two ways this function will fail (i.e. do nothing): If the first if block is ignored then the second if block will not do anything (I believe it will actually show a notice, because $movie would not be defined). If is_page() does not evaluate to true then nothing will be done in any case. If you know anything about programming then this should be obvious. So, either you have no idea what you are doing, or I am misunderstanding something here.

Categories : PHP

Wordpress custom post type return 'post'
get_post_type() function is to get post type of specific post. So, you need to pass argument as post id or a post object to get type of specific post. If you use it without argument it will print default post type which is 'post'.

Categories : PHP

Transfer All Custom Field Data From Custom Post Type to User Accounts - Wordpress
Take a look to the excellent Posts 2 Posts plugin. In the official Wiki you can find a specific topic that seems to fit your needs: it's called Posts 2 Users. I hope this will be helpful for you.

Categories : Mysql

wordpress adding custom columns to custom post type
$columns that is being passed to your function my_edit_product_columns is an array of all of the existing columns. You can replace the entire thing or use any standard array manipulation to change the columns & column order. For example, if you wanted to specify the columns you would do something like (taken from an events custom post type I use): $columns = array( "cb" => "<input type="checkbox" />", "title" => "Event Name", "event_date" => "Date", "start_time"=>"Time", ); So if you simply print_r($columns) to see what it currently has, you could manually reorder it. To insert your column at a specific position in the existing $columns array use: # Insert at offset 2 $offset

Categories : PHP

Wordpress Shortcode in custom field within custom post type
It's because, you are missing do_shortcode function for parsing shortcode. Assuming you just want to target a single value, you could just do this inside the loop. <?php echo ( do_shortcode( get_post_meta( $post->ID , 'Your textarea Key Name' , true ) ) ); ?> If your post has multiple values for that custom field, then you can set the above to false.. and loop over the array... <?php $values = do_shortcode( get_post_meta( $post->ID , 'Your textarea Key Name' , false ) ); ?> <?php if($values && is_array($values)) : ?> <?php foreach( $values as $meta) : ?> <p><?php echo $meta ?></p> <?php endforeach; ?> <?php endif; ?>

Categories : Wordpress

Associating a custom post type with a custom (user) taxonomy
$pagename = get_the_title(); $user_query= new WP_User_Query( array( 'meta_key' => 'tm-name', 'meta_value'=>$pagename )); if ( ! empty( $user_query->results ) ) { foreach ( $user_query->results as $user ) { echo '<p>' . $user->display_name . '</p>'; } } else { echo 'No users found.'; } ?>

Categories : Wordpress

Custom fields on custom post type archive
May way of doing this is to create a page and put the content in there then use the following code at the top of your archive"post-type".php to display it. $myposts = get_posts( array('post_type'=>'page','numberposts' => 1,'include' => 45) ); foreach( $myposts as $post ) : setup_postdata($post); ?> <article id="post-<?php the_ID(); ?>" <?php post_class('grid_5'); ?>> <header class="entry-header"> <h1 class="entry-title"><?php the_title(); ?></h1> </header><!-- .entry-header --> <div class="entry-content"> <?php the_content(); ?> </div><!-- .entry-content --> </article><!-

Categories : Wordpress

Wordpress Custom Post Type and Custom Taxonomy
Try using the slug instead on the name of the taxonomy term. $tax = 'gallery_type'; $terms = get_the_terms($post->ID, $tax); if($terms){ foreach($terms as $term){ $single = $term->slug; // Also instead of this query for the taxonomy, as you are on the taxonomy page, you should use $single = $wp_query->query_vars['taxonomy_name']; <- This is the slug of the current viewed taxonomy ?> <?php $args = array('post_type'=>'galleries', 'posts_per_page'=> -1, 'tax_query'=>array( array('taxonomy'=>'gallery_type','field' => 'slug', 'terms'=> $single) ), 'order_by'=>'post_date'); $query = new WP_Query($args); if($query->have_posts()){ while($query->have_posts()): $query->the_post(); $post_id = $pos

Categories : Wordpress

How to display custom post type by custom taxonomy?
You have to pass the arguments array to you $wp_query->query($args); in which you define the tag name or category name , taxonomy of tag or taxonomy of category $args = array( 'post_type' => 'your custom post type name', 'paged' => $paged, 'showposts' => 8 , 'your custom goes here taxonomy' =>"tag name or category name" ); $wp_query= null; $wp_query = new WP_Query(); $wp_query->query($args); Generally taxonomy name is what you defined in register_taxonomy('here_goes_taxonomy',array('post_type'), array(...))

Categories : PHP

Custom Permalink of Custom Post Type
If you are using Chrome to test this you will want to make sure your browser cache is emptied. Use the Chrome menu to empty the cache. This has bitten me more than once. I clear the cache, exit Chrome, re-access the site. I've also had issues with Save Changes on permalinks not flushing the permalinks table. Change to the default post ID post type than back to your normal post type. The other issue I've run into with my customer base is a WordPress theme that is augmenting the permalink rules. If not done correctly it can cause custom post types to malfunction. Try a default WordPress theme like Twenty Thirteen. If all else fails start with a test site with a clean WordPress 3.6 install, add your custom post type and NOTHING else (no theme changes or extra plugins). That wi

Categories : Wordpress

custom search against custom post type
Use following code for achieve this function custom_search_where( $where ) { if(isset($_POST['your-custom-serchtext'])){ $where = "post_content Like %$_POST['your-custom-serchtext']% ", $where ); } return $where; } $query = new WP_Query( array('post_type' => 'faq-item','tax_query' => array( array( 'taxonomy' => 'faq-group', 'field' => 'slug', 'terms' => 'australia ' ) )) ); add_filter('posts_where', 'custom_search_where' ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); echo '<li>' . get_the_title() . '</li>'; } } else { // no posts found } remove_filter( 'posts_where', 'custom_search_where' ); I have not

Categories : Wordpress

Add Custom Post Type Every Few Posts
If I'm reading it correctly you've got one query that is getting both regular posts and your custom post type testimonials. So theoretically you could pull 10 results all of which would be posts or all of which would be testimonials, depending on your search criteria. What you probably want to do is make two queries, one for posts and one for testimonials. That will give you two arrays of post objects and then it's easy to loop through and display one type or the other depending on an incremented counter. Very roughly, something like: $args = array('post_type'=>'post', 'posts_per_page'=>9, 'category_name'=>'news); $posts = get_posts($args); $args = array('post_type'=>'testimonials', 'posts_per_page'=>3); $testimonials = get_posts($args); /** see how many of the regula

Categories : PHP

Getting cateogry id from custom post type
You may try this (wp_get_post_terms) //Returns Array of Term ID's for "category" $term_list = wp_get_post_terms($post->ID, 'category', array("fields" => "ids"));

Categories : Wordpress

Get archive category ID of custom post type
wp_get_post_categories can only get POST categories not a custom post's categories, try this instead: $category = get_the_terms( $post->ID, 'custom-taxonomy-here' ); //////find custom taxonomy category name foreach ( $category as $cat){ echo $cat->name; } http://wordpress.org/support/topic/wp_get_post_categories-equivalent-for-custom-taxonomies

Categories : PHP

WordPress Custom Post Type taxonomy
Not sure if this is what you need or mean but it works good here: <?php /* Plugin Name: Page 1 Post Type Plugin URI: Author: Author URI: Version: 0.1 Description: License: GPL2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html */ function codex_custom_init() { $labels = array( 'name' => 'Page 1s', 'singular_name' => 'Page 1', 'add_new' => 'Add New', 'add_new_item' => 'Add New Page 1', 'edit_item' => 'Edit Page 1', 'new_item' => 'New Page 1', 'all_items' => 'All Page 1s', 'view_item' => 'View Page 1', 'search_items' => 'Search Page 1s', 'not_found' => 'No Page 1s found', 'not_found_in_trash' => 'No Page 1s found in Trash', 'parent_item_colon' => '', 'menu_name' => 'Page 1s'

Categories : Wordpress

How can I show only one taxonomy using custom post type?
Just get the first term from the taxonomy terms array <?php $terms = get_the_terms( $post->ID , 'instruments' ); $first_term = reset($terms); echo $first_term->name; ?> If you are using > php 5.4, here's a one liner echo reset($terms)->name; The reset function "Set the internal pointer of an array to its first element". So you basically access the first term of the array.

Categories : PHP

Cannot rename the slug for a custom post type
you are using a wrong array use this instead register_post_type( 'roofers-peakdistrict', array( 'labels' => array( 'name' => __( 'Peak District' ), 'singular_name' => __( 'Roofers Peak District' ), 'add_new' => 'Add New Peak District Page', 'add_new_item' => 'Add New Peak District Page', 'edit' => 'Edit Peak District Page', 'edit_item' => 'Edit Peak District Page', 'new_item' => 'New Peak District Page', 'view' => 'View Peak District Page', 'view_item' => 'View Peak District Page', 'search_items' => 'Search Peak District Pages', 'not_found' => 'No Peak District Pages found', ), 'has_archi

Categories : PHP

Displaying Custom Post Type on page
To display custom posts, use the following code: $args = array( 'post_type' => 'Members', 'posts_per_page' => 10 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); the_title(); echo '<div class="entry-content">'; the_content(); echo '</div>'; endwhile;

Categories : Wordpress

How to get all posts in all categories custom post type?
Use something like this. Here my post type is "post-type-name" and taxonomy is "taxonomy-name" <?php $cat_args = array ( 'taxonomy' => 'taxonomy-name', ); $categories = get_categories ( $cat_args ); foreach ( $categories as $category ) { $cat_query = null; $args = array ( 'post_type' => 'post-type-name', 'taxonomy-name' => $category->slug ); $cat_query = new WP_Query( $args ); if ( $cat_query->have_posts() ) { echo "<h5>". $category->name ."</h5>"; echo "<ul>"; while ( $cat_query->have_posts() ) { $cat_query->the_post(); ?> <li> <?php the_title(); ?> <?php the_content(); ?>

Categories : PHP

Combine three custom post type in function.php
It's been a while since I've used that plugin... Did you try this? $child_posts = types_child_posts(array('business-reviews', 'restaurant-cafe-rev', 'travel-tip-review'));

Categories : Wordpress

List custom post type with certain tag (wordpress)
display all list of post which in add webonly tag notice-tag = your tag taxeonomy name tems in define your tag slug name 'post_type'=>'notice', in define your post type <?php $args = array( 'tax_query' => array( array( 'taxonomy' => 'notice-tag', 'field' => 'slug', 'terms' => array( 'webonly' ) ) ), 'post_type'=>'notice', 'order'=>'ASC', 'posts_per_page'=>-1 ); query_posts($args); ?> <?php while (have_posts() ) : the_post(); ?> <?php echo the_title(); ?> <?php endwhile; ?>

Categories : Wordpress

Wordpress Custom Post Type Archive Issue
Did you take note of this from the manual: In the same way single posts and their archives can be displayed using the single.php and archive.php template files, respectively, single posts of a custom post type will use single-{post_type}.php and their archives will use archive-{post_type}.php where {post_type} is the $post_type argument of the register_post_type() function. http://codex.wordpress.org/Post_Types

Categories : Wordpress

WordPress Custom Post Type Category Not Listing
I just figured this out minutes after posting the question here on Stack Overflow. For anyone that might stumble across this page with the same problem, you have to set post_type in the $args for WP_Query(). WP_Query() should look like this at the start: $args = array('cat' => get_cat_id($category), 'post_type' => 'track-record'); $category_posts = new WP_Query($args);

Categories : PHP

Custom post type exclude taxonomy posts
You have to use the tax_query parameter. See http://www.wpexplorer.com/exclude-taxonomy-wordpress/ for a perfect example of what you're trying to do and http://codex.wordpress.org/Class_Reference/WP_Query for the reference for tax_query.

Categories : PHP

Wordpress: Custom post type with no single page
in your homepage template you will find something like this: <h2>Latest News</h2> <ul> <?php while ( have_posts() ) : the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php endwhile; ?> </ul> Just get rid of the anchor tag linking to the the_permalink and you should be good to go. No need to "disable" the URL, just don't display it in your theme.

Categories : Wordpress

query custom post type by advanced custome field value
Did you try to use 'life_style' => 'firsthome', instead of 'meta_query' => array ( 'key' => 'life_style', 'value' => 'firsthome' ) meta_query is not in class reference of query_posts

Categories : Wordpress

Adding custom post type programmatically doesn't add it to the admin
Silly me. I've been using pre_get_posts to modify WP's search results (allowing users to sort on different fields for one), but I forgot to make sure it doesn't run on admin pages. So on admin listings it would still try to sort on a custom field that only some posts have, thus every post lacking the custom field would not show up. Hope this helps someone in the future.

Categories : Wordpress

how to allow simple user like author in wp to add custom post type in wp-admin?
Basically you can pass this "capabilities" parameter while registering your custom post type : ..., 'capabilities' => array( 'publish_posts' => 'read', 'edit_posts' => 'read', 'edit_others_posts' => 'edit_others_posts', 'delete_posts' => 'delete_posts', 'delete_others_posts' => 'delete_others_posts', 'read_private_posts' => 'read', 'edit_post' => 'read', 'delete_post' => 'read', 'read_post' => 'read', ), ... Assuming that a "suscriber" has just the read capability, he will then be able to access the CPT menu in the admin, list all the CPTs, ... But this may not be very safe because the read capability has nothing to do with what the suscriber will actually do. It may be better

Categories : PHP

Wordpress Custom Post Type Permalink Below Root Directory
If WordPress is handling both the blog and the pages for the products and peoples, you may want to rethink your folder structure. You can still keep most of WordPress where it is (the /blog/ subdirectory), and move its index.php and .htaccess files up to the root. See Giving WordPress Its Own Directory: Using a pre-existing subdirectory install. That being said, if you really don't want to move anything, then you need a more complicated programmatic solution. For that, you need to use the WordPress Rewrite API. The trick is to use its various functions (add_rewrite_rule, add_rewrite_tag, etc.) to create a set of rules WordPress will recognize but then write your own .htaccess file in the root of your website, above the WordPress root folder. So, if you did something like this… <?ph

Categories : Wordpress



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.