Tag Info

New answers tagged

2

Nice sleuthing. Every single person on this SO site has been foiled by something exactly like this at one point or another with the WordPress template hierarchy. You might think of this backwards though. All the steps you found lead you back to the shortcode [pmpro_account] which gets output in the loop-myaccount.php by way of the_content(). That ...


1

Before I start, it will be a good idea to check out my answer to the following post What is singular.php? It will give you some more insight As I stated in the linked answer, You can have a fully functional website with just index.php as template to display posts with for all pages What you are doing is fine, and if there are any speed difference, it ...


0

For me, it's perfect to use that sort of IF logic statements in Index than writing new template files. In fact, what you're doing in your example code is already there in themes like TweentyTwelve etc. However, if you see any chance of need for different HTML code structure in future, it's better to keep the template files separate apart. So, give it a ...


1

Use php dot notation. Try: $my_templates = get_stylesheet_directory() . '/lp/'; $base = array( trailingslashit(get_template_directory()), $my_templates );


0

I don't think we can do that as a page in Wordpress, but I have another idea.. You can add a new taxonomy for your posttype template, like categories, then create a custom field for your posttype, (do the metabox) to show templates.


0

If you can count on the URI always following the same pattern, e.g. /link/###, then you can selectively load a different template using a query variable and a rewrite (will need to flush rewrites to test): /** * Register a query variable to check against for loading a template. * * @param array $vars Registered query variables. * @return array (Maybe) ...


0

So the problem was redirect_guess_404_permalink was detecting a 404 error and 'guessed' /members/blog to be /blog My hacky solution was to hook into the status error check (Stop Wordpress from "guessing" redirects for nonexistent URLs) and if URL parts match then unset the guessed solution function blog_no_redirect_guess_404_permalink( $header ){ ...


0

To find the size of a file added through the custom fields plugin, I did this: $fileObject = get_field( 'file '); $fileSize = size_format( filesize( get_attached_file( $fileObject['id'] ) ) ); Just make sure you set the custom field's "Return Value" to "File Object".


2

I assume you mean fetching an external feed with an HTTP authentication. Fetching feeds with HTTP Authentication Note that fetch_rss() uses the MagPie library, that's deprecated in WordPress. Use instead fetch_feed() that uses the SimplePie library. It looks though it doesn't support this kind of url: http://user:pass@example.tld/feed/ like we can ...


0

I think, you are looking for this //to get all the terms for current post - $terms = get_the_terms( $post->ID, 'tapahtumat' ); //get description of each term foreach ( $terms as $term ) { echo term_description( $term->term_id, 'tapahtumat' ); }


2

I'm surprised get_current_blog_id() didn't work, since that's probably the best way to approach it. Always try doing a var_dump( $current_blog ) to make sure you're testing for what you need. Edit (19 Aug 2015): Also, triple check that you know which header you're expecting to see and that you're making the change you want in the right header file. ...


2

You are fetching all the terms of your taxonomy, Use this instead : $terms = wp_get_post_terms(get_the_ID(), 'city-type'); if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ foreach ( $terms as $term ) { echo '<span>' . $term->name . '</span>'; } } Note : First argument to the function is id of the ...


0

To change the template of a post, call update_post_meta($query->the_post->ID, '_wp_page_template', 'YOUR-NEW-TEMPLATE-HERE.php') Here, then, is the example from the WP Codex found in @Xeross's link with the code snippet from the original question: $query = new WP_Query($args); while ( $query->have_posts() ) : $query->the_post(); if ( ...


5

Yes it is. It might get a bit clearer if you re-format this line $title .= " $sep " . sprintf( __( 'Page %s', '_s' ), max( $paged, $page ) ); to: $title .= " $sep "; $title .= sprintf( __( 'Page %s', '_s' ), max( $paged, $page ) ); The first parameter of sprintf expects a format which is here the return value of the __ function. The second ...


1

It is excruciatingly painful to deeply customize WordPress load process. It's not quite clear if your requirements here are performance related or tied to soemthing else. For your question as stated there would be about following approaches (madness ascending): get rid of actual code causing unwanted queries, altogether or via techniques like caching ...


0

OK, well, I've put the search for a proper answer on hold and instead cobbled together a 'for now' solution. First, in the referring page that is linking to the individual Post page, I've added this: $theid = $post->ID; echo "<li><a href='"; the_permalink(); echo "?id=" . $theid; echo "'>"; echo "blah"; echo "</a>"; So, on line 1 of ...


2

In a nutshell it's really done with shortcodes but many themes use a visual builder so you don't really need to know the shortcodes. One of the most used visual builder is Visual Composer plugin.


1

What you would do, is have your default single-article.php. This will get called by default because of the WP permalinks and templating system. At the top of your single-article.php do the following before your get_header() call: <?php $language = get_the_terms( get_the_ID(), 'language' ); if ( ! is_wp_error( $language) && $language && ...


0

Sorry I was using wrong structure, after looking through a bit more i found out exact difference for CPT and cutom taxonomies. For custom post types the template structure is like:-\ single-{post-type}.php archive-{post-type}.php search.php index.php And for Custom taxonomies, the template structure I found out from here:- Link:-Templates for Custom Post ...


0

I used the following functions to solve this problem. //This adds a custom query variable to the permalink function add_custom_query_var( $vars ){ $vars[] = "shop_name"; return $vars; } add_filter( 'query_vars', 'add_custom_query_var' ); function add_rewrite_rules($aRules) { $aNewRules = array('shop/([^/]+)/?$' => ...


1

Using is_page(8) will make your code a bit static. Let's make it dynamic as you're after with is_page_template(): <?php function prefix_conditional_body_class( $classes ) { if( is_page_template('mytemplate.php') ) $classes[] = 'mytemplate'; return $classes; } add_filter( 'body_class', 'prefix_conditional_body_class' ); Worked for me in ...



Top 50 recent answers are included