w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Query multiple custom post types using ratios (or similar)
I would probably handle this manually with 2 separate custom queries (using WP_Query). I'm going to assume you want paging enabled (since it's your only blogroll and eventually this will get very large). In general, the strategy is going to be: 1) Build two different queries (1 for your projects, videos, and posts... And 1 for your tweets). 2) Setup the ratio you'd like to mix using the posts_per_page attribute of your query arguments. 3) Loop each query, but don't output their titles or content just yet, but rather, store each in its own array. 4) Create a new array to contain your "shuffled" blogroll. 5) Loop through this new array to output the content. $posts_array = array(); // this will temporarily hold your projects/videos/posts $tweets_array = array(); // this will temporar

Categories : Wordpress

Array for recognizing multiple custom post types?
Try <?php if( in_array('movies','books') != get_post_type() ) { get_template_part( 'content', get_post_format() );} ?> <?php if( 'movies' == get_post_type() ) { get_template_part( 'content', 'movies' );} elseif( 'books' == get_post_type() ) { get_template_part( 'content', 'books' );} ?>

Categories : PHP

WP_Query - multiple custom post types and sort by custom meta
use orderby instead of order_by $warsztaty_q = new WP_Query(array( 'post_type' => array('kalendarium', 'warsztaty'), 'orderby' => 'meta_value', 'meta_key' => 'data_start', 'order' => 'ASC' )); refer codex for more details

Categories : Wordpress

wordpress the_category for custom post types
You have to use 'taxonomies' => array('category') in your register_post_type() function to make it connected to the category. Also, you can use this register_taxonomy_for_object_type('category','portfolio'); after you call the register_post_type() function. If you want your custom post type posts to show up on standard archives or include them on your home page mixed up with other post types, use the pre_get_posts action hook. add_action( 'pre_get_posts', 'add_my_post_types_to_query' ); function add_my_post_types_to_query( $query ) { if ( is_home() && $query->is_main_query() ) { $query->set( 'post_type', array( 'post', 'page', 'portfolio' ) ); } return $query; }

Categories : PHP

Get Custom field value from Custom Post Types with a Parent Child Relationship in Wordpress
I hope I understood your question correctly First we need to call the Hotel Query. Then display its image and custom meta. Then within the hotel query - display the room post and meta. <?php $parent = array( 'post_type' => 'hotel', 'post_parent' => 0, 'order' => 'DESC', 'orderby' => 'date'); $hotelparent = new WP_Query($parent); if ( $hotelparent->have_posts() ) : while ($hotelparent->have_posts()) : $hotelparent->the_post();?> <article> <header> <figure><img width="300" height="160" alt="Placeholder" src="<?php echo get_post_meta($hotelparent->ID,'wpcf-image',true);?>"><div class="fit-a"></div></figure> <h3><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h3> &l

Categories : PHP

