How to create a shortcode with HTML code in it and custom parameters/

As per the shortcode documentation, your shortcode callback recieves any parameters set by the user in a $atts variable. You can combine them with any default values you might have with shortcode_atts(). function newsletter( $atts ) { $atts = shortcode_atts( array( ‘url’ => ‘https://domain.com/newsletter/z2o7q6’, // change default value as needed ‘headline’ => ‘Newsletter Box Headline’, … Read more

Custom CSS File wont work on second Page

Sounds like your are not creating a proper WordPress template when you copy your index.php. Here you can find the list of standard template files: https://codex.wordpress.org/Theme_Development#id=%22Template_Files_List%22 And here you can learn how to create a custom template: https://codex.wordpress.org/Theme_Development#Custom_Page_Templates My guess is you need to add the following to the top of your index copy. Then … Read more

Applying my own css classes in wp_menus 3?

Do you need to modify walker or hook into it unmodified? Since there is filter provided for that id, it is easy to hook into. Try this: add_filter( ‘nav_menu_item_id’, ‘modify_menu_item_id’ ); function modify_menu_item_id( $text ) { static $myCounter; if( !isset( $myCounter ) ) $myCounter = 0; return ‘menu-item-‘ . ++$myCounter; } Update Changing walker // … Read more

Custom Page Template and Category Exclusion

Try this code in your template. <?php /** * Template Name: Exclude Comic Category */ get_header(); ?> <div id=”primary”> <div id=”content” role=”main”> <?php query_posts( array( ‘category_name’ => ‘comic’, ‘paged’ => get_query_var(‘paged’), ‘posts_per_page’ => 5 ) ); ?> <?php if ( have_posts() ) : ?> <?php twentyeleven_content_nav( ‘nav-above’ ); ?> <?php while ( have_posts() ) : … Read more

HTML in PHP problem [closed]

You get the error because you try to call php inside php. Try to use this snippet and see what is different: <?php if(get_field(‘post_image’)) { echo ‘<img src=”‘. get_field(‘post_image’) .'” />’; } else { echo ‘<img src=”‘ . get_bloginfo(‘template_url’) . ‘/images/images/default.jpg” />’; } ?> Also pay attention that bloginfo immediately prints value, when get_bloginfo returns … Read more

Gallery Pagination by Row

It is definitely possible!! Ok, here is what I did… My new loop looks like: <?php $ids = array();?> <?php foreach(query_posts(“category_name=photos&showposts=-1”) as $post_blog): ?> <?php $url = wp_get_attachment_image_src( get_post_thumbnail_id($post_blog->ID), ‘gallery-full’ ); ?> <?php $thumbs = wp_get_attachment_image_src( get_post_thumbnail_id($post_blog->ID), ‘gallery-thumbnail’ ); ?> <?php list($width) = getimagesize($thumbs[0]); ?> <?php $ids[] = array(“id_post” => $post_blog->ID, “width” => $width, ‘url’ … Read more

Change the behaviour of archive cpt category and single cpt by plugin, not by theme

You can use templates located within your plugin instead of theme files, like so: add_filter(‘archive_template’, ‘redirect_to_plugin_archive_template’); function redirect_to_plugin_archive_template($template) { if(is_post_type_archive(‘my_cpt’)) { return dirname(__FILE__) . ‘/templates/my_archive_template.php’; } } add_filter(‘single_template’, ‘redirect_to_plugin_single_template’); function redirect_to_plugin_single_template($template) { if(is_singular(‘my_cpt’)) { return dirname(__FILE__) . ‘/templates/my_single_template.php’; } } Obviously you need to change the custom post type slug and the template paths, but … Read more