w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Wordpress related posts only show the last three posts in the category. Is there a way to randomize every related post?
Add orderby rand in your arguments and use it like below, <?php $posts = get_posts('orderby=rand&numberposts=5'); foreach($posts as $post) { ?> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> <?php } ?>

Categories : Javascript

Wordpress PHP posts using category as query
In order to only display posts from a single category (or subcategory), you do not need to write any code on page.php file of wordpress. If you want to modify the way posts or list of posts work, on twenty twelve theme, check the file category.php. In order to display the posts of the wanted category you only have to call the category's link. For example, in order to show all the posts on BTCC category, just use this url: http://talkativebroadcasting.co.uk/category/BTCC/ In the same way, you can show all categories you need.

Categories : PHP

Fetch WordPress sticky posts from category
I'm assuming that you defined your $category somewhere as RST mentioned? <?php /* Get all sticky posts */ $sticky = get_option( 'sticky_posts' ); /* Sort the stickies with the newest ones at the top */ rsort( $sticky ); /* Get the 5 newest stickies (change 5 for a different number) */ $sticky = array_slice( $sticky, 0, 5 ); /* Query sticky posts */ $query_args = array( 'post__in' => $sticky, 'category__in'=>array($category) ); ?> $my_query = new WP_Query($query_args); ?> <?php while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?>

Categories : PHP

how to get all the id's of posts made under specific category in wordpress
I hope below are the posts of web articals Frame Work <----- these are my post titles Open Source Model–View–Controller (MVC) If it is so, then use the_ID() function like you have used the_title();.

Categories : Wordpress

How to get the unique tags of the posts under a category in wordpress?
The best workaround is to write custom SQL query and fetch all tags at once. Any other approach which uses WP core functions will generate tons of small SQL queries, what is redundant. Use this query to fetch all category tags: SELECT DISTINCT pt.term_id, pt.name FROM wp_terms AS t LEFT JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id LEFT JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id LEFT JOIN wp_term_relationships AS ptr ON ptr.object_id = tr.object_id AND ptr.term_taxonomy_id <> tr.term_taxonomy_id LEFT JOIN wp_term_taxonomy AS ptt ON ptt.term_taxonomy_id = ptr.term_taxonomy_id AND ptt.taxonomy = 'post_tag' LEFT JOIN wp_terms AS pt ON pt.term_id = ptt.term_id WHERE t.name = 'Car' AND tt.taxonomy = 'category' AND pt.term_id IS NOT

Categories : Wordpress

Wordpress display category posts on different page
Creating a template for this is a solution, but I think it will only work efficiently if you have small number of categories. Try using: http://wordpress.org/plugins/wp-no-category-base/ http://wordpress.org/plugins/top-level-cats/ I think there are other available plugins to do this.

Categories : PHP

Can not query posts by category in WordPress loop
If you use the query you're using query_posts('cat=###') then you need to give the query the category Id not the name. If you don't know the Id offhand, you can find it before you do the query with something close to this: $categories = get_the_category(); //gets all the categories $i=1; $name='design'; $id=''; while(count($categories) > i){ //Loops through the categories if(($categories[$i-1]->cat_name)==$name){ $id=$categories[$i-1]->cat_ID; //Sets the variable $id to be the id you need } i++; }; $id should be the category Id you need to do the query you were using.

Categories : PHP

