I'm using the following line to show content from one page on another.
This line outputs the content's raw text of a shortcode:
<?php $id=3934; $post = get_page($id); $content = apply_filters('the_content', $post->post_content); echo $content; ?>
How can I add to or filter this snip...
@bungeshea in WP static classes are often used for code organization in kind of fake namespaces. it's not "real" OOP, just encapsulation from global scope
@bungeshea classes can't be static. There're interfaces, abstract, normal and final classes. But if you were talking about static initializing, then the "only" benefit is, that you set the class itself inside the init function to a static (and therefore persistent) variable and question if it was already set. This saves you from running the init procedure multiple times.
When developing a plugin should the functions be grouped together into a Class to avoid namespace conflicts?
Yes, but that's only one of the minor arguments. In-fact that's not the "true" nature of a class in OOAD.
Does using classes create performance overheads for PHP?
No, not notabl...
Can't ask this (code review-type) question on the main site, so if anyone can take a look, that would be great.
Here's the thing. I am modifying the loop of a custom taxonomy ('edition') to include posts not assigned to any specific term in the custom taxonomy to be shown under all these terms. Here's the function (in part i.e. code only for one term) I am using in my theme's functions.php.
The problem is, it redirects the custom taxonomy term's feed back to the term archive page. So, for instance, example.com/edition/usa/feed/ redirects back to example.com/edition/usa/. I've checked, there are no syntax error either. Does anyone know what I am doing wrong?
@kaiser Yes, I know something's wrong with that line. Don't know what. Here's what I think it represents: If page is custom taxonomy term archive OR feed of the custom taxonomy tag archive, do the following.
Don't jump around and try to talk about some guess weather something is a problem or not. Please just do what I ask you. Trying to guide you towards something that works.
If the current page being queried is the archive of the term (id 6) of the custom taxonomy ('edition'), OR if the page being queried is a feed AND the archive of the term (id 6) of the custom taxonomy AND it's the main loop, then do the following.
@kaiser that's how I understand it. Let me guess, I am wrong.
**IF** the current page being queried is the archive of the term (id 6) of the custom taxonomy ('edition'), OR the page being queried is a feed AND the archive of the term (id 6) of the custom taxonomy AND it's the main loop, then do the following.
IF the current page being queried is...
the archive of the term (id 6) of the custom taxonomy ('edition')
OR the page being queried is a feed
AND the archive of the term (id 6) of the custom taxonomy ('edition')
AND it's the main loop
THEN...
IF the current page being queried is...
the archive of the term (id 6) of the custom taxonomy ('edition')
AND the archive of the term (id 6) of the custom taxonomy ('edition')
OR the page being queried is a feed
AND it's the main loop
THEN...
Since the first two lines are just the same, it's as good as one. So, now that might translate to:
IF the current page being queried is
the archive of the term (id 6) of the custom taxonomy ('edition')
OR the page being queried is a feed
AND it's the main loop
THEN...
If one condition, let's say $query->is_main_loop() isn't met, then return immediately. Then go and check the next condition or condition set and so on.
Just a note: I'm really not interested in your specific problem, so I didn't read your goal. I'm just trying to tell you a more sane and easier process: Do it step by step.
And you're then assigning this array as the query_vars. Now the query_vars is a pretty large object. And you're basically overwriting the data in there and just adding your custom ones. This means that you 'unset' everything that is added per default.
$wp_query is an object. This means it's a class. And this class has methods (as functions are called inside classes). So you can check a value inside the $query object with $query->get( 'some_key_name' ); and set it with $query->set( 'some_key_name', 'some_value' );.
And this search form features a drop down for each non hierarchical taxonomy. It also got a hidden input field that has the post type as value to exclude other post types. Now I fired that form and the query was mislead and thought it was as well a post type archive. This set $wp_query->is_post_type_archive to TRUE and shot the wp_title() function in my header.php file. Question was how to get the custom post type in without intercepting the post type archive boolean.
Hm. Now I moved in hierarchical taxonomies and run into the next problem.
How would I set the ID/name in a way, that I get the tax_query string set right. Currently I use $taxonomy_name[ $term_slug ], which produces an array of terms assigned to the $wp_query. The query itself expects it as string. Either comma delimited or separated through +es. Example: term_a+term_b+... or term_a,term_b,term_c,....