Tag Info

New answers tagged

0

Depending on your home page, you either can set up a template file home.php (archive) or front-page.php (static page). In the according file, you can do whatever you want. Run additional queries, load content from whatever source etc. If this is not what you want, then you can have a look at the template_include filter hook. If you want/need to do more than ...


1

There are a lot of ays to do the trick, one possible is use a function that use a static variable. However, before you can be able to get the arguments set in shortcode, the shortcode must be processed... function foobar_func( $atts = array(), $out = FALSE ){ static $args = array( 'foo' => 'default foo', 'bar' => 'default bar' ); ...


0

Themes should not create content. Ever. That is plugin territory. When you activate the plugin, search for pages with a special custom field. Its name should start with an underscore, so it doesn’t show up in the Custom Fields metabox, for example _pluginslug_required_page. If there are no such pages, create your own. But I would question the underlying ...


3

The answer is eager loading or cache or both. Eager loading Have a look to this pseudo-code: $ids = get_ids_from_a_db_table(); foreach ( $ids as $id ) { $row = get_row_from_foreign_table_using( $id ); echo "Row title for the ID: $id is $row->title"; } If the number of $ids is n than this simple code runs n+1 queries, the first to load the ids, ...


1

It is quite difficult to understand what you have done. One of my concerns is using get_the_post_thumbnail() and catch_that_image() together in the same code as you have done. I have knowledge of catch_that_image() function and have used it before. It is a nice-to-know-function that is usually used by coders to retrieve the first image to display it in the ...


0

You can use template_include to set a specific template to a specific types of content using query_vars. Here is a example of how to set a specific single.php called single-information.php to a custom post type called information function pietergoosen_info_template_include( $original_template ) { if ( isset( $wp->query_vars['information'] ) ...


0

You can simply include a custom search function into your search by using pre_get_posts You can do something like this function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set('post_type', 'your-custom-post-type' ); } } } ...


3

Yes, this is the intended behaviour: page-{slug}.php - If the page slug is recent-news, WordPress will look to use page-recent-news.php So, simply use a different filename for your templates, like template-contact.php for example. You can find more info about this here: https://codex.wordpress.org/Template_Hierarchy


2

What you want to do is impossible without a page.php type of template. There is no template hierarchy that support what you want to achieve. It works exactly the same with categories. taxonomy-categorycourses.php will not display a list of categorycourses, so would category-categorycourses.php if categorycourses was a normal category. If you click on ...


0

You could just get the permalink and strip the home root from it- $path = substr( get_permalink(), strlen( home_url('/') ) );


0

I recently had a similar issue. How did you go about moving your website? Did you move all the files to the root folder, or did you simply redirect your site URL in the wordpress dashboard? Did you have a look at the wordpress guide: Giving_WordPress_Its_Own_Directory ? Have you checked your database that the site and home urls are now correct? Does your ...


2

Your code doesn't really do any "user logged in" check, and you aren't using a couple of the globals you import. function restrict_access_to_unlogged_users($template) { if (!is_user_logged_in()) { $template = get_stylesheet_directory() . '/need-login.php'; } return $template; } add_filter( 'page_template', 'restrict_access_to_unlogged_users', 20 ...


0

EDIT http://www.example.com/playlist.xml is not valid playlist url. Also you are missing " at the end of the url. Please refer to http://www.longtailvideo.com/support/jw-player/28850/using-the-javascript-api for jwplayer usage. You also need to call jwplayer().play() Try this, wp_register_script('myJW', get_bloginfo('template_url') . ...


1

You need to properly enqueue your script. You should hook your script to the function enqueue_custom_script() { wp_register_script('myJW', get_bloginfo('template_url') . '/jwplayer.js'); wp_enqueue_script('myJW'); } add_action( 'wp_enqueue_scripts', 'enqueue_custom_script' );


2

Parsing shortcodes from strings WordPress parses and replaces shortcodes from a piece of content via the do_shortcode function. This function, in turn, calls get_shortcode_regex, which returns the regular expression for matching shortcodes in a string. Using this function, we can get a list of all shortcodes ourselves: $pattern = get_shortcode_regex(); ...


0

SOLVED, the problem wasn't with wordpress. Just a couple of css and table formatting issues was the cause of gmail displaying wrong my table. In desktops and mobile email clients was looking just good so I was assuming the problem were beyond my html table code. But the own developer of the plugin review it and makes the final touches to my MailPress ...


0

if you want to make intent in the beginning of sentence after <br> (SHIFT+ENTER), then you may need to use custom solution: in functions.php add: add_action('init', 'add_cust_button'); function add_cust_button() { if ( get_user_option('rich_editing') == 'true') { add_filter('mce_external_plugins', 'add_mycust_plugin'); ...


0

It's not super clear to me what you are trying to do (and why)... but you know you can change the Media Library upload folder to something out of the 'Wordpress directory', so that your uploads all become, eg. www.yourdomain.com/files/media1.jpg etc. Here's a good basic tutorial on this. Would that solve it for you?


3

Use a use statement: add_filter( 'single_template', function ( $template ) use ( $name ) { Or just pass all templates at once, and create just one function: add_filter( 'single_template', function ( $file ) use ( $templates ) { global $post; if ( in_array ( $post->post_type, $templates ) ) return __DIR__ . ...


0

Generally, you can tell WordPress to load a different template. The mostly seen approaches make either use of the template_redirect or the template_include hook. It is preferable to use template_include as described in this article. Following an example on how to approach this: Code: // load the woocommerce category archive template add_filter( ...



Top 50 recent answers are included