Home Forums Front-end Issues Page Links in Dropdown


Page Links in Dropdown

  • I want to create a “related posts” option for a CPT that’s manually related. Page links is perfect for that.

    But I also want to display related posts on the front end in a drop down.

    I’m groping around in the dark with this, but rather enjoying myself. And thought something like this might work:

    function wpwoof_resource_sidebar() {
    	<section class="widget resource-toc">
    		<div class="widget-wrap">
                     	<h3><?php _e( 'Document Details', 'wpwoof-plugin' ); ?></h3>
    			<div class="document-meta">
    					<li><strong>Title:</strong> <?php the_field('document_name'); ?></li>
    					<li><strong>Download:</strong> <a target="blank_" href="[i4w_s3link protocol='http' object='<?php the_field('s3_file_path'); ?>']"> <span class="dashicons dashicons-download" style="font-size: 72px; display: block; width: fit-content; height: auto;"></span></a></li>
    					<li><strong>Version:</strong> <?php the_field('version_control_number'); ?></li>
    					<li><strong>Last Updated:</strong> <?php the_time('F jS, Y'); ?></li>
    <div class="dropdown">
            <button onclick="myFunction()" class="dropbtn">Dropdown</button>
            <div id="myDropdown" class="dropdown-content">
          // vars
          $urls = get_field('urls');
          // check 
          if( $urls ): ?>
          	<?php foreach( $urls as $url ): ?>
          	   		<a href="<?php echo $url ?>"><?php echo $url; ?></a>      	
            <?php endforeach; ?>
    <?php endif; ?>

    Now, it’s not working (no surprises), but am I on the right lines, or completely miles away?

  • One option would be to create a front-end form and just include that one field in the form:

    The documentation is here: Front end form

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Page Links in Dropdown’ is closed to new replies.