Add custom taxonomies as class names to an archive page of custom post types, wordpress
wordpress has a clean way of outputting the class name for a post item - using post_class so in your case first set the div to <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>...</div> and to add the taxonomy name to the class you have to add a filter. So in your functions.php drop this in (change YOUR_TAXO_NAME to the name of your custom taxonomy): (taken from here) add_filter( 'post_class', 'custom_taxonomy_post_class', 10, 3 ); if( !function_exists( 'custom_taxonomy_post_class' ) ) { function custom_taxonomy_post_class( $classes, $class, $ID ) { $taxonomy = 'YOUR_TAXO_NAME'; $terms = get_the_terms( (int) $ID, $taxonomy ); if( !empty( $terms ) ) { foreach( (array) $terms as $order =

Categories : PHP

Displaying only custom post types that's custom date fields values are either today or in the future
You should use meta_query custom field parameters. $args = array( 'post_type' => 'events', 'posts_per_page' => '3', 'orderby' => 'meta_value', 'order' => 'ASC', 'meta_query' => array( array( 'key' => 'event_date', 'value' => date( YOUR-FORMAT-HERE ), 'compare' => '>=' ) ) ); $query = new WP_Query( $args ); Hope it helps!

Categories : PHP

Custom Post Types in main index? (wordpress)
This is from wordpress documentation Write this in your theme folders functions.php file: function add_post_type_home_query( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set('post_type', array( 'post', 'your_custom_post_type' ) ); } } add_action( 'pre_get_posts', 'add_post_type_home_query' ); Don't forget to replace 'your_custom_post_type' with your actual post_type that you created.

Categories : PHP

How to extract a Custom Post types content from WordPress
I think you need to specify your post type in the query, otherwise it will just search the regular posts $args = array( 'post_type' => 'custom_post_type', 'name' => 'footer-address-details' ); $query = new WP_Query( $args );

Categories : Wordpress

Change WORDPRESS permalinks Structure to use Custom Field Values Dynamically for Custom Post Types
The fastest and easiest way with almost 0 coding to do this is to stop using Custom Fields, and set all those fields as Taxonomies Categories, hierarchical categories in which geocraft_state would have geocraft_city as children, and using the permalink structure as /%category%/%postname%/ More about taxonomies here: http://codex.wordpress.org/Taxonomies

Categories : PHP

wordpress custom post types - broken publish button
Strict Standards: Only variables should be passed by reference in /Applications/MAMP/htdocs/Web/ChristophRokitta/wp v.1.0/wp-includes/pomo/mo.php on line 210 The error message tells it all. The ".../popo/mo.php" file has to do with (is related to) the Wordpress translation. (I bet you're using Wordpress with German language files). I can't see what could be wrong in the code you've posted here, but something is interfering with translation. Looking at what the error message tells us, some variable that Wordpress tries to translate fails to be translated since it's not the correct type. Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/Web/ChristophRokitta/wp v.1.0/wp-includes/pomo/mo.php:210) in /Applications/MAMP/ht

Categories : Wordpress

Filter WordPress custom post types by taxonomy term
For me it was a conflict in naming. I had a post type with the same name as the taxonomy. That caused a conflict. register_post_type( 'some_name' ); register_taxonomy( 'some_name' ); Rename the taxonomy to something unique. register_taxonomy( 'some_tax_name' );

Categories : Wordpress

style listing wordpress 2 custom post types and 1 taxonomie
You can check the post type in the loop and add class to that post Please check the content template_part Trying modifying the template part like below <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <?php global $post; <span id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"> <?php the_post_thumbnail('large');?> </a> </span> <?php endwhile; // end of the loop. ?> Add this to function.php add_filter( 'post_class','your_post_class' , 20, 3 ); public function your_post_cla

Categories : Wordpress

Can't save meta box data in Wordpress using custom post types
Problems with your code: Unnecessary block (it's not related to the goal at hand): $values = get_post_custom( $post->ID ); $text = isset( $values['my_meta_box_text'] ) ? esc_attr( $values['my_meta_box_text'][0] ) : ”; $selected = isset( $values['my_meta_box_select'] ) ? esc_attr( $values['my_meta_box_select'][0] ) : ”; $check = isset( $values['my_meta_box_check'] ) ? esc_attr( $values['my_meta_box_check'][0] ) : ”; You're saving testimonial_text with: update_post_meta( $post_id, 'testimonial_text', $testimonial_text ); but getting _my_meta_value_key with: $value = get_post_meta( $post->ID, '_my_meta_value_key', true ); Change the get_ to testimonial_text. A textarea doesn't have value, the content goes inside the open/close tags: echo '<textarea id="test

Categories : Wordpress

How to create custom post types with categories in wordpress with its category?
try this : <?php add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'news', array( 'labels' => array( 'name' => __( 'News' ), 'singular_name' => __( 'News' ) ), 'capability_type' => 'post', 'public' => true, 'supports' => array( 'title', 'editor', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'thumbnail', 'author', 'page-attributes', ) ) ); } register_taxonomy( 'news_category', 'news',array('label' => __( 'Categories' ),'rewrite' => array( 'slug' => 'news_category' ),'hierarchical' => true, ) ); ?>

Categories : PHP

Custom layouts for custom post types? (wordpress)
If your custom post type is "products" then Archive file should be : archive-products.php Taxonomy should be : taxonomy-product_category_slug.php Single file should be : single-products.php if you want different content template then create file of like content-product.php and in your single.php use get_template_part( 'content', 'product' ); For current situation if everything working fine then just create content file, customize it.

Categories : PHP

How to make custom pages for custom post types
Here is the solution for your problem. Follow the steps for Creating a Custom Template Dedicated to Custom Post Types

Categories : Wordpress

Custom Data Types containing multiple standard types in Umbraco v6
While rooting through the source for the Repeatable Custom Content Package(which I found through the question I linked to in my question above) I stumbled upon an extremely simple solution. Add the Ultimate Picker to "RepeatableCustomContent.config" Simple but I couldn't find any clue through google. Anyway hope this can help someone else.

Categories : C#

Change index feed appearance of custom post types for twentytwelve theme? (wordpress)
If you want to customise the Custom Post Type's archive page then you will need to also create a template called archive-[posttype].php, and in this, call the content-[posttype].php template part that you have already created. For example if your Post Type is 'movies' then you would create archive-movies.php and in it call this (assuming content-movies.php is already present): <?php get_template_part( 'content', 'movies' ); ?> An invaluable reference when working out which template files to use for what is the 'Official' WordPress Template Hierarchy page in the codex: http://codex.wordpress.org/Template_Hierarchy

Categories : PHP

How do I return the count of multiple relationship types with one query?
Maybe something like this will get you started. It is helpful if you post some example graph data, especially on console.neo4j.org, so we can test out queries. start c=node(...) match c<-[:FAN_OF]-fan, c-[:FRIEND_OF]-friend, c-[:RELATIVE_OF]-r return c, count(distinct fan) as fancount, count(distinct friend) as friendcount, count(distinct r) as relativecount

Categories : Neo4j

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

Why does decltype remove const from return types for built-in types?
The behavior you observe is correct: decltype(makeCI()) is int, not int const. The makeCI() function call expression is a prvalue expression. Per C++11 §3.10[basic.lval]/4: Class prvalues can have cv-qualified types; non-class prvalues always have cv-unqualified types. The term "cv-qualification" refers to const- and volatile-qualification. int is not a class type, so the type of the rvalue expression makeCI() is int and it is not const-qualified. (In recent drafts of the C++ language standard, e.g. N3690, this text has been removed and replaced by new text at §5[expr]/6, which states, "If a prvalue initially has the type "cv T," where T is a cv-unqualified non-class, non-array type, the type of the expression is adjusted to T prior to any further analysis." See CWG defect 12

Categories : C++

Can't get a JSON back from POST - Incompatible block pointer types
The error you are getting is correct. The block is not supposed to return anything, and your return _jsonDictionary; is trying just that. What you need to do is update _jsonDictionary inside the success block (like you already do), and then invoke another function to fire up events that refresh you UI (something like calling [self.tableView refreshData]).

Categories : IOS

What does mean "symmetry" between predefined types and custom types?
The meaning of the text is that all of the types in the language "behave like objects". For example, you can do this: int i = 42; Console.WriteLine(i.ToString()); // called a method on an int as easily as you can do this: DateTime d = DateTime.Now; Console.WriteLine(d.ToString()); // called a method on a DateTime That is, if you did not know the types of i and d you would not be able to deduce anything by just reading the code that calls .ToString(). Contrast this with a language like C++: std::string s = "hello"; std::cout << s.length(); int i = 42; // ...but you cannot invoke any method on i; "ints are special" Here the fact that s.length() compiles tells us that s is not an int, or a pointer, or any other primitive type. This uniformity does not buy you anything from a

Categories : C#

Validate advanced post types in pods framework on save in backend
Probably the pre_save filter is our best bet. http://pods.io/docs/code/filter-reference/pods_api_pre_save_pod_item/ Not sure yet how to return an error, but the pods_error method should handle the bits of the different circumstances.

Categories : PHP

How to return multiple types from single method
You need to return Sprite, since it is common to each class. I would prefer to create new subtype, or type interface (e.g. IBoss), which would group all "bosses". That would be more explicit and easy to understand solution.

Categories : Java

Return multiple types from single method in C#
Nearly there! //In engine: public T GetEntity<T>(int index) where T : Entity2D { return objects[index] as T; } //Somewhere else: Enemy e = GetEntity<Enemy>(0); Note: if objects[index] is NOT a T, it will return null instead. However, if it was my game, I would just keep separate lists for each type of object.

Categories : C#

Java - Best way to return multiple object types from a method
You could do two different things. The first have the method signature be public List<Object> getPeople(). This will allow you to do instanceof and figure out which is which. OR you could have DataExporterPerson extend Person (or make a new class/interface that both DataExporterPerson and Person extend/implements and use that as the type).

Categories : Java

LINQ and web service cannot return anonymous types, and you cannot construct an object in a query?
I think the answer is to create another object to serve as a DTO. This object would not be mapped to the data context and can contain fields that cross the mapped objects. This solves the problems of repetitive properties in the mapped objects, and allows for instantiation of the DTO class in the query as it is not mapped. FYI: with respect to the problem with the join- I revisited that and I think I may have had the inner and outer components of the join switched around before.

Categories : Asp Net

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

Categories and Post Tags are disable when adding custom post
I have change your code .Please use this code.. add_action('init','create_custom_posttype'); function create_custom_posttype(){ $labels = array( 'name' => __( 'Custom Posts' ), //- general name for the post type, usually plural. The same as, and overridden by $post_type_object->label 'singular_name' => __( 'Custom Post' ), //- name for one object of this post type. Defaults to value of name 'menu_name' => __( 'Custom Post Menu Name' ), //- the menu name text. This string is the name to give menu items. Defaults to value of name 'all_items' => __( 'Custom Post All Items' ), //- the all items text used in the menu. Default is the Name label 'add_new' => __('Add

Categories : PHP

SQL Query to select post title & post ID from a particular category from wordpress table
Here's one I've used. You probably need to change (or remove) the post_type condition. tt.taxonomy would probably be "category" in your case (sorry, not near a database to confirm). SELECT p.ID , p.post_title FROM wp_posts p JOIN wp_postmeta pm on pm.post_id = p.id LEFT JOIN wp_term_relationships tr ON p.ID = tr.object_id LEFT JOIN wp_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id LEFT JOIN wp_terms t on tt.term_id = t.term_id WHERE p.post_status = 'publish' AND p.post_type = 'event' AND tt.taxonomy = 'event_type' AND t.slug = 'atelier' If you're running it from within WordPress you should use the $wpdb table names / prefix as a best practice. This one's for running standalone.

Categories : Wordpress

Custom wordpress post query
Try this while ( have_posts() ) : the_post(); echo '<li>'; the_content(); echo '</li>'; endwhile; See The Loop in Action for reference

Categories : PHP

WordPress custom query post-format
I don't use the Post Formats for any of my wordpress sites, so I cannot test this code, but try this: function ex_get_random_post_link () { $args = array( 'posts_per_page' => 1, 'ignore_sticky_posts' => true, 'post_type' => 'post', 'orderby' => 'rand', 'tax_query' => array( array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => 'post-format-quote' ) ) ); $query = new WP_Query($args); $query->the_post(); return get_permalink(); } I'm not sure how to get "None" for the post format, but the line: 'terms' => 'post-format-quote' is where you would change what post format you are using. http://wordpress.org/support/topic/post-formats http://wordpress.stackexchange.com/q

Categories : PHP

Get Custom Post's Post Id By URL doesn't work
You probably have to build your own query, so then you can use the following code: /* A custom Query (without global var) */ $query2 = new WP_Query( $args2 ); // looping through the query2 result, you may use some other code while( $query2->have_posts() ) { $query2->next_post();//here your next post is set echo '<li>' . get_the_title( $query2->post->ID ) . '</li>'; } // Restore original Post Data wp_reset_postdata(); //do not forget this line! This example code is taken from http://codex.wordpress.org/Class_Reference/WP_Query where you can find other examples and custom queries. Read especially this part of the page: http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters, I think, it solves your problem.

Categories : Wordpress

using multiple custom post in the same page
Add this in your functions.php file add_filter( 'pre_get_posts', 'my_get_posts' ); function my_get_posts( $query ) { if ( is_home() && $query->is_main_query() ) { $query->set( 'post_type', array( 'post', 'product' ) ); } return $query; } Also $query->set('post_type', 'any'); is mentioned here but never tried. Check this too.

Categories : Wordpress

Quick way to convert CSV types to original types with PowerShell's Import-Csv cmdlet?
Import-Csv wants to create a PSObject based type. You can create a conversion function (or filter) to convert to a Material type. Then pipe the output of import-csv to this function and into your target array: filter convert-csvToMaterial([Parameter(Mandatory=$true,ValueFromPipeline=$true)]$csvMaterial) { $material = new-object -TypeName Material $material.BusinessUnit = $csvMaterial.BusinessUnit $material.LegacyMaterialNumber = $csvMaterial.LegacyMaterialNumber $material.PrimarySource = $csvMaterial.PrimarySource $material.Source = $csvMaterial.Source $material } $importedMaterial = import-csv .materialList.csv | convert-csvToMaterial

Categories : Powershell

Unable to create a constant value - only primitive types or Enumeration types allowed
@AndrewCoonce is right, the .DefaultIfEmpty(ObjNull) is the culprit here. Entity Framework turns DefaultIfEmpty into something like... CASE WHEN ([Project1].[C1] IS NULL) THEN @param ELSE [Project1].[Value] END AS [C1] ...but there's no way to coerce an instance of ObjGetAllPendingPmntDetails into something that can take the place of @param, so you get an exception. If you move the DefaultIfEmpty call to after the ToList it should work correctly (although you'll need to call ToList again after that if you really want a concrete list instance).

Categories : Linq

Unable to create a constant value of type ''YYY". Only primitive types or enumeration types are supported in this context
You can do like this , var Ids=vm.PersonCollection.Select(y => y.Id).ToArray(); ICollection<Person> prsn = new PersonRepository().GetAll().Where(x => Ids.Contains(x.Id)).ToList();

Categories : Linq

Are there any best practices for implementing Java-types vs SQL-types mapping different from default ones
If you annotate java.util.Calendar fields with @Temporal(TemporalType.DATE), then the generated SQL should be of type DATE, for example: @Temporal(TemporalType.DATE) @Column(name = "SOME_DATE") private Calendar someDate; Additionally, you can specify how to generate a column's DDL with columnDefinition: @Column(name = "SOME_FLOAT", columnDefinition = "FLOAT(8)") private Float someFloat;

Categories : Java



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