Wordpress: alphabetice posts using custom category template
With the piece of code you have there you are including a loop in a loop. Using get_posts() with a foreach loop is essentially a WP loop, then you are including get_template_part('loop', 'designers'); which is more than likely another loop. You can remove get_template_part('loop', 'designers'); from your piece of code and just stick in your tags to get the desired content, (i.e the_content(); the_title; the_excerpt; etc..) or you can create a new loop with wp_query() like the below example. <?php $query = new WP_Query(array('post_type' => 'post', 'cat' => 1, 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC')); while ( $query->have_posts() ) : $query->the_post(); ?> // put your content template tags here <?php endwhile; wp_reset_p

Categories : Wordpress

Display featured posts from a specific WordPress category
Try this: $sticky=get_option('sticky_posts'); $query_args=array( 'post__in' => $sticky, 'category__in'=>array($category) ); $the_query = new WP_Query($query_args); You can get the top 5 sticky posts using rsort and array_slice as shown in http://codex.wordpress.org/Sticky_Posts

Categories : PHP

Show only posts related to category or page wordpress
For connect this category to this page you can set product to category archive page from wp-admin/nav-menus.php you can create a simple page template to list category post you can use http://wordpress.org/plugins/list-category-posts/ plugin and use short code like [catlist name="news"] in you page content.

Categories : Wordpress

Hide specific posts from category list in wordpress
Try this: Apply Custom Fields Parameters in get_post query itself. $posts = get_posts(array( 'posts_per_page' => 10, 'post_type' => '<YOUR_POST_TYP>', 'meta_key' => 'taken_check', 'meta_value' => '<DEFAULT_VALUE_OF_taken_check>' )); Lots to read here: http://codex.wordpress.org/Template_Tags/get_posts

Categories : PHP

Plugin WordPress JSON API - How get posts for category with offset?
You can't use get_category_posts with offset. You have to construct the query from the basic get_posts which has a lot of parameters, see here: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters and here (read Method: get_posts): http://wordpress.org/plugins/json-api/other_notes/ I think you should use something like: blablabla.xxx/?json=get_posts&count=10&status=published&cat='id of the category news'&offset='int offset' Be aware that use offset 'breaks' pagination

Categories : Json

Wordpress: Changing a posts category after a comment is posted
<?php $args = array('post_type' => 'post'); $post_obj = new WP_Query($args); while($post_obj->have_posts() ) : $post_obj->the_post(); //display posts with comments $comments = get_comments(array( 'post_id' => $post->ID)); foreach($comments as $comment) { echo '<li>'.the_permalink().'</li>'; } endwhile; ?>

Categories : Wordpress

get posts of category in JPA, mysql
You should do the one that makes more sense in code. Make your code clear and easy to refactor until you have performance issues. I would use the way that doesn't require you to write any queries. This makes it easier for you to change things up later when you do have performance issues. You can probably make better use of your time optimizing the slow parts of your program. For performance, a single trip to the database is faster than multiple trips. Hence, one query would be faster. If there are many fields, you will also want to consider limiting the number of fields you are fetching to improve performance.

Categories : Mysql

Adding new user roll in WordPress that can only add custom posts
you could try this plugin, it should do everything you need http://wordpress.org/plugins/advanced-access-manager/

Categories : PHP

wp category showing all posts from all categories instead of specific posts from specific category
Since you are creating your own WP_Query you have to precise the actual filter you are using. For categories look at the relevant documentation here: http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters Note that if you are modifying the category.php template you are already inside the wordpress Loop and you do not need to specify your own WP_Query. You can simply use a while(have_posts() ): ... endwhile; loop. I would recommend downloading the TwentyTwelve theme and observing its inner workings.

Categories : PHP

Wordpress: adding category filter to custom built wp list table
Use this function wp_dropdown_categories( $args );. It will create dropdown for categories. <?php wp_dropdown_categories( $args ); ?> <?php $args = array( 'show_option_all' => '', 'show_option_none' => '', 'orderby' => 'ID', 'order' => 'ASC', 'show_count' => 0, 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'echo' => 1, 'selected' => 0, 'hierarchical' => 0, 'name' => 'cat', 'id' => '', 'class' => 'postform', 'depth' => 0, 'tab_index' => 0, 'taxonomy' => 'category', 'hide_if_empty' => false 'walker' => '' ); ?> Please re

Categories : PHP

Is it possible to not cut off Wordpress excerpts blog posts in the middle of a text line?
Since this is happening because the title is spanning 3 lines - A possible way is to check how big the title is and then adjust the excerpt from there. so in your functions.php this will adjust the excerpt size - make it the amount that you would want it if the title spans over 3 lines function excerptlength($length) { return 50; //enter your desired ammount } function short_excerpt($length_callback='excerptlength') { global $post; if(function_exists($length_callback)){ add_filter('excerpt_length', $length_callback); } $output = get_the_excerpt(); $output = apply_filters('wptexturize', $output); $output = apply_filters('convert_chars', $output); echo $output; } then add this - which counts the size of the title and if it goes over 70 (or your de

Categories : Wordpress

how can i stop a function from adding a line break after it adds a readmore extension to a wordpress excerpt in a customized recent posts widget?
hi thanks for you input anpsmn. i got it to work by removing the anchor link from within the other anchor link thanks to your insight and replacing it with '...' its still a click able permalink by connecting it directly to the excerpt which is exactly what i needed =) im just preparing to style it with onhover css and a jsscrollpane scrollbar so i needed to be able to control the length of the title and excerpt with the ability to style the title and excerpt separately here is the new function code below the output to the page remained the same thanks =) //rpwp_excerpt function rpwp_excerpt($count){ $permalink = get_permalink($post->ID); $excerpt = get_the_content(); $excerpt = strip_tags($excerpt); $excerpt = substr($excerpt, 0, $count); $excerpt = substr($excerpt, 0, strripos($

Categories : PHP

How to make Wordpress Category menu items display the category as title?
You can look at the category slug in the URL, and get the category by its slug. $cat = get_category_by_slug( $slug ); echo $cat->name; http://codex.wordpress.org/Function_Reference/get_category_by_slug

Categories : Wordpress

Wordpress - Posts Page shows same 5 posts
You may try this (remove the offset) $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $recentPosts = new WP_Query( array( 'cat' => 3, 'posts_per_page' => 5, 'paged' => $paged) ); More on Codex.

Categories : PHP

Show Wordpress Category Based on Category Name's Content
I think, you may try this global $wpdb; $query = SELECT GROUP_CONCAT( wp_terms.term_id ) AS IDS FROM wp_term_relationships LEFT JOIN wp_term_taxonomy ON ( wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id ) LEFT JOIN wp_terms ON wp_term_taxonomy.term_taxonomy_id = wp_terms.term_id WHERE wp_term_taxonomy.taxonomy = 'category' AND wp_terms.name LIKE '*%' $ids = $wpdb->get_var($query); wp_list_categories("include=$ids");

Categories : Wordpress

Display all Posts by their category
You can do it symply by <% @categories.each do |c| %> <li><%= link_to c, blog_path(:category_id => c.id) %></li> <% end %> in controller def blog category_id = params[:category_id] @category = Category.find(category_id) @posts = @category.posts.order("posts.created_at DESC") end

Categories : Ruby On Rails

Query all posts in a certain category
I believe you have to add the buttons and possibly build up the function: Read the Codex friend: https://codex.wordpress.org/Pagination#Function_Reference Also, I believe the commented out part of your code must be active to declare paged. <nav class="wp-prev-next"> <ul class="clearfix"> <li class="prev-link"><?php next_posts_link(__('&laquo; Older Entries', "bonestheme")) ?></li> <li class="next-link"><?php previous_posts_link(__('Newer Entries &raquo;', "bonestheme")) ?></li> </ul> </nav>

Categories : PHP

Display posts based on category one after the other
I don't how you can do such a thing in SQL, so I'll show how you can do it in Ruby code. Unfortunately you need to do two queries. One to get the burgers and one to get the sandwiches. Then we'll use Ruby to alternate between them: burgers = Post.joins(:category).where(:categories => { :name => 'Burgers' }) sandwiches = Post.joins(:category).where(:categories => { :name => 'Sandwiches' }) @posts = if burgers.size > sandwiches.size burgers.zip(sandwiches) else sandwiches.zip(burgers) end.flatten.compact This code uses zip to "weave" burgers and sandwiches into one array. zip results in nested arrays, so we'll call flatten on the result to make the array flat. Finally we use compact to get rid of any nil values in the array.

Categories : Ruby On Rails

Displaying a list of category posts?
If you want to display posts for one category you have to use "get_posts" function (you have many examples here : http://codex.wordpress.org/Template_Tags/get_posts) But you can try to add : $args = array( 'posts_per_page' => 3, 'category' => id_number_of_your_category ); $myposts = get_posts( $args ); echo "<ul>"; foreach( $myposts as $post ) : setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; echo "</ul>"; ?> Hope it's what you were looking for and will help you !

Categories : PHP

MYSQL select Distinct category and list items under that category
You can get the list of elements for each category: select categorytype, group_concat(distinct elements) from t group by categorytype; This returns them as a comma-delimited list.

Categories : PHP

Show posts in random order from category loop
Use shuffle( $array ); to shuffle elements in array. $categories = get_categories(); shuffle( $categories ); foreach( $categories as $category ){ //Your stuff } Hope it helps!

Categories : PHP

Wordpress: when I click on a post, in a category, it loads the category, instead of the post content
When you click on a post ("Wedding Test" or "Long's Wedding Gallery") it takes you to that post. Wordpress by default when you add a post it creates a link after your website (for example http://YOURWEBSITE.com/YOUR-POST/) - If you want it to go to http://YOURWEBSITE.com/YOUR_CATEGORY/YOUR-POST/ you will have to set up custom taxonomies

Categories : Wordpress

Limit homepage posts to one category and maintian sticky order and pagaintion
Not sure about the pagination thing, and this doesn't address your performance concern either, but here is a workaround I came up with a few years ago regarding the sticky posts issue. You basically run two queries, with the sticky posts stacked on top of the non-sticky posts. Below is a simplified version of the original code, so I haven't tested this exact code. The general principle is there however. If you want I can post the original implementation (it was a homepage widget). <ul> <?php $args_sticky = array( 'cat' => 2, 'post__in' => get_option( 'sticky_posts' ); ); /* *STICKY POSTS */ //Display the sticky posts next $the_query = new WP_Query( $args_sticky ); while ( $the_query->have_posts() ) : $the_query-&

Categories : Wordpress

wordpress query first two posts then query remaining posts
Try this way: 1st WP_Query object give you the first two posts. Then store the IDs of those first two posts in array and pass that array in post__not_in parameter of 2nd WP_Query object. $args = array( 'posts_per_page' => 2, 'post_type' => 'product', ); $query_1 = new WP_Query( $args ); $exclude_posts = array(); while ( $query_1->have_posts() ) { $query_1->the_post(); echo '<li>' . get_the_title() . '</li>'; $exclude_posts[] = get_the_ID(); } $args = array( 'posts_per_page' => -1, 'post_type' => 'product', 'post__not_in' => $exclude_posts ); $query_2 = new WP_Query( $args ); while ( $query_2->have_posts() ) { $query_2->the_post(); echo '<li>' . get_the_title() . '</li>'; $exclude_posts[] = g

Categories : Wordpress

How to use WordPress get recent posts?
I'm not certain about what you mean with "post area". With "string text output" I presume you mean unformatted text links in a list. If you need to have more control over how to format the output (to make it more like a regular post listing for example), use a regular WP Query for this. You can get the 5 latest blog entries with these arguments: $recent_args = array( "posts_per_page" => 5 "orderby" => "date", "order" => "DESC" ); $recent_posts = new WP_Query( $recent_args ); And to loop through them just use the regular WordPress main loop structure: if ( $recent_posts -> have_posts() ) : while ( $recent_posts -> have_posts() ) : $recent_posts -> the_post(); // ... Use regular 'the_title()', 'the_permalink()', etc. loop func

Categories : PHP

How to add posts in wordpress pages?
If you want to do it the easy way, you can use a plugin like Display Posts Shortcode. Or, if you want to do it manually, you can use get_posts(). Here's an example you could use: <?php if (is_page()) { $cat=get_cat_ID($post->post_title); //use page title to get a category ID $posts = get_posts ("cat=$cat&showposts=5"); if ($posts) { foreach ($posts as $post): setup_postdata($post); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <?php endforeach; } } ?> I hope this helps!

Categories : PHP

posts showing in same div Wordpress
put the <div class="postswrap"> inside the loop.something like that: <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="postswrap"> <div class="commentsetall"><img src="<?php bloginfo('template_url'); ?>/images/ico_folder.png" alt="Posted" /><span class="commentfix"><?php the_time('F j, Y') ?> in <?php the_category(', ') ?> by <?php the_author() ?></span></div> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> <?php endwhile; else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> <div class="clearfix"></div> </div> <?php

Categories : Wordpress

Different templates for Posts in WordPress
No,It is not possible to do.Different Posts is a normal post type called posts.And pages are called Page. So you can not mess up with pages and posts.Please see wordpress codex templates http://codex.wordpress.org/Templates

Categories : Wordpress

Get category id in wordpress
It depends on what you want to do, but can you try this? echo get_cat_ID('services'); See http://codex.wordpress.org/Function_Reference/get_cat_ID

Categories : Wordpress

How to make Future Posts in Wordpress
Both functions wp_insert_post and wp_update_post accepts an array of posts. And among the parameters, you can set the value of post_date and post_date_gmt.

Categories : PHP

Excluding posts from menu wordpress
This is covered here http://9-sec.com/2012/10/how-to-exclude-pages-from-wp_nav_menu-2/ The other option is to use a custom walker function.

Categories : Wordpress

How can I exclude certain posts from the wordpress loop
try this: query_posts(array('post__not_in' => array(1,2))); if ( have_posts() ) : while ( have_posts() ) : the_post(); where 1 and 2 are posts that you want to exclude.

Categories : Wordpress

Can't add new posts in Wordpress: memory error
In /wp-admin/admin.php on line 108: if ( current_user_can( 'manage_options' ) ) @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); This could be why its for some admin users and not others. You can set constants in the wp-config.php file in the root wp directory, like so: define( 'WP_MAX_MEMORY_LIMIT', '512M' ); However, you shouldn't really need to do that... it seems like there's something else going on.. Good luck.

Categories : Wordpress